RCRx Class Reference

Remote Control Receiver module for RCOIP protocol on Arduino. More...

#include <RCRx.h>

Collaboration diagram for RCRx:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 RCRx ()
 Constructor. After contruction and initialisation, call the init() and run() functions.
void setOutputs (Setter **analogOutputs, uint8_t numAnalogOutputs)
virtual void setAnalogOutput (uint8_t channel, int value)
void init ()
void run ()
void handleRequest (uint8_t *msg, uint16_t len, uint16_t rssi)
void failsafe ()
void periodicTask ()
boolean connected ()
void sendReply ()


Detailed Description

Remote Control Receiver module for RCOIP protocol on Arduino.

Overview
This class implements a receiver for RCOIP (Remote Control Over IP). It starts and manages a WiFi receiver, which receives UDP messages containing RCOIP commands such as remote control channel values. When channel setting commands are received they are translated into output values which are sent to Setter objects to control the phycical output devices and pins on the Arduino. Supports WiShield 1.0 etc.
Outputs
RCRx maps RCOIP channels to physical output devices through the analogOutputs array. This is an array of Setter objects, one for each physical output to be controlled by RCRx. Whenever a RCOIP message is received with new channel settings, the input() function of each Setter with new data will be called. This will cause each Setter to set its physical output in response to the remote control data received by an RCOIP.
Failsafe
RCRx supports failsafe behaviour if a connection to the transmitter is lost. RCRx monitors the time of each received RCOIP request. If no request is received for more than failInterval milliseconds, it will be considered as disconnected, and the failsafe() function of every Setter will be called, allowing each Setter to adopt its failsafe configuration (eg throttle to 0 etc). This allows remote control vehicles to fail safe if the transmitter fails or goes out of range.
WiShield Library Configuration
Requires the Asynclabs WiShield library. See http://asynclabs.com/wiki/index.php?title=WiShield_library Install the WiShield library in the libraries directory of your arduino IDE installation, then follow the configuration steps below:
Support of RSSI (receiver signal strength indicator) requires mods to WiShield library g2100.c as per http://asynclabs.com/forums/viewtopic.php?f=10&t=385&start=0. You dont have to add this but its a good feature.

Correct operation of the WiShield requires you to set the jumper on the WiShield to INT0 or DIG8 to select the arduino pin to use for WiShield interrupts, and also to make sure it agrees with the settings of USE_DIG0_INTR or USE_DIG8_INTR in spi.h in the WiShield library (which defaults to using Arduino digital pin 2, and which means setting the WiShield jumper to INT0 setting). Yes, the naming conventions are inconsistent :-(. In summary:

  WiShield jumper   spi.h          Arduino
       INT0        USE_DIG0_INTR  Digital pin 2
       D8          USE_DIG8_INTR  Digital pin 8

In order for WiShield library to support UDP (as needed by this module), you MUST set UDP UIP_CONF_UDP to 1 in uip-conf.h. This is an unfortunate but necessary requirement, otherwise UDP support will not be compiled into the WiShield library. Further, you must edit apps-conf.h and make sure the only APP_* defined is APP_UDPAPP. Failure to do this will cause compile errors. A modified version of the WiShield library already edited for use with RCKit is available at http://www.open.com.au/mikem/arduino/WiShield-v1.3.0-0-mikem-RCKit.zip

WiShield will work with Arduino Mega, but with difficulty. The problem is that with the Mega, the SPI pins that are required for interface with WiShield come out on different pins to the smaller form factor arduinos like Diecimila and Duemilanove. So, to make the Mega work with the WiShield, you have to reroute the SPI pin to different Arduino pins, as per http://asynclabs.com/forums/viewtopic.php?f=13&t=19&hilit=mega&start=10

This library has been tested with Duemilanove and WiShield 1.0 and iPhone 3.0

Installation
Install in the usual way: unzip the distribution zip file to the libraries sub-folder of your sketchbook. Dont foget the prerequisites too.

Member Function Documentation

void RCRx::setOutputs ( Setter **  analogOutputs,
uint8_t  numAnalogOutputs 
)

Specifies the Setters that will be used by this receiver to set its output values Whenever a RCOIP message is received with a new value for channel n, it will be passed to the Setter at index n by calling the Setters input() function.

Parameters:
[in] analogOutputs Pointer to an array pointers to Setter objects.
[in] numAnalogOutputs Number of elements in analogOutputs

void RCRx::setAnalogOutput ( uint8_t  channel,
int  value 
) [virtual]

Set the output for channel n. Calls the Setter at index n of the analogOutputs array. Not usuallly called exernally, this is usually only called from within RCRx. Subclasses can override this to get control when new analog output values become available

Parameters:
[in] channel The analog channel number output to set
[in] value The new value to set

References Setter::input().

Referenced by handleRequest().

void RCRx::init (  ) 

Initialises the wireless WiFi receiver Call once at startup time after addresses etc have been configured.

void RCRx::run (  ) 

Call this to process pending Wireless events. Call this as often as possible in your main loop. Runs the wireless driver stack.

void RCRx::handleRequest ( uint8_t *  msg,
uint16_t  len,
uint16_t  rssi 
)

Call to handle an incoming UDP message containing an RCOIP command message. This is usually only called from within RCRx, but could be called externally for testing purposes etc.

Parameters:
[in] msg Pointer to the UDP message
[in] len Length of the UDP mesage in bytes
[in] rssi Receiver Signal Strength as reported by the WiFi receiver when the message was received.

References RCOIPv1CmdSetAnalogChannels::channels, RC_VERSION1, sendReply(), setAnalogOutput(), and RCOIPv1CmdSetAnalogChannels::version.

void RCRx::failsafe (  ) 

Called by RCRx when no RCOIP message has been received for more than failInterval miliseconds. Calls the failsafe function for all configured output Setters.

References Setter::failsafe().

Referenced by periodicTask().

void RCRx::periodicTask (  ) 

Called by RCRx periodically (typically twice per second) to do period processing such as detecting loss of messages

References failsafe().

boolean RCRx::connected (  ) 

Returns whether the RCRx considers itself to be connected to the transmitter. Initialsed to false. Whenever an RCOIP request is receved, set to true. If no RCOIP request is receved for more than failInterval miliseconds, set to false.

Returns:
true if the RCRx is still receiving messages from the transmitter.

void RCRx::sendReply (  ) 

Sends an RCOIP reply message Usually called internally at most once every _replyInterval milliseconds.

References RCOIPv1ReplyReceiverStatus::batteryVoltage, RC_VERSION, RCOIPv1ReplyReceiverStatus::RSSI, and RCOIPv1ReplyReceiverStatus::version.

Referenced by handleRequest().


The documentation for this class was generated from the following files:

Generated on Wed Jul 21 07:33:52 2010 for RCKit by  doxygen 1.5.6