Reading analog input values fast on Axon M505 (under 5ms)
-
Hi everyone,
I've got an Axon M505 and I'd like to read values from the analog inputs ai_2_1 to ai_2_4 in under 5 ms. I tried using SysFS, but it was on average only 25 ms. Do you know a way to get this fast reading through EVOK or another interface on the UniPi? -
Hi @tomkling,
the analog measurements are typically not that fast and the 25ms is more or less the sampling speed in the HW. The best is using the AI on the Group 1 (AI1.1), but measuring resistance is generally slow due to averaging multiple measurements.You would be able to get better speed using ModbusTCP, since Evok is yet another layer between your SW and the HW.
Best regards,
Martin -
Hi Martin, thank's for the quick answer. I meant that I'd like to read the voltage when I wrote 'value'. What do you think, how fast could the voltage be read as I really need a reading interval lower than 5 ms for my application to work properly. I've seen that the MCP342x controllers could reach 240 SPS or some 4,16 ms interval time. Do you think this is possible or is there some kind of bottleneck in the communication?
Currently, I'm also trying to replicate EVOKs communication over the I2C bus to get the values directly. EVOK therefore uses Python Scripts and the pigpio module. If it's possible to reach the 240 SPS, that would be a good point to start for me, that's why I'm interested if it's possible in general to get that sampling speed.
Also, I've seen in an infographic that the Modbus interface is provided by EVOK. So is this faster than SysFs and the other EVOK interfaces or isn't it provided by EVOK but rather a standalone interface which makes it fast?
The Infographic: https://www.unipi.technology/upload/clanky/EVOK/EVOKedited.png -
This post is deleted! -
Hi @tomkling,
the HW architecture in the Axon is different than in UniPi 1.1 which you probably use as a reference. The ADC in the Axon is connected to the STM32 microcontroller which does the heavy lifting and the measured values are passed via SPI to the main CPU. The software protocol is modified Modbus, which is then translated to the ModbusTCP via unipitcp service. Therefor the fastest way is to talk to the unipitcp.Since the communication is layered, there will be some slowing down along the way. Keep the requests to the other IO on the same group to as low as possible to speed up the communication. This would be harder to achieve in the Evok, which polls all the IOs all the time.
Best regards,
Martin -
Hi again and thanks for the help,
I've used ModbusTCP now and the input / output rates are much better, if someone's interested:
Reading only = 2,5 - 7,4 ms
Reading and Writing to another pin = 7 - 15 ms
Reading, Processing the measures, and Writing to another pin = 6 - 18 ms
I used Analog Input 2.1 / 2.2 and Analog Output 2.1 for my application