View previous topic :: View next topic |
Author |
Message |
stma
Joined: 16 Feb 2004 Posts: 26
|
Serial Input |
Posted: Fri Aug 26, 2005 4:47 am |
|
|
Could somebody please solve a problem for me. I have read numerous posts on the forum and implemented (tried to) them with no sucess.
I have a PIC16F877 4MHz interfaced to a sensor which outputs serial data ( a string of ascii characters that can be read by a pc serial port)
I initiate a reading then want to read back the data.
It is being transmitted at B9600 (although this can be slowed to B1200)
I want the PIC to read the data and store it in avariable. The data is numbers 24 characters long (consisting of 4 seperate measurements).
Can anyone post code that works? or any ideas please.
Many Thanks
Steve |
|
|
Ttelmah Guest
|
|
Posted: Fri Aug 26, 2005 5:01 am |
|
|
How are the numbers seperated?. What marks the start/stop of the 'packet?. How are the nubers represented (integer, floating point etc.). Post an example of the string involved, and somebody may be able to help.
Best Wishes |
|
|
Guest
|
|
Posted: Fri Aug 26, 2005 7:07 am |
|
|
Good Point. String example as follows.
+13.238, +24.855, +07.6382, +1504.6563
Could live without the sign and decimal points though, would be happy with raw numbers. ( I can do it in PBP but need CCS C code to work!)
Thanks in advance
Steve |
|
|
Guest
|
|
Posted: Tue Aug 30, 2005 2:37 am |
|
|
Also using fget, fprint etc instead of get print, as i am using multiple software serial ports defined with seperate streams.
Thanks |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Aug 30, 2005 6:28 am |
|
|
Search the help file or manual for STRTOK() for your answer. If you need to convert each substring into a number take a look at atof() also. |
|
|
|