↑ Return to Tutorials

Print this Page

Using LabVIEW to test IO Control with a RN171-XV

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.

Let’s start.

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. DSC02495

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>

Beacon=100<CR><LF>

Probe=5<CR><LF>

Reboot=0<CR><LF>

OPEN=*OPEN*<CR><LF>

CLOSE=*CLOS*<CR><LF>

REMOTE=*HELLO*<CR><LF>

FlushSize=64<CR><LF>

MatchChar=0<CR><LF>

FlushTimer=10<CR><LF>

IdleTimer=0<CR><LF>

CmdChar=$<CR><LF>

IF=DOWN<CR><LF>

DHCP=OFF<CR><LF>

IP=169.254.1.1:2000<CR><LF>

NM=255.255.0.0<CR><LF>

GW=0.0.0.0<CR><LF>

HOST=0.0.0.0:2000<CR><LF>

PROTO=TCP,<CR><LF>

MTU=1524<CR><LF>

FLAGS=0x7<CR><LF>

TCPMODE=0x0<CR><LF>

BACKUP=0.0.0.0<CR><LF>

DNS=161.72.0.0<CR><LF>

Name=server1<CR><LF>

Backup=backup2<CR><LF>

FTP=208.109.78.34:21<CR><LF>

File=wifly-EZX.img<CR><LF>

User=roving<CR><LF>

Pass=Pass123<CR><LF>

Dir=public<CR><LF>

Timeout=80<CR><LF>

FTP_mode=0x0<CR><LF>

SSID=RDAPaintball507<CR><LF>

Chan=1<CR><LF>

ExtAnt=0<CR><LF>

Join=4<CR><LF>

Auth=OPEN<CR><LF>

Mask=0x1fff<CR><LF>

Rate=12, 24 Mb<CR><LF>

Linkmon=0<CR><LF>

Passphrase=rubygirl<CR><LF>

TxPower=0<CR><LF>

SleepTmr=0<CR><LF>

WakeTmr=0<CR><LF>

Trigger=0x1<CR><LF>

Autoconn=0<CR><LF>

IoFunc=0x0<CR><LF>

IoMask=0x21f0<CR><LF>

IoValu=0x0<CR><LF>

DebugReg=0x0<CR><LF>

PrintLvl=0x1<CR><LF>

TimeEna=0<CR><LF>

TIMEADR=129.6.15.28:123<CR><LF>

Zone=7<CR><LF>

Baudrate=9600<CR><LF>

Flow=0x0<CR><LF>

Mode=0x0<CR><LF>

Cmd_GPIO=0<CR><LF>

JoinTmr=1000<CR><LF>

Replace=0x24<CR><LF>

DeviceId=WiFly-EZX<CR><LF>

Password=<CR><LF>

Format=0x0<CR><LF>

Signal=0<CR><LF>

Average=5<CR><LF>

BCAST=255.255.255.255:55555<CR><LF>

Interval=0x7<CR><LF>

Sensor=0x0<CR><LF>

SensePwr=0x0<CR><LF>

<2.32>

Next connect to your Wi-Fi network, it should looks like:

RDAPainball507Conn

Whew we issue the “ipconfig” command on windows, if we look, we will see that we are in the net!.

ipconfigRDAYou can “ping” your RN-XV at “169.254.1.1” and make a telnet connection at port 2000 if you want.

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

RDALabVIEWFPNow that we have the front panel, lets explain the code window.  I made it simple not using Sub-Vis to understand the basic approach.

Timeout Event

TimeOut

Engage Event

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).

EngageTrue

 

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.

EngageFalse2 EngageFalseFor every situation above that doesn’t goes to the normal path of communication is a disconnection of the TCP channel and return to the initial state (including indicator and buttons).

Fire (Mouse Down  / Click)

FireMouseDown

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)

FireMouseUp

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

RN-XV configurations to test

RN-XV LabVIEW Project

 

Permanent link to this article: http://cerescontrols.com/tutorials-3/using-labview-to-test-io-control-with-a-rn171-xv/

Leave a Reply

Your email address will not be published. Required fields are marked *