Using PLX-DAQ with Arduino.(Getting started)
Many engineering projects involve collection of data especially from sensors connected to microcontrollers. PLX-DAQ is among the easy platforms that provide easy spreadsheet analysis of the data collected in the field, laboratory analysis of sensors and real-time equipment monitoring. In this tutorial I will show how PLX-DAQ is interfaced with Arduino for data analysis.
What is PLX-DAQ?
PLX-DAQ is a short form for Parallax Data Acquisition and it is an add-on tool for Microsoft Excel. This software enables easy communication between Microsoft Excel on a Windows Computer and any device that supports serial port protocol. We can now be able to send data directly to Excel from any microcontroller connected to any sensor and the serial port of a PC although PLX-DAQ was intentionally written to allow communication between Arduino and Excel.
Using the PLX-DAQ platform you can be able to take measurements for data like temperature, humidity, light intensity and a lot more using Arduino, and then send the results to Excel where this data can be printed on a spread sheet and analysis done using graphs and charts.
Other major features of PLX-DAQ include ability to record up to 26 columns of data, read or write any cell on a worksheet, support for up to 128k Baud rates and support for COM port 1 to 15.
All this communication is done using simple serial commands like the ones used when sending data from Arduino board to the Arduino IDE serial monitor.
Installing PLX-DAQ
You can download the zip file from this website. I also recommend an improved version of PLX-DAQ for people using newer versions of the Microsoft Office Suite which can be got from the Arduino forum.
Un-zip the downloaded “PLX-DAQ” folder and inside it you will find the “plx_daq_install” file which is used for installing the software.
After the installation process, a new folder named “PLX-DAQ” is created on the desktop. On opening this folder you can then access the Excel spreadsheet by clicking on “PLX-DAQ Spreadsheet”.
Enabling Macro and ActiveX
When you start the Excel spreadsheet, you may be prompted to allow macro and ActiveX to run. This is because some VBA macros are malicious ware and if activated may delete all your office files. Therefore Microsoft has set security features to prevent macros from running by default. However for PLX-DAQ to operate you need to enable macros and ActiveX.
After opening the Excel Spreadsheet, a yellow warning message at the top of the spreadsheet will prompt you to running the macro. Another message for enabling the ActiveX will also pop up and you just click ‘OK’.
In some cases Excel security may be set as “High” which will not allow macros to run but will not also ask about running macros when Excel is started. In such a situation you need to manually set the security to “Medium” using the following steps:
- From Excel, Select menu item “Tools–>Macro–>Security”
- Set security to “Medium” to allow Excel to ask about running macros. “Low” is NOT recommended for security reasons.
- Close Excel and re-open the PLX-DAQ spreadsheet.
- Port: to set the Arduino COM port in use (in my case it is COM 3)
- Baud: set the baud rate that your Arduino is running on (e.g., 9600 if you are using Serial.begin(9600); in your code)
- Connect: connects to your Arduino and starts logging
- Reset Timer: sets the Timer to 0. The Timer can be used to measure how long Excel is already logging
- Clear Columns: delete all logged data from the sheet but does not clear the labels of the columns.
How PLX-DAQ works with Arduino.
PLX DAQ works with a special Microsoft Excel Spreadsheet and is connected to any Arduino device that sends specially formatted commands for communication. These commands can include parameters, variables and functions.
The Arduino device and PLX-DAQ rely on the UART serial communication therefore we use functions from the serial class especially Serial.print() and Serial.println().
Basic commands.
CLEARSHEET: this command clears all data on the Excel sheet including labels! If you are to use this command then it should be the first command on the sketch.
RESETTIMER: It will reset the timer that is used to count the time PLX DAQ is already logging
CLEARDATA: clears up any logged data left from previous projects on the Excel sheet.
LABEL: set the labels for the top most row of the Excel sheet.
DATA: This is the most basic and crucial command of PLX-DAQ. It is used to send data from your Arduino to Excel and have it printed on the Excel sheet.
Comma “,”: when entering data in an Excel sheet, the data should be split by commas where every comma is for moving to the next column.
The PLX-DAQ software can recognize some reserved key words for example DATE and TIME which can enter the current date and time using your computer’s settings. The TIMER keyword enters the active logging time.
Syntax
In most cases we have to enter many variables in one row of the excel sheet. To achieve this we use the Serial.print();
command for entering the variables. A comma (“,”) is used to move to the next column and to indicate the end of row we have to send a Serial.println();
command.
The example below shows how you can enter the time, date and values of two variables into an Excel sheet.Serial.print("DATA,DATE,TIME,”); //display date and time
Serial.print(Variable1); //display first variable
Serial.print(",”); //move to next column
Serial.print(Variable2); //display second variable
Serial.print(",”); //move to next column
Serial.println(); // move to next row
Example of using Arduino with PLX-DAQ
A simple example to demonstrate the working of Arduino with PLX-DAQ can be displaying the change in analog values using a potentiometer connected to Arduino pin A0. You can make reference for the setup of this experiment from my other post where I wrote about how to use a potentiometer with Arduino.
Code for using PLX-DAQ with Arduino.
int pot = A0;
void setup(){
Serial.begin(9600);
Serial.println("CLEARDATA");
Serial.println("LABEL, Time, Started Time, Date, Analog Value, POT%");
Serial.println("RESETTIMER");
}
void loop(){
int pot_val = analogRead(pot);
int pot_percentage = map(pot_val, 0, 1023, 0, 100);
Serial.print("DATA, TIME, TIMER, DATE,");
Serial.print(pot_val);
Serial.print(" ,");
Serial.print(pot_percentage);
Serial.println(" ,");
delay(1500);
}
This code will enable the time, date , the analog value and percentage rotation of the potentiometer to be entered in the Excel spreadsheet in real time. The collected data can then be analyzed using graphs or charts as I have demonstrated in the video below.
You can also check out the other tutorial where I have demonstrated how PLX-DAQ is used with Arduino for data logging.