Shop OBEX P1 Docs P2 Docs Learn Events
BS2 SERIN Pin 16 Problems — Parallax Forums

BS2 SERIN Pin 16 Problems

staulkorstaulkor Posts: 5
edited 2006-08-18 17:50 in BASIC Stamp
I am learning how to use SERIN and I am having a problem with my computer communicating with the BS2.

Note: I have a HomeWork Board

result  VAR Byte
DO
  DEBUG "Hello!", CR
  SERIN 16, 84, [noparse][[/noparse]DEC result]
  HIGH result
LOOP
END



What I would like to do is have a perl script I wrote command the BS2 to turn on the LED.

My plans are to have my BS2 control 2 servos that are the pan and tilt mechanism for a camera which would be controlled over the web. I was hoping to use a perl script to control the BS2 over /dev/ttyS0 on my linux web server.

Currently, I am just trying to turn on an LED and go from there. I see no point in writing the entire servo control software and find out I cant tell it what to do [noparse];)[/noparse]

Any help would be greatly appreciated!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-08-18 14:41
    Hello,

    ·· If you are, indeed, opening a DEBUG window in that program, you won't be able to get data through the port because the DEBUG window will have the port.· Also, you should set your baud rate parameter to 16468.· Since you're using virtual port 16 it will be done for you (that port always assumes inverted mode) but so your code is clear you should use the inverted value.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • staulkorstaulkor Posts: 5
    edited 2006-08-18 15:28
    Well the thing is that I have tried that before; removing the DEBUG and 16468 as baud. I can talk to the BS2 in the BASIC Stamp Editor in the debug window, but if i open up HyperTerminal and do 9600, 8, none, 1, none...I normally can see the DEBUG if there is one....but I cant type in the window. In linux, if i do an 'echo 9 > /dev/ttyS0' the green light on the HomeWork Board blinks, but the light doesnt turn on.

    Here is my perl script that I am using to try to turn on the LED... (The green light on the board also blinks as I run the script)

    #!/usr/bin/perl -w
    
    use Device::SerialPort;
    
    $PortName = "/dev/ttyS0";
    $PortObj = new Device::SerialPort ($PortName) || die
    "Can't open $PortName: $!\n";
    
    $PortObj->user_msg(ON);
    $PortObj->baudrate(9600);
    $PortObj->databits(8);
    $PortObj->stopbits(1);
    $PortObj->parity("odd");
    $PortObj->handshake("rts");
    
    $PortObj->write("9");
    $PortObj->close();
    
    



    And when I use the script, the light blinks, but the LED does not turn on.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-08-18 15:42
    Staulkor -

    Dump the ODD Parity and make it NONE.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • staulkorstaulkor Posts: 5
    edited 2006-08-18 17:50
    OK, I got it working. I just went down to rat shack and bought a female DB9 and wired in a new serial port on p0. Its working great now. Thanks for the help [noparse];)[/noparse]
Sign In or Register to comment.