Variables
TexFly
Posts: 26
Hello,
I'm trying to send/receive information via RS232. I'm able to do so however I need help translating the information I receive on the Propeller.
For example when I send the letter "C" from the computer I can intercept on the SPIN using $43. But how do I output to the video Propeller? I use the graphic library
gr.text(84,20,sin)
But I get weird numbers!
What I really like is to send/receive bits/bytes so I can use the sequence of "1" and "0" to turn on and off Propeller IOs...
Any suggestion?
Thanks!
I'm trying to send/receive information via RS232. I'm able to do so however I need help translating the information I receive on the Propeller.
For example when I send the letter "C" from the computer I can intercept on the SPIN using $43. But how do I output to the video Propeller? I use the graphic library
gr.text(84,20,sin)
But I get weird numbers!
What I really like is to send/receive bits/bytes so I can use the sequence of "1" and "0" to turn on and off Propeller IOs...
Any suggestion?
Thanks!
Comments
From what you have posted yet it's not really clear which object you are using (TV, VGA? and there which one exactly?)
Minimum would be to insert code with the CON-OBJ-VAR-sections of your code and the method that tries to display the characters.
If you only wnat to switch on/off 8 IOs you could simply send a single byte where each bit represents one IO-pin
if you send an ASCII-codes sequence of "0"s and "1"s
ASCII-Code of "0" is 48
ASCII-Code of "1" is 49
so substract 48 from the ASCII-codes to get 0 and 1
best regards
Stefan
What I really like to do is establish a sort of protocol to exchange information between my PC (VB6) and the Propeller. I can do that partially but I would like to send an information to the Propeller (via RS232) to turn on/off some of the bits. So for example let's say I have 16 graphic buttons on my PC code, when I push one of those buttons I like to turn on/off one of the Propeller IOs.
Is there a sort of "midstr" instructions in SPIN so I can parse/extract the bits form the sent string?
There are several "strings" libraries in the OBEX. Brandon Nimon's "Strings Library v2" has several methods such as "SubStr" that will help in pulling individual characters from a string. Kye's "string engine" library allows conversion of strings from and to integers. Send data from your PC to the Prop in any form that makes sense to you (binary string: "11111111", integer text: "255", HEX: "FF"). On the Prop side, convert the string to a usable form (binary, integer)...
if the PC sends "00000001", something like this should work to set pin 23 to ON
ser.GetStr(@myString) ' assumes "ser" is your serial input object (FullDuplexSerialPlus from the OBEX)
setVal := binaryToNumber(myString) ' convert binary string to an integer
OUTA[16..23] := setVal ' set pin(s) to ON
Would you give me an example?
Let's say I send "81" HEX (or 10000001 Bin or 129 Dec) to the Propeller. How do I process this information to turn bit 16 and 23 ON?
Can I do ser.GetStr(@myString) (FullDuplexSerialPlus from the OBEX)
OUTA[16..23] := mystring
???
Thanks!
I use the OBJEX Graphic interface that works great but I have some trouble printing the variables.
I have
gr.color(1)
gr.textmode(2,2,5,%0001)
GR.text(60,165,string("CONNECTED!"))
gr.TextMode(2,1,6,%0001)
gr.text(54,20,string("P="))
gr.text(84,20,sin)
but I get weird numbers on the screen...