Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp reading a variable from Processing, no luck — Parallax Forums

Basic Stamp reading a variable from Processing, no luck

federicofederico Posts: 6
edited 2008-05-04 01:10 in BASIC Stamp
Hi Everyone,
I'm trying to send a number with PROCESSING to be read by the Basic stamp 2 but so far no luck.
I'm using serin to read the number but nothing.
Any ideas on the code to use both for the Basic stamp and Processing? at this point i just need to check that they are able to communicate.
thanks a lot
Federico

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-05-02 21:46
    What is PROCESSING? Please elaborate on what it is you're trying to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • federicofederico Posts: 6
    edited 2008-05-02 22:21
    Hi Chris,
    Processing is this open source programming language that works with Arduino microcontroller, is close to wiring, and so far I have found several examples on how to read FROM the basic stamp (using serout) to processing but not the opposite. the thing is that this language is getting really powerful in the physical computing scope and is being used for a lot of art projects incorporating microcontrollers
    the web page of processing is
    http://processing.org/
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-05-02 22:25
    I’m not familiar with the language, but as the BASIC Stamp 2 has no UART or FIFO buffers it needs to be waiting at the SERIN command to receive data from a remote device when that data is sent. If it is doing something else it will miss all or part of the data. You didn’t post any code so there’s no way to know what might be happening, but you may need to use handshaking to make sure data is sent only when the BASIC Stamp is ready to receive it. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • federicofederico Posts: 6
    edited 2008-05-02 22:30
    thanks a lot Chris , sure is helpful!
  • stamptrolstamptrol Posts: 1,731
    edited 2008-05-02 23:06
    Had a quick look at the Processing webpages.

    Are you sure Processing has the capability to use a COM port by itself or does it depend on calling another program?

    As Chris suggested, having a few sections of your code (from both sides) would enable much fuller answers.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • PARPAR Posts: 285
    edited 2008-05-03 17:02
    federico said...
    Hi Everyone,
    I'm trying to send a number with PROCESSING to be read by the Basic stamp 2 but so far no luck.
    I'm using serin to read the number but nothing.
    Any ideas on the code to use both for the Basic stamp and Processing? at this point i just need to check that they are able to communicate.
    thanks a lot
    Federico
    As Chris noted, you haven't posted any PBasic and Processing code showing how you are trying to send from Processing to PBasic.

    Are you using the Processing Libraries, ...\processing-0135\processing-0135\reference\libraries\index.html, the SERIAL library, ...\processing-0135\processing-0135\reference\libraries\serial\index.html,·and its methods/etc?· (Look in your Processing Help/Reference for the documentation.)

    PAR
  • federicofederico Posts: 6
    edited 2008-05-03 18:00
    thanks a lot for all your responses, Here is some processing code I'm trying. the thing is that I have no example code for the stap
    some code:

    import processing.serial.*;

    Serial myPort; // The serial port
    void setup()
    {
    background(255);
    size(SCREEN_WIDTH ,SCREEN_HEIGHT);
    setUpTextProperties();
    setTextColor();
    allNums = new ArrayList();

    println(Serial.list());
    myPort = new Serial(this, Serial.list(),
    9600);
    }

    void draw()
    {
    currentFrame++;
    if (currentFrame >= Long.MAX_VALUE)
    {
    currentFrame = 0;
    }
    if (currentFrame % TEXT_UPDATE_FREQ == 0)
    {
    getNums();
    if (isThereANumber())
    {
    makeFinalNum();
    }
    }
    text(finalNum, textHPos, textVPos);

    sendSerial();
    receSerial();
    delay(10);
    }
    void sendSerial ()
    {
    myPort.write(finalNum);
    }

    void receSerial ()
    {
    while (myPort.available() > 0)
    {
    int inByte = myPort.read();
    println(inByte);
    }
    }

    And was is happening is that it just doesn't do anything- no errors, and the rest of
    the code is running fine, but these parts might as
    well not have been there (println is like the "debug" and it is not printing
    anything.)
  • FranklinFranklin Posts: 4,747
    edited 2008-05-04 01:10
    For the stamp try something like

    DO
    DEBUG "Hello World!", CR
    pause 5000
    LOOP

    Download the code to the stamp and check to see if it prints Hello World! in the debug screen. If that works close the stamp editor and try reading the stamp from your program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.