Shop OBEX P1 Docs P2 Docs Learn Events
serin.bs1 example question — Parallax Forums

serin.bs1 example question

duluskiduluski Posts: 7
edited 2004-11-22 20:26 in BASIC Stamp
Hello,

I just recently got the Stamp 1 Project Board and am trying to make a simple switch controller. I plan on sending data from the PC to the controller to activate a specific switch. I am trying to send the data via the SERIN command, but am not sure exactly how it works. I found the SERIN.BS1 sourcecode in the samples that came with the BASIC Stamp Editor software and tried to execute it. It seems to just sit in the debug terminal and I cannot get it to react to the sequence ABCD. How do I input this string ABCD, followed by a number, followed by a carriage return using the basic stamp software?

Thanks

Comments

  • kb2hapkb2hap Posts: 218
    edited 2004-11-17 02:55
    If you could post some code it would help but it looks like you may want to use the debugin statement.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    DTQ
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-17 03:40
    How are you connecting your BS1 to the PC? Are you going direct (through a 22k resistor) or through a level-shifter like the MAX232? What baud rate are you using? The max for the BS1 is 2400 baud.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • duluskiduluski Posts: 7
    edited 2004-11-17 07:18
    I believe I am going direct. I know that the baud rate is supposed to be 2400, but it seems that when I run the program, the debug window by default sets it to 4800 and I cannot change it.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-17 08:51
    You're right, DEBUG on the BS1 operates at 4800 baud.· What you'll need to do is open a different terminal window (there is no DEBUGIN on the BS1) to send data to your BS1 so that it can be set to 2400 baud.· Once you have a terminal that you can talk to your BS1 you can use the circuit and code below to control the LEDs.· Note that you may need to build a cable using a DB9-F (female) connector to connect to your breadboard -- everything else will just plug right in.


    attachment.php?attachmentid=36604

    SYMBOL          Sin     = 7
    
    SYMBOL          pnNum   = B2
    
    
    Reset:
      PINS = %00000000      ' clear LEDs
      DIRS = %01111111      ' make P0 - P6 outputs
    
     
    
    Main:
      SERIN Sin, N2400, ("ABCD"), #pnNum
      IF pnNum > 6 THEN Main
      TOGGLE pnNum
      GOTO Main
    
    

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 11/22/2004 6:31:59 PM GMT
    331 x 209 - 3K
  • duluskiduluski Posts: 7
    edited 2004-11-17 16:41
    I tried the new debug window set @ 2400 baud with the souce code given...I try typing in ABCD with a number then press enter, and I still can't seem to get any sort of reaction from the controller.· Do I need to enable DTS or RTS in the debug window?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-18 04:40
    Nope. I ran the code attached to my response message, using a Debug Terminal to send messages (exactly as you specify) -- and it happily toggled the state of six LEDs on my development board. Are you connecting to the correct pin on your serial connection?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • duluskiduluski Posts: 7
    edited 2004-11-18 14:45
    Well I don't have leds on the board. I was hoping I could just send a message and get a debug message in return to verify that it works. When I put a DEBUG line after the SERIN command in the source, it never seems to reach it.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-19 02:25
    Are you using two separate serial ports? You must in order to do what you want to do: the DEBUG window runs at 4800 baud, the "command" window sends messages in at 2400. Trust me, the program I posted works.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • duluskiduluski Posts: 7
    edited 2004-11-22 14:24
    I am using the same serial port. I don't doubt that the sample program you gave works...I'm pretty sure I am doing the new debug terminal properly. is there anything I need to configure on the breadboard that I am not doing?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-22 15:22
    Well, there's your problem. You cannot have the same serial port operating through a single terminal, or at different baud rates. What I suggest you do is connect some LEDs to your BS1 and use them as the output for the program that I gave you earlier (be sure to remove [noparse][[/noparse]comment out] the DEBUG statements from your program).· That's how I tested the program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office


    Post Edited (Jon Williams) : 11/22/2004 3:24:21 PM GMT
  • duluskiduluski Posts: 7
    edited 2004-11-22 16:59
    How do I connect the LEDs on the board to test the program?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-22 17:31
    It's VERY simple -- see the schematic I added to my post above.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • duluskiduluski Posts: 7
    edited 2004-11-22 17:47
    Sorry, for some reason my browser didn't pick up that image.· I can see it now though...in the schematic, I see how the leds are supposed to be set up, but how do you set up the connection that goes to RS-232 IN?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-22 18:34
    I've updated the schematic -- if it still doesn't make sense then you may want to work your way through our WAM (What's A Microcontroller?) book before proceeding.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-11-22 20:26
    The RS232 IN pin gets a serial 22 Kohm resistor.
    The purpose of this resistor is to reduce the current enough on the input pin that the PIC internal protection diodes can 'clamp' the signal. Thus, the far end of the 22 Kohm resistor sees + 12 and - 12 volts. The PIC end of the 22 Kohm sees 0 volts and +5 volts.
Sign In or Register to comment.