jbe
is its supported with arduino mega ?
 
i see is juste suported by jaguar ?
 
 
tansk for your help
thiagoralves
Indeed, those AVR 8-bit micros have the hardware capability to drive fast pulses. The problem is to try to drive these pulses from a higher layer language running on top of a IEC 61131-3 runtime on an 8-bit micro. Pretty close to impossible. That's what I meant when I said that this "is not something a PLC [runtime] can do without hardware or specialized drivers". Through specialized drivers it is possible to exercise the hardware timers on the 8 bit AVRs to achieve something like that on the IEC runtime. The closest thing OpenPLC has for that type of control is the PWM_CONTROLLER block. It allows you to create PWM pulses of multiple frequencies and duty cycles generated in hardware. However, since it is a hardware thing, it doesn't work on all boards as it requires a specific driver to be written for each board. From the top of my head I think this driver was implemented for all AVR 8-bit boards, ESP32 and I believe some SAMD boards as well like Arduino Zero and MKR.
Reply 0 0
openplc80
Yes it is probably not easy to implement an input module for a fast counter, as it will need some hardware interrupt code talking to the upper layers. But it should be possible to make a pulse generator, this is not so different from a PWM generator. If the pulse frequency can be changed at every PLC cycle, (sending a parameter in the hardware timer) then it is enough to create a simple pulse generator, for a stepper, that can generate pulses up to a few Khz speed. If the PLC code can change the frequency of the hardware timer every cycle, say every 10 ms, this is enough to generate smooth acceleration curves up to a few kilohertz.
 
I did use successfully the Schneider Twido pulse generator for two projects as i said before, i was able to generate smooth acceleration and deceleration curves with a simple math formula using a square root, and i was able to use the hardware interrupt system in those PLCs to get a coder input for precise end of move positioning at a low stepper speed. The control loop was only closed at low speed, but this was precise enough and performant enough to replace some old blocs of electronics costing a lot more.
 
At this time i did watch the capabilities of low end Mistsubishi PLCs, they were 10 times faster than the Twido and and were able to generate automatically the moves acceleration curves, but programming was more complicated, so i decided to stay with Schneider Twido. It is probably the same story with some small differences, for other brands (Omron, Siemens, Rockwell...) that i do not know.
 
This will not drive a stepper motor to its max performance, specially if using a microstep driver, but will be enough for most small project that just need a low performance stepper or servo control in step / dir mode.
 
If someone wants to see what it possible to do on a small 8 bits processor, then watch at the entry level PLCs from well known manufacturers, most have PWM outputs, some have pulse outputs (for servos or steppers motor), and most have a high frequency counter input, a few Khz, or up to something like 100 KHz.
 
 
Using entry level PLCs for motion control is something that is not commonly done probably, because frequency performance is limited, or because sometimes the motion acceleration curves need to be computed by you, but for a number of projects, this is enough and can reduce the hardware cost, a lot.
 
Anyway a pulse generator block for small 8 bits processor boards would be at least an interesting thing for training and students that do not have access to more expensive hardware.
 
As a side note, a few years ago we had some advanced 8 bits processor, like the AVR Xmega, that had a more capable interrupt and timer system that could be used to make more capable motion controllers or signal capture / conditioning systems. I remember i did study those low level capabilities when we decided to rewrite the low level RC control arducopter code, but it was too late to change something on the PCB manufacturing then we did stick on basic 8 bits AVR, and Mega AVR for the main processor. Later a switch to 32 bits has been done for more capabilities, but for simple flying, and even acrobatics, 8 bits processors clocked at 16 MHz were enough !
 
Anyway, the embedded small processor market seems to have switched now to 32 bits, and those new processors have probably some better capabilities for motion control.
Reply 0 0
thiagoralves
I believe you should be able to generate the pulses you need on OpenPLC using the PWM_CONTROLLER block, and then setting the duty cycle to 50. This will generate a square wave with 50% time ON and 50% time OFF. If a shorter on time is required you can play with the numbers having maybe 20% duty cycle or even 10%. Frequency can be changed as much as every scan cycle, so you should be able to reproduce the exact same thing you had with the Twido. The only problem with this approach is that the width of the ON time will vary when you vary the frequency.
Reply 0 0
openplc80
Yes this should be possible. Nevertheless there is one major difference. Mainly, on the Twido for example, you send two parameters to the pulse generator : the pulse frequency, and the number of pulses to be generated. After you sent the number of pulses, you can still change the frequency, for example to generate an acceleration curve.
 
There is a third parameter to stop or run the pulse generator. If i remember correctly there is only those three parameters. The direction signal has to be managed separately, this is a simple on / off signal.
 
This gives you an exact control on the number of pulses that has been sent, regardless the realtime frequency changes you did. If the stepper motor did follow them correctly, this gives an exact positioning.
 
Using a PWM block, you will not have the pulses number parameter, this will be a problem for precise control.
 
If the acceleration curves and max speeds have been setup correctly, if the stepper motor and mechanics are ok, it is possible to have an openloop system using this kind of pulse generator that have a very precise positioning, even more precise than a servo in some cases.
 
Canon for example is using steppers inside their autofocus lens system for Video use. Probably because the steppers are easier to manage (lower cost) to get an exact positioning.
Reply 0 0
Reply