receiving long instead of a byte
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.
CON _clkmode = xtal1 + pll16x ' use crystal x 16 _xinfreq = 5_000_000 ' 5 MHz cyrstal (sys clock = 80 MHz) TAB = $09 CR = $0D VAR byte array[noparse][[/noparse]24] ' buffer for numeric fields long X, Y, Z, R ' these are actually 32 bit integers long temp1, temp2 OBJ ser : "fullduplexserial" term : "tv_terminal" PUB Start | i ser.start(0, 1, 0, 9600) 'rec tx mode baud term.start(12) 'enable TV terminal repeat if receiveStr(@array,24) <> TAB term.str(string("Missing TAB after temp1",CR)) quit Temp1 := convertstr(@array) if receiveStr(@array,24) <> CR term.str(string("Missing CR after temp2",CR)) quit Temp2 := convertStr(@array) CaseTemp PRI receiveStr(address,count) | c repeat count 'start counting c := ser.rx 'c = first rec'd byte if c == TAB or c == CR 'c == CR or TAB, byte[noparse][[/noparse]address] := 0 return c 'now return delimiter for optional checking byte[noparse][[/noparse]address++] := c 'update c return 0 'default delimiter is zero PRI getrx recbyte := ser.rx PRI getarray | i repeat i from 0 to 4 if recbyte == $0D recbyte := 0 PRI convertStr(address) | C repeat while c := byte[noparse][[/noparse]address++] result := result * 10 + (c - "0") PRI CaseTemp case temp1 4270 : x := temp2 '4270 is decimal equiv to ascii string "XID" , if it is X, then the vairable X is written to the value rec'd repeat until not lockset(SemId) RetEcheck(string("XID"), X) 'return the value back to the app to verify prior to motor run lockclr(SemId) case temp1 4370 : y := temp2 repeat until not lockset(SemId) RetEcheck(string("YID"), Y) lockclr(SemId) case temp1 4470 : z := temp2 repeat until not lockset(SemId) RetEcheck(string("ZID"), Z) lockclr(SemId) case temp1 3670 : r := temp2 repeat until not lockset(SemId) RetEcheck(string("RID"), R) lockclr(SemId)Post Edited (originator) : 1/14/2007 8:54:01 AM GMT