kinsa
Hi,

I just want to share my work on running OpenPLC on STM32 hardware.

https://github.com/kinsamanka/openplc-stm32-freertos

My goal is to run OpenPLC on cheap hardware that you can find on Aliexpress (try "WS2N-14MR-S").

It is using PlatformIO for the build environment so that it will be easy to port to other platform/architectures.

At the moment the code is configured for an AMSAMOTION ETH-MODBUS-IO5R module with a working modbus tcp slave.

Note that this is still an ongoing WIP.
Reply 5 0
kinsa
My FX3U-24MT board has arrived:

fx3u-24mt.png 

This is actually a nice board. It has a provision for a supercapacitor to serve as backup for power loss. Together with the external eeprom, Persistent Storage can be implemented.

The board also has a CAN bus, it just needs a driver  (U29) and some passive components.

The pin mappings:
DIGITAL INPUTS :
    PB13 - X0.0
    PB14 - X0.1
    PB11 - X0.2
    PB12 - X0.3
    PE15 - X0.4
    PB10 - X0.5
    PE13 - X0.6
    PE14 - X0.7
    PE11 - X1.0
    PE12 - X1.1
    PE9  - X1.2
    PE10 - X1.3
    PE7  - X1.4
    PE8  - X1.5
    PC7  - 24v OK
    PB2  - run switch

DIGITAL OUTPUTS :
    PC9  - Y0.0
    PC8  - Y0.1
    PA8  - Y0.2
    PA0  - Y0.3
    PB3  - Y0.4
    PD12 - Y0.5
    PB15 - Y0.6
    PA7  - Y0.7
    PA6  - Y1.0
    PA2  - Y1.1
    PC7  - Y1.1
    PD10 - run LED

ANALOG INPUTS :
    PA1 - AD0
    PA3 - AD1
    PC4 - AD2
    PC5 - AD3
    PC0 - AD4
    PC1 - AD5
    PC2 - trimmer R00
    PC3 - trimmer R01

ANALOG OUTPUTS :
    P4 - DA0
    P5 - DA1
Reply 0 0
kinsa
Almost all of the features of the FX3U board are now implemented. What's missing is the RTC, I2C EEPROM and the RS485. port

I'll try to implement Modbus master as this board has plenty of ram to spare.
Reply 0 0
vibram
Hello
Is this one will work zith zork done by both of you?
https://www.aliexpress.com/item/32798616041.html?spm=a2g0o.productlist.0.0.6ac5784e6oHXiN&algo_pvid=c4e4b261-4c90-4834-a022-d6b503c9b0b8&algo_exp_id=c4e4b261-4c90-4834-a022-d6b503c9b0b8-3&pdp_ext_f=%7B%22sku_id%22%3A%2264016371090%22%7D&pdp_npi=2%40dis%21EUR%2147.86%2147.86%21%21%21%21%21%402100bb4916605033351876043ed816%2164016371090%21sea&curPageLogUid=7IPsempeq0Zw

Capture d’écran 2022-08-14 210117.png 


thank you
Reply 0 0
thiagoralves
I believe it would. These chinese clones are manufactured by several different companies, so it is really hard to be 100% sure. The only catch is that you will have to open it up and solder a button to the Boot0 pin of the MCU to be able to program it. Currently there is no way around it. Since boards are manufactured by different people, the location of the Boot0 pin might vary.
Reply 1 0
kinsa
It looks like a bigger brother of this one: https://www.lollette.com/fx1n-20mr

If it is, then I guess it is using STM32F030. OpenPLC can work but you might be limited with the amount of RAM.
Reply 0 0
vibram

Thank you for your input.

For me this is the perfect example why we should have an opensource PLC hardware to go with openPLC, something plug and play. Maybe a copy of this kind of FX1 or FX3 ? If they are working well maybe we should try to reverse engineering it ?

Reply 0 0
kinsa
It is just a standard STM32 board with built-in optically isolated I/O circuit; Blue pill with optically isolated IO. 😉
Reply 0 0
thiagoralves
The "optically isolated IO" can be a little bit more complex than just putting optocouplers everywhere. It is not that simple. It has a PSU to feed 3v3 to the MCU and other peripherals. There is a MAX232 serial chip (although we could use USB), analog isolation circuitry for the analog IOs, a mosfet driver, and a couple other things. The worst part of that story is that even if we manage to copy exactly the same circuit and add just the Boot0 button to ease the programming, we would never be able to manufacture it at the same price tag of those Chinese boards. Their manufacturing costs are way lower than anything we can get on the west side of the planet.
Reply 2 0
vibram
I don't want to be off topic. Even if it's 10/20USD more expansive. Havingthe end on everything with a plug and play hardware would be very beneficial to the whole project. but this in mypoint of view, not the absolute truth

I don't have a lot of spare time but maybe we can collaborate on a kicad project ? up to you
Reply 1 0
lucianod6
kinsa wrote:
Almost all of the features of the FX3U board are now implemented. What's missing is the RTC, I2C EEPROM and the RS485. port

I'll try to implement Modbus master as this board has plenty of ram to spare.

the eeprom is not needed because most of the ram is buffered
Reply 0 0
kinsa
The main reason why I worked on this project is because the hardware is easily available and it fit my needs. I can just grab a board, reflash it and use it on whatever application I'm tasked to do.

If I need backups, I'll just buy plenty of spares. Worst case, I'll design my own board.

For the three boards that I've looked into, they are pretty similar. So I'm not worried about the HW, there are plenty to choose from.
Reply 1 0
vibram

Will this be officially supported by OpenPLC?

 

Another question: any advice on HMI to go with these PLC? And also supported officially by OpenPLC?

Reply 0 0
thiagoralves
Sorry I've been busy with other projects at work, but yes, this will be officially supported by OpenPLC at some point. I have pretty much all the mapping done, it is just a matter of writing the hal driver and updating the supported boards list.

As for HMIs, anything that can talk Modbus RTU or TCP should be fine. I haven't tested it yet but I'm pretty sure that OpenPLC's Modbus implementation will work out of the box with these PLCs on both the Serial and Ethernet ports.
Reply 1 0
vibram
Sorry I've been busy with other projects at work, but yes, this will be officially supported by OpenPLC at some point. I have pretty much all the mapping done, it is just a matter of writing the hal driver and updating the supported boards list.

As for HMIs, anything that can talk Modbus RTU or TCP should be fine. I haven't tested it yet but I'm pretty sure that OpenPLC's Modbus implementation will work out of the box with these PLCs on both the Serial and Ethernet ports.


OK thank you then I will for the official support and the link where to buy and will go on with this solution 
Reply 1 0
kinsa
Just a quick update, the FX3U board (or any boards with at least 20k of ram) can now act as  Modbus RTU master to multiple slaves.
Reply 1 0
Reply