Serout Using Binary Values
Gary D.
Posts: 37
Hello...
·· I am working on an ecryption project... and have hit a little speed bump.
Here is the scenario. i am trying to send Binary data from 0 to 1024 using the serout command. baud is not important at this time. not familiar with parity bit nor the polarity bit. if it helps this data will·NOT be received by·another Stamp nor Computer.. It will be received on a Binary Decoder Chip for my project.·would this be easier using Shiftout...
I·just want to send the Binary data and perhaps loop every value··4 or·5 times so that it definitely gets·transmitted.
SEROUT·tpin,baud, ....... then im lost
thanks for all feedback...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 kinds of people....
Those who know binary and those who Don't.
·· I am working on an ecryption project... and have hit a little speed bump.
Here is the scenario. i am trying to send Binary data from 0 to 1024 using the serout command. baud is not important at this time. not familiar with parity bit nor the polarity bit. if it helps this data will·NOT be received by·another Stamp nor Computer.. It will be received on a Binary Decoder Chip for my project.·would this be easier using Shiftout...
I·just want to send the Binary data and perhaps loop every value··4 or·5 times so that it definitely gets·transmitted.
SEROUT·tpin,baud, ....... then im lost
thanks for all feedback...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 kinds of people....
Those who know binary and those who Don't.
Comments
·· Because you're trying to send a number larger than 255, you will need to send it as two bytes, as in lowbyte then highbyte.· Is the receiving end going to be able to handle a 2 byte value?
SEROUT tpin, baud, [noparse][[/noparse]wordVal.LOWBYTE, wordVal.HIGHBYTE]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Next Step is to Increment the 12 bits of data... so in actuality i must start from 0 and end at 4095.
i am unfamiliar with the "Wordval" function...
Thanks for your feedback.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 kinds of people....
Those who know binary and those who Don't.
If your receiver can receive 12 bit values you can probably use something like:
SEROUT tpin, baud, [noparse][[/noparse]wordVal.LOWBYTE, wordVal.HIGHBYTE.LOWNIB]
which should send 12 bits of data. As far as incrementing the 12 bit value, just increment the 16 bit variable wordVal. If you need bounds checking (making sure the value does not exceed 4095) simply do a
IF (wordVal > 4095) THEN wordVal = 0 ENDIF
Though if you send the data in a 12 bit quantity, like I showed above, and you dont need to use the 4 bits left over for some other variable, you do not need to do the boundry checking because when you send the lower 12 bits of the 16 bit value, 4096 will be sent as 0 since the 13th bit isn't transmitted.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 7/27/2005 8:08:11 PM GMT
I will give this a try and see how it goes...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 kinds of people....
Those who know binary and those who Don't.
SEROUT encodes each byte as an RS232 byte -- with a start bit, level change for each of 8 data bits, maybe a parity bit, and then a stop bit as the line goes back to 'idle'. You'll have to sample the data at exactly the baud rate to get each bit.
SHIFTOUT also sends a shift clock with the data, and will send 16 bits at a time (or 12 bits at a time, with the "\12" modifier). This is much closer to the 'raw serial' your binary decode probably wants to recieve.