PDA

View Full Version : serial problem.



Cranz
01-23-2006, 04:23 AM
Hi!

I have read the manual, but can't find a solution to my serout problem.

I want to serout this:

1 start bit (0), 9 data bits, 1 stop bit (1), no parity


baudrate: 62.5 K

Can this be done with my basic stamp 2 p ?

Jon Williams
01-23-2006, 04:36 AM
Sorry, SERIN and SEROUT are 8-bits only. What kind of device/system are you trying to connect to? I've seen 8 data bits with 2 stop bits, but not 9 data bits.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Cranz
01-23-2006, 04:43 AM
Well... I'm trying to communicate with Lenz Xpressnet. (model railroad control)

Xpressnet is a RS-485 bus. I want to use a rs-485 line driver with a bs2p and send commands to the expressnet.



http://www.lenz.com/manuals/xpressnet/xpressnet.pdf

page 6.

9 data bits :(

Is there a way to make this work? http://forums.parallax.com/images/smilies/freaked.gif

Jon Williams
01-23-2006, 05:02 AM
Notice how that document is talking about the LI100 computer interface; that's what converts "standard" 8N1 serial to the 9N1 (RS-485) format needed by the system. If you're wanting to skip that interface, then you may want to look into the SX chip with SX/B. That would allow you to write serial code that could output nine data bits (you'd have to do this manually as the built-in SERIN and SEROUT instructions also use 8 data bits). Note that you'll also need an RS-485 interface (e.g., LTC485) chip.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Cranz
01-23-2006, 05:09 AM
Great! SX/B is the fast thing I've heard about?

Do you know any places on the net to learn this things about writing a serial code ?

I think the LI100 is out of production. And the new model LI101F is much more complex.. and expensive.

Thanks a lot anyways!

Jon Williams
01-23-2006, 05:19 AM
Sure -- we have information.· You can download Al Williams's (no relation) book at no charge:

http://www.parallax.com/dl/docs/books/ExploringTheSx.pdf

... and when you're ready to expand your SX horizons even further, you really should consider Guenther Daubach's excellent book:

http://www.parallax.com/detail.asp?product_id=70002

And do remember the SX/B is designed to let you look "under the hood" as the source code that's generated -- it's not designed to be a mystery.· You could look at the code produced by SEROUT for example, copy it, and then modify it to send nine bits.

And the SX is one of our favorites.· Look at your BS2p... it uses the SX48 as its core.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Bruce Bates
01-23-2006, 06:39 AM
cranz -

If you want to do this in hardware only, the following should work for you. As I remember the MAX-3100 will output either 8 or 9 data bits, depending on how you set the internal registers.

/code

PBASIC·Stamp <==> Shiftin/Shiftout <==> MAX-3100 <=RS-232=> MAX-3162 <==RS-485==>
· processor··················serial comm.·············· UART·············· ··· Protocal Convertor

code/

The data sheets for those IC's can be found here:
http://www.maxim-ic.com/

Regards,

Bruce Bates

Buck Rogers
01-23-2006, 07:16 AM
Cranz said...

Well... I'm trying to communicate with Lenz Xpressnet. (model railroad control)

Xpressnet is a RS-485 bus. I want to use a rs-485 line driver with a bs2p and send commands to the expressnet.

http://www.lenz.com/manuals/xpressnet/xpressnet.pdf

page 6.

9 data bits :(

Is there a way to make this work?



Hello!
Are you sure its exactly 9 data bits sent? The majority of serial data is 8 data bits and one stop bit. Sometimes there's a parity bit. or even two parity bits.In either case the Stamp can indeed send 8 bits plus one stop bit. There's a chart in help pages that explains this perfectly.

And Jon, your doing fine explaining this issue. It's one that can and usually do manage to confuse even the most advanced technician. I·know. It's done that to me even before discovering the stamps.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buck Rogers

www.gregg.levine.name (http://www.gregg.levine.name)

Cranz
01-23-2006, 07:50 PM
9 bits is correct.


The MAX3100 chip seems is made for 7 and 8 bit communication. It supports 9 bit address recognition on 9-bit networks. I don't think this will work?
·

Bruce Bates
01-23-2006, 10:18 PM
cranz -

I downloaded any number of PDF's from the Lenz web site and did a bit more reading. Here is my take on what I read from various resources found there.

According to their documentation, the ninth bit appears ONLY on the hardware side, although one would think that it must appear somewhere in the software, otherwise it could never be set (1) or reset (0). In one of the discussions about the purpose of this ninth bit, the documentation says that it's to differentiate "address" from "data" information. This seems to me to be a late-found fault or deficit in one of the the network layers, but I shouldn't be casting aspersions without more information.

Here is the part which I find MOST confusing if you believe that the ninth bit is a necessary part of this network. The following is paraphrased, but I'm reasonably sure I can find the original source in one of the PDF's:

All data packets sent across the network are·comprised of·8-bit bytes, with multiple bytes per field. Multiple fields are contained within each packet. Etc.

With that information in mind, one might begin to think that indeed the ninth bit IS used only at the (so called) hardware level, and thus it may never NEED to be transmitted or received, or set or reset by the programmer (more on this below). This may be merely a "tag" or "flag" (so to speak) that is added or manipulated by one or more of the hardware elements in this Xpressnet System, although I have not found any direct indication of that.

Just by way of a possibly marginal comparison with another formal, serial transmission protocal,·the read/write bit used in the I2C protocal is often not set or reset by the user (programmer). Except for machine language, and straight (non-macro) assembler, generally the higher level language component (compiler, interpreter, etc) is often able to differentiate a read from a write, and sets the bit accordingly (PBASIC: I2CREAD vs. I2CWRITE). While this is not truly at the hardware level, since it's not manipulated by the programmer in most cases, one could say it's not done at the software level. Since there is no firmware involved, where else might the responsibility lie - by default the only level left, the quasi-hardware level albiet actually done by an internal element of the language component internal software. I agree, this is not a very supportable argument and hinges very much on semantics, so you'll get no argument from me if others disagree with this marginal, comparative presentation.

Last, I found information which would indicate that a number of different baud rates are supported. Thus, it may be very important to see what the baud rate is, in any given Xpressnet system, before any attempts are made to interface with it.

As far as the MAX-3100 is concened, I've never used it for 9 bit anything, so you're on your own with that. I just know that I read it supported 9 bits in some manner or form. Since you say it supports 9-bit address recognition, I just wonder how that fits in with the above regarding the comment:·"to differentiate address from data information" <shrug>.

Regards,

Bruce Bates

Cranz
01-23-2006, 10:55 PM
That helped me alot!

Well... I'm not english, so maybe I was misunderstanding some of the text I was reading.

I'll write back when I make it work :)


Pål.