CloudHead84
Hi guys,
 
i made a small test to figure out the fastest cycle time of the OpenPLC runtime for ESP32.

I did that because i want to create to Step/Dir-Signal out of the PLC-program and wondered how fast a stepper can be with this method.

This is what i got for the step signal:
[203128%2F8352904%2Fmceclip0]

So about 0.35ms for two Cycles (1 Cycle Puls/ 1 Cycle Pause).
Thats a min cycle time of 0.175ms.
 
The task cycle time was set to 0.001ms in the PLC-program, so the difference to meassured min is relative big.
[203128%2F8352906%2Fmceclip0]

The simple test program looks like this:
 
[203128%2F8352910%2Fmceclip0]
 
 
I connected a tmc2208 stepper driver and got about 228rpm max speed at 1/4 microstepping.
 
Now i wonder if there is a hard minimum cycle time included in the Microcontroller runtime.
Reply 0 0
thiagoralves
To answer your question, there isn't a minimum cycle time for the runtime, this is totally hardware dependent. However, this is not the best approach. You shouldn't read fast signals like that on the PLC program itself. Fast signals should be handled by proper hardware that can interpret them. To the very least, it could be possible for a low level software driver to read those with hardware interrupts. But not on top of a PLC runtime, no. That's too much overhead for a fast signal like that.
Reply 0 0
CloudHead84
i know that this isn’t the best way to do things like motion control.
im also working on a solution with a Arduino stepper lib implemented via the cpp file that can communicate via Modbus with the runtime on the MCU or a remote OpenPLC runtime (raspberry).
 
but his is much more difficult to use/modify for a beginner then just use custom motion blocks that can directly run a stepper, even tho at slow speed.
there may be project where the speed will be enough.
Reply 0 0
thiagoralves
Perhaps the best approach then would be to implement a proper encoder reading block on OpenPLC Editor that actually implements encoder reading using hardware interrupts / counters that usually are present on any microcontroller nowadays. Check https://openplcproject.com/docs/3-3-adding-new-blocks-to-openplc-editors-library/
Reply 0 0
CloudHead84
Is it somehow possible to include an arduino library (Arduino.h) in a function block when you code in C?
 
Or do I have to go all the way adding a custom block/lib, like the link you gave me above?
Reply 0 0
Reply