I am doing and RF application with PIC chip and using picbasic pro to write my code. My poblem is that I have a 8 bit number I want to send serially. The serout command work up to 8 bit , so the number should not be distorted, Althought I want to use manchester encoding which will double the bandwidth (16bit), therefore I cannot use the serout command which is only good for 8 bit.Doe someone know how to bypass this problem. thanks ken
Didn't find your answer? Ask the community — no account required.
J
James Beck
Yes, send 2 bytes.
A
Anonymous
Ken,
******************************************** To receive 16bit Manchester and decode to 8bit
for rx=0 to 7 'for-next loop 8 times - BYTE vairable
rec_code.0[rx]=~incode.0[rx
L
lerameur
send 8 bit packet, you are using it to send a word (16bits), so what is the deal there ? Why does it work with a word size... ken
L
lerameur
by the way, I am trying to use an array with picbasicpro
lcdout $FE,$C0, bin encoded1[3]
I thought it would give the 4 th digit of the array in binary, but instead it gives me a 13 bit number... what is going on .
ken
A
Anonymous
Ken,
Forgive me for too much Xmas cheer.
My application, from memory was a simple remote control. Instead of taking a byte, encoding it each time a button was pressed and then sending it I just used a 16bit already Manchester encoded WORD constant and sent that - in two parts. Lowbyte and then highbyte with a qualifier byte and perhaps a preamble at the start.
Serout or Serout2 sends in user specified values like 8N1, 8bits, no-parity, 1-stop bit. Thats 8bits or one byte at a time so for a WORD vairable it takes two bytes for a WORD - lowbyte and highbyte. If you read the PICBASIC PRO manual you'll see that it drops the preamble, qualifier and other Serout bits. Manchester encoding takes a single byte (8bits) and makes it a WORD through encoding (16bits). Serout2 can't handle that directly so you need to break it down into bytes - lowbyte/highbyte. Hence the encoding/decoding required.
I have dug out the printout that I used to do what I needed and below is the code provided by Greg Yent from the picbasic.com forum archives. Alter it to suit your needs.
TempWord VAR WORD TXData VAR BYTE RXData VAR BYTE
'assign your special data to TXData
ENCODE:
for i = 0 to 7 TempWord.0[i
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.