RoadTest: Advantech USB-5830 USB 3.0 Digital I/O Module
Author: shabaz
Creation date:
Evaluation Type: Development Boards & Tools
Did you receive all parts the manufacturer stated would be included in the package?: True
What other parts do you consider comparable to this product?: National Instruments has some embedded control devices, but in my view Advantech is more geared for industrial automation and industrial IoT. Other players worth exploring would include Siemens and Wago.
What were the biggest problems encountered?: Nothing of major significance. However, a couple of points removed for a few minor things. (a) the supplied paper documentation has tiny diagrams where connector/channel numbering is miniscule and therefore unreadable, and (b) it would be nice to one day see ARM support too, and finally (c) it would be super-nice to have two USB Type-A sockets on the module instead of just one.
Detailed Review:
Advantech produce lots of interesting stuff to connect the software world to machines. The portfolio is huge – it includes ruggedized computers, displays and controls for human-to-machine interfaces, and electrical interfaces to control and sense machinery.
The USB-5830USB-5830 is one device in a family of modules that allows a computer to connect safely to machines. A machine could be an air conditioning system in an office, or part of a production line, or a robot on a shop floor.
I was quite interested to examine the USB-5830 because it connects via USB, and this makes this particular module useful where computing resources are nearby – such as in a lab for test automation – and also for chaining up additional devices with high throughput and low latency. In the industrial IoT world, it is sometimes known as edge computing.
The USB-5830 has 16 digital inputs and 16 digital outputs. Other models in the range have different quantities of I/O. Of course, there are different ranges of products with analog I/O too. They can all be controlled and monitored in similar ways however.
Why would you want to use such a device? There are several reasons!
Personally, I've been looking forward to trying out Advantech hardware and software for a very long time. Advantech are one of the few companies that have their clearly passionate staff attend IoT meet-ups in my local area, and this is nice to see.
The USB-5830 is a lightweight (mainly plastic) unit that can clip onto a DIN rail. It connects to the PC via USB as mentioned, but additional devices can be chained up too. There are four recessed DIP switches on the front panel to configure each chained device to have a different binary address.
The input/output connections are via four ports (each 8-bits or channels wide). Four connector plugs are supplied to connect to these ports.
The USB-5830 has open collector outputs, but other models have relay outputs too. The outputs on the USB-5830 can each sink 350mA (at room temperature; slightly less in a very hot environment), so that’s sufficient to activate relays if desired too.
The unit is not sealed to be dustproof - it is expected to be installed in an enclosure or cabinet. The connectors actually are reasonably finger-safe when running at low voltages, but all usual precautions must be taken when connected to high voltage equipment.
Everything was easy-to-read on the front panel, and there is clear LED indication of each input (using green LEDs) and output (orange LEDs).
The USB connections can be secured with a thumbscrew to prevent accidental removal. There are also connectors for redundant power supplies.
Lots of useful information is supplied on the Advantech website, including 3D CAD files so that the module can be perfectly fitted inside a customer solution.
Underside view, for mounting to a DIN rail:
In summary the hardware is as expected, there isn’t really anything much to fault. During my time using it, the hardware was never warm, so that provides some confidence that it may have a long operational life. I queried with Advantech and they reported a Mean Time Before Failure (MTBF) of 1.2 million hours and 2.5 million hours (these are for ‘ground fixed’ and ‘ground benign’ environmental conditions respectively). That’s several times the expectancy compared to high-end PCs that the hardware may be connected to, so this is reassuring.
Advantech hardware comes with drivers and a software development kit. The drivers allow for integration with LabVIEW for graphically creating control and monitoring software applications that can interoperate with a mixed variety of hardware. LabView is software available from National Instruments.
For software developers, Advantech supplies application programming interfaces (APIs) for many platforms and programming languages including Microsoft platforms (Visual Basic language, C, C++ and others are covered) but also for Linux users C++ and Java are available. Qt is also supported for Linux. Note that all platforms require x86 (ARM is not supported).
For my tests, I decided to use a small mid-performance server – an Intel NUC with i3 processor. To make things realistic, I did not run Linux and Windows natively, but instead as virtual machines (VMs). I figured real installs could very likely run with virtual or containerised applications for ease of support and deployment. So, I installed ESXi and Windows 10 and a stable version of Ubuntu, and then installed the Advantech drivers and SDK on each VM.
Installing on Windows is a double-click exercise. For Linux it is straightforward too, but via the command line. The steps taken are documented here for anyone wanting to use the SDK. The information applies for use with any Advantech interface module, not just the USB-5830. Everything went smoothly, and the Advantech instructions were very clear, with screenshots of each step.
As root user:
apt-get update apt-get install linux-source apt-get install build-essential apt-get install linux-headers-$(uname -r)
as normal user:
mkdir ~/advantech-drivers cd ~/advantech-drivers
Copy the linux_driver_source_3.2.13.0_64bit.zip file into the folder, then type:
unzip linux_driver_source_3.2.13.0_64bit.zip cd linux_driver_source_3.2.13.0_64bit/drivers/driver_base/src/lnx_ko
As root user:
make cd ../../../usb5800dio/src/lnx_ko make mkdir /lib/modules/$(uname -r)/biodaq cd ../../..
You should now be back in this folder: linux_driver_source_3.2.13.0_64bit/drivers.
From this folder, the bin folder will now contain the following two files:
bio5800dio.ko and biokernbase.ko
Execute these commands:
cp bin/*.ko /lib/modules/$(uname -r)/biodaq/. depmod
Next, edit the /etc/modules file and append this to it:
biokernbase bio5800dio
Save the file, and then type these instructions:
cd ../libs cp * /usr/lib/ cd ../inc/ cp bdaqctrl.h /usr/include/ mkdir /usr/share/advantech cp Automation.BDaq.jar /usr/share/advantech/. chmod 444 /usr/share/advantech/Automation.BDaq.jar
It is good to build some example code in order to be sure things are working. Personally, I like C and C++ so that’s the example that I initially chose. From the home folder, become root user and type:
apt-get install dos2unix
as normal user:
cd ~ mkdir -p development/advantech cd development/advantech/test1
Copy across a demo from this folder:
linux_driver_source_3.2.13.0_64bit/examples/C++_Console by typing these commands:
cp -r DO_StaticDO ~/development/advantech/ cp inc/compatibility.h ~/development/advantech/DO_StaticDO
rename the folder to whatever you're developing:
cd ~/development/advantech mv DO_StaticDO mytest1 cd mytest1 dos2unix StaticDO.cpp
Now, plug in the device, type lsusb to confirm it is there (if you’re using ESXi then the USB device also needs to be plumbed to the VM using the VMware browser tool) and then type this command to find out what the path is of the device:
cat /sys/class/daq/daq0/desc
Edit the deviceDescription line in the C++ file, e.g.
#define deviceDescription L"USB-5830,BID#0"
And then compile using the command:
make
As root user, execute the compiled code:
su ./StaticDO
That’s it! Now that demo code can be successfully compiled, it is possible to write some custom code for experimenting with the USB-5830. But first, I briefly decided to run a couple of demo apps on Windows too. You can skip the next two sections if you’re more interested in Linux.
The Windows SDK comes with pre-built applications which was great to see. I tried the data logger (the screenshot below just shows a 50Hz signal being captured on one of the inputs of the USB-5830). I didn’t spend too long because I was more interested in writing my own apps.. but I can see this pre-built tool being handy to quickly see if things are wired up correctly.
The inputs are connected up to the USB-5830 as shown below. The blue wires are connected to input channels 0 and 1 in the photo and any voltage above 10V (up to 30V) is considered a logic 1 value. The black wire is the common ground for all the inputs. Optionally the white wire can be used as a common wire for ‘dry contacts’ such as a push-switch between the white wire and the inputs. Input channel 1 happens to be energised in the photo, and a green LED indication is shown.
MATLAB is a piece of software developed by MathWorks. It consists of a programming language (MATLAB itself) along with thousands of ready-made functions written in that language. Programs can call all these functions to construct very feature-rich applications. It is particularly useful when dealing with intensive volumes of data; it doesn’t fall over like Excel! Advantech supplies example MATLAB code (they have a .m suffix). No compilation is needed – just double-click the .m source file, and MATLAB will launch and the code can then be executed by typing the title of the .m file (i.e. the file name but without the suffix) in the MATLAB command window.
Key strengths of MATLAB are the data analysis, filtering and graphing tools. These would be more interesting to try with Advantech’s analog input USB modules : ) but the concept is the same – it would be very easy to extract data using the Advantech API for MATLAB and do lots of fancy analysis and charts!
I installed a copy of the Advantech DAQNavi SDK on my PC, and as part of that software called Navigator is installed. It is like a massive comprehensive help file, where you can select the interface module (i.e. USB-5830 in my case) from the hundreds of options on the leftmost side, and then drill down in the SDK based on the task (such as read an input, or control an output) that you wish to achieve.
As part of the SDK, it was nice to see that there are several dozen folders with example code per language (several hundred in total). This and Navigator are a great help when developing code.
A key feature of the USB-5830 of course is the ability to control devices using digital outputs. The photograph below shows how to wire these up. In this photo, output channels 0 and 1 are open collector, and the black wire is the common ground. The orange lights indicate when any channel is at logic ‘1’ condition (i.e. the output transistor is on, and the channel is pulled to ground). Anything between 5V and 40V is supported for the digital output channels, with a current of up to 250mA at 60 degrees C. Relay output versions are available too (PhotoMOS with fast response time, such as the USB-5855, or mechanical relay output with higher voltage and current capability such as the USB-5862).
I was curious to see the nature of the output signals. I was expecting to see some jitter due to Linux. The USB-5830 has open collector outputs that have optoisolation specified to have 100 usec response time, so I was expecting to see a value slightly higher than this (due to Linux code speed and USB interface). I connected output channels 0, 8 and 15 to 100 ohm resistors and a 10V supply. This would result in 100mA current sinking per channel when enabled. I also connected an oscilloscope to these channels, and then wrote some code (based on an Advantech example code) to toggle all the channels in a loop with no delays. Of course, Linux has pre-emption and so delays and jitter are expected. There are software techniques to reduce this (beyond the scope of this review). Futhermore the opportunity exists to reduce jitter slightly by implementing code at the driver level instead of in user-space. Advantech supply the driver source code, so this is feasible.
As can be seen from the screenshot, it takes a lot longer to turn on an output (this is open collector, so a low value on the oscilloscope signifies an output turning on) than to turn it off. Nevertheless, the ‘on’ period is still of the order of 100 usec, so it is good to see that the drivers, including USB stack, are having very little impact on performance. The USB-5830 datasheet specification of 100 usec response time for the optoisolators is indeed the main delay experienced. The visible jitter (due to Linux and possibly ESXi) is fairly low here (under 20 usec mostly) but can be higher – it depends on what Linux decides is more important to run.
In summary, performance of the Advantech and USB drivers and i3 processor and virtualization are excellent, as is the USB-5830 hardware performance, all having little impact on performance with the optoisolator response time being the bottleneck.
Although there is an API for directly reading the input channels, I was happy to see that event-based reporting was supported too. Using this capability it is possible to register a function that will get called whenever the configured event occurs. As a result, user code doesn’t need to loop continuously until an input changes; a separate handler gets executed. I decided to write some code which would use this capability to measure the frequency of a connected signal. Linux is good at this because it has an easy-to-use real-time clock. The code counts the number of pulses or events using the separate handler function, recording the time of the first pulse. When some pre-defined amount of pulses have been counted, the current time is recorded. The delta provides the period for that number of pulses and then simple arithmetic will reveal the frequency. I supplied a 1kHz 10Vp-p signal and the measured frequency was reported by the software to within a few percent. In theory up to 16 signals can have their frequency measured in this manner using the USB-5830. This worked well to beyond 10kHz (after about 15kHz the reported results had inaccuracy, so a ballpark of 10kHz is best considered to be a usable limit). It’s no replacement for an analog input module of course. Although there are other Advantech modules that support analog input, if there was just one or two channels of basic analog input capability that were needed then at a pinch this frequency measurement method could be used in conjunction with a voltage-to-frequency converter circuit.
I didn’t have a voltage-to-frequency converter circuit to hand, but I decided to just vary the frequency of a signal generator to simulate this. Using MATLAB on the Windows VM, it was possible to write some code that would measure the frequency, and plot it on a chart dynamically. Some example output is shown in the screenshot below. Similar code (but of course with more analog measurement accuracy) could be used with an analog Advantech module; MATLAB is very useful for plotting data in real-time.
The nature of the jitter (predominantly due to the operating system) and the optocoupler response time was investigated above, but I was also curious about latency. To examine this, code was written that would call an event handler if a rising edge occurred on one of the input channels. Once that occurred, an output channel would be turned on and off briefly (it appears as a low voltage on the oscilloscope output when that occurs). Both the input and output signals were recorded by the oscilloscope.
From this code, it was possible to see that typical latency will be less than 150 usec.
In order to explore deeper what kinds of bottlenecks there could be in the product, I decided to open it up – there’s a lot of hardware!
From my understanding of it, it looks like a Cypress HX3 USB 3.0 hub is incorporated, with one downsteam port connected to the USB Type A socket (so that additional devices can be chained) and another downstream port connected to an FTDI 32-bit USB to parallel first-in-first-out (FIFO) bridge. The parallel outputs go to a Lattice ECP3 FPGA which I’m guessing is used to implement all the features required for the various modules in the Advantech range. The input/output buffers and LED indicators are actually on a separate circuit board connected alongside the control board. It’s a nice design that provides for many different products in the range by swapping out the input/output board for (say) a relay board.
I though the design was nice; the embedded USB hub means that the Advantech boards are quite future-proof for solutions that could start small, and then dozens of Advantech modules could be daisy-chained as required, with all the benefits of high throughput not being significantly impacted, since there is such high throughput available with USB 3.0. Other interesting uses could be where third party USB devices such as cameras are also required; the USB Type-A port allows for any standard USB device to be attached to the Advantech module. I don’t know if that is officially supported, but I don’t see why that would not work. I tested by attaching a USB memory stick, and it worked as expected.
The custom light pipe arrays for those who enjoy seeing mechanical and optical detail : )
The USB-5830 proved to be very easy to use with both Windows and Linux. It operates at good speed for a variety of control and monitoring applications. It can be seen that the APIs are easy-to-use and one should feel very comfortable using any Advantech module because the APIs and procedures are similar across hundreds of Advantech products. I’m looking forward to using the USB-5830 for future automation needs as they arise.
The APIs were used to explore the output toggle speed, frequency measurement and for frequency plotting (useful for analog-to-digital conversions with a voltage-to-frequency converter). The example code that was written for this review is attached below.
The unit was always cool in operation, and I liked that there was redundancy in power supplies and some elements of ruggedness although it is intended for use in enclosures or cabinets.
The module is hard to fault, but if I could suggest any changes, it would be that it could have been convenient to have another USB Type-A port on the modules. Also, ARM capability for the SDK would be nice.
The support was extremely good which gives me confidence that solutions could be rolled out rapidly with these modules; there is an impressive array of documentation and examples, and when I reached out to Advantech for MTBF figures, a detailed report was supplied within 24 hours.
I hope this review was useful. Thanks for reading!
Top Comments
Very comprehensive and clearly written. As usual :-). Nice to see that the software and documentation was done well as that is not always the case these days.
Frank
Nicely written. Looks like the device has a lot of potential
Cheers
Another great road test review! Well done.
Gene