In the previous post, I wrote about testing requirements, which led us to create Modular sensor platform. I told you about ASP.NET Core technology, which can simplify developing web API server application. You could try developing your own API server. Today I am going to introduce you USB to CAN converter and universal board for connecting sensors.

USB to CAN converter is the STM32F4 powered device for translating USB communication to CAN bus and vice versa. The converted is USB HID class based device. The HID class was chosen because there is guaranteed delay of packets, which is an important parameter in some cases of measuring a response time of testing devices. It is connected to the web server by USB micro and there are two RJ12 connectors on the board. RJ12 connectors are used for connecting sensors or actors (see image below).

Sensors and actors

Sensors and actors can be connected to USB converter via cable with the RJ12 connector through which it is powered and it can receive and sent messages from web API server. The board on CAN bus have to be addressable by a unique address. So each device has its own encoder. Using encoder on the board, you can set the address of the device (see image below – the black box with orange shaft). The encoder is 4 bit, so you can add up to 16 different devices.

The universal version of the board has 3 connectors (the blue ones). These connectors you can use for connecting different kinds of SPI or I2C sensors. The following sensors are in process of development:

  • RGB sensor – For sensing status of LED of a tested device
  • Paper sensor – Detection of paper in printer

These sensors will be introduced in upcoming parts of this article series. The advantage of the universal board is that it simplifies developing new sensors. You do not have to develop custom PCB (Printed Circuit Board), but you can use this board, connect sensor and write firmware specific to the sensor

The firmware is written in pure C using STM32 HAL library (Hardware abstraction layer). The initialization code was generated by STM32CubeMX, which is a graphical software configuration tool that allows configuring MCU by graphical wizards. The tool allows configuration of pin multiplexing, clock, and other peripherals configuration. Then you can generate C project for any common embedded IDE.

Both PCBs were designed in CircuitMaker by Altium, which is free also for commercial use. There is no license to worry about. The disadvantage is that you have only two private projects, others must be public (see


The article describes the hardware part of the Modular sensor platform. The USB to CAN converter and the universal sensor board for developing custom devices compatible with the platform. The concrete developed sensor and actors will be in next parts of the Modular sensor platform series.  This post also describes tools and technologies that were used for developing converter and sensor board. If you are interested in developing embedded systems, you should definitely try STM32CubeMX and CircuitMaker.

When will the robotic revolution come and what will be its impact? What does Industry 4.0 mean and how will it change the world around us?

Come, listen and discuss this with me during a talk titled “Robotic revolution: How robots help during development and testing SW & HW” during the Žijeme IT event on the 16th of February 2018.

The event will take place at the Brno University of Technology, find out more at

I will discuss how Y Soft’s Research and Development department uses robots for development and testing of SW and why we have started to use them. We implement tons of automated tests which are executed as continuous integrations. But how do we proceed when we need to test closed ecosystems which are hard to control remotely or needs to be replaced by simulators? Is robotic testing better than manual testing? What are the advantages and disadvantages of a robotic approach? And why we have ultimately decided not to stay with manual testing? Lastly, what about using simulators, can they provide trustworthy test results?

I will share with you how Y Soft started its robotic development and how this is connected with students. Are students changing the world?

Y Soft is using a robotic arm for testing multi-functional devices, but the robotic arm is not enough for our testing purpose. We need to interact with the device in different ways than just tapping on the touchscreen. A Screen of the tested device is already captured by a camera, therefore it is needed another feedback from a device and react to that feedback. Due to that, we developed Modular sensor platform, which can be easily plugged into a computer (Web API server) by USB. Via REST API protocol you can read information or command different kinds of sensors and actors. The following diagram illustrates how the platform is composed.

Web API server

As this diagram shows you can connect multiple sensors to the server via USB to CAN converter. When the web server starts it sends discovery packet. From the responses, the web knows what types and how many sensors are connected. After initialization, it starts listening to sensors commands from clients.

The web API server is written using ASP.NET Core framework. In the following link, you can find a tutorial, which shows you a simplicity of creating a RESTful application and from which components the server is composed.

The .NET Core is cross-platform so the web server can run on any device running Linux, macOS or Windows.

Try to create ASP.NET Core application based on tutorial above or you can just create a console application (see link). The Created application can be built for any supported OS, for ARM there is available only runtime, not SDK for developing an application (see SDK support, ARM Runtime).

Build for a device is as simple as run this command

dotnet publish -r <Runtime identifier>

in the directory of the project (after -r switch you can specify any supported platform, for more information use this link). You must also install prerequisites to the target device (see link), then you can copy this folder

<Project path>bin\<Configuration>\netcoreapp2.0\<Runtime identifier>\publish

to ARM device and run the application.


This article shows the composition of parts of the platform and how parts communicate with each other and that the platform is not limited only to one operating system. It works with Windows, Linux, macOS, even on ARM architecture. In next part of an article, I will tell you about the development of USB to CAN converter and sensors.


At Y Soft, we use robots to test our solutions for verification and validation aspects, we are interested if the system works according to required specifications and what are the qualities of the system. To save time and money, it is possible to use a single robot to test multiple devices simultaneously. How is this done? It is very simple so let’s look at it.

When performing actions to operate given a device, the robot knows where the device is located due to a calibration. The calibration file contains transformation matrix that can transform location on the device to robot’s coordinate system. The file also contains information about the device that is compatible with the calibration. How the calibration is computed is covered in this article. There is also calibration of the camera that contains information about the region of interest, meaning where exactly is the device screen located in the view of a camera. All of the calibration files are stored on the hard drive.

Example of calibration files for two Terminal Professionals:

   "DeviceName":"Terminal_Professional 4,",
   "MatrixArray":[[0.728756457140,0.651809992529,-0.159500429741,75.4354297376],[-0.683749126568,0.734998176419,-0.10936964140,71.1249458777],[0.0422532822652,0.187897834122,0.981120733880,-34.923427696],[0.0,0.0,0.0,1.0]] ,
   "DeviceName":"Terminal_Professional 4,",
   "MatrixArray":[ [0.713158843830,-0.686471581194,0.220191724515,-176.983055],[0.699596463347,0.6783511825194,-0.15148794414,-71.7788394],[-0.05297850752,0.2635031531279,0.963621817536,-29.83848504],[0.0,0.0,0.0,1.0] ],

For the robot to operate on multiple devices, all of the devices must be within the robot’s operational range, which is quite limited, so this feature is currently is only used for smaller devices, like mobile phones and Terminal Professional. It is theoretically possible to use a single robot on more devices, but for practical purposes, there are usually only 2 devices. Also, all devices must be at relatively the same height, which limits testing on multifunctional devices that have various height and terminal placement. Space is also limited by the camera’s range, so multiple cameras might be required, but this is not a problem as camera calibration also contains the unique identifier of a camera. Therefore a robot can operate on multiple devices using multiple cameras or just a single camera if devices are very close to each other.

Before testing begins, a robot needs to have all calibrations of devices available on the hard drive and all action elements (buttons) need to be within its operational range. Test configuration contains variables such as DEVICE_ID and DEVICE2_ID which need to contain correct device IDs as stored the robot’s database. Which tests will run on the devices and the duration of the tests also need to be specified. Tests used for these devices are usually measurement and endurance tests, which run in iterations. There are multiple variants for these tests, for example, let’s say we wish to run tests for 24 hours on two devices and each device should have an equal fraction of this time. This means that the test will run for 12 hours on one device and 12 hours on the other, which is called consecutive testing. Another variant is simultaneous testing, which means that the robot will alternate between the devices after each iteration for a total time of 24 hours. The robot loads the calibration for another device after each iteration and continues with the test on that device.  This is sometimes very useful should one device become unresponsive, the test can continue on the second device for the remaining time. Results of each iteration of the test for each device are stored in a database along with other information about the test and can be viewed later.

Testing multiple devices with a single robot also makes it possible to test and compare different versions of an application or operating system (in this case on Terminal Professional) without ending the test, reinstalling of the device and running the test again. This saves a lot of time and makes the comparison more accurate.

Reaction time measurement is a process of acquiring timespan for how long it takes for the tested device to change its state after clicking on action element. The most common scenario is the measuring of time needed to load new screen after clicking on the button that invokes screen change. This measurement directly testifies about user experience with the tested system.

So how does our robotic system do it?

The algorithm of reaction time measurement is based on calculation of pixel-wise differences between two consecutive frames. That simply subtracts values of pixels of one image from another. Let’s have two frames labeled as fr1 and fr2, there are three main types of difference computation:

  • Changes in fr1 according to fr2: diff = fr1 – fr2
  • Changes in fr2 according to fr1: diff = fr2 – fr1
  • Changes in both directions: diff = | fr1 – fr2 |

The last mentioned computation of differences is called Absolute difference and is used in our algorithm for reaction time measurements. In general, the input frames are grayscale 8-bit images of the same size. Computation of differences for color images is possible however it would only deliver more errors in RGB color spectrum due to more variables being dependent on surrounding lighting conditions. The final computed difference is just a number indicating the amount of changes between two frames, therefore, it is perfect for detecting the change of screen in the sequence of images.

Enough of theory, let’s make it work!

First of all, we need two images indicating the change of screen. For this purpose, I choose the following two pictures.

Imagine those are the two consecutive frames in the sequence of all frames we talked about earlier.

Next step is to change them into grayscale and make sure they are of the same height and width.

After those necessary adjustments, we are ready to calculate the difference between them. As was told before, it is computed as an absolute subtraction of one image from another. In about every computer vision library there is a method implemented for this purpose, i.e. in opencv it is called AbsDiff. The following image shows the result of subtraction of two images above. As you can see there is a visible representation of both images. That is completely fine because every non zero pixel tells us how much given pixel is distinct from the same pixel in the second image. If result image would be black it would mean that difference is zero and images are identical, vice versa for white image.

Next step is to sum values of all pixels in the result image. Remember that each pixel value for grayscale 8-bit image is in a range from 0 to 255. The difference for this image:

diff = 68964041

This value itself is not very descriptive of the change between the two images, therefore normalization needs to be applied. The form of normalization we use is to transform that computed difference number into a percentual representation of change in the screen with a defined threshold. Threshold specifies what value of a pixel is high enough to be classified as changed so rather than computing sum of all pixels in result image we find how many of pixels are above the defined threshold. The normalized difference for this image:

diffnormed =96.714% (with threshold =10)

This result compared to the previous one very precisely tells us how much change happened between the two images. The algorithm to detect the amount of change between two images was just the first part of the whole time measurement process. In our robotic system, we have implemented two modes of reaction measurement, Forward and Backward reaction time evaluation.


Forward reaction time evaluation

Forward RTE is based on real-time-ish evaluation meaning that algorithm procedurally obtains data from an image source and process them as they arrive. The algorithm does not have the ambition to find desired screen immediately but it rather searches for screen changes, evaluates them and then compares them to desired one.

Forward RTE diagram shows the process flow of the algorithm. At the start, it sets the first frame as the reference image. Differences against this reference are then computed with incoming frames. If the computed difference is above the threshold then the frame is identified and the result is compared to desired screen. If this does not match, the frame is set as new reference and differences are then calculated against it. If that does match then timestamp of image acquirement is saved and the algorithm ends. In theory, every screen change during measuring is identified only once, however it strongly depends on the threshold value that user needs to set. Even if this algorithm tries to be real-time the identification algorithms take so much time that it is not possible yet.



Backward reaction time evaluation

Backward RTE works pretty much the other way. Rather than searching desired image from the start, it waits for all images to be acquired, identifies the last frame and sets it as a reference, after that looks for the first appearance of given reference in sequence.

Backward RTE diagram shows the process flow of the algorithm. First of all, it waits for all frames from the subsequence of frames. After all frames are acquired, the last frame is identified and if the last frame is the actual desired screen then the reference is set and the algorithm proceeds. If the last frame was not desired screen it would mean that desired screen did not load yet or some other error happened. For this case, algorithm records backup sequences to provide additional consecutive frames. If there is no desired screen in those sequences then the algorithm is aborted.

After reference is set the actual algorithm starts. It looks for the first frame which is very similar to the reference one using difference algorithms described earlier. Found image is identified and compared to desired. If identified and desired screens match then the time of acquirement is saved and the algorithm ends. However, if they do not match then the sequence is shortened to start at the index of falsely identified frame and then the algorithm searches further. The furthest index is the actual end of sequence because image at the end sequence was at the start of RTE identified as desired.


This article contains information about difference based measurement of reaction time. It guides you through computation of differences between two images. Also, this article describes our very own two reaction time evaluation modes which we use in practice.


Additional notes

To keep the description of algorithms as readable as possible few adjustments are missing. Preprocessing of the images is the essential part where elimination of noise has high impact on the stability of the whole algorithm. We have also implemented few optimization procedures that reduce the amount of data that needs to be processed, e.i. bisection.