Author Topic: Sending packets of data through RF UART  (Read 27728 times)

0 Members and 1 Guest are viewing this topic.

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sending packets of data through RF UART
« Reply #30 on: October 25, 2008, 11:48:29 AM »
i had a read of the datasheets.
they don't mention any special encoding being required. manchester encoding should not be required.

if i were you i'd post your findings on the Sparkfun forum.
see if you can find anyone who has successfully used them.


dunk.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #31 on: October 25, 2008, 05:33:53 PM »
I'm posting the question now

thanks
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #32 on: October 25, 2008, 06:49:34 PM »
hey dunk  maybe I should try these modulation styles that are stated in the datasheet?
Quote
MO-RX3400-A is an ASK receiver module. The MO-RX3400-Ais based
on a single-conversion ,super-heterodyne receiver architecture and
incorporates an entire Phase-Locked Loop (PLL) for precise local oscillator
generation. It can use in OOK / HCS / PWM modulation signal and
demodulate to digital signal. MO-RX3400-A had a high performance and
easily to design your product.

OOK -  http://robotics.eecs.berkeley.edu/~sastry/ee20/modulation/node5.html   ( no idea about this)
HCS -  no fricken idea , google yields nothing
PWM - good ole Pulse width modulation  http://en.wikipedia.org/wiki/Pulse-width_modulation

This brings me to another question :
UART just happens to work with these , but isnt intended to work like that.  But so many people have it working

oh one big thing to note - the bastardly Sparkfun people's tutorial says that pin3 of the receiver should be left alone.  Over here : http://www.damonkohler.com/2008/09/arduino-rf-link.html it correctly states that in the datasheet the two data pins should be connected to each other. Whatever, i'll try out that data pin wiring changes tomorrow.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sending packets of data through RF UART
« Reply #33 on: October 25, 2008, 07:03:43 PM »
OOK is just any digital signal that passes data by switching between 2 logic states.
your UART is an implementation of this.
so, yea, no complicated transmission schemes *should* be required....

one more thing actually,
when i was first playing with my RF modules i found they were particularly susceptible to noisy power supplies.
any sort of slight brown out of the power caused transmission errors.
it caused me lots of headaches until i realised what was causing it.

are you sure your power to the modules is clean?


a last piece of debugging for you as well:
you've probably tried this but just to confirm it's definitely your RF modules at fault and not your code,
have you tried removing the RF modules from the circuits and joining the TX pin on one AVR to the RX pin on the other?


dunk.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #34 on: October 25, 2008, 10:27:35 PM »
what do you mean by clean power?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sending packets of data through RF UART
« Reply #35 on: October 26, 2008, 04:33:56 AM »
Quote
what do you mean by clean power?
constant voltage.
no spikes or dips.
completely constant voltage.
when i was building my RC circuits my servos were causing a *slight* drop in the RX power.
it was not even nearly enough to affect the AVRs program but it caused the receiver module to give really nasty results.


dunk.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #36 on: October 26, 2008, 04:59:53 AM »
Receiver power is connected to Axons regulated line , Transmitter line is connected to the other axons unregulated line. 12V Nimh battery is connected to Transmitter Axon. No other circuitry is on Transmitter axon besides the transmitter. Is that clean enough?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #37 on: October 26, 2008, 04:44:00 PM »
ok this is wierd
Jumpered Tx to Rx  with a wire and I get this
Quote
55 56 56 56 59 59 59 59 59 55 55 55 55 55 55 56 56 56 56 56 59 59 59 59 59 55 55 55 55 55 55 56 56 56 56 56 59 59 59 59 59 55 55 55 55 55 55 56 56 56 56 56 59 59 59 59 59 55 55 55 55 56 59 59 59 59 55 55 55 55 55 56 56 56 56 56 59 59 59 59 59 59 55 55 55 55 55 56 56 56 56 56 59 59 59 59 59 59 55 55 55 55 55 56 56 56 56 56 59 59 ....

As you can see I get a repeat of bytes.

heres my code:
Code: [Select]
SendByte(data1);  //55
SendByte(data2);  //56
SendByte(data3);  //55

and here are my subroutines.
Here is my SendByte routine
Code: [Select]
void SendByte(char c) {
  while (!(UCSR0A & (1<<UDRE0)));  // wait until you are able to send a byte
  UDR0 = c;
}

Here is my getbyte routine
Code: [Select]
int GetByte0(void)
{
    while((UCSR0A&(1<<RXC0)) == 0); // wait until a byte is received
    return UDR0;
}

This is really really wierd. What can I do to fix this mess?

Also, can I just use PWM on the transmitter and take an ADC on the receiver?

P.S. dunk I think we scared away all the forum members from this post  ;)
« Last Edit: October 26, 2008, 05:01:31 PM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sending packets of data through RF UART
« Reply #38 on: October 26, 2008, 05:57:49 PM »
ok, well that's a little progress.
at least you now know the problem is not with the RF modules.

do you have a level shifter built so you can feed the TX side into your PC serial port?
you could verify the TX code that way. make sure you are transmitting the right thing.

getByte and sendByte look fine to me.
i think you are going to have to post your full programs here.
i'll confirm whether i see the same weirdness on different hardware.


dunk.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #39 on: October 26, 2008, 06:05:00 PM »
I do not have a shifter.

As for my program , there is nothing to show
I did the tests with two Axons , so that way it was easier to program quickly. Forget the ATmega168 for now. Both programs are standard axon setup code , with uart0 set to 2400 baud. I guess I can't really verify the transmission directly. I could do it indirectly and have uart1 ( the USB) send the same thing as uart0 .

Why would there be repetition of bytes in a transmission anyways?

Receiver just does
Code: [Select]
void report(void)
{
int data;
while(1)
{
data = GetByte0();
SendByte1(data);
}

and Transmitter just does:
Code: [Select]
void send(void)
{
while(1){
//#define data1 0b01010101
//#define data2 0b01010110
//#define data3 0b01011001

SendByte(data1);  //55
SendByte(data2);  //56
SendByte(data3);   //59
 }
}

Also, can I just use PWM on the transmitter and take an ADC on the receiver?
« Last Edit: October 26, 2008, 06:17:00 PM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

paulstreats

  • Guest
Re: Sending packets of data through RF UART
« Reply #40 on: October 26, 2008, 06:33:42 PM »
Hi,

 I have the same tx/rx pair. I also got the other pair operating on a different frequency so i could have both sides of devices sending and receiving.

 I havent used them for about 4 months now but from what i remember doing with them is basically they are wysiwyg style senders meaning what is seen on the transmit pin of 1 module is what you get on the receive pin of the other module.

 I made a packet style system which sent 8 bytes per packet with some startbytes of (|TX|S|) and end bytes of (|TX|E|) to know when the packets were being sent and when the end of the packet was finished. I know that it is probably unnecessarry but I also built in a system where each packet was transmitted twice to ensure data integrity.

An easy way to test these modules is to power both the transmitter and receiver up, then attach your multimeter to the rx pin on the receiver (and of course ground) and connect +5v or GND to the tx pin on the transmitter and monitor what the multimeter has on its display, it should change accordingly.

Also you mentioned a couple of posts ago that you jumpered the tx pin to the rx pin, this in itself explains the repetition of bytes it similar to the sqeaky noise you get when you put a microphone next to a speaker.

There was a post where you showed occasional bytes being received but spaced with FF FF FF etc... , presumably this is when the transmit pin is left floating high or maybe low? probably in between data transmission.

Youve got to know that these are quite raw radio modules and are going to take a lot of work to use them properly (I realised this and then told myself that i could have spent another $60 on one of the other transmission systems or put the effort in to get them working).

One more quick note. Unless you have a dedicated microcontroller just for this module alone on the receive end, then you will never reliably be able to use them for an interrupt on UART change which is why i stopped using them.... (I might be using them again a couple of months time if i get a chance to work on my new project)


Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #41 on: October 26, 2008, 07:01:55 PM »
thanks for the reply paulstreats

so what I can do now to get these things to work right? Can you share some of your code ( assuming its in C )
Also paulstreats few questions : What voltage was the transmitter at ? Did you use a capacitor between antenna and GND ?

and I do have a dedicated microcontroller for the receiver .

How well did the modules work ? How much 8 byte packets did you get per second? How accurate was it?

I have a month to get these things working , so I'm not so worried about time and effort.
thanks again
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sending packets of data through RF UART
« Reply #42 on: October 26, 2008, 07:02:40 PM »
Quote
Also you mentioned a couple of posts ago that you jumpered the tx pin to the rx pin, this in itself explains the repetition of bytes it similar to the sqeaky noise you get when you put a microphone next to a speaker.
hey Paul, nope. he means the TX on one AVR to the RX on another.
basically testing the code without the RF modules. just a wire between the UARTs (and a common GND ).

Airman,
yea. nothing complex with that code.
you 100% sure all interrupts are disabled, WDT disabled, brownout detection disabled etc no the AVRs?

can you try transmitting a number sequence again to try and confirm whether you are seeing repetittions of the same byte or whether you are only getting one byte in every 4.2 ?
something like this:
Code: [Select]
while(1){
   for(i = 0; i < 255; i++){
      for(j = 0; j < 255; j++){
         SendByte(i);
         SendByte(j);
         SendNewLine();
      }
   }
}

Quote
Also, can I just use PWM on the transmitter and take an ADC on the receiver?
sure. just make sure the PWM frequency is around 2400bps.


dunk.

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: Sending packets of data through RF UART
« Reply #43 on: October 26, 2008, 07:08:19 PM »

 I guess I can't really verify the transmission directly. I could do it indirectly and have uart1 ( the USB) send the same thing as uart0 .


I think you can hook up a serial LCD in paralel with the RX pin on the receiving Axon (or a RS232 interface to your computer). That way you can directly see what it is received. You can use the LCD hooked in paralel with the TX pin of the first Axon and the RS232 interface to the RX of the receiving Axon, that way you can double check what is transmited and received. Hmm... never tryed but I think it may be possible to use 2 RS232 to USB interfaces and open 2 sesions of telnet on the 2 USB serial ports and compare the signals. This way you can determine if the errors come from the radio modules or not.
Check out the uBotino robot controller!

paulstreats

  • Guest
Re: Sending packets of data through RF UART
« Reply #44 on: October 26, 2008, 07:29:16 PM »
Quote
hey Paul, nope. he means the TX on one AVR to the RX on another.
basically testing the code without the RF modules. just a wire between the UARTs (and a common GND ).
he he .. I should really read full posts instead of just scanning through them ;D

Quote
What voltage was the transmitter at ? Did you use a capacitor between antenna and GND ?
I just used the transmitter at regulated 5 volts, I never needed to use it at a full 500metre range, I just wanted to use it instead of a wired connection to hyperterminal.

I never used a capacitor between the antenna and ground, though I did solder a bit of wire to the antenna just to make myself feel better :) (I could only think that unless you are completly accurate with the type and values of the capacitor then it is going cause a long drop off after a high send, such as when you connect a capacitor to an led then connect power. when you remove the power the led light fades over time rather than turning crisply off. A capacitor would do the same with the transmitting antenna meaning that the signal is not going to be crisp. I imagine that it could be advantageous but you really would have to get the perfect combination).

The code was very simple really it was just standard sending the bytes through the uart and the receiving side similar, ill dig up the code for you but it doesnt have to be difficult, just a bit of thought into it.

 I used the modules at 2400 baud, obviously bytes being sent twice reduced the transmission rate. Even with this I did get an occasional faulty byte meaning that i had to have some other system, I remember two different systems either a transmit the full packet back or just transmit a confirm byte cant remember which i went with. Neither of these will work for you if you only have the one module though because the receive end cant send any data back.

In your case I would try and send each packet maybe 3 or 4 times and then compare them at the receive end hopefully you should get 2 or more matching packets, if not then you have no idea which one is good and which one is bad, so the more times you send the same packet the more chance you are of getting 2 matching packets meaning that they are the correct packet. In the event of not getting 2 matching packets you'll have to build in a flush/reset system of some variety...

Quote
Also, can I just use PWM on the transmitter and take an ADC on the receiver?
I would never have thought of doing that ???


Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #45 on: October 26, 2008, 07:55:07 PM »
ok thanks
@paulstreats
so approximately how much bytes per second were you getting ? I need a maximum 21 three byte packets to be received in one second. The RF link at 2400 baud can do that without a problem , right?

Did you use AVRlib or did you do all coding from scratch?

@dunk
you know what I just realized ! uart.c (from AVRlib) makes use of the interrupt for the UART. I'll disable that and do some tests tomorrow night.  I've been using AVRlib uart.c all this time to initialize the UART.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

paulstreats

  • Guest
Re: Sending packets of data through RF UART
« Reply #46 on: October 27, 2008, 06:49:04 AM »
2400 baud translates as 2400 bits per second loosely. So byte per second are 2400 / 8  (since there are 8 bits in the byte). So 2400 baud can send 300 bytes per second if used optimumly.

The system that I used sent 6 start bytes 8 data bytes and 6 stop bytes meaning 20 bytes per complete packet. so 2400 baud (300 bytes per second) / 20 (bytes per packet) equals exactly 15 packets per second.

If you used 6 startbytes 3 databytes and 6 stopbytes that would give you 20 packets per second. You could reduce the amounts of start and stop bytes but the more start bytes you have the more sure you can be that you are receiving a real packet and not an interference pattern.

Quote
Did you use AVRlib or did you do all coding from scratch?


I use pic's but the code should be similar - ish, All you have to do is place the byte to be sent onto the UART register and the pic does the rest. I'll post the code I used in about 8 or 9 hours (tonight for me :)) And i'll comment it where I can....



edit
-----------------

Also my code does use the interrupt on uart, but throws any bytes away that dont conform to the packet start sequence.

« Last Edit: October 27, 2008, 06:53:07 AM by paulstreats »

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #47 on: October 27, 2008, 07:07:01 AM »
My module supports up to 4800 baud , so I guess I can go up to there  and double my packet
Quote
Also my code does use the interrupt on uart, but throws any bytes away that dont conform to the packet start sequence.

also paulstreats some things to note :
I only need two bytes of data  - they are  address and data . Thats it  . So I guess I don't need the start bytes and stop bytes??? So what would the packet form be ?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

paulstreats

  • Guest
Re: Sending packets of data through RF UART
« Reply #48 on: October 27, 2008, 10:24:26 AM »
It is definately good practise to use start bytes and stop bytes. When the start bytes are received in sequence the receiving program then know that the following 2 bytes are data, and you can be sure to get them in the correct order. These modules do suffer from interference, so the interference can translate into uart transmission and give false signals. Also without a start byte how would your receiver program know which bytes were data and which were register addresses?

You can probably get away with just 2 start bytes.

in your case the packet could consist of just 6 bytes in total. 2 start bytes, 2 data bytes and 2 stop bytes (just for good form.)

so you would want to create a char array like this:

sendarray[0] = "|"                  //start byte 1
sendarray[1] = "S"                 //start byte 2
sendarray[2] = <address byte>
sendarray[3] = <data byte>
sendarray[4] = "|"                  //end byte 1
sendarray[5] = "E"                 //end byte 2

then use a put string command to send the entire array instead of doing it byte by byte yourself.

so:

puts(sendarray);         //send all six elements of the array

on the receive end you'll need something like this:

boolean potential_packet = false;
unsigned char receivedarray[6]; //this is where the packet will be stored
unsigned char packetflag = 0 ;

void interruptonuartfunction{      //just here to show what to do inside the uarts interrupt function

              if (rxregister eq "|"){                  //the rx register is where the microcontroller stores the received byte
                    potential_packet = true;      //because its found the first character of a start byte, we have a potential packet

              }

              if (potential_packet == true){
                    store_packet();
              }
           
               rxinterruptflag=0;    //were all done so reset the microcontrollers interrupt flag and lot it get the next byte

}


void store_packet(){

receivedarray[packetflag] = rxregister;           //store the contents of the rxregister in the array
packetflag++;
     if (packetflag == 6){
            potential_packet=false;        //the packet length has come to an end
            packetflag=0;                     //reset the packet flag to 0
     }
}



You should then have a char array of 6 bytes which contain the packet. So just check the start bytes and stop bytes to ensure they are the correct characters "|" , "S" and "|", "E". If so then the two bytes at receivedarray[2] and receivedarray[3] are your address and data bytes. If the start bytes or stop bytes dont conform then it isnt a true packet either made by random white noise or interference. In this case nothing is done, the received packet can be wasted........

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #49 on: October 27, 2008, 10:38:09 AM »
wouldnt it be better to do address,data,checksum - so I can get rid of needing all those start and stop bytes?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

paulstreats

  • Guest
Re: Sending packets of data through RF UART
« Reply #50 on: October 27, 2008, 11:10:56 AM »
you could use a checksum, this operates in a similar way as a stop byte but also keeping a sequence.

The start and stop bytes are just the way that i did it myself and offer a solution to the problem. It was also from my view the best way of countering interference and noise problems and ensuring that i got accurate data.

When i come to use them again I might incorporate a checksum along with start and stop bytes, it could help speed my old system up rather than having to acknowledge data back and forth.

Again if you dont have a known start sequence, how does the receiver know which are the 3 bytes you are sending. If the receiver just picks up noise to start with this can be interpreted as the address byte then when you transmit the address byte the receiver will see this as the data byte and the data byte will be seen as the checksum. Probably meaning that the sequence gets ignored. Most things you can do this with but the noise and intereference can mess up a simple transmission thats why i went with start and stop sequences to differentiate between noise and data

paulstreats

  • Guest
Re: Sending packets of data through RF UART
« Reply #51 on: October 27, 2008, 11:14:22 AM »
A thought did occur to me earlier that if you use a pull down resistor on the transmit pin of the radio module then it might cut out the noise altogether.... maybe ::)

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sending packets of data through RF UART
« Reply #52 on: October 29, 2008, 10:17:34 AM »
hey Airman,
did you make any progress with this?
was it the UART interrupt interfering with your receive function?

i'm guessing silence either means it's working
or you got sick of it and decided to leave it alone for a wile....


dunk.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #53 on: October 29, 2008, 01:23:24 PM »
i've been crazy busy and haven't had a chance to test it out yet
I'll do some tests tonight
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #54 on: October 29, 2008, 06:44:37 PM »
I disabled the interrupts by commenting one line for each of the uartInit
Code: [Select]
// enable interrupts
//sei();    <---- this was usually uncommented , I commented it

I seem to get slightly better results then before. No more repeating characters but still crappy transmission. Again I intended to send 55,56,59 . Looks like I have  a lot of 59,56,55. Is transmission supposed to be perfect when jumpered together?
Code: [Select]
56 55 56 55 56 56 55 59 56 59 55 59 56 56 55 59 56 59 56 55 59 56 55 59 55 56 55 59 56 55 59 55 59 56 55 56 55 59 56 59 59 56 55 59 56 55 56 55 55 56 55 56 55 59 56 59 55 56 59 56 56 56 55 55 56 59 56 55 59 56 55 56 55 55 55 56 59 55 59 55 59 59 59 56 59 55 56 56 56 55 59 56 55 55 59 59 59 56 55 55 59 55 59 56 55 56 59 56 59 56 55 56 55 59 56 55 59 56 55 56 55 56 59 56 59 56 55 55 59 56 56 55 59 56 56 55 59 56 55 59 56 59 56 55 59 55 59 56 56 56 55 55 56 55 59 56 55 56 59 56 55 59 56 56 55 56 55 59 56 55 59 55 59 59 55 56 55 55 56 56 59 59 55 59 56 56 56 55 59 55 56 56 55 59 55 59 55 59 56 56 56 56 56 59 55 55 59 59 59 56 55 56 55 55 59 56 56 55 56 55 59 55 59 56 55 55 55 56 59 56 55 59 56 59 56 55 56 55 59 55 56 55 56 55 59 56 55 56 55 59 55 56 55 56 55 59 56 56 59 55 59 59 55 59 56 59 56 56 59 56 55 59 56 55 56 56 56 59 59 56 56 59 55 59 56 55 59 55 59 56 56 59 56 55 56 59 59 56 55 59 56 55 56 55 59 56 59 56 55 59 59 55 56 59 56 55 55 56 59 56 55 55 59 56 59 56 59 55 59 59 56 55 59 59 56 55 56 55 59 56 56 55 59 56 56 55 56 55 56 56 56 59 59 56 56 59 55 59 56 59 55 56 59 56 56 59 56 55 59 56 55 55 55 59 56 59 56 59 55 55 55 59 56 55 59 55 59 56 59 56 55 59 56 59 56 55 56 55 55 55 56 55 56 59 55 56 55 59 55 59 56 55 59 56 59 56 55 56 59 59 56 55 59 55 55 55 59 55 59 59 59 55 56 55 56 55 59 56 55 56 55 55 59 56 59 55 59 56 56 59 56 55 56 55 59 56 59 59 55 59 56 55 59 59 59 56 59 55 55 59 56 59 55 59 56 59 56 55 59 56 55 56 56 55 56 55 55 56 56 59 56 59 56 55 56 55 56 55 56 55 59 55 59 56 55 56 56 59 56 56 55 59 55 59 55 55 59 55 59 55 56 56 55 55 55 56
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #55 on: October 29, 2008, 06:54:59 PM »
Fixed it  , I get all the packets correctly when I'm jumpered . I'll do tests over RF in the next few days.

you need to remove the bit registers that enable Interrupts. Just uncommenting sei() doesn't do it.

Here's the code:
Code: [Select]
void uart1Init(void)
{
// initialize the buffers
uart1InitBuffers();
// initialize user receive handlers
UartRxFunc[1] = 0;
// enable RxD/TxD and interrupts
outb(UCSR1B, BV(RXEN)|BV(TXEN));   // <-------    took out RXIE and TXIE
// set default baud rate
uartSetBaudRate(1, UART1_DEFAULT_BAUD_RATE);
// initialize states
uartReadyTx[1] = TRUE;
uartBufferedTx[1] = FALSE;
// clear overflow count
uartRxOverflow[1] = 0;
// enable interrupts
//sei();
}
« Last Edit: October 29, 2008, 08:12:08 PM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #56 on: October 31, 2008, 02:45:26 PM »
did the RF test  and I am incredibly happy.
2018 correct 3 byte packets in 30 seconds. That's 67.2 packets a second ---> 201.6 bytes per second. Mind you this is at 2400 baud.

I'm going to switch up to 4800 baud and also play around with the delays I use. Heres the code I used to get 2018 packets per second.
Code: [Select]
while(1){
SendByte(data1);  //55
delay_ms(5);
SendByte(data2);  //56
delay_ms(5);
SendByte(data3);  //59
delay_ms(5);
 }

Is there some way to calculate the optimum delay in between bytes based on what baud you are using?

Thanks for all the support guys ! I really appreciate it. I'll put up some documentation in the coming weeks.
« Last Edit: October 31, 2008, 02:46:10 PM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

paulstreats

  • Guest
Re: Sending packets of data through RF UART
« Reply #57 on: October 31, 2008, 03:56:58 PM »
Im not sure that you need to set any delays at all, It wont send the data faster than the predetermined baud rate and the send functions such as SendByte() will hold the program until the buffer is ready.

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: Sending packets of data through RF UART
« Reply #58 on: October 31, 2008, 04:02:20 PM »
yea, you should not need any delay between bytes.
try it and see what works best.

well done. got there in the end.

dunk.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Sending packets of data through RF UART
« Reply #59 on: November 04, 2008, 07:36:37 PM »
OK so without delay I get screwy packets  . I get  65 , 95, 55 instead of the proper 55,56,59.  I also get this screwy packet when I have a delay of 1ms between packets . Other higher than 1ms delays give me the proper bytes perfectly.

At 2ms delay between packets I get 2396 correct 3 byte packets in 30 seconds. That means around 80 packets per second which is  240 bytes per second. Mind you this is at 2400 baud. I might go up to the maximum 4800 baud later on if need be.

Few questions now for you guys:
1. how come with no delay I get those screwy packets?
2. also is this a reliable way of encoding the data  - start bit,address,data,checksum ( a 4 byte packet)
3. Whats the theoretical maximum bytes per second of 2400 baud - is it 300 bytes per second? ( = 2400/8 )
4. What percentage of the theoretical maximum is considered normal ? 80% perfect considered good, 50% , etc.
5. Is it true that if you go up to a higher baud rate then your risk of error is increased?

Thanks
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

 


Get Your Ad Here