Jump to content

Orange Pi Zero, Python GPIO Library


Rafał Wolak

Recommended Posts

7 hours ago, jdugat said:

Looks like PA17 is not being used.

No, this lists used (claimed) GPIOs, though even this is not a complete list - some pins not listed there will be claimed in non-GPIO modes.

 

7 hours ago, jdugat said:

I guess my next step to is figure out which connector. its assigned to.

Board schematic is usually the best way to map pin headers to SoC pins, though for many boards there are existing maps in form of pictures or tables, i.e. this for Orange Pi Zero.

Link to comment
Share on other sites

okay...I wasn't clear on the GPIO-17 and PA17 naming conventions. So GPIO-19 will be a better starting point for me to test with.  In that case I'm going to assume that the connector.gpiolp19 would be GPIO-19?

Link to comment
Share on other sites

I was looking at one of the examples,  and the connector for GPIO40 was. connector.gpio1p40, so I assumed (I know a major screw up) that's how they were mapped.  I'm guessing by your reply that is not the case.  Here's the code I was looking through for ideas.

 

 

import os
import sys
if not os.getegid() == 0:
    sys.exit('Script must be run as root')

from time import sleep
from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector
__author__ = "Stefan Mavrodiev"
__copyright__ = "Copyright 2014, Olimex LTD"
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "support@olimex.com"

button = connector.gpio1p40 
gpio.init()
gpio.setcfg(led, gpio.OUTPUT)
try:
    print ("Press CTRL+C to exit")
    while True:
        gpio.output(led, 1)
        print "led set 1 \r\n"
        sleep(2)
        gpio.output(led, 0)
        print "led set 0 \r\n"
        sleep(2)
        """
        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)
        sleep(0.6)
        """
except KeyboardInterrupt:
    print ("Goodbye.")


 

Link to comment
Share on other sites

Since Olimex-A20-Micro and OrangePiZero doesn't have common pinout, you should not rely on connectors.

You should simply rely on the port like this :

#!/usr/bin/python

import sys, time
from pyA20.gpio import gpio
from pyA20.gpio import port

gpio.init()
gpio.setcfg(port.PA18, gpio.OUTPUT)
gpio.setcfg(port.PA19, gpio.OUTPUT)
while True:
	gpio.output(port.PA18, gpio.HIGH)
	gpio.output(port.PA19, gpio.LOW)
	time.sleep(0.25)
	gpio.output(port.PA18, gpio.LOW)
	gpio.output(port.PA19, gpio.HIGH)
	time.sleep(0.25)

 

Link to comment
Share on other sites

Hi All,

I am trying to interface LCD display JHD 204A to my Orange Pi zero. My display characters on LCD display are not consistant .

So I tried to verify the ouputs of correponding gpio pins. I suspect some problem at pin 13 on my Pi zero board(pin I used for LCD).

The pin 13 is mapped to GPIO PA02 ,I am using gpio_lib.c for my application. Following is my test code.

 

int main(){
    sunxi_gpio_init();
    sunxi_gpio_set_cfgpin(SUNXI_GPA(02), SUNXI_GPIO_OUTPUT);
    while(1) {
    sunxi_gpio_output(SUNXI_GPA(02), 1);printf(" high\n");
    sleep(1);
    sunxi_gpio_output(SUNXI_GPA(02), 0);printf("low\n");
    sleep(1);
    }
return 0;
}

 

 

My preliminary observation is as following.

I am testing the pin13 voltage with a multimeter.

I get the reading in multimeter as nearly 3 volts during "high" then it switches back to 0 volts during "low", but this is not repetitive as it need to be. Sometimes the pin stays at 3 volts for longer duration than expected. 

 

Has anyone found similar problem with the GPIO pins while using gpio_lib.c , any help is appriciated

 

Thanks in advance,

 

 

 

 

 

 

Link to comment
Share on other sites

4 hours ago, blprasad said:

Hi All,

I am trying to interface LCD display JHD 204A to my Orange Pi zero. My display characters on LCD display are not consistant .

So I tried to verify the ouputs of correponding gpio pins. I suspect some problem at pin 13 on my Pi zero board(pin I used for LCD).

The pin 13 is mapped to GPIO PA02 ,I am using gpio_lib.c for my application. Following is my test code.

 

int main(){
    sunxi_gpio_init();
    sunxi_gpio_set_cfgpin(SUNXI_GPA(02), SUNXI_GPIO_OUTPUT);
    while(1) {
    sunxi_gpio_output(SUNXI_GPA(02), 1);printf(" high\n");
    sleep(1);
    sunxi_gpio_output(SUNXI_GPA(02), 0);printf("low\n");
    sleep(1);
    }
return 0;
}

 

 

My preliminary observation is as following.

I am testing the pin13 voltage with a multimeter.

I get the reading in multimeter as nearly 3 volts during "high" then it switches back to 0 volts during "low", but this is not repetitive as it need to be. Sometimes the pin stays at 3 volts for longer duration than expected. 

 

Has anyone found similar problem with the GPIO pins while using gpio_lib.c , any help is appriciated

 

Thanks in advance,

 

 

 

 

 

 

You don't say much about the mechanics of your interfacing, are you pulling the GPIO to a known level with a resistor, or just letting it float around aimlessly, hoping that the software will be enough? The LCD will not provide enough load to provide this service.

A 10k resistor between the pin and vcc or gnd will maybe cure your problem.

Link to comment
Share on other sites

16 hours ago, billybangleballs said:

You don't say much about the mechanics of your interfacing, are you pulling the GPIO to a known level with a resistor, or just letting it float around aimlessly, hoping that the software will be enough? The LCD will not provide enough load to provide this service.

A 10k resistor between the pin and vcc or gnd will maybe cure your problem.

 

I am using Pi GPIOs to drive  the data lines of  of LCD  , the following are the details how am I using the GPIOs.


#define _RS   SUNXI_GPA(12)
#define _RW   SUNXI_GPA(16)
#define _E     SUNXI_GPA(11)
#define _D4   SUNXI_GPA(01)
#define _D5   SUNXI_GPA(02)
#define _D6   SUNXI_GPA(03)
#define _D7   SUNXI_GPA(15)
#define _LED  SUNXI_GPA(06)

 

I am connecting GPIO pins on PI directly to corresponding pins on LCD. I am using jumper wires directly to connect them.I am not using any resistors inbetween ,except for LED and contrast pins of LCD.

 

Finally I tried to use SUNXI_GPA(14) instead of SUNXI_GPA(02) the LCD worked as expected.Now I am getting "Hellow world " displayed on my LCD correctly.  I dont know what is going wrong with SUNXI_GPA(02).

 

The connections is are almosts same as the following picture execpt the PI board (Orange Pi zero in my case)

HD44780-LCD-Advanced-2.png.59b082968d3eb2e9bc69c4a3145ebbd3.png

 

 

Link to comment
Share on other sites

19 hours ago, blprasad said:

 

I am using Pi GPIOs to drive  the data lines of  of LCD  , the following are the details how am I using the GPIOs.


#define _RS   SUNXI_GPA(12)
#define _RW   SUNXI_GPA(16)
#define _E     SUNXI_GPA(11)
#define _D4   SUNXI_GPA(01)
#define _D5   SUNXI_GPA(02)
#define _D6   SUNXI_GPA(03)
#define _D7   SUNXI_GPA(15)
#define _LED  SUNXI_GPA(06)

 

I am connecting GPIO pins on PI directly to corresponding pins on LCD. I am using jumper wires directly to connect them.I am not using any resistors inbetween ,except for LED and contrast pins of LCD.

 

Finally I tried to use SUNXI_GPA(14) instead of SUNXI_GPA(02) the LCD worked as expected.Now I am getting "Hellow world " displayed on my LCD correctly.  I dont know what is going wrong with SUNXI_GPA(02).

 

The connections is are almosts same as the following picture execpt the PI board (Orange Pi zero in my case)

HD44780-LCD-Advanced-2.png.59b082968d3eb2e9bc69c4a3145ebbd3.png

 

 

https://raspberrypi.stackexchange.com/questions/4569/what-is-a-pull-up-resistor-what-does-it-do-and-why-is-it-needed

I don't know if a pull-up resistor will cure your issue, or whether it is something else entirely, but it was the first thing that sprang to mind when I read your original post.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines