lcostello
Hi all!

I'm working through getting OpenPLC running on a Raspberry Pi 4 B V1.2 with 4gb RAM.

This thread is a bit of a follow-up of this one: https://openplc.discussion.community/post/openplc-on-raspberry-pi-no-control-of-gpio-pins-10358436?highlight=raspberry+pi+4&trail=15
but I wanted to detail some of the testing I've done.

One import note: I did have to update to wiring Pi version 2.52 as per the instruction in the above thread:
http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/

The problem I'm having is that several of the input pins (specifically, BCM GPIO 4, 5 and 6) seem to be pulled high. Here's a screenshot of my webserver monitoring tab:
webserver_monitoring.png 
These pins can be pulled low to ground, thus setting their value to FALSE - but given that the core hardware layer for OpenPLC Raspberry Pi sets these to pull down by default, this shouldn't be happening.

I was able to setup them after boot via the RPi.GPIO Python module, using the following code:

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(5,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(6,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)


After running this code, OpenPLC functions normally, and the aforementioned GPIO pins are able to be read by OpenPLC:
webserver_monitoring2.png 
Any thoughts on how to resolve this? My personal approach would be to simply run this Python code on startup, but I feel that's a bit dirty and would prefer a fix in the OpenPLC core code.

Thanks!
Reply 0 0
lcostello
Another note: it appears switching between pull-up and pull-down resistors using the "gpio" command line utility doesn't work;

Running the command:
gpio mode 7 down

or
gpio mode 7 up

does nothing to change the read value, regardless of if it's done before or after I execute the above Python code (after a clean reboot).
Reply 0 0
lcostello
Final update: it appears this is a result of WiringPi being deprecated. However, it looks like the problem has fixed in a WiringPi fork:
https://raspberrypi.stackexchange.com/questions/104312/setting-pull-up-pull-down-mode-doesnt-work-mostly/106737#106737

I was able to fix this using the following commands:
echo "--------------------------------------------"
echo "Uninstalling any existing WiringPi versions "
echo "--------------------------------------------"
sudo apt-get remove wiringpi -y
echo "--------------------------------------------"
echo "Cloning latest WiringPi sources from repo   "
echo "--------------------------------------------"
git clone https://github.com/WiringPi/WiringPi --branch master --single-branch wiringpi
cd wiringpi
echo "--------------------------------------------"
echo "Building and installing WiringPi library"
echo "--------------------------------------------"
sudo ./build uninstall
sudo ./build clean
sudo ./build
Reply 0 0
thiagoralves
Thanks for the detailed research and fix! Yeah, wiringpi is deprecated and it is showing it’s age now. I think it is time to look for another C gpio library
Reply 0 0
Reply