I bought a Parallax 433.92 MHz RF Transmitter and Receiver. I’m using Basic Atom 28 bot boards with both transmitter and receiver. The receiver will be hooked to my ex Lawnmover tank. It is using a scc-32, sabertooth2x25, and a text to voice module(lets the robot speak). The voice module can accept up to 256 bytes. Here is sample code for bs2 transmitter.
[code]x var Word
y var Word
Do
PULSOUT 8,1200
SEROUT 8,16468,"!",x.HIGHBYTE,x.LOWBYTE,y.HIGHBYTE,x.LOWBYTE]
x = x + 1
y = y + 1
PAUSE 10
LOOP
[/code]
Here is sample code for bs2 Receiver.
[code]x var Word
y var Word
Do
LOW 0
SERIN 7,16468,[WAIT("!"),x.HIGHBYTE,x.LOWBYTE,y.HIGHBYTE,x.LOWBYTE]
HIGH 0
DEBUG x
DEBUG Y
LOOP
[/code]
If i want to send 256 bytes from transmitter to reciever does that mean i will have to reciever that many bytes at once in ever msg. Is there a way with the basic atom 28 i can decide how many bytes to reciever based on the first 2 bytes i recieve after the start byte “!”. For example the first byte decide which device to send msg to and second byte will be amount of bytes to recieve.
Will not make sence to reciever 256 bytes when i just want to send a msg about the speed to the sabertooth2x25.
Yes, you can write your code to have variable packet sizes. There are many approaches you might try.
If you have a small number of packet types and each packet type has a fixed size, you could simply do something like:
On the transmit side, send out a packet header byte, which tells which type of packet is going to be sent. Pause a very short time to allow the receiver side time to setup for the real packet. Then send out the rest of the fixed side packet.
On the receive side, wait for a byte to come which tells you which packet type you have and branch to another serin command that is specific for the type of packet you are receiving.
You could do a more generic solution, which in a fixed portion, would contain the count of bytes for the packet, and then on the transmit side simply loop through each byte. If on the receive side you are losing data, you could either put a slight pause between bytes or try the pacing argument on the serout command. On the receive side you could have a generic buffer, that you simply go into a for loop or the like receiving the bytes of the message and once you received all of the bytes you would process the message.
Each approach has it’s merits, the first is easiest to implement, the second has more flexibility. You could implement a hybred version where one of the message types was receive a buffer.