Formula AllCode and LabVIEW

LabVIEW from National Instruments is a widely known and capable programming language which can be great for controlling hardware. The Formula AllCode (launched by Matrix TSL in January 2016) is no exception and in this blog we will look at how we interface LabVIEW to the Formula AllCode hardware.

On loading LabVIEW I create a new blank VI

To get the functions of the Formula AllCode into your program click on File -> Open and select the FASlave.lvlib file from the example Lib folder.

FASlaveLib

The library communicates with the Formula AllCode hardware using a dynamic link library (DLL) which contains a number of functions to control the robot.

Once you have opened the LabVIEW library you can then drag the functions into the block diagram window of your program as required.

Here is a simple VI I have put together to allow me to control the LEDs using a simple slider on the LabVIEW panel.

FP1BD1

I created a flat sequence structure to ensure that the various parts of the program are called in turn. The left most window is executed first and opens the selected COM port of the Formula AllCode Bluetooth connection. The middle window contains a while loop that keep executing until the stop button is pressed. Inside the loop we take the value of the slider and send it to the LEDs on the Formula AllCode along with a 100 millisecond delay. When the stop button is pressed we move to the right most window which closes the connection to the Formula AllCode.

Here is another simple program to control the LEDs on the AllCode this time using switches to allow individual control of the LEDs.

FP2BD2

Ok so we know the LEDs work, let’s do something a bit more exciting and make the motors move the robot around. From this we could easily add a WIFI enabled webcam to the robot and then we have a vehicle we can drive around remotely allowing us to send the robot to investigate areas where it may be unsafe for humans to venture.

The switches decide the value that will be passed as the index into the case structure which in turn sets the motor speeds to predetermined values.

FP3BD3

Controlling the robot using switches works but is a bit hard to control. In the next example we use a joystick style control interface to make the control of the robot move around a bit more analogue than simple on and off. I have added another window to the sequence structure to ensure the motors stop when we click the stop button.

FP4BD4

Ok so one last test to check that we can read the sensors, make a decision based on their values and then control the robot to do a job. The job in question being “Line Following”. The program will follow a dark line on a light surface. We used a piece of MDF as the surface and some black electrical tape for the line. The Threshold sets the differentiation between dark and light allowing multiple surfaces to work by tweaking the value.

FP5BD5

LabVIEW example files, VI libraries and FA DLL can be downloaded below.

FALabview

Formula AllCode is an easy route into robotics and is programming language agnostic, meaning you can use the language you feel most comfortable with. The solution is launched in January 2016 and is available to pre-order today from the Matrix TSL website.

6,362 total views, 5 views today

Leave a Reply