View Full Version : Converting ASCII Serial Strings
01-27-2006, 09:14 AM
Hi, Can anyone help me with a problem to receive, store and retrive a huge ASCII string from pressure transducers? So far I can display it in DEBUG window, but I need to store it (temporarily) in 24LC256 and then clean it from “,#_ and send it out to another serout pin.
String looks like this:
"ID#01_14.2 psi"," ID#02_14.235 psi ",," ID#03_-18.23 psi ","ID#06_114.245 psi"," ID#08_2.247 psi ",," ID#13_518.126 psi ", ID#14_114.23 psi ",," ID#15_12.23 psi ","ID#56_-114.245 psi"," ID#88_2.247 psi ",," ID#103_61.126 psi "
String can have a different "lenght" with each replay. ·I'm using BS2p at 9600 bps.
Post Edited By Moderator (Chris Savage (Parallax)) : 1/27/2006 2:43:24 AM GMT
01-27-2006, 09:42 AM
·· Have you tried storing the data in the ScratchPad RAM then sending out the segments from there?· You could use a compare routine in a loop to do this.· If you still want to use the EEPROM, which will slow things down, at least attach your code so we can see what you're doing.· By the way, you should give you posts a descriptive subject line.· I have corrected this one for you.
Parallax Tech Support
01-27-2006, 11:17 AM
You could use the WAIT modifier like this:
· SERIN Rx, Baud, [WAIT("ID#"), DEC sensorNum, DEC psi, DEC psiFrac)
Of course, you'd have to put it into a loop -- but if your sensor is constantly streaming information you should be able to catch everything
Applications Engineer, Parallax
01-28-2006, 10:13 AM
Thanks to both of you guys for your replay.·I haven't tried anything interesting yet because
I don't have the complete plan and needed components for this project. I need to have a keybord from which I can send a command to transducer, or to set some parameters. Next challange would be to store part of received replay (or input from the keyboard) in variable that can be used later to preform some calculations. I was thinking to use ezKey or PAK VIa adapter for this purpose. Is it possible to create a variable for input from the keyboard or other serial port without knowing what and how big is't going to be, but it will be terminated with "CR" for sure.·Is it possible to add new byte to the one which is allready received. Something like: string = string & newbyte.·A soon as CR is received I·want to send out:
SEROUT pin, baud, [string, CR] .Thanks again for your help.