Serin at 19200baud
CMcG
Posts: 17
Hello,
I am trying to·extract·a few data values from an RS232 string of about 50 ASCII characters. The string is sent into my stamp every 10 seconds, but the baud rate·being fixed at 19200bps., is just too fast for the BS2IC it seems. I have also tried a BSCpx24 but that too is foxed by the 19200 speed.
The 19200baud is fixed. Has anyone any idea of how an external serial buffer might be used to capture the data and for the stamp to then read the buffer at say 1200baud?
Thank you for any suggestions.
Carl
I am trying to·extract·a few data values from an RS232 string of about 50 ASCII characters. The string is sent into my stamp every 10 seconds, but the baud rate·being fixed at 19200bps., is just too fast for the BS2IC it seems. I have also tried a BSCpx24 but that too is foxed by the 19200 speed.
The 19200baud is fixed. Has anyone any idea of how an external serial buffer might be used to capture the data and for the stamp to then read the buffer at say 1200baud?
Thank you for any suggestions.
Carl
Comments
The external buffers I know of either can't work at 19.2KBps or don't provide a host speed that's lower than the input speed.
Thanks for taking the time to respond to my question.
I did buy a BS2PX24-IC but that just could not handle the data reliably.
If for example, I asked for a capture of (STR datain\20) only aout 90% of the displayed characters were valid, with gibbereish being displayed alongside good characters.
I have spotted a previous post of yours advocating the RSB6505 chip, but from what you are saying, I guess it does not have the baud rate conversion facility that I am after?
Not sure if mentioning it will get me struck off, but I am looking at trying a Basic atom which I see is advertised as having a UART on-board.
All the best
Carl
The RSB6505 is the one that, from its datasheet, ought to work, but isn't for sale yet according to Protean Logic's website.
If you're going to move to some other processor, I would seriously suggest you look at either using SX/B (SX Basic) on an SX
or use Spin for programming on a Propeller. Both use software UARTs that work "in the background" so characters won't be
dropped.
Can I just clarify. Do you think that a BS2sx might work for me at 19200baud? I see that it has a 50MHz crystal and can execute ~10000 instructions per second.
I bought the BSCpx24 because I read it could achieve ~19000 instructions per second. It has a 32MHz crystal on-board. This BSCpx24 did not work well enough for me.
Cheers
Carl
There may be another alternative such that you may still be able to use a PBASIC Stamp. Maxim makes the MAX3100 (MAX31xx series) external UARTS designed for use with microprocessors.
On the input/output side to and from the Stamp the SHIFTIN/SHIFTOUT commands (synchronous serial) are used in lieu of SERIN/SEROUT. They also have an 8 byte buffer if I remember correctly.
There is application information available for use of the MAX31xx series with the Stamp, if you need it.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
With your BS2p24 have you tried using the SPSTR modifier to store the incoming data into the Scratch Pad RAM? I would recommend trying that instead of STR.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Regards
Carl
Not only should the SPSTR modifier be a little more efficient, but it will provide you with 126 bytes of space instead of the <26 you had available before. In your example you were capturing 20 bytes, but I can’t help but wonder if any of those bytes were being over-written by other variables. You only have 26 bytes of variable space, so if you were using more than 6 bytes for general system variables you may very well have been over-writing some data. Let us know. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I have tried the SPSTR modifier with my BS2p24 and all I can say is WOW!!!!
I cannot believe how well it works. I can happily read in serial strings even at 115200baud. I never thought this possible with stamps.
Thank you very much for your very useful advice.
' {$STAMP BS2p}
' {$PBASIC 2.5}
Datain Pin 1
i VAR Byte
serdata VAR Byte
Start:
'SERIN datain,16494,[noparse][[/noparse]SPSTR 52 ] '19200
'SERIN datain,16429,[noparse][[/noparse]SPSTR 52 ] '38400
'SERIN datain,16407,[noparse][[/noparse]SPSTR 52 ] '57600
SERIN datain,16385,[noparse][[/noparse]SPSTR 52 ] '152000
FOR i = 0 TO 51
GET i,serdata
DEBUG serdata
NEXT
DEBUG CR
GOTO start:
This is the my test string and the stamp reads it 100% at all baud rates.
"The quick brown fox jumps over the lazy dog 0123456789"
Best wishes
Carl
I’m glad you got it working…Besides faster speed you gain the ability to buffer larger incoming strings. For me this helps with such devices as GPS, Vinculum (Datalogger) and the PINK Module...all devices which can return large strings to have to deal with. When translating data between serial devices it not only cuts down on variable space but allows you to use a single byte variable for translation/transfer. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
A·further·question about the SPSTR modifier...
I would love to be able to read in a long string, but be able to handle different string lengths. The strings all end with a $0D (carriage return).
I am looking for something like SERIN,pin,baudrate,·[noparse][[/noparse]SPSTR 127 \CR]· that would read in up to 127 bytes OR until a CR is seen.
The \CR modifier does not work. Is there any other way to handle variable length strings with SPSTR?
Cheers
Carl
The only thing I can suggest in this case is to specify the maximum number of bytes you’re expecting and then use the timeout feature to break input. This is how the code for the PINK Module is written. When a variable is read it reads in up to 64 characters unless it times out. Very small values shouldn’t be noticeable but don’t get too small or you may timeout before getting a response. I don’t know if this will work in your situation. It works on the PINK because you send a command and expect return data immediately. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Sorry, I have no idea what a PINK module is. Is there a link to some info that you could send me?
I thought of using a timeout as you suggest. I am just afraid that I might miss some of the first bytes of an incoming string, if the stamp just happens to be diverted off to a timeout branch at the instant that the string starts. Anyhow, I will continue to experiment.
Thanks for all your help.
Carl
SERIN RX,baud,[noparse][[/noparse]WAIT("!")]
SERIN RX,baud,200,time_out,[noparse][[/noparse]SPSTR 127]
in the GET loop I look for a CR to exit the loop (end of string)
IF serdata=13 THEN EXIT
Jeff T.
I was thinking along those lines but had not thought of using two instructions like you suggest. Like it!
My mind was stuck with trying to do it all with a single SERIN with WAITs and timeouts.
I have a ";" semi colon that I can trigger on, i.e. WAIT for.
SERIN pin,baudrate,[noparse][[/noparse]WAIT ";"]
SERIN pin,baudrate,200,processdata,[noparse][[/noparse]SPSTR 127]
processdata:·
' loop using GET until CR is found
Thanks for the idea. I am confidentthat it will work.
Aren't these Stamps amazing? There always seems to be a way to achieve what you need to.
Rgds
Carl
Unfotunately 19200 is just too fast for the two SERIN commands.
I have however come up with a suitable solution using a timeout that I am happy with.
Thanks for your help.
Happy Christmas
Carl