Difference between revisions of "PIC32MX: XBee Wireless Round-trip Latency"
(→Code) |
(→Code) |
||
Line 47: | Line 47: | ||
// ****** Variables |
// ****** Variables |
||
unsigned int Time; |
unsigned int Time; |
||
char RS232_Out_Buffer[64]; |
char RS232_Out_Buffer[64]; // The buffer may be changed if lots of data is being sent at a high BaudRate |
||
char message; |
char message; |
||
Revision as of 17:15, 13 February 2010
Original Assignment
Do not erase this section!
Your assignment is to set up one PIC32 to send data to another using XBees for wireless RS-232 comm. One PIC will send a series of numbers; the other PIC will receive them and echo them back; and the first PIC will time the total time to send and receive back. To time, the first PIC can set a digital pin high, then set it low again when the original sent data is correctly received. It could also keep track of the count of a counter-timer. You can time how long it takes for the round-trip using an oscilloscope or by reading the counter-timer. You should try this for different baud rates and a couple of different sizes (in bytes) of the message. How low can you get the total round-trip time while guaranteeing low data loss?
Overview
Summarize briefly what the page is about.
Circuit
Include a schematic and give any part numbers. A photo of your circuit is OK, but not as a replacement for a schematic.
Code
The code below is for the transmitter XBee chip. Note that the message string sent included only one period and was placed at the end. The program scans the message it receives looking for that period, so it knows that the whole message was received.
/********************************************************************** Transmitter Code Lab 5: High Speed XBee Latency George Randolph Nathan Hirsch 10 February 2010 This code is for the TRANSMITTER XBee chip. It takes a string of characters and sends them from the PIC to the XBee and broadcasts it out into the world. The reciever chip should receive the message and echo it back to the transmitter. At the point when the transmitter first broadcasts the message, a pin on the PIC is set to high. When the message is successfully echoed back, that pin is set low so the whole process can be timed using an oscilloscope. **********************************************************************/ // ****** Includes #include "HardwareProfile.h" // ****** Constants #define DESIRED_BAUDRATE (115200) // The desired BaudRate Note: This must be changed when changing the XBee chip BaudRate #define PIN_D1 LATDbits.LATD1 #define PIN_D2 LATDbits.LATD2 #define PIN_D3 LATDbits.LATD3 #define PIN_D4 LATDbits.LATD4 // ****** Variables unsigned int Time; char RS232_Out_Buffer[64]; // The buffer may be changed if lots of data is being sent at a high BaudRate char message; // ****** Function Declarations void initInterruptController();