abhinaykdn1
How do we declare and initialize arrays in OpenPLC Editor and use it's values in a loop by incrementing the indices of the array in a Ladder Logic Program?
Reply 1 0
thiagoralves
You can declare arrays by selecting "Array" as the variable type on the variables list window. Once you select "Array", a new window will appear asking for the array dimension. Use the IEC 61131-3 nomenclature for array dimension. For example, if you need to declare an array with 20 positions, the dimension can be [1..20] or [2..21], etc.

To work with arrays and loops, I rather write the code in Structured Text instead of Ladder Logic. I've attached a small example that does that. This is a little program to control the level of a water tower. The level is read by a sensor that gives a lot of noise, so I created a little functionBlock to "filter" the noise by just calculating the arithmetic mean (average) of the last 20 values. You can take a look at the filtering functionBlock to see how it works.
Reply 1 0
Sumit
Hello,

I am trying to open this file (Water_Tower) in open PLC, but it is showing error that "folder doesn't contain any project"
please tell me how to open this file in open PLC

Thanks
Reply 0 0
thiagoralves
This project uses the old format. Create a new blank project, save and close it. Then replace the plc.xml file with the water tower .xml file on the download and open the project again
Reply 0 0
Sumit
Hello,

I followed the steps as you mentioned here, but it still giving error "Invalid project"
Reply 0 0
thiagoralves
Here it is
Reply 0 0
Sumit
Thanks
Reply 0 0
kortenbach
Quote:
You can declare arrays by selecting "Array" as the variable type on the variables list window. Once you select "Array", a new window will appear asking for the array dimension. Use the IEC 61131-3 nomenclature for array dimension. For example, if you need to declare an array with 20 positions, the dimension can be [1..20] or [2..21], etc.


Just a little remark on declaring array dimensions:
Actually you just need to write 1..20 or 2..21 instead of [1..20] or [2..21] otherwise you get an error message.
Reply 0 0
Hardie
Good day

I am new to OpenPLC.
When programming my Arduino UNO v3 board (with Ethernet module) I got an error :

wrong location for var __QX99_0 (pump_man Bool address %QX99.0).
I removed the 2 addresses to eliminate them and programmed the board successfully.

I will appreciate it if anybody can help me out with the following:
1) The bool addressing.
2) and how to expand the amount of registers (%QW0-%QW16) up to %QW100 or more if possible in this Water Tower example.

Thanks in advance
Hardie
Reply 0 0
jota10
I don't know if I can help, but to increase the number of registers I think you should add more electronics, due to the limitation of micro addresses, you would need multiplexers, registers or things like that.
Reply 0 0
thiagoralves
Address %QX99.0 is way beyond Arduino mappings. You can check the mappings for all boards here:  https://openplcproject.com/docs/2-4-physical-addressing/
Reply 0 0
thiagoralves
edit:
You can increase the number of available registers editing the OpenPLC runtime source code directly, but I strongly advise against it. Arduino boards (specially the Uno and other 8-bit variants) are very low on RAM. An ATMega 328P, the CPU running on the Arduino Uno, has only 2KB of RAM. This limits the amount of registers the runtime can have. If you simply increase the number of registers, you may experience crashes and instability on 8-bit micros.
Reply 0 0
Abderrahmane
Hello, I was trying to use an array as an input to a function block, the main program is in ladder, when I create the array as a variable and pull it to the program and click on the array variable connection, I get the following exception: exception_array.png
Reply 0 0
shivajik
How to store INT or REAL value in ladder programming?
Reply 0 0
thiagoralves
Use the MOVE block
Reply 0 0
Reply