Displaying a variable current value?
What command in spin language is used or what can I do if I want to display the value stored in a variable. I am sending the number 1 from a Matlab program to the device. I am using the program below to receive the number 1 and turn a led on. The communication blue light on the propeller blinks once when I run the matlab program so it is receiving something but I don't know why the led that is supposed to turn on is not turning on. The code below works because when I use the parallax serial terminal and write 1 the led does turn on.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ ser : "FullDuplexSerialPlus" PUB main | Number, Value ser.Start(31, 30, 0, 9600) waitcnt(clkfreq*2+cnt) repeat ser.Str(String("Valor recibido por MATLAB:")) Number := ser.rx Value := ser.GetDec ser.Dec(Number) ser.tx(13) if Number=="1" dira[4]~~ outa[4]~~
Comments
This is my Matlab code
Is there anyway to check what variable am I receiving from Matlab?
2) Yes, is a numeric 1, do I need to change any coding to make it work?
3) For the last block of code you sent me, should I delete everything else in the repeat block and just copy paste that?
Sorry for the questions, I am a beginner excited to understand and make this work
Thank You
Sorry for the delay, had a walk at the beach.
1. yes
2. if Number == 1 ' no quotes around the 1
3. That would only be useful for continuous monitoring. Just remove the GetDec call from your original code for now: The red bit does the monitoring/echo for you.
I'm not familiar with Matlab but it would be worth checking how bidirectional file I/O works. There must be an equivalent fread() call which would allow you to see debug output in Matlab.
please tell us what you want to do in the end.
if we (the other forum-members) have an overview about your project much better solutions can be found.
If you are just want to learn the basics about using the propeller and are using mathlab just because you are familiar with it
I would recommend to switch to EZLog from hannoware instead of using mathlab.
If you are forced to use mathlab then it would be interesting to know which board you are using.
On a PPDB you have a second serial interface ready to use which could be used for debugging parallel to the communication with mathlab.
on other boards you can use any propeller-IO-pins to establish another interface.
So what do you want to do in the en?
best regards
Stefan