x_tinker
I am in a FA&C work environment looking into opensource PLC alternatives.
I am considering a microcontroller (rp2040 / rp2350) implementation running OpenPLC.
 
The idea is to create a Ladder Logic diagram on the PC, and "flash" the program to the microcontroller over USB.
The MCU running OpenPLC would then R/W to address space based on the Ladder Logic, not toggling GPIO directly.
 
Then, based on the value written to the MCU's internal memory, the DMA would transfer data to a peripheral (i2c/spi/uart/pio/etc) to trigger a serial WRITE or READ event.
 
So let's say Ladder Logic wrote QX0.0 = "1" then the OpenPLC runtime on the MCU would write to a defined memory address.
The DMA would kick-in and transfer a packet to the SPI TX BUFFER initiating a transfer, the response stored in memory for the OpenPLC runtime to detect and perform it's next action, etc.
 
Q1. If you flash the OpenPLC to a microcontroller, are you still able to do things like setup DMA on the microcontroller?
Q2. If not, how feasible is using a dual-core MCU (rp2350) to handle such a setup (OpenPLC on one core, DMA init. on the other)
 
Is there any more detailed pointers someone can provide, so I can look around the github source code or w/e to start modifying hardware layer software to do such a thing?
 
P.S.
I noticed OpenPLC supports Modbus Addressing, so I assume it already does something similar. What would I need to do to modify OpenPLC Modbus Addressing implementation for DMA/PIO initialization/setup?
Reply 0 0
thiagoralves
OpenPLC already does all of that, except for handling your specific hardware over DMA. For this you just need to write your own hardware layer at editor/arduino/src/hals. There are specific hooks that asks you what should be done with the data at the beginning and end of a scan cycle. Just take a look at the other hardware layers for an example on how that’s done.
Reply 0 0
Reply