Up Squared GPIO stuck on high signal? GPIO pins not working correctly?

Options
Bart van Oort
Bart van Oort New Member Posts: 8

Hi,

I'm currently trying to control some LED strips with my Up Squared (N4200), but I cannot seem to get them working. After a lot of debugging to get to the root of the problem, I found out that the GPIO pins may be malfunctioning.

My Up Squared is running Ubuntu 16.04, my BIOS version is 1.8 and the output of uname -srv is:
Linux 4.10.0-42-generic #5000~upboard10-Ubuntu SMP Tue Dec 19 12:58:48 UTC 2017

I have a 9 jumper cables connected to (what I think are) pins 3, 5, 7, 11, 13, 15, 19, 21, and 23 as shown in the picture below. Due to debugging, none of these cables were actually attached to anything.

Using the mraa library, I was trying to execute the following code:

import mraa
import time

redPin = mraa.Gpio(19)
time.sleep(0.1)
redPin.dir(mraa.DIR_OUT)

while True:
    print("On")
    redPin.write(1)
    redPin.dir(mraa.DIR_IN)
    print("Should be 1:", redPin.read())
    redPin.dir(mraa.DIR_OUT)
    time.sleep(2)
    print("Off")
    redPin.write(0)
    redPin.dir(mraa.DIR_IN)
    print("Should be 0:", redPin.read())
    redPin.dir(mraa.DIR_OUT)
    time.sleep(2)

When I execute this code as root, I get the following output:

On
('Should be 1:', 1)
Off
('Should be 0:', 1)
On
('Should be 1:', 1)
Off
('Should be 0:', 1)
On
('Should be 1:', 1)
Off
('Should be 0:', 1)

(and so on..)

Keep in mind that the specific cable was not attached to anything. I currently don't have access to a multimeter, so I can't really check if these readings are in accordance to what is actually emitted through the cable. However, when I attach this cable to the according MOSFET in my LED powering circuitry (built following this tutorial, though with IRLB8721 MOSFETs), the LED strip does light up, but does not turn on and off like the code should make it do (or even slightly change brightness for that matter).

Seeing as I'm not inclined to believe that the printed output is expected behaviour, what could be wrong here? Might it be something in my BIOS settings (haven't checked those yet)? And / or should I update my BIOS? Am I using the wrong pins? Or is there something wrong with my Up Squared?

Comments

  • Javier Arteaga
    Javier Arteaga Emutex Posts: 163 mod
    Options

    Hi Bart,

    Sorry we didn't get to you sooner. When you call redPin.dir(mraa.DIR_IN), you're actually changing the pin settings on both the SoC and FPGA to GPIO input mode. When the pin is in input mode and left floating, you're not guaranteed to get a meaningful value (and not necessarily even the value that was last set).

    You can just remove the .dir(...) calls and still get the current pin state with .read() even if the pin is set as an output.

  • Bart van Oort
    Bart van Oort New Member Posts: 8
    edited March 2018
    Options

    Hi @Javier Arteaga, thanks for your reply! I somehow never got noticed of your reply, so I only saw it a couple weeks back, but I only had the possibility to do some more extensive debugging today. I removed the .dir(..) calls in the while loop, but the problem persists. I've also updated my BIOS to v3.3 and double-checked the BIOS settings to see if the GPIO pins I'm using are actually set up as GPIO pins, which also didn't solve anything...

    In the mean time, I've also been able to borrow a multimeter to try and measure the outputs of the pins. I attached the positive pole of the multimeter to the wire coming from the pin being turned on and off, and the negative pole to the negative pole of the power adapter that was powering my circuitry. Regardless of the sleep time I gave to time.sleep, the readings would sway between 0 and 50 mV with consistent intervals. I decided to plug a wire into pin 17 (which should be 3.3V) and measure that, but this gave the same readings. As a test to see if my multimeter was actually working correctly, I hooked the positive pole up to the positive pole of the power adapter, which read a steady 11.8V, as expected.

    Can I conclude that my GPIO pins are not working? What should I do?