Shop OBEX P1 Docs P2 Docs Learn Events
RS232 input — Parallax Forums

RS232 input

eddedd Posts: 6
edited 2013-08-14 20:35 in BASIC Stamp
Good day everyone
I’m currently working on a project to control a Pan and Tilt system remotely, using two servos. I was successful using wireless transmitters but the hard part is using RS232 communication over Ethernet. Im using Digital video recorder (DVR) that streams over the net. The dvr has a PTZ control option that communicates using Visca and Pelco-D protocols. After reading on Viscal, The interface to the controller is RS-232C, 9600 bps, 8 bits data, 1 start bit, 1 stop bit and non parity.
I have programmed the BS2 to receive RS232 input but im unable to display that input via debug terminal or serout.
fB VAR Byte
again:
SERIN 1, 16468, [ fB]
SEROUT 16, 16468, 100, [ fB]
PAUSE 1000
GOTO again

If any one could help me receive R232 input to control the pan and tilt ( using two servos) , or any suggestion on how to improve the current code I would really appreciated

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-07-20 08:04
    As mentioned in the reply to your blog entry, the BS2 is not buffered and is a single-threaded processor ... it only does one thing at a time. The SERIN will wait for the first character to be received (after the statement starts executing). While the SEROUT and PAUSE are executing, it will completely ignore anything sent to the Stamp. That's a 1.1 second delay between characters ... 100ms in the SEROUT because of the pacing parameter (100) and 1000ms for the PAUSE.

    Without a description of the protocol used to send to the BS2, it's hard to say whether this is possible or how to do it. Basically, the BS2 would have to control how quickly and how much information is sent to it. This is hard to do at 9600 Baud. You're much more likely to get this to work at 2400 Baud. You'll have to provide much more information about the interface to the BS2 and the protocols used. Does the RS232 interface support flow control (RTS / CTS)?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-07-20 08:13
    I don't see that as workable, a SERIN immediately followed by a SEROUT - a lot of data will get missed that way.
    You will have to fill (SERIN into) an array and then SEROUT that accumulated data.

    Are you using the 22K series resistor on the SERIN pin?
    Or are you using a MAX232 (or sim.) ?

    The Pelco data is numeric data not ASCII, you should probably SEROUT the data as HEX or DEC, if it's going to a terminal or you're trying to read it.
    SEROUT 16,16468,100,[HEX fB]
    Since you are using "16", then use DEBUG:
    DEBUG DEC fB
    or
    DEBUG HEX fB
  • eddedd Posts: 6
    edited 2013-07-20 18:29
    I’m currently using a 22k resistor in series with SERIN pin. I’m not using MAX232 or anything similar to that. I plan on ordering RSB509c serial Data buffer from proteanlogic.com
    The DVR doesn’t say much about the RS232 output other than it supports Visca and Pelco PTZ cameras. So I started reading on Visca RS-232 control protocol.
    thanks for the post is you guys can give me some aid in hooking the RSB509 to the BS2 and basic program that awesome
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-07-21 07:05
    When their site is searched, results are listed with an inactive protean-logic.com address whereas their address, now, is proteanlogic.com

    There is accessible an "Application Notes" section --
    http://www.proteanlogic.com/applications/an012/rsb509.htm
    http://www.proteanlogic.com/applications/an045/AN045_RSB509C_RCservo.htm
  • eddedd Posts: 6
    edited 2013-07-21 08:34
    This is the first time i have post an issue on line, i spend lots of time reading post to try to solve issue i may encounter, i just want to say thank you both for your support and your help, its deffinatly appreciated.
    Ill post more once i get the items in
    thanks you guys
    Edd B
  • eddedd Posts: 6
    edited 2013-08-04 08:37
    Hey guys,
    I have finaly receive the parts I needed to interface the basic Stamp 2 with RS232 input. I received the RSB509c and MAX232N. I followed the proteamlogic direction for inputting and displaying RS232 with no luck. I used the MAX232N by its self and I was able to get weir symbols. When I try to convert the input into DEC or HEX nothing displays on the debug terminal.
    inval VAR Byte
    HIGH 1
    PAUSE 2
    INPUT 1
    SEROUT 1, 49236, [%00000100]
    PAUSE 1
    around:
    HIGH 1
    SERIN 1, 16468, 1, around, [inval]
    DEBUG inval
    GOTO around
    END
    If you guys have any suggestion, programming, and schematics I would really appreciated it.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-08-04 20:14
    If you are getting "weird" signals this is normally the result of incorrect baud settings. Verify that both devices have the smae baud settings. If they are both the same, then try lowering the baud rate.
  • eddedd Posts: 6
    edited 2013-08-14 17:07
    I don’t know exactly how to verify that the DVR is outputting 9600 bts, according to DVR its manual its using viscal protocol which is 9600 bit/s, 8N1, no flow control typically though a DB9 connector.
    I have tried every baud that the Basic stamp supports as per syntax manual, with no luck
  • FranklinFranklin Posts: 4,747
    edited 2013-08-14 17:31
    Have you tried connecting the DVR to a computer and using a terminal program to see what it is sending?
  • eddedd Posts: 6
    edited 2013-08-14 18:50
    would you mind walking me through how to hook it up ?
  • FranklinFranklin Posts: 4,747
    edited 2013-08-14 20:35
    would you mind walking me through how to hook it up ?
    I'd connect a serial cable between the computers serial port and the DVRs serial port.
Sign In or Register to comment.