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
thiagoralves
kinsa wrote:

So using Arduino as a platform is not an issue with the FX3U boards.

It shouldn't even on the WS214RS. OpenPLC uses arduino-cli and can upload a few nice (not very long though) programs to Arduino Uno boards, running on the ATmega 328P with 2KB of RAM. I know that the 328P is an 8-bit architecture, so in theory it should use less RAM for the same operation when compared to 32-bit architectures but... it works.
Reply 0 0
thiagoralves
So I've spent a few hours looking for the FX3U schematics on the web, but all I could find were sites in Chinese selling the files. So I decided to go on the tedious process of mapping every single IO to the CPU pin and its corresponding Arduino pinout. I managed to find all the mappings for the discrete IOs. Here they are:
Discrete Output (Y00 - Y05): 41, 40, 8, 0, 19, 60
Discrete Inputs (X00 - X07): 29, 30, 27, 28, 79, 26, 77, 78

Next week I will look for the analog IOs, but essentially with this mapping I can write a rudimentary OpenPLC hal file for this device and have it running all 5 IEC 61131-3 languages as opposed to the ugly and disgusting ladder dialect from GX Works.
Reply 2 0
lucianod6
hello i've been using for several years fx3-u with gx works2 it is very reliable
Reply 0 0
thiagoralves
I’m pretty sure gxworks is reliable. It is just outdated…
Reply 2 0
rtuman
Couple of questions:
  • Will the new boot loader/firmware work on FX3U's with RS422 (round) connectors?  I have a AMX-FX3U with Ethernet and it doesn't have a RS232 port.
  • Is it possible to change the default IP of the AMX-FX3U from 192.168.1.xxx to 10.0.0.xxx?
I was able to read and write to the  FX3U if I stay on the 192.168.1.xxx network.  It would fail if I change the FX3U and my PC's IP to run on 10.0.0.xxx.
Reply 0 0
kinsa
I have the AMSAMOTION's ethernet to modbus adapter, most likely they share the same hw design.

If you could take a hi-res photo of the board, front and back, we can figure out if there's a connector for the uart (PA9 and PA10).

The main advantage of OpenPLC over gxworks is extensibility, you can do whatever you want with the hardware. Changing the IP address is no big deal 😉
Reply 2 0
rtuman
Here they are:
Reply 1 0
thiagoralves
As long as that RS422 port is wired to UART1 (PA9, PA10) you should be good. You’ll need a serial cable connected to that port to be able to program the PLC. You can’t program it through Ethernet.

Talking about Ethernet, it seems from the pictures that this board is using the Wiznet chip for that, so Ethernet should work out of the box with OpenPLC as well
Reply 0 0
rtuman
Just curious about whether there is a fundamental difference between how OpenPLC handles Ethernet and the FX3U.

After I set up the FX3U using the serial cable, I was able to read/write and program it through Ethernet as long as I stay with the default 192.168.1.xxx network.
Reply 0 0
thiagoralves

This is fundamentally the difference between how OpenPLC and gxworks. Gxworks PLC programs are interpreted by the firmware that runs on the FX3U MCU (STM32). OpenPLC programs are not interpreted. They are compiled to native machine instructions and then written to the MCU’s flash memory. The advantage of interpreted programs is that you don’t have to replace the MCU’s firmware every time you upload a new PLC program, which means that it should be fine to upload programs through Ethernet. For compiled programs on the other hand, the only way possible to upload programs through Ethernet would be to make an Ethernet-capable bootloader that can rewrite the MCU’s flash from Ethernet packets. Not an easy task. Serial is easy because the STM32 itself has a native serial bootloader that does exactly that through the UART1 interface.

So, in the end, it is very unlikely that you will ever be able to program your device from OpenPLC through Ethernet.

Reply 0 0
kinsa
The uart1 pins are connected to the RS422 chip:

rs422.png 
What is the part number for this chip?

You can reflash the firmware using this port as this is full-duplex (not RS485).

The other option to reprogram this unit is to use the stlink port:

stlink.png 

There are some ethernet based bootloaders floating around but I haven't tried them yet.
Reply 0 0
rtuman
These three lines are printed on the chip:

SP490EE
200BL
B95770
Reply 0 0
kinsa
It's  a full-duplex transceiver so the serial bootloader works on that port.
Reply 0 0
kinsa
This is BOOT0:

Screenshot_20220801-072512_Bromite.jpg  And it looks like the BOOT1 pin is also connected to the RUN switch 
Reply 0 0
kinsa
U26 is indeed the RS-232 driver (SP232EEN). I checked that part pinout and found out that T2IN and R2OUT are connected to PA9 and PA10 on the STM32. So in fact the serial port is wired to UART1, which is great. Next step is figuring out how to program this thing. Perhaps the easiest way would be to burn a serial bootloader. Do you know any? The Mapple bootloader, as far as I can tell, is USB.


I've implemented an AN3155 compatible USART bootloader.

It has firmware checksum checking at startup; it switches to bootloader mode if the stored checksum doesn't match. This prevents problems in case the upload is interrupted.
Reply 0 0
Reply