9.f. I/O Repeater App
This app allows you to wirelessly extend the reach of your microcontroller’s I/O lines up to 50 feet using two or more Wixels. An input pin on one Wixel can be mapped to an output pin on another Wixel. When the input pin reads high, the output pin will be driven high (3.3 V) and when the input pin reads low, the output pin will be driven low (0 V). Each Wixel can have up to 15 input pins, 15 output pins, or a mixture of input and output pins. Each input pin can map to one or more output pins on one or more Wixels.
Download the I/O Repeater App (v1.3) (22k wxl). Open it with the Wixel Configuration Utility, choose your settings, and write it to two or more Wixels. See Section 4 for more information on how this is done.
The following 15 pins on each Wixel can be used as inputs or outputs (or be disabled):
- All the pins on Port 0: P0_0, P0_1, P0_2, P0_3, P0_4, P0_5.
- All the pins on Port 1: P1_0, P1_1, P1_2, P1_3, P1_4, P1_5, P1_6, P1_7.
- Pin P2_1 (the red LED pin).
The behavior of each pin is determined by its link ID, which is a parameter that you can set individually for each pin on each Wixel using the Wixel Configuration Utility. A link ID of 0 means the pin will be disabled (it will be an input but its input value will not have any effect). A negative link ID between -1 and -127 means that the pin will be a digital input and its value will be transmitted over the radio. A positive link ID between 1 and 127 means that the pin will be a digital output and its output value will be determined by the input value of the pin with the opposite (negated) link ID on another Wixel. For example, if the P1_3 pin on one Wixel has a link ID of -13, then it will be a digital input and its value will be reflected on all the output pins that have a link ID of 13 on all the other Wixels. Input pins do not have any effect on output pins that are on the same Wixel.
If a Wixel is running this app and has one or more pins configured to be inputs, then it will transmit a single radio packet every 7–10 ms that contains input values and link IDs of all of its inputs. Any other Wixel that successfully receives this packet will process it and use it to update the state of its output pins.
This app will work with more than two Wixels on the same radio channel. In that case, make sure that you do not have multiple input pins on different Wixels with the same link ID: otherwise, the corresponding output pin(s) will change state unpredictably whenever there is a conflict between the different input pins. It is OK to have muliple output pins with the same link ID.
Every pin configured as an input has an internal 20 kΩ pull-up resistor except P1_0 and P1_1, which float when they are inputs. This means that if you leave the input pin disconnected, it will be pulled high by default.
Each output pin will drive low (0 V) by default before any radio packets are received that change its state.
After you have loaded this app onto a Wixel, the Wixel will appear to the computer as Virtual COM Port (with USB product ID 0x2200). If you are using Windows, you should see an entry labeled “Wixel” in your Device Manager in the “Ports (COM & LPT)” category while this app is running. You can not send or receive data on this COM port. Its only purpose is to let the Wixel Configuration Utility easily get the Wixel into bootloader mode.
- radio_channel: The channel number is from 0 to 255 and determines which frequency to broadcast on. The default is 128. Wixels must be on the same channel to communicate with each other. To avoid interference, Wixels that aren’t supposed to talk to each other should be at least 2 channels away from each other. For example, you could have one pair of Wixels on channel 128 and another pair on 130.
- Pm_n_link: The link ID of pin Pm_n where m is the port number (0–2) and n is the pin number (0–7).
The default settings are:
|P0_0||-1||Input with pull-up resistor.|
|P2_1 (red LED pin)||1||Output linked to P0_0 on the other Wixel.|
Therefore, if you load this app onto two Wixels using the default settings, they should behave as follows: If nothing is connected to either Wixel’s P0_0 line, the red LEDs on both Wixels will be on. If you connect the P0_0 line of one Wixel to GND using a wire, then you should see the red LED on the other Wixel turn off. This demonstrates the basic operation of the app.
- A Wixel output pin can be used to control an LED. Be sure to use an appropriate current-limiting resistor in series with the LED (e.g. 1 kΩ)
- A Wixel input pin can be used to read the state of a button or switch. Connect the button or switch between the input pin and GND, so that when the switch is open the pin will read high, and when the switch is closed the pin will read low.
- A Wixel output pin can be connected to an input pin on another microcontroller.
- A Wixel input pin can be connected to an output pin on another microcontroller. The output must not drive to a voltage higher than 3.3 V. If your microcontroller is running at 5 V you could get around this by using a diode or putting your output pin into open-collector mode (never drive high).
- A change on an input pin will usually be reflected on the corresponding output pin(s) within 10–100 ms, but every radio packet has a chance of being lost so there is no guaranteed latency. Therefore, this app is only suitable for very low-speed digital signals such as the signal from a pushbutton or the signal used to control an LED. This app is not suitable for PWM or RC servo signals.
- This app uses digital I/O which means that every reading is transmitted as a 0 or 1. This app does not support analog voltages.
Caution: The Wixel’s I/O lines are not 5V tolerant. You must use level-shifters, diodes, or voltage dividers to connect the Wixel to outputs from 5V systems. Also, avoid drawing more current from an I/O line than it can provide (see the discussion of P1_0 and P1_1 in Section 1.a). Avoid connecting multiple output pins together.
- I/O Repeater App v1.3 (22k wxl), released 2012-07-03: Adds randomness to the radio packet transmission timing to prevent two transmitting Wixels from being synchronized if they start up at the same time.
- I/O Repeater App v1.1 (20k wxl), released 2011-07-26: Fixes a bug in v1.0 which prevented P1_6 and P1_7 from being used as outputs.
- I/O Repeater App v1.0 (18k wxl), released 2011-03-25: Initial release.