LabVIEW and VISA interface, with chipKIT Digilent UNO32 and Basic I/O Shield


NI LabVIEW can communicate with external devices such as microcontrollers through VISA a standard I/O language for instrumentation programming.

LabVIEW ties the creation of user interfaces (called Front Panels) into the development cycle. A key feature of LabVIEW over other development environments is the extensive support for accessing instrumentation hardware.


Write step by step a simple serial read VI that can communicate with chipKIT Digilent UNO32 and Basic I/O shield, and serial read  values processed in UNO32 and display  these on LabVIEW’s front panel.


MAP_3782-400x265– chipKIT Digilent UNO32 development board
MPIDE software
– Digilent BASIC I/O shield
LabVIEW software and VISA drivers

Your LabVIEW software and VISA and drivers as well as MPIDE software for programming chipKIT Digilent UNO32 baord must be installed in your PC. Check previous tutorial on this blog LabVIEW Interface for chipKIT Digilent UNO32 Development Board.


a) Install libraries of Basic I/O Shield in MPIDE environment for UNO32 board

On Uno32 you must have Jumpers JP6 and JP8 set in the RG3 and RG2 positions. Install the Basic I/O shield on top of UNO32 as shown on the above image . Connect to the PC with USB cable. USB connection will power UNO32 and the Basic I/O shield simultaneously.

We assume that you have already installed MPIDE environment.

You will need to know the location of MPIDE sketches folder:

Run MPIDE  (in my PC with Windows XP Pro I need to do it with Administrator’s priviledges). In menu do File -> Preferences find the sketchbook location:


Take note of the location of your sketches (MPIDE codes are called “sketches”). In your Windows navigate to where the folder is, and create a directory named ‘Libraries’.


Download from here the zipped file containing libraries and documentation for using the Basic I/O Shield™ with the chipKIT MPIDE and unzip into the Libraries folder you have just created:


Now if you do File -> Examples you will see three folders IOShieldEEPROM, IOShieldOled and IOShieldTemp. Open the sketch IOShieldTemp_Demo:


Next choose the board (in our case UNO32):


And Serial Port to which the board is connected:


To be sure of what you are doing, I advise that you read my previous tutorial here in this blog  LabVIEW Interface for chipKIT Digilent UNO32 Development Board.

Now we are ready to upload the sketch to the board. Click the Upload button on MPIDE environment.

If successful you will see the following results at bottom of MPIDE environment:


We are now ready to check what is being sent to our COM21 port (your PC’s may be other) in Tools -> Serial Monitor:


A new window will pop up showing the readings sent to our PC’s serial port:


We are  getting readings in ºC and ºF.

We will need now to modify our code in order to allow easy manipulations by LabVIEW communicating with micrcontroller through VISA.

Find //Print Temperature to serial port in IOShieldTemp_Demo sketch and substitute everyting up to delay(1000);  with the following code:


So the code with void loop will now look like as shown:

void loop()
float tempF, tempC;

//Get Temperature in Celsius.
tempC = IOShieldTemp.getTemp();

// Convert the result to Fahrenheit.
tempF = IOShieldTemp.convCtoF(tempC);

//Print Temperature to serial port

We check again what is being sent by RS232 in Tools -> Serial Monitor:


The readings now are in a convenient format for LabVIEW hopefully. Exit MPIDE environment in order to free the serial port.

b) Write VI in LabVIEW to read the values of temperature processed by UNO32

You need to have VISA and LabVIEW installed in your PC.  I advise you to read my previous post in this blog LabVIEW Interface for chipKIT Digilent UNO32 Development Board.

Launch LabVIEW (my licensed version is LabVIEW 2010). Search for basic serial write and


Download it from NI’s website:


And download it to a convenient directory, and run it by opening with LabVIEW.


Press Ctrl + E in your PC’s keyboard to get into Block Diagram of LabVIEW’s VI, and identify two Case Structures as shown:


Add While Do structure around them:


Next, delete the Write bytes to port loop and make adjustments to get the following result:


We are now ready to run the VI and see what we get. View the Front Panel and choose the right port of communication which in our case is COM21 :


Once port is selected Run the V,I clicking on the button Run 

You will see immediately that some results are appearing on the Front Panel’s read string field. If you change bytes to read to 14 you will see immediately at least one line of readings:


You may get some inconsistencies in reading but this will be sorted out next.

We will now go back to the Block Diagram and make changes to get the right readings for later manipulation.

We will add character termination ‘\n’ to our VISA configuration, selecting it first:


And then with right button of your mouse create a constant on VISA serial:


The constant assumed will be ‘\n’ i.e. line return which in decimal is number 10.


Now we are ready to go back to Front Panel and Run the VI. The results will be not very consistent. Change bytes to read to 20 and bingo you will get a line of clear readings:


You can play with Basic I/O shield to check if readings are coming from the sensor. Place a finger on the sensor, and temperature reading will approximate to those of your body temperature:


It is fair to ask that you need save the VI, perhaps with a new name such as

Create a Flat Sequence within the Case Structure as shown bringing the read string within it:


Now right-click inside this loop and search palette ‘scan string’:


And select ‘Scan From String’:


And place it on Block Diagram as shown:


Now we will split the string to get both readings we are obtaining from UNO32 as shown:


The constant ‘%[^,]’ will split the first reading wich we can then display:


By now surely you know how to create Constant and Indicator (tip: point with mouse at the connection and right click your mouse and in the menu choose Create whatever you wanto to do).

We will now obtain the rest of string adding again the decimal string pallete and as shown we will need to add one more constant to let the second Scan palette know where the second part of the string is which will be after comma ‘,’ which in fact is the first character:


So we add constant 1:


Edit ‘output1’ to ‘Temp. ºC” and ‘output2’ to ‘Temp. ºF’.

Finally we will do only one last thing that will fix bytes to read to 20, so that we do not need to change this value on the Front Panel everytime we reinitiate our VI.


We will delete bytes to read control and replace with constant with number 20 in it:


Make sure the Front Panel looks a bit like the following image:


Make sure you have save your VI. Now after setting the port, run the VI.  You will see results as shown:


We are almost finished with our work. We will show a graphic display of centigrade temperature (there is more room for improvement but we will point these out when concluding).

In Front Panel place Thermometer’ found in Numeric Indicator set by right-clicking with mouse:


Thermometer reads numbers and not strings. So in our Block Diagram we need to place ‘decimal string’ palette. Do a search for it:


Choose ‘Decimal String to Number’  and place it as shown next to Thermometer:


Now if you go back to the Front Panel and Run the VI you will see the thermometer displaying the value read in centigrades:


Now in Block Diagram we will first change the description ‘Visa rsource name’ to ‘Port Number’:


And we will hide all other resources that are not needed on Front Panel, such as ‘baud rate’ etc., leaving out ‘Port Number’ that we may need to set:


So the final Front Panel should look like the following image shows:


Save the final work as

Run VI and I think you should see something like the following image:


On the Block Diagram you can click the Highlight Execution button


You can see in slow motion the running of VI.

You can download at free repository Bitbucket The zip file  contains the VI we have just written

You may watch a video on this project at Youtube:


My main aim was to demonstrate that one can combine two powerful tools at disposal of engineers and students: LabVIEW and chipKIT Digilent UNO32.

There is room for improvement with UI (user interface) and to turn this project into full PID control.  Also the LabVIEW VI can have more controls to cater for errors, and other situations such as Alarms.

I will appreciate any comments on the project, specially if there are any errors.

About Tayeb

Electronics engineer, part-time webmaster and owner of "Aliatron", a tech-oriented company registered in Portugal and Mozambique. Owner of "EU Halal", a trading and consulting company in Halal & Tayyib, 100% stun-free compliant.
This entry was posted in Electronic Projects, Programming and tagged , , , , , , . Bookmark the permalink.

5 Responses to LabVIEW and VISA interface, with chipKIT Digilent UNO32 and Basic I/O Shield

  1. Pingback: Remote Viewing with NI LabVIEW, Digilent UNO32 and Basic I/O Shield | RedAcacia

  2. Meher HOUEIDI says:

    I have a project wich control the movement fo a person indoor a house, in which a would like to add a picture in my Labview user interface which contains the plan of the house in 2-D on the first job a person like a point which move from the cordinates stemming from Visa

  3. Haitham says:

    HI I appreciate your help and sharing your project, I have used this project to get distances by using three PmodMAXSONAR and its works good, but I need to write the readings to excel or csv file.


    • Tayeb says:

      Thank you for sharing. With LabVIEW you can write the readings to a csv file. Just Google it, you will find out how to do it. Once you have project working and published do share here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s