TX433 and RX433
Jon Keinath
Posts: 146
I have been trying to interface the Transmitter and Receiver that is available here... http://www.rentron.com/Stamp_RF.htm It has Basic stamp code, and I have been able to convert most of it to the javelin, but it doesn't seem to be working properly.
If I send codes right after another it will work for a while,(it occasionaly receives a wrong byte, I can live with this), but if I put any sort of pause it only receives the first properly, then returns only junk bytes.
Is there a way to use the serin, WAIT modifier in the Javelin?
Here is the RX code:
And here is the TX code:
If I send codes right after another it will work for a while,(it occasionaly receives a wrong byte, I can live with this), but if I put any sort of pause it only receives the first properly, then returns only junk bytes.
Is there a way to use the serin, WAIT modifier in the Javelin?
Here is the RX code:
public class RFtx { public static char data = 'o'; public static char sync; public static char junk; public static int txPin = CPU.pin2;//transmit pin public static int loop = 1; public static boolean flip = true; public static Uart txUart = new Uart(Uart.dirTransmit, //Uart for sending data txPin, //to RF transmitter Uart.dontInvert, Uart.speed2400, Uart.stop1); public static void main() { loop = 0; sync = 'a'; //sycronizes tx and rx junk = 'z'; //warm up byte while (true) { loop++; data = 'o'; if (loop%3 == 0) data = 'r'; if (loop%3 == 1) data = 'g'; if (loop%3 == 2) data = 'b'; txUart.sendByte(junk); txUart.sendByte(sync); txUart.sendByte(data); CPU.delay(2500); System.out.println(data); } } }
And here is the TX code:
public class RFrx { public static int rxPin = CPU.pin8; public static Uart rxUart = new Uart(Uart.dirReceive, //Uart for sending data rxPin, //to RF transmitter Uart.dontInvert, Uart.speed2400, Uart.stop1); public static char sync; public static int data; public static void main() { color(1,1,1); //turn "off" all three colors. while (true) { sync=(char)rxUart.receiveByte(); //wait for sync byte System.out.println(sync); if (sync =='a') { data = rxUart.receiveByte(); //receive data byte System.out.println(data); switch (data) { case 'b': blue(); color(red,green,blue); //these commands are simple subroutines that update 3 pwm uarts break; case 'r': red(); color(red,green, blue); break; case 'g': green(); color(red,green,blue); break; } } } } }
Comments
Why have you chosen sync = 'z' (0x7A) instead of sync = 126 (0x7E) as in the BS example?
Try the BS values: it may make a difference.
regards peter
Post Edited (Peter Verkaik) : 12/2/2005 5:32:57 AM GMT
Upon further investigation I think what is happening is the receiver is missing a bit somewhere, and that is where all the garbage values are comming from.
If I understand the WAIT modifier for the BS's Serin it will solve this problem my waiting for the sequence '01000001' ('A') and then starts the next byte after that. The Javelins UART only receives a byte at a time and if one of the bits is missing a different value is returned.. I'll try to explain this with some ascii art...
Based on this I can see why I get it to work sometimes, but not others.
This is how I assume it is working, I may or may not be correct in my assumptions. (Do my assumptions make sense?)
Does this mean that "all" I have to do is build some code that looks at the data steam a bit at a time?
Thanks for your help
-Jon
that bits move to other bytes. You already wait for sync before continuing but you could
rewrite your while (true) loop to reflect WAIT more closely. Is also less code.
··public·static·void·main()·{ //main receive
····color(1,1,1);··//turn·"off"·all·three·colors.
··· while·(true)·{
······do {
········data=(char)rxUart.receiveByte();··//wait·for·sync·byte
······} while (data != sync);
······data·=·rxUart.receiveByte();·······//receive·data·byte = byte following sync
······switch·(data)·{
········case·'b':·blue();
····················color(red,green,blue);··//these·commands·are·simple·subroutines·that·update·3·pwm·uarts
··················· break;
········case·'r':·red();
··················· color(red,green,·blue);
··················· break;
········case·'g':·green();
··················· color(red,green,blue);
··················· break;
······}
····}
··}
regards peter
·
But I did discover one thing, if I send bytes right after one another (remove the delay(2500) line from my tx code), it will recive the correct data every time..(well 99 out of 100) or so, but if I have the delay anything over about 200 it will only receive the first one, then a few (1-2 out of 100) after that.
I have attached the current stripped down code that I have been using to test these.
if i run it with out a delay, the terminal returns
~Ab
~Ab
~Ab
...
and with a delay... it's just a bunch of random characters with an occasional ~Ab in it.
If anyone has any ideas, they would be greatly appreciated.
Thanks,
-Jon
Post Edited (Jon Keinath) : 12/3/2005 3:33:41 AM GMT
receiver's oscillator. Having a gap in the transmission (your delay) may cause
this oscillator to destabilize. Try sending more junk bytes before the sync and data.
These extra junk bytes give time to stabilize the oscillator. Try to send
junk,junk,junk,sync,data and see if that improves your reception.
regards peter
THANKS Again!
-Jon