Controlling your World the Easy Way

Demonstration Code

Demonstration Code

Posted: Sat Jan 31, 2015 5:34 pm

by Daniel

I have attached the demo code loaded on the delivered modules to this post. When two modules are delivered one will have been programmed with the code called PC2ArduRF and the other with ArduRF1s_Slave2. If you received a PC2ArduRF module then the position of the code is obvious. If you did not order a PC2ArduRF board then the code assignment will be marked on the anti-static bag the board is shipped in.

The code is very basic and the 'Master' or 'Gateway' listens for transmissions from 'Nodes' or 'Slaves'. When it received such a transmission it replies with an Acknowledge. After every few messages it transmits a message to the Node asking for an Acknowledge. It displays the signal strength on the terminal. Terminal setting should be 115.2kbps. The node periodically sends a message to the gateway asking for an Acknowledge. When it receives a message from the Gateway it responds with an Acknowledge message. On the node side, the software responds to two terminal commands. If you press 'i' it will print its node number. For number between 1 and 9 it will change the transmit rate to 100ms, 200ms etc. 0 results in a message every second.

On the PC2ArduRF code the terminal has four characters that produce a response. Like before, 'i' prints the node number, always 1. 't' prints the radio temperature and 'p' toggles promiscuous mode that allows any node to listen to any packet on same network. In effect promiscuous mode ignores the node id and is useful for debugging. 'r' prints the contents of all the registers in the radio. Again, useful for debugging when changing radio parameters.

By default the radios are set to a 50kbps bit rate and a 50kHz frequency deviation. For longer range the bit rate can be decreased. When time permits I'll publish some values optimized for range at the expense of data rate. The radios are capable of 300kbps at the cost of reduced range.