Shop OBEX P1 Docs P2 Docs Learn Events
Dealing with serial comm and floating point values. — Parallax Forums

Dealing with serial comm and floating point values.

Hi,

I am trying to program for a dialogue over RS232 like this:
VOLT?
+2.5000000000000E+00
VOLT 2.0
VOLT?
+2.0000000000000E+00




And I am hung up on the query/catch part. This is how I am trying to do the work:
CurPZTVoltage    VAR     Byte(5)
COMOutput CON   16
COMInput  CON   16
COMBaud CON     110
FC  CON 0  
....
  SEROUT COMOutput\FC, COMBaud,[noparse][[/noparse]"VOLT?", CR, LF]
  SERIN COMInput\FC, COMBaud, [noparse][[/noparse]STR CurPZTVoltage\5]




The execution is hanging at the SERIN instruction, and my assumption is that since +2.0000000... is being sent over the wire in ASCII, then catching it in a byte(5) array would result in +2.00 being stored in the var CurPZTVoltage. Does this approach seem to make sense? Given that, what could cause the hangup?

Thanks

Comments

  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-06-05 15:58
    Need a little more information first of all;

    I assume (?) that you are using a BS2SX or BS2P?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • edited 2006-06-05 15:59
    Yes, its the BS2P40.
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-06-05 16:08
    SERIN COMInput\FC, COMBaud, [noparse][[/noparse]STR CurPZTVoltage\5]
    



    The line above will look for 5 bytes, and not terminate until it sees 5 bytes. You have PIN 0 set as a flowcontrol pin. You are however using (I assume) a built in DB9 port (and appropriate level shifting) from a BOE or similar board (16)- Have you connected your PIN 0 for flow control properly then?

    I'll bet if you add a timeout to your serin statement, you'll find you're either getting only 1 byte of data, or none at all.

    Can you go into more detail about your connection scheme?

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • edited 2006-06-05 16:19
    Well I couldnt find a way to access the DTR signal from the RS232 interface. I am using the BS2P24/40 Demo Board, and I think that DTR is supposed to be connected to ATN in the BS2P40. I did not know how to use that pin, although I assume there is a way, since you can access the serial IO pins by using 16.

    My device uses an RS232 crossover to connect to the demoboard, so i suppose if i soldered from pin 6 of the RS232 thats coming into the board to pin 0 of the BS2p40, then I would have flow control on pin 0...does that sound sane?

    Thanks for the help
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-05 16:30
    Bear in mind that on the programming port DTR is connected to the BASIC Stamp reset line.· So toggling that on the PC side would result in resetting the BASIC Stamp.· It is impossible to affect it from the BASIC Stamp side using the programming port.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • edited 2006-06-05 16:35
    No, I know, but I am programming the controller to interface with another device via RS232. Am I right though, that if that device implements the flowcontrol handshake method, then the DTR line would be the one to use this way? THe dialogue mentioned above would be between the controller and this device.

    Thanks
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-05 16:39
    Actually typical flow control uses RTS and CTS.· DTR is Data Terminal Ready and can be ignored on many devices.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • edited 2006-06-05 16:47
    I don't know, I guess all devices are different. This one, the agilent 33250A, uses DTR/DSR as its default, though I could change it to CTS, though the difference seems small. Anyway, it says

    "The function generator monitors the state of the DSR line on the RS-232. When the line goes true, the function generator sends data over the interface. When the line goes false, the function generator stops sending finformation."

    Since I have the crossover cable going from the agilent to the demo board, does it sound right then that the DTR pin 6 could be used as the flow control?

    If there is an easy way to access the CTS line from the BS2P40, perhaps its pin 16 or something like that, then it would be easy to change the agilent for that handshake mode.

    Thanks,
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-05 17:19
    Hello,

    ·· You cannot use flow control on port 16 (programming port).· If you want to do that you could use standard I/O pins and declare the FP pin in your SERIN/SEROUT statement.· DTR/DSR work very similar to RTS/CTS so it would be possible to implement that in the same way, although I have never used DTR/DSR for flow control, only to sense when a modem is available.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.