PDA

View Full Version : Stamp -> Matlab



soorya
06-09-2005, 12:38 PM
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

Chris Savage
06-09-2005, 10:07 PM
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 (mailto:csavage@parallax.com)

soorya
06-09-2005, 11:29 PM
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 Savage
06-10-2005, 12:07 AM
···Okay, so what's happening when you do this?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Chris Savage
06-10-2005, 12:18 AM
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,[DEC redon]
FOR iter = 1 TO redon
HIGH red
PAUSE 200
LOW red
PAUSE 200
NEXT
SERIN serial, baudrate , [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 (mailto:csavage@parallax.com)