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
rtuman
I have a AMX-FX3U-26MR-E PLC along with an USB-to-RS422 programming cable, but I don't know how to send an OpenPLC program to it.  Any help would be appreciated.
Reply 0 0
William Zhang
rtuman wrote:
I have a AMX-FX3U-26MR-E PLC along with an USB-to-RS422 programming cable, but I don't know how to send an OpenPLC program to it.  Any help would be appreciated.

I am going to buy one too, we can talk about it together soon, haha
Reply 0 0
richw
Hi Guys,

Been trying to get the AMX-FX3U-26MR-E to work with Openplc as a slave, haven't had any luck but was able to blink the sysled using Arduino.
It took me awhile but I have mapped almost all the I/O. Was not able to do analog in, below are the mappings, hope you can get this working as a standalone or slave because I would really like to use this.

CPU  is STM32F103VET6

X input             Y output          Leds                           programming port             i2c2        
0 - PA5             0 - PE8            sys led - PE1               rs422                                  access on circuit board
1 - PD9             1 - PE7            run led - PE0              tx - PA9                               scl - PB10
2 - PD10           2 - PB0            com led - PC11          rx - PA10                             sda - PB11
3 - PD11           3 - PE6
4 - PD12           4 - PE5            eeprom                      rs485                                  Run switch                
5 - PD13           5 - PE4            24lc128                      uart 4                                  PB1
6 - PD14           6 - PE3            i2c1 remap                 tx - PC10
7 - PD15           7 - PE2            scl - PB8                     rx - PC11                            analog in
10 - PD0          10 - PE15         sda - PB9                                                              #1 - PC3
11 - PD1          11 - PE14                                           dac Aout                             #2 - PC4
12 - PD2                                 ethernet                      0 - PA4
13 - PD3                                 wiznet w5500 spi2                                                  
14 - PD4                                 mosi - PB15                                                             
15 - PD5                                 mios - PB14                 Boot 0                                  
16 - PD6                                 sclk - PB13                   Pin 94                                  
17 - PD7                                 ss - PB12
Reply 0 0
rtuman
@thiagoralves
OpenPLC didn't work with my FX3U-14M.  The Ladder program compiled OK but I wasn't able to upload the program to it from my PC.  I monitored the serial connection with a breakout box and saw nothing coming out of the serial port (Com3).  

I tested the FX3U-14M using Mitsubishi's trial software and everything worked.

What could be the problem? 
Please see the attached screen shot.

Reply 0 0
kinsa


Likely you have not erased the original firmware. 

These PLC's are not like the Arduino boards. You will need to enable the UART DFU mode (by shorting BOOT0 pin to gnd) if you want to upload using the existing setup. Otherwise you will need to install a custom serial bootloader if you want to use my implementation.
Reply 0 0
kinsa
kingmatrix wrote:
I use stlink in the editor to upload the program to stm32 bluepi successfully, but using the serial port will report an error without success


Are you using the Arduino code?
Reply 0 0
kinsa
You will need to flash the arduino bootloader on the bluepill before you can use the USB port for uploading. 
Reply 0 0
thiagoralves
The upload parameter is defined on the arduino-cli command line parameters. To change that just edit the hals.json file (located here: https://github.com/thiagoralves/OpenPLC_Editor/blob/master/editor/arduino/examples/Baremetal/hals.json 😉. For both blackpill and bluepill boards, the upload method is set to the default, whatever that is. For the FX3U PLC, the upload method is set to serial with the string "upload_method=serialMethod", as those PLCs only provide a direct connection to the UART. For this method you will need to place the PLC in bootloader mode to be able to upload a program.
Reply 0 0
rtuman
@thiagoralves
I tried to compile my LD program using OpenPLC for my FX3U-14MR and got a Compilation Failed! message. Can you please help?  Please see the attached screen shot.
Reply 0 0
rtuman
@thiagoralves,@kinsa
Is it possible to change the default baud rate for OpenPLC when uploading to the FX3U from 115200 to 38400? 

It seems like the FX3U will only accept 38400 when communicating through its serial port. I got the following error message when uploading:

Serial Port COM3 is successfully opened.
Port configuration: parity = even, baudrate = 115200, data-bit = 8,
stop-bit = 1.0, flow-control = off

Timeout error occured while waiting for acknowledgement.
Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again...

Done!

Thank you very much.
Reply 0 0
kinsa
see here:
https://github.com/arduino/arduino-cli/issues/305

Maybe you'll need to edit the hals.json file.
Reply 0 0
rtuman
@kinsa

I went to the hala.json file and saw the board reference to fx3u-14.cpp
"FX3U-14M / LE3U-14M": {
 "platform": "STMicroelectronics:stm32:GenF1😋num=GENERIC_F103VCTX,upload_method=serialMethod",
 "source": "fx3u-14.cpp"
 }

but I couldn't find any reference to the baud rate and serial port settings.  Please help and see the attached file (renamed with .txt extension).
Reply 0 0
kinsa
I'm not actually using the arduino-cli code for my STM32 boards.

Have a look  at this thread:

https://openplc.discussion.community/post/how-to-get-openplc-on-stm32-work-12468682?pid=1333687811
Reply 0 0
kinsa
@rtuman, Please try this one:

https://openplc.discussion.community/post/fx3u-clones-12536292
Reply 0 0
rtuman
@kinsa
Thanks for responding, but when I clicked on the link-I got:
The post you specified was not found.
Reply 0 0
Reply