Shop OBEX P1 Docs P2 Docs Learn Events
Another Serin Question — Parallax Forums

Another Serin Question

JomsJoms Posts: 279
edited 2008-03-10 20:06 in BASIC Stamp
I am having another problem with the serin command.· I am trying to take a command in and store it to a veriable.· The devise that is hooked to the input of the basic stamp sends the command out automatically about every two seconds.· In the end I want to turn an LED on depending on if the command is the same as what is in memory.· I am working in small steps and right now I just want it to write the command to a variable and display it on the debug.· I have also included a few lines of code that will flash an LED and delay the program just to tell me that the thing is running...

I know that the SERIN command is supposed to wait until input detected but when I connect the input to the computer and monitor the serial port I see 7 HEX charactors come past.· Also, the settings I used on the computer to monitor the data are 4800 baud, 8 data bits, 1 stop bit, no parity.· Please let me know any ideas on where I am going wrong.· Thanks!...


'{$STAMP BS2}
'{$PBASIC 2.5}

serStr· VAR·· Byte(7)
DO
· SERIN 14, 16572, [noparse][[/noparse]STR serStr\7]
· DEBUG STR serStr
· HIGH 13
· PAUSE 250
· LOW 13
· PAUSE 250
LOOP

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-03-10 19:06
    Hi joms, the routine you are using looks ok, although there is no synch between the data you are sending and the serin instruction. Did you try a baud of 188 (true), maybe even temporarily shorten the expected input serStr\4 just to see what you get.

    Jeff T.
  • JomsJoms Posts: 279
    edited 2008-03-10 19:31
    I have already tried changing the baud to 188 like you have suggested and that did not work. I also tried changing both the variable byte size to 1 and the serStr]\1 to 1 and I was still having the same problem. Do you have any other ideas on things to try?...
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-10 19:40
    Perhaps you could post a datasheet for the device you are using. There's nothing fundamentally wrong with your program although you didn't say what, if anything, happened when your device sent out its data. Hopefully there's a common ground and the connections from your device to the Stamp are correct. If the device puts out +5V logic signals, you won't need anything to protect the Stamp. If the device puts out RS232 signal levels (you didn't say), you may have damaged the Stamp I/O pin. An RS232 input requires a protective resistor as described in the SERIN statement description chapter in the PBasic Manual.
  • FranklinFranklin Posts: 4,747
    edited 2008-03-10 19:43
    Take a look at the help file for serin in reference to the WAIT directive. I think you will need to use that as without it the serin command inputs data as soon as it is invoked and in your case that is most often when nothing is being sent.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • JomsJoms Posts: 279
    edited 2008-03-10 20:06
    Mike, I dont think it is in the hardware, although it wouldn't be the first time I am wrong. I am connecting a Pelco KBD300 Pan/Tilt/Zoom controller to it via RS422-232 adaptor. I am splitting the rs485 out of the controller so it will controll the camera aswell as the basic stamp. In the end I want the basic stamp to control four relays that will select which video goes to the monitor. The controller sends out a command whenever one of the aux buttons are pressed. Whenever an aux button is pressed I need one of the four relays to activate to switch a video source. The reason I don't think that it is hardware is because I have used this exact same RS422-RS232 adaptor with a few other projects wired up this same way and it works fine with the stamp. I have checked to make sure the signal ground of the convertor is tied to the VSS pin (ground) on the stamp board.

    Stephen, I have read through the help file and dont think that the WAIT command will do what I want. I actually need it to trip a different relay depending on one of the four commands coming in. From my reading I think the WAIT command would only be helpful if I was attempting to switch one relay.

    Also, I pretty much need to switch the relays off of the RS422 or RS232 because of the current cabling setup, otherwise I would just wire 4 buttons beside the controller and wire them directly to the relays or use a stamp for the latching part.

    Do you have any other ideas on things to try. I have been playing with this off and on over the past few days using different commands and configurations....

    THANK YOU FOR ALL YOUR HELP SO FAR!
Sign In or Register to comment.