XU4 + Shifter Shield = strange voltages and wiringPi issues

Post Reply
dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

XU4 + Shifter Shield = strange voltages and wiringPi issues

Unread post by dsz123 » Sat Dec 03, 2016 5:22 am

I'm using an ODROID-XU4 plus the shifter shield and trying to use wiringPi to access the GPIO pins. I am seeing two different issues and hope someone can help.

(I installed wiringPi from https://github.com/hardkernel/wiringPi)

Issue #1:

As user odroid (not root), if I run:

Code: Select all

gpio export 174 out
gpio write 0 1
I do see a change in the voltage on the corresponding pin (note that "export" seems to require the GPIO pin number, but "write" requires the wiringPi pin number). Unfortunately, the voltage is not correct. If I have the shifter shield set to 3.3V, then the voltage for value "1" is 1.641V. If it is set to 5V, the voltage reads around 2.33V.

Issue #2:

I would like to write a C (or C++) program to access the GPIO pins (read and write). If I compile the blink.c example from wiringPi, I can run it as root and it will toggle the pin. If I change the program to use wiringPiSetupSys() instead of wiringPiSetup(), I cannot get the output voltage to change. (I do know that I need to run the "gpio export ..." command before executing the program. It still does not work.)

How can I access the GPIO pins from a C/C++ program running as user odroid (i.e. not root)?

Any advice or hints would be much appreciated!

Best,
-Dave

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Sat Dec 03, 2016 11:17 am

Refer this WiringPi example first.
http://odroid.com/dokuwiki/doku.php?id= ... ith_driver
This GPIO/WiringPi pin map must be helpful too.
http://odroid.com/dokuwiki/doku.php?id= ... ift_shield

You don't need to export GPIO if you use the WiringPi because the WiringPi access the GPIO registers directly instead of sysfs.
Something like this.
http://odroid.com/dokuwiki/doku.php?id= ... o_register

But there is no way to access the GPIO via WiringPi without root access.

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Tue Dec 06, 2016 7:13 am

Thank you for the tips. I can work with root-only access to GPIO.

Any ideas about the voltage level problem? It does seem strange that the "HIGH" voltage level would only be half of the correct voltage (1.6V instead of 3.3V and 2.3V instead of 5V).

Thanks again,
-Dave

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Tue Dec 06, 2016 12:08 pm

We couldn't reproduce the voltage issue.
How did you measure that? Wrong reference ground pin?
Can you take a picture for our review?

Did you connect any devices on the GPIO?
Since the source/sink current is less than 4mA, your load should bigger than 1Kohm.

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Wed Dec 07, 2016 8:10 am

I did not connect any devices on the GPIO, only used a multimeter (Fluke 179) to measure the voltage on the pin.

Photo #1 shows the Odroid XU4 only (no shield). The only other connection to the device is the USB-UART for console/terminal connection. When I run a wiringPi example to toggle the value of pin 0 (in the wiringPi program, it is pin 0, but on the 30 pin conenctor, it is pin 5, also called GPIO.174), I see the voltage go from 0V to 1.794V. This is expected.

Photo #2 shows the XU4 + level shifter shield, with the level shifter shield set to VCCB 5V. When I run the same wiringPi program, the voltage on the pin labeled GPIO.174 changes from 0V to about 2.3V. This seems unusual. If I change the switch on the level shifter shield to VCCB3.3V, that voltage changes to about 1.65V.

The wiringPi code is shown below:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <wiringPi.h>

#define BLINK_PIN  0

int main (void)
{

  wiringPiSetup();
  pinMode(BLINK_PIN, OUTPUT);

  for (;;)
  {
    printf ("blink\n");
    digitalWrite (BLINK_PIN, HIGH) ;    // On
    delay (1000) ;              // mS
    digitalWrite (BLINK_PIN, LOW) ;     // Off
    delay (1000) ;
  }
  return 0 ;

}
Thank you once again.
Attachments
Odroid-GPIO-With-Shield.jpg
Photo #2 - with level-shifter shield
Odroid-GPIO-Without-Shield.jpg
Photo #1 - no shield

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Wed Dec 07, 2016 12:23 pm

Thank you for the pictures.
Our hardware engineers will check it and I will get back to you.

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Thu Dec 08, 2016 2:15 am

Okay - thank you. I look forward to your reply!

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Thu Dec 08, 2016 11:03 am

We could reproduce the issue only when we changed your code "delay (1000)" to "delay (1)".
Faster toggling might generate the half voltage due to slow sampling on your DMM.
Do you have an oscilloscope to see the signal shape?

If not, measure the voltage on the Slide-Switch to doublecheck the hardware issue on your Shifter-Shield.
Refer the schematics.
http://dn.odroid.com/homebackup/XU4_SHI ... REV0.1.pdf

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Fri Dec 09, 2016 2:42 am

I understand your suggestion -- if the GPIO is toggled at a high frequency, the DMM would see only the average voltage. This is definitely not happening when I use the XU4 board only -- the voltage changes from 0V to 1.8V each second (1000ms).

I did connect an oscilloscope, and can confirm the voltage level on the GPIO pin on the shifter shield is not oscillating between 0 and 5V. Rather, it is stable at ~2.5V.

I did measure the voltage levels at the slide-switch on the shield, and can confirm they seem to be correct. One leg is 5V, the other is 3.3V.

So I think this must be a problem with the shield somehow. I will contact the vendor for a replacement.

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Fri Dec 09, 2016 8:53 am

I agree that something is wrong on your shifter-shield. :(

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Wed Dec 14, 2016 7:48 am

I received a new shield in the mail, and to my surprise, I am seeing the same issue (as described above).

Can you confirm you are able to measure the output voltage of the pin directly on the shield using a DMM?

I did try to add a simulated load, in case that was the problem. I connected the output pin (GPIO.174) to ground via a 4.7Kohm resistor. I measured a similar voltage on the high side of the resistor (2.3V instead of 5V).

I will try to re-install wiringPi, in case that is the issue. Anything else I should try? Is there something about setting the pull-up state of the pin? Is it possible the first (defective) shield somehow damaged the XU-4 board?

Thanks as always,
-Dave

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Wed Dec 14, 2016 8:58 am

Okay, I uninstalled wiringPi, deleted the source directory, and re-installed (git clone https://github.com/hardkernel/wiringPi, etc.).

Modified the blink.c example that comes with wiringPi -- I changed the delay to 100ms (instead of 500). Everything else is the same.

Here's the trace of the voltage on that pin (GPIO.174, or pin "0" in wiringPi):
Blink500.png
Blink @ 100ms intervals
(19.08 KiB) Downloaded 827 times
I am totally at a loss here. What's going on?

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Wed Dec 14, 2016 6:39 pm

@dsz123
What happens if you remove the 4.7K pull-down resistor?

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Thu Dec 15, 2016 1:24 am

You mean connect the output pin directly to ground? That sounds like it would be a short, and draw too much current...

But if I disconnect the resistor and let the output pin float, I see the same behavior as earlier -- the voltage is about half of what it should be. I will post a trace of that setup from the 'scope shortly.

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Thu Dec 15, 2016 5:05 am

This is the trace without the 4.7K resistor (connecting oscilloscope probe to ground and the output pin):
BlinkNoR.png
Scope trace, no resistor
(20.56 KiB) Downloaded 805 times
Still strange behavior.

Today, I tried to power the XU-4 from a benchtop power supply so that I could measure the current. Nominal current (after boot) was about 0.58A.

If I run my wiringPi program with no shield, and use a DMM to measure the voltage on the output pin, the voltage changes from 0V to 1.8V, and the power usage does not change.

If I use the shifter shield and run the same program, the output pin goes from 0V to 2.5V (should be 5V), and the power usage changes - instead of 0.58A, it reads 0.59 or 0.60A. (Unfortunately, I don't have a power supply with a better resolution.)

But clearly there is some problem with either the board or the shifter shield, since the output pin should only draw 4mA (0.004A). This is the SECOND board and SECOND shield I've tried. What's going on?

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Thu Dec 15, 2016 5:02 pm

Can you check the voltage on the VCCB rails of U1/U2/U3 ICs with your oscilloscope?
It must be 5Volt.
Refer Shifter-Shield schematics.
http://dn.odroid.com/homebackup/XU4_SHI ... REV0.1.pdf

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Sat Dec 17, 2016 9:16 am

Yes, the VCCB rails for each of the U1/U2/U3 ICs remains at 5V whether the output pin is high or low (measured using the DMM). I also performed this test while simultaneously measuring the output pin voltage with an oscilloscope, just in case it changed anything. But the result is the same -- the VCCB rail is always 5V. The other voltages seem okay -- VCCA is 1.8V, and OE pin also measures 1.8V

Today I tried a new experiment:

I removed the shifter shield from the XU-4 altogether. I provided 5V power and 1.8V power to the board using a benchtop supply. Then, I connected an LED and 1K resistor in series, from pin GPIO.174 to ground on the 40 pin header.

If I connect the corresponding input pin on the 30 pin header (pin number 5) to ground, the LED goes off, and the voltage on GPIO.174 is right around 0V (actually 0.035V).

If I connect that same input pin (number 5) to 1.8V, the output voltage on GPIO.174 is 2.8V, and the LED is dim. If I leave the input pin floating, the output voltage is about 2.3V, and the LED is a little dimmer.

(If I connect the LED directly to 5V, it is bright.)

I tried this experiment with several pins, at least one on each of the level shifter chips. The behavior is the same.

So there is clearly something funny going on with the level shifter, and it has nothing to do with code. The parts on the board are marked YF08E, so they seem to be correct, but this behavior does not seem correct to me.

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Sat Dec 17, 2016 9:43 am

Do I need to use a pull-up resistor on the output? Seems like the level shifter has no problem pulling output to ground, but a harder time driving the output high. Is it open-drain?

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Sun Dec 18, 2016 10:57 am

Let's check the TXS0108E specification together to learn how it switches between push-pull mode and open-drain mode.
http://www.ti.com/product/TXS0108E
I will get back to you early next week.

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Mon Dec 19, 2016 10:22 am

Okay - that sounds good, and thank you again.

It is interesting that you see a different behavior with the DMM than I do, so I wonder if perhaps there is some change in the components or a new version of the chip?

Once more, thanks for your help.

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by odroid » Tue Dec 20, 2016 11:58 am

We could reproduce the issue only when the connected cables are long.

TXS0108E output is always open-drain until the input frequency is not higher than 2Mhz.
Since this chip is a special bi-directional level shifter it does not have strong output pins that can drive LEDs or long cables.
So we needed to add transistors to drive some LEDs.
http://odroid.com/dokuwiki/doku.php?id= ... ith_driver

@dsz123,
Please measure the waveform with the oscilloscope probe on the shifter-shield directly without any jumper cable nor resistive/capacitive loads.

dsz123
Posts: 13
Joined: Sat Dec 03, 2016 5:06 am
languages_spoken: english
ODROIDs: XU4
Contact:

Re: XU4 + Shifter Shield = strange voltages and wiringPi iss

Unread post by dsz123 » Wed Dec 28, 2016 7:21 am

Hi - I wanted to say thank you again for your help, and that I have found a workaround (for me) for this issue. I will use a separate Arduino to communicate at 5V with the various devices. The communications latency between the XU4 and Arduino is not a problem in my application, and the cost is actually lower than the shifter shield. Thanks once more.

-Dave

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: Ramesh Chandra and 3 guests