Shop OBEX P1 Docs P2 Docs Learn Events
Stamp -> Matlab — Parallax Forums

Stamp -> Matlab

sooryasoorya Posts: 2
edited 2005-06-09 16:18 in BASIC Stamp
Hi All,

I am an amateur in the field of microcontrollers. This forum has been proved to be very useful for exchanging the information.
I have a problem communicating with stamp through the matlab, I can explain the problem briefly

I am trying to send two data values from matlab and store it in two different valued in the basic stamp . Using those Variables as the counters I am switching On and off the LEDS conencted to two control lines. The code is pretty simple but when I run th program, the lights doest work the way it should.

Is there any method that I can send some information from stamp to matlab so that it will be acting as a pointer so as to stop the data to be sent and resume the data to be sent

I am attaching the matlab code and the stamp code ( verymuch simplified version ) for those interested in helping me sort out the problem

Thanks in advance

Soorya

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-09 14:07
    Hello,

    ·· I'm not familiar with MatLab, but I'm going to assume it uses the programming port to exchange data with the Stamp so you can't use your DEBUG window?· If this is the case, do you have a Serial LCD display you could use for debugging?

    ·· Specifically what I would try is to confirm that the data you're sending the BASIC Stamp is what it's getting.· This could be done by displaying these values on another device (Usually DEBUG window) such as an LCD.· If the values are as expected, then it's got to be a code error.· Not knowing exactly what you're trying to do, I cannot tell if your code is doing that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • sooryasoorya Posts: 2
    edited 2005-06-09 15:29
    Hi Chris

    I am trying to store 2 values in two varibles declared as u and v onto stamp and those 2 values are calculated and sent by matlab via serialport. I have been using the LEDs for displaying if the values i am sending are being recieved or not as I am making the counter set to be equal to u ( value i have sent ) and v and making the pins 1 & 2 ( for which i have connected the LEDS) high and low for that count.

    Thanks

    Surya
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-09 16:07
    ···Okay, so what's happening when you do this?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-09 16:18
    Hello,
    ·· Found a couple of small bugs in the attached code, but I fixed those and what I have here works as you requested...
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    red CON 1
    blue CON 2
    serial CON 16
    baudrate CON 240
    redon VAR Word
    blueon VAR Word
    iter VAR Word
    main :
    SERIN serial,baudrate,[noparse][[/noparse]DEC redon]
    FOR iter = 1 TO redon
    HIGH red
    PAUSE 200
    LOW red
    PAUSE 200
    NEXT
    SERIN serial, baudrate , [noparse][[/noparse]DEC blueon]
    FOR iter = 1 TO blueon
    HIGH blue
    PAUSE 200
    LOW blue
    PAUSE 200
    NEXT
    GOTO main
    

    So if this doesn't work on your end, it has to be either the MatLab code or something in the communication.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.