Shop OBEX P1 Docs P2 Docs Learn Events
Basic stamp communication through visual studio — Parallax Forums

Basic stamp communication through visual studio

SD2POSD2PO Posts: 11
edited 2009-11-19 18:10 in BASIC Stamp
Hello,

I am working on a object detection system. I currently have the Basic Stamp Homework Board. At first I was going to try to do things wirelessly but time has been shortened and so I am wanting to run everything off of one machine. I am new to Basic stamp and was wondering is there anyway I could communicate through the Serial-USB to my laptop and see the data that is coming from the Basic Stamp....Based on Status change 0,1, send an email to a customer.

Thanks...Please Someone Help!!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-27 05:08
    You can use the DEBUG or SEROUT 16 statements. Both transmit standard serial data via the serial-USB adapter to the PC. If you're using a BS2, the Baud is 9600. On the PC side, you can use any program or programming language that can read from a serial port at 9600 Baud. The Stamp Editor's DEBUG window can do this and you can test the Stamp programming this way or you can write a Visual XXX program (whatever XXX happens to be) to receive the serial data.
  • SD2POSD2PO Posts: 11
    edited 2009-10-27 23:54
    Thanks so Much Mike! I am new to the Basic Stamp and I thought it would be interesting to try something new that I could learn about. I am just trying to figure out how to program the board using Visual Studio now...hopefully I can get this done in the next week or so...
  • FranklinFranklin Posts: 4,747
    edited 2009-10-28 02:20
    You can't "program the board" (stamp) with Visual Studio. You can communicate with a program on the stamp though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SD2POSD2PO Posts: 11
    edited 2009-10-28 03:32
    Oh ok...so if I wanted to check if a certain pin is high or low I could communicate with the board. On the board I have IR pairs connected, and I want to be alerted when the status change. I am doing object detection, and I want to assign a certain box to a customer..say box 1 is attached to pin0 and pin1...if the status changes to high(1) send an email through a local server.
  • FranklinFranklin Posts: 4,747
    edited 2009-10-29 01:49
    You would need to monitor the serial line of the stamp and have the stamp send "pinx high" when the pin goes high. What you do on the PC side is up to you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SD2POSD2PO Posts: 11
    edited 2009-11-04 02:14
    Hello, I have a question. I have programmed the homework board through my serial port on my laptop with the following code for object detection:

    ObjectDetectBox1 VAR Bit
    DO
    FREQOUT 8, 1, 38500
    OjectDetectBox1·= IN9
    DEBUG HOME, "ObjectDetectBox1 = ", BIN1 ObjectDetectBox1
    PAUSE 1000
    LOOP

    What would I do to call this information through Visual Studio C#? I am wanting to read from the Homework board when the box has an object...to send an email to a contact in a specific database.

    Please could anyone help me? I am not familiar with the coding.

    Thanks
  • FranklinFranklin Posts: 4,747
    edited 2009-11-04 03:12
    Set VC++ to monitor the serial port and when it sees "ObjectDetectBox1 = "<whatever a 0x1 would be to VC++> you should program it to do your task.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SD2POSD2PO Posts: 11
    edited 2009-11-13 11:49
    Hello Everyone,

    I have a few questions. Ok I have ran a few programs with help for the VS2008 end to access my serial port. Now I have a question about basic stamp 2 supporting interrupt commands. For instance when Pin1 = 0, then changes to 1 because of the object being detected, I want the project to awake upon interrupt. So in other words when someone inserts an object and blocks the emittance of light I want the machine to become active instead of being active the whole time. Also, Stephen I do not quite understand your previous post. <whatever a 0x1 would be to VC++> also I am using C#, not C++. Thanks.
  • SD2POSD2PO Posts: 11
    edited 2009-11-16 03:38
    How to access pins from Parallax Homework Board, Through Visual Studio 2008? To read when the values of the pins are high so I can send an sms message to cellphone. Thanks
  • FranklinFranklin Posts: 4,747
    edited 2009-11-16 04:45
    You need to write a program for the stamp that will test the pins and send a serial message to your program when they change. Your program on the computer will then send the SMS message.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SD2POSD2PO Posts: 11
    edited 2009-11-16 07:32
    So to send a serial message would I use SERIN, SEROUT, or the POLLIN command? I am confused between the three. Also would I have to convert to HEX, BINARY, OR ASCII or can I just write the code in plain English?
  • FranklinFranklin Posts: 4,747
    edited 2009-11-16 18:40
    Start with a program on the stamp that outputs a debug statement that meets your needs like
    DEBUG "pin 9 is high", CR
    when you get that part working so it sends the message when it sees the sensor activated and sends nothing or another message when not then post your code here and we can discuss the next step.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SD2POSD2PO Posts: 11
    edited 2009-11-18 15:58
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    Declarations
    BoxIR1 VAR Bit
    BoxIR2 VAR Bit
    BoxIR3 VAR Bit
    BoxIR4 VAR Bit
    '
    Main Routine
    main:

    FREQOUT 7, 1, 38500
    BoxIR1 = IN8 ' Store IR detector output in RAM.
    FREQOUT 1, 1, 38500
    BoxIR2 = IN0
    FREQOUT 8,1, 38500
    BoxIR3 = IN9
    FREQOUT 0,1, 38500
    BoxIR4 = IN1
    DEBUG HOME, "Box1= ", BIN1 BoxIR1
    PAUSE 20
    DEBUG " Box2= ", BIN1 BoxIR2
    PAUSE 20
    DEBUG " Box3= ", BIN1 BoxIR3
    PAUSE 20
    DEBUG " Box4= ", BIN1 BoxIR4
    PAUSE 20
    GOTO main

    Debug Terminal

    Box1 =
    Box2 =
    Box3 =
    Box4 =

    This program....displays a 0...when there is nothing there....and a 1 when there is something blocking the emitter and receiver. So now comes how do I read it through Visual Studio. I know I want to either use SEROUT or POLLIN commands but I do not understand the syntax.

    Thanks
  • FranklinFranklin Posts: 4,747
    edited 2009-11-18 16:13
    First let's start with what you want to get in your program on the PC then send that from the stamp. Check the help file for the syntax for SEROUT but it is something like:
    SEROUT pin, baud, <formatter> data

    Also if you plan to have four sensors it would be a good idea to have them on four adjacent pins. Take a look in the help file on IN1 and INA.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen

    Post Edited (Franklin) : 11/18/2009 4:18:21 PM GMT
  • SD2POSD2PO Posts: 11
    edited 2009-11-19 04:56
    I want to monitor the signal change from low to high on the pins and if the output is high....Visual studio will send an email to that particular person.
  • FranklinFranklin Posts: 4,747
    edited 2009-11-19 16:34
    SD2PO said...
    I want to monitor the signal change from low to high on the pins and if the output is high....Visual studio will send an email to that particular person.
    No one is stopping you.
    What part of this do you have done?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SD2POSD2PO Posts: 11
    edited 2009-11-19 17:17
    I have the program in basic stamp that detects when an object is present. So I am wanting to know how do I get this info to be sent through the serialport, like when pin0=1, object is present. In visual studio there is a serialport class which is easy but my question is how do I get the info from the board like would I say SEROUT 0, 16648 to call this from Visual Studio? or POLLIN 0,1?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-19 17:31
    You would use SEROUT. Look in the BASIC Stamp Syntax and Reference Manual (downloadable from Parallax) in the chapter on SEROUT. This manual and other information on the SEROUT statement are also included with the Stamp Editor. Look in the HELP menu.

    Typically you'd send a character or a couple of characters every now and then from the Stamp to the PC. The choice of characters depends on whether the sensor detects something or not. The Visual XXX program sits there and receives whatever is sent from the Stamp. When the received data indicates that the sensor has sensed, then the Visual XXX program can do something.

    Post Edited (Mike Green) : 11/19/2009 5:36:38 PM GMT
  • SD2POSD2PO Posts: 11
    edited 2009-11-19 18:10
    Thanks for your help!!! I will be trying to finish up this programming by the end of the week.
Sign In or Register to comment.