receiving long instead of a byte
Owen
Posts: 100
I think this likely a basic question, but one I have yet to figure out. I have applicatio that i wrote wich controls a stepper motor via serial comands. I'm sending the number of steps for the motor to turn from a visual basic brogram I have writen but I only know how to send an array of bytes or a string through the serial port which is limiting the number of steps to 0-255. Is there a way to send a larger number? I need the propeller to see a number as large as 180,000. is there a way to send 4 seperate bytes and have the propeller create a long from them?
here is the current code i'm writing Is attached if it helps.
thanks,
Owen
here is the current code i'm writing Is attached if it helps.
thanks,
Owen
Comments
byte b0,b1,b2,b3
b0:=serin
b1:=serin
b2:=serin
b3:=serin
pos[noparse][[/noparse]0]:=b0
pos:=b1
pos:=b2
pos:=b3
byte b0,b1,b2,b3
b0:=serin
b1:=serin
b2:=serin
b3:=serin
pos:=(b0<<24) and (b1<<16) and (b2<<8) and b3
pos:=(serin<<24) and (serin<<16) and (serin<<8) and serin
thank you!
The Propeller receives the two bytes, the ID then the position, and converts the ascii string to a 32 bit integer. After each set is rec'd, a case statement compares the ID to a list, if it is X then a variable X is updated, same for Y, Z, R. Another cog sends the motor to any newly arrived position.
Post Edited (originator) : 1/14/2007 8:54:01 AM GMT