circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

April 2005, Issue 177

Simple USB Data Acquisition


DAQ GUI

The user interface is the final piece of the USB ARM DAQ system. It’s the finishing touch that gives the system a professional-looking way to view the temperature data. The serial data feeding the GUI comes from the USB port and originates from the CP2101 bridge board. The PC application thinks the data is coming over a standard COM port. In reality, however, it gets data from the USB port via the Silicon Labs virtual COM port driver. This gives you the benefit of using the USB port for communication without all the complexity because it looks like just another serial COM port.

The GUI was developed in Visual Basic. If you’re familiar with BASIC programming languages like Qbasic, you’ll probably find the migration to Visual Basic to be fairly straightforward. Writing code for various actions or events, like receiving serial characters or a button click, is extremely simple. For this application, the goal was to take serial data from the virtual COM port, convert it from a raw temperature A/D value to a real temperature (Celsius), and then graph and display it. Visual Basic provided the control components for the graphing and the serial data communications, and I wrote the temperature conversion code. 

The serial data is received over the COM port. It’s provided by a control component called MSComm Control in Visual Basic. By simply adding this component to the project, you can set up and open and close serial ports (data rate, etc.). It also allows you to respond to a variety of events, like receiving characters. 

The COM port speed is preset to 9,600 bps to match the speed from the MCB2130 board. The receive Comm event will provide a receive character event and allow viewing and reacting to incoming serial characters from the virtual COM port. After the raw temperature A/D data has been received, it can be converted to real temperature data for graphing. This conversion involves multiplying the raw temperature data, which is the LPC2138’s A/D sampled voltage, by the A/D reference (3.3 V) divided by 10 bits (210 = 1,024). Following this, the LM60 sensor’s 424-mV offset must be subtracted. The value left must be divided by 6.25 (6.25 mV/°C) to get the actual temperature in degrees Celsius, and then converted to an integer.

After the temperature conversion is finished, MSChart Control provides the graphing. By adding this component to the project, a variety of charts and display options are provided for graphing data. Little set-up code is needed because the chart is set up beforehand via the chart properties windows. This is definitely an advantage. You can modify the component controls via a categorized list of options without having to write code to do it.

Combing all the control component interface and application code results in the code in Listing 2 (page 26), which is all you need to accept a serial string from the virtual COM port via USB, convert it to degrees Celsius, and graph and display it. Graphing the data takes only one real line of code!

This is a powerful design tool for GUIs. The end result is shown in Photo 3. The temperature data is graphed nicely (the red line), and the current temperature updates every time a serial string is received over the virtual COM port. This puts the finishing touch on the USB ARM DAQ system and makes for a professional-looking demo.

(Click here to enlarge)

Photo 3—Watching live graphics updates is a lot more interesting than watching raw datastreams in a terminal emulator.