nishizu
Hello, im trying to use openplc with an old raspberry pi b, but it is not working as expected.

I created a simple project, with just a button ( connected to %IX0.5 and ground) and a led (+ terminal connected to %QX0.4 and - terminal connected to ground). When i press the button the led should light up  but it doesnt.

The log seems fine:

OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Skipping configuration of Slave Devices (mbconfig.cfg file not found)
Issued start_modbus() command to start on port: 502
Modbus Server: Listening on port 502
Modbus Server: waiting for new client...
Issued start_dnp3() command to start on port: 20000
DNP3 ID manager: Starting thread (0)
DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000


here is the program:
Inkedopenplc.jpg   
Can someone help me understand what i'm doing wrong? Thanks a lot in advance.
Reply 0 0
thiagoralves
It is very likely that your problem is related to pin mapping. It wasn't me who wrote the old Pi driver and I don't have an old Raspberry Pi to test, but just for comparison, here is the mapping for the current Pi driver (in wiringPi pin number):

inputs = { 8, 9, 7, 0, 2, 3, 12, 13, 14, 21, 22, 23, 24, 25 }
outputs = { 15, 16, 4, 5, 6, 10, 11, 26, 27, 28, 29 }

And here is what is in the old Pi driver:

inputs = { 7, 0, 2, 3, 12, 13, 14 };
outputs = { 4, 5, 6, 10, 11 };
Reply 0 0
kriss
exactly the same problem, just six years later and a newbie to OpenPLC...
can't understand which file I shall modify to make things work
thx in advance
Reply 0 0
thiagoralves
Most likely your problem is different. What exactly is the model of your Pi?
Reply 0 0
fg71
Do you like me to do a pull request (I have never done it before) to update the OpenPLC_v3 to the latest WiringPi ??
That also include I will update the compile_program.sh and hardware layer for raspberry pi.
Reply 0 0
thiagoralves
Do you like me to do a pull request (I have never done it before) to update the OpenPLC_v3 to the latest WiringPi ??
That also include I will update the compile_program.sh and hardware layer for raspberry pi.
Yes please! Making a PR is quite simple. If you have a Github account, all you need to do is fork OpenPLC_v3 (which will create a copy of it in your account). Then you clone it in your raspberry pi, make the changes, make sure it works, then commit your changes back. This will make your version different than mine. Then Github will give you a button to open a Pull Request to merge your changes back to mine.
Reply 0 0
fg71
I will give it a try, before I do that I need to solve other issue I'm doing a backup of my main Raspberry Pi OS.
I had a problem with kernel update from Raspberry Pi and after that I couldn't login. I was able to use USB stick and mount the sd-card to backup my settings.
 
But I hope I will be able to make it this week.
Reply 1 0
kriss
The Pi should be the old model B (in the pic).
 
20250318_044102.jpg

Compilation goes well (the LD the same as the orignal post by nishizu, only the variables differ):
 
Generating C files...
POUS.c
POUS.h
LOCATED_VARIABLES.h
VARIABLES.csv
Config0.c
Config0.h
Res0.c
Moving Files...
Compiling for Raspberry Pi
Generating object files...
Generating glueVars...
varName: __IX0_3 varType: BOOL
varName: __QX0_2 varType: BOOL
Compiling main program...
Compilation finished successfully!
 
Can't understand much of the runtime logs, but the interface says "Running":
 
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Skipping configuration of Slave Devices (mbconfig.cfg file not found)
Persistent Storage is empty
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
Issued stop_dnp3() command
Issued start_enip() command to start on port: 44818
Server: Listening on port 44818
Server: waiting for new client...
Issued stop_pstorage()
 
When clicking the button, the current flows correctly to pin 11 (sixth pin, first column) which should correspond to IX0.3 as for:
 
 
Still the "Monitoring" page of the runtime does not change, neither for the input, nor for the output. That's why I thought that maybe the pin mapping was wrong...
Reply 0 0
fg71
The default or current OpenPLC_v3 hardware layer if you download it from @thiagoralves github page use pigpio.
This implementation use BCM (prefix for Broadcom) GPIO pin number.
 
ex.
 
The physical pin 16 (row 8, column 2) is GPIO/BCM 23 for pigpio and is pin 4 for WiringPi
 
In other words there is 3 different types of configuration for Raspberry Pi. Some libraries allow the user to choose when you initialize a object.
 
Good site to use if you do not know
 
If you ask me I prefer the physical pin mode same as Arduino boards and that is the same for most commercial PLC.
Its label on the hardware show a number and that is the number to use. Raspberry Pi do not include it so you need to
count or use other option to knonw.
 
ex. Green pin = is the pin that could be used for GPIO
 
[203128%2F9241112%2Fmceclip0]
Reply 0 0
kriss
> The default or current OpenPLC_v3 hardware layer ... pigpio.
Trying to backtrack the various trial-and-errors I've been doing the past week... however, for sure I changed "pigpio" into "wiringPi" in file compile_program.sh (as suggested somewhere in the forum) but do not remember whether I did something else (such as, as the file name suggests, compiling anything).
Is there a way to ascertain which configuration is currently working?
I suppose that would be a good starting point.
Reply 0 0
thiagoralves
On the hardware tab, instead of picking the Raspberry Pi driver, pick the Raspberry Pi - Old Model. If you've enabled WiringPi, this will probably make it work correctly.
Reply 0 0
kriss
unfortunately that's not the problem: the hardware has been correct since the beginning and WiringPi is working:
 
gpio version: 3.14
Copyright (c) 2012-2025 Gordon Henderson and contributors
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Hardware details:
Type: Model B, Revision: 02, Memory: 512MB, Maker: Sony UK
System details:
* Device tree present.
Model: Raspberry Pi Model B Rev 2
* Supports full user-level GPIO access via memory.
* Supports basic user-level GPIO access via /dev/gpiomem.
* Supports basic user-level GPIO access via /dev/gpiochip (slow).
 
I will keep on trying...
Reply 0 0
kriss
I exhaustively instantiated input and output variables and checked which ones were activated by button(s). Turns out that:
 
pins 11 and 13 correspond to variables %IX0.1 and %IX0.2
variable %IX0.0 corresponds to either pin 1 or 3 (as it is on by default)
pin 16 corresponds to variable %QX1.0
 
Does this shed some light on the pin mapping I should rely on for future LD diagrams?
Reply 0 0
Reply