Maiza
Is there any way to expand the Arduino UNO inputs and outputs from OpenPLC without using another Arduino UNO as a slave? It can be done with the expansion integrated circuit: 74HC595. I want to make a didactic kit and for that I need more digital and analog inputs and outputs available from OpenPLC.
[203128%2F8991119%2Fmceclip0]
Reply 0 0
filou
There is an easy way to create a new variant in the OpenPLC Editor. The procedure is similar to that described in my tutorial. https://openplc.discussion.community/post/add-a-new-arduino-platform-13477511.
 
In this case, however, the platform is not changed, but the source code:
 
"Arduino Uno SPI IO": {
        "platform": "arduino:avr:uno",
   "source": "uno_leonardo_nano_micro_zero_spi_io.cpp",
        "version": "1.8.6",
        "last_update": 0,
        "core": "arduino:avr",
        "default_din": "2, 3, 4, 5, 6",
        "default_ain": "A0, A1, A2, A3, A4, A5",
        "default_dout": "7, 8, 12, 13",
        "default_aout": "9, 10, 11",
        "user_din": "2, 3, 4, 5, 6",
        "user_ain": "A0, A1, A2, A3, A4, A5",
        "user_dout": "7, 8, 12, 13",
        "user_aout": "9, 10, 11"
      },
 
Simply copy the old code and give it a new name, then everything should work as before. Now the code can be expanded step by step.
Restart OpenPLC Editor and select the new target.
 
 
 
 
Reply 0 0
thiagoralves
This is one alternative. The other, perhaps simpler but less permanent, is to use Arduino Extension. You can create an Arduino Extension on your project (clicking on the grey plus icon on the project tree) and then write the sketch code to interface your 74HC595. Then you can use shared variables between the Arduino Extension and your PLC project to "read" or "write" to your expansion interface.
Reply 0 0
saifudaullah
This is one alternative. The other, perhaps simpler but less permanent, is to use Arduino Extension. You can create an Arduino Extension on your project (clicking on the grey plus icon on the project tree) and then write the sketch code to interface your 74HC595. Then you can use shared variables between the Arduino Extension and your PLC project to "read" or "write" to your expansion interface.
Hi Thiago. I would like to get your input on expanding digital output of my arduino uno. My arduino uno is connected to raspberry pi as modbus slave. in my arduino blank project, i set pin 7,8,9,10,11,12 as digital output, and pin 13 as analog output. when I add arduino as modbus slave in web interface, i'm unable to change the configuration of coils size to 6 (default size 4, uneditable).

My questions are:
1) will arduino automatically serve coils at %XQ100.0 until %XQ100.5 (default is %XQ100.0 - 100.3)?
2) do we need to modify anything at raspberry pi side?
 
my runtime is v3.
Reply 0 0
saifudaullah
The issue is solved. I just need to stop and start the runtime, and everything works. Silly me 😅
Reply 0 0
thiagoralves
If you use your own custom IO layout on Arduino, you should pick “Generic RTU” profile on v3 runtime instead of the plain “Arduino Uno, etc” profile. The Generic RTU allows you to define which layout of coils, registers you want
Reply 0 0
wesley
Another way to expand I/O is by using I2C with an Arduino extension. I have a board that increases I/O points in this manner. https://youtu.be/5MImxgPWaxU
Reply 0 0
Reply