One of the most basic things that you will want to do in your embedded life is control anything wirelessly.
Basic things like sense a door input, control an actuator and view wirelessly the information of your sensor is a common use that we, embedded designers and hobbists likes. Personally i don’t like wires and wiring so, right now, the technology is available and it is possible. By the way, there is an alternative using PLC (Power Line Communications) that is not wireless, but permits go throught your entire home without wiring and has good throughoutput, better than all wireless technology.
In this issue i will explain to you how to make an I/O TTL control, to control everything that you want. This kind of simple control is called ON/OFF and its the most basic functionality. For our purposes:
- First we will set the RN171-XV that is a wireless 802.11b/g module of the company Roving Networks, with a tool called Docklight scripting (is a very good tool).
- And last, we will make a LabVIEW code to test the functionality of the tool with I/O control.
First we will make a connection between the PC and the RN171-XV with a Sparkfun XBee Explorer, that is only a USB to RS232 converter using a FTDI FT232RL.
At your left side is an RN-XV module, and for the right side is the XBee Xplorer. OK, attach the RN-XV and connect to your PC, install necesary drivers of FTDI page for this link.
Next, we will setup the RN-XV with docklight scripting using these commands to create an Ad-Hoc network. On section 4.8 of RN-XV manual explains that are two ways of setup the connection, one is via hardware and the other (the better for me) is via software. The way we do is issuing the commands:
Command Issued Command Description $$$ $$$ Enter command mode. set wlan join <value> set wlan join 4 Create an ad hoc network using stored SSID, IP address, and netmask.
You MUST set the channel and if your devices is not a server, set DHCP to 0 (static IP).
set wlan ssid <string> set wlan ssid RDAPaintball507 This command sets the SSID with which the module associates, where <string> is 1 to
32 characters (32 bytes).
set wlan chan <value> set wlan chan 1 This command sets the WLAN channel, where <value> is a decimal number from 1 to
13 representing a fixed channel.
save save Saves the configuration reboot reboot Reboots the device
Remember!. Every command except entering command mode must be carried returned (0x0D) for the RN-XV issue the command. If you want to know my configuration in my device, next i will post the params:
RN-XV “get everything” command:
WiFly Ver 2.32, 02-13-2012 on RN-171<CR><LF>
Rate=12, 24 Mb<CR><LF>
Next connect to your Wi-Fi network, it should looks like:
Whew we issue the “ipconfig” command on windows, if we look, we will see that we are in the net!.
Next, move to the LabVIEW part.
Let me explain the issue: The client wants to trigger a paintball gun wirelessly through a robotic platform (skid steer mobile robot) to show it on a fair. When they trigger the interface, the gun will start in automatic mode to make shots simultaneously. BTW, the client make me work for nothing, it was never used and never solicited finally.
Next is to make a simple intuitive front panel. The panel will have only one action button, but two status buttons and a log output window only for verify, but its not neccesary.
- Engage: Gets the gun online and executes a trigger command
- Online: status of the Wi-Fi connection
- Trigger: status of the trigger of the gun
- Fire: Hidden button to make a gunshot
- Output window: this is optional and is for verify the command output
The left side is for initializing the variables, the engage button is off and all status led are off too. The main application starts to loop in the event “while loop” up to the connection is refused or missed (error 56).
First we make a connection to the Ad-Hoc network through the IP 169.254.1.1:2000 and wait 5 seconds if no connection response.
After that we read the buffer of the TCP response and verify that the data *HELLO* arrived.
When things goes well, the next step is to enter command mode, this is done sending the $$$ command and then read the string CMD<CR>. Status LED “Online” will go up. Additionally the fire button will show up.
Fire (Mouse Down / Click)
Now on the fire button, when triggered (Mouse Down / Left Click) we will send the command SET SYS OUTPUT 0x0100 0x0100 to set the flag of the GPIO8 high (Fire).
Fire (Mouse Up / Unclick)
When unclicked, the command issued is the same but for trigger down the gun. GPIO8 will be deasserted and the gunshot will be waiting for the next command.
That’s all. I will post here the media information used in this project