Shop OBEX P1 Docs P2 Docs Learn Events
add usb, and control with C++ in real time — Parallax Forums

add usb, and control with C++ in real time

edited 2011-02-28 12:53 in BASIC Stamp
OK kinda new to the parallax family chips...

right now i have a stamp II kit, serial programmed.

i want it to be connected to USB, controlled through C++, but i want it done in real time, not program the stamp and run the program...

the reason, the stamp doesnt hold the amount of programming needed, and it also doesnt store the amount of variables needed...

and it needs to be controlled from ANY systme it is plugged into, not just one with serial, seeing most computers including my 3 main laptops dont have serial ports, just usb...

anyone have any ideas?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-28 11:56
    The Rolling Stones sang "You can't always get what you want ... you get what you need". That may hold true here.

    You can get any of a variety of USB to serial adapters and use that for the serial connection to the PC. Not all USB to serial adapters will work for programming, but most will work to otherwise send data back and forth to the PC. I suggest Parallax's USB to RS232 serial adapter. It's small, cheap, and reliable ... and you can use it to program the Stamp.

    You can't directly control the Stamp from the PC. There has to be a program running on the Stamp and it's what's controlling the I/O pins. That said, it can be a simple program that just continually waits for bytes to be sent from the PC and outputs those bytes to the I/O pins or reads the state of I/O pins and sends that data to the PC. There's no specific format for that data. It's just arbitrary bytes as far as the Stamp is concerned. You'll need to set up your C++ program to interpret what the Stamp sends and to send appropriately formatted data to the Stamp. You'll also have to write a short program on the Stamp side to do the work there.

    Have a look at the StampPlot Pro program which can be found on Parallax's Stamp Downloads webpage. This shows what can be done along these lines.
  • edited 2011-02-28 12:22
    the usb to serial will work...

    dont think i have a prob with writing a "transfer" program on the stamp...

    thinking i can get away from programming the chip, if i can send, for example

    turn on 0,1,2,3,4,5,6,7
    turn on 8
    turn off 8
    turn on 0,1,2,3
    turn off 4,5,6,7
    turn on 9
    turn off 9

    this will "program" the chip, run it, then stop

    then when i want to send "new" data, have it program it again

    in the example, 0-7 are my "data" i am sending

    pins 8 and 9 are the "triggers" for my flip flops...

    but i kinda need c++ to be able to send the "program" to the chip, that way it is computer controlled, and the variable can be stored

    hope this clarifys the question...
  • edited 2011-02-28 12:39
    found the following http://www.jawed.com/programs/robot.html

    i could use serial to send data that the stamp could "decode"

    preprogrammed stamp to take the input, like 1-320, and "toggle" the resulting bits....

    just need to know how to program stamp to decode the input from the serial....
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-28 12:53
    Typically, you'd have the PC send something like: "!!", <LSB on>, <MSB on>, <LSB off>, <MSB off>

    The Stamp would execute: DEBUGIN WAIT("!!"), turnOn.BYTE0, turnOn.BYTE1, turnOff.BYTE0, turnOff.BYTE1
    This would read 5 bytes from the PC via the serial/USB connection. The first two are just for synchronization.

    This would have the Stamp wait until it receives the "!!", then it would receive 4 more bytes and store the
    first 2 in one 16-bit variable and the second 2 in another 16-bit variable. You'd then turn the I/O pins on and off
    with: OUTS = (OUTS & !turnOff) | turnOn. The I/O pins would need to be configured as outputs (rather than inputs).
    Look at the Stamp Manual (Basic Stamp Syntax and Reference Manual) for details on OUTS and DIRS.

    Because of the way the serial connection is wired on the Stamp, the characters sent from the PC would be echoed
    back to the PC (and would have to be ignored).
Sign In or Register to comment.