enki Posted July 26, 2017 Posted July 26, 2017 What is the process to get python3 talking to the GPIO pins? I have installed the ASUS-GPIO package but it is not working. Under the tinker debian release, this h/w was working correctly, so I know this is some kind of s/w issue. Thanks!
TonyMac32 Posted July 26, 2017 Posted July 26, 2017 Let me know the uname -a output and any errors from trying to use the ASUS software.
enki Posted July 27, 2017 Author Posted July 27, 2017 Linux durango 4.11.6-rockchip #9 SMP PREEMPT Fri Jun 23 20:37:25 CEST 2017 armv7l armv7l armv7l GNU/Linux I'm not getting any errors, it is just not working. I will get out the scope tomorrow and conduct some debugging and update you. I downloaded the ASUS_GPIO instructions on the tinker board website for a python install. Was this correct?
enki Posted July 27, 2017 Author Posted July 27, 2017 Here is a code snippet of the program I am using: #!/usr/bin/python3 import ASUS.GPIO as GPIO import time relay_gpio_pin = [7,8,10,11,12,13,15,16,18,19,21,22,23,24,26,27] GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) for pin in relay_gpio_pin: GPIO.setup(pin,GPIO.OUT) GPIO.output(pin,GPIO.HIGH) # Turn relay off for pin in relay_gpio_pin: time.sleep(0.025) GPIO.output(pin,GPIO.HIGH) time.sleep(0.025) GPIO.output(pin,GPIO.LOW) The above code worked correctly running on the same Tinker Board with the Tinker OS 1.8 and 1.9. Now under the armbian it no longer works. Thinking it might be the relay board, I put some led's on the GPIO pins and manually turned in pins 7 and 11, I could never turn them off with the Python statement: GPIO.output(11,GPIO.LOW). I followed the following steps to install the python ASUS.GPIO code (as root): apt-get install python3-dev wget http://dlcdnet.asus.com/pub/ASUS/mb/Linux/Tinker_Board_2GB/GPIO_API_for_Python.zip unzip GPIO_API_for_Python.zip cd GPIO_API_for_Python/ python3 setup.py install
TonyMac32 Posted July 27, 2017 Posted July 27, 2017 I will see if I can recreate it, have you tried with the legacy kernel? There is also a nightly 4.12.3.
enki Posted July 28, 2017 Author Posted July 28, 2017 I have not tried the 4.4 of the 4.12 Kernels, would you like for me to? What is the repo for the nightly 4.12 kernel?
chwe Posted July 28, 2017 Posted July 28, 2017 There's your legacy armbian. Why not burn it to a SD-Card and try it by yourself? @TonyMac32 nor armbian gets money for the work & support which they give for the tinker board (in case of armbian you can change it by donate to the project). IMHO working with you instead of working for you is how it should work.
TonyMac32 Posted July 28, 2017 Posted July 28, 2017 https://dl.armbian.com/tinkerboard/nightly The latest nightly is 4.12
TonyMac32 Posted July 28, 2017 Posted July 28, 2017 @chwe remember how I said I was gifted a screen for experimentation? ;-). Besides, it's not such a hard thing.
zador.blood.stained Posted July 28, 2017 Posted July 28, 2017 It's just compatibility with 3rd party libraries that can't be guaranteed since it's the userspace library problem to ensure compatibility with different kernels. I presume that GPIO via the sysfs interface works the same on all kernels.
TonyMac32 Posted July 28, 2017 Posted July 28, 2017 Right, I was just making sure everyone was on the same page, especially since the 4.11 kernel is eol and the hardware support on Tinker was less than complete. (Partially the kernel's fault, partially the speed I've been able to roll out changes) I also need to take a look and make sure I didn't have https://github.com/rockchip-linux/kernel/issues/15 Going on, I never specifically looked at it, it could be the issue. Checking tonight.
enki Posted July 31, 2017 Author Posted July 31, 2017 I just noticed that the 3.3 GPIO pin is at 4.98 volts when running under the 4.11 and 4.12 kernels. When I booted under Debian 1.9 I saw 3.25 volts on the 3.3 GPIO pin. The 16 post relay board I am using wants 3.3 volts to signal the logic board as 12 volts to power the relays. Could this be the issue as to why my relays are now working correctly?
TonyMac32 Posted July 31, 2017 Posted July 31, 2017 Now that is interesting. Let me take a look. which physical pin in particular? The 3.3 volt supply? I'm getting 3.3 on all pins...
enki Posted July 31, 2017 Author Posted July 31, 2017 Pin 1, I have the Board powered via pins 2 and 6 connected to https://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=10001&freeText=323362&langId=-1&productId=323362&storeId=10001&krypto=t00e9wISx8kLs0ITwFZz%2BEDPVx%2Bh0wYoIoYT3yrNaLQW5kHl6LG0hi19%2F%2BhbvP0fR7JJpz4XlOgB6yy84xnrERG%2F1uIZgJUEC925owV8Eks%3D&ddkey=https%3AStoreCatalogDrillDownView 5 vols supply. Once booted, I tested the voltage on pin 1, which is 4.98V
TonyMac32 Posted July 31, 2017 Posted July 31, 2017 Strange, I've got a solid 3.3 on that pin. Is there anything else plugged in, and can you check the voltage on any of the other GPIO pins? They all feed from VCC33IO. [edit] Checked 4.12 and 4.13 kernels, 3.3 Volts on both.
enki Posted July 31, 2017 Author Posted July 31, 2017 The relay board was pulling the 3.3 volt line to 4.98. Disconnected the relay board and re-confirmed pin 1 is now 3.25.
martinayotte Posted July 31, 2017 Posted July 31, 2017 You're lucky that you didn't destroyed those GPIOs ... You're better use some MOSFET or other circuit to drive this relay board.
TonyMac32 Posted August 1, 2017 Posted August 1, 2017 For industrial purposes I would recommend opto-isolating quite literally everything, and having the opto-isolators in DIP sockets for easy replacement in case of fire. For power, "Ideal Diode" circuits using a FET are useful as well to prevent back-feeding. This is a general rule of thumb for me at work, it also allows level shifting without much difficulty. I have an application where I need to switch from 9 to 24 volts as part of a communication protocol to a special sensor, and the opto-isolators made it a breeze.
enki Posted August 1, 2017 Author Posted August 1, 2017 Thanks a great idea, thanks! Could you share some of the chips you are using to give me a starting point?
TonyMac32 Posted August 1, 2017 Posted August 1, 2017 http://www.vishay.com/docs/83725/4n25.pdf This series is the "garden variety", basically made by everyone. Pay attention to speeds, if you're doing high-speed communications stuff these will have a detrimental effect. Ideal diode circuits are something you can do yourself, or buy prepackaged: http://www.linear.com/product/LTC4358 They aren't the cheapest, but can keep everything happy (say you power your Tinker from the GPIO then plug in the OTG connector. The two supplies can "fight" if they aren't at the same level.)
enki Posted August 2, 2017 Author Posted August 2, 2017 Thanks, I will implement this in the design! Thanks, Dude!!
patrick-81 Posted December 12, 2017 Posted December 12, 2017 Hello, I am trying to use GPIO in c and with wiringPi. I use GPIO_API_for_c. I can't pilot pins from my current user count. I need to be root to use it. And even this is not evident when I try to use Whatever I find on the web and test, nothing seems to work. Otherwise if I do this sequence I obtain weird result: nafa@tinkerboard:~$ sudo su root@tinkerboard:/home/nafa# echo 167 > /sys/class/gpio/export root@tinkerboard:/home/nafa# echo in > /sys/class/gpio/gpio167/direction root@tinkerboard:/home/nafa# gpio readall | grep 167 | 167 | 3 | GPIO5B7 | IN | 0 | 15 || 16 | 0 | IN | GPIO5B2 | 4 | 162 | root@tinkerboard:/home/nafa# echo out > /sys/class/gpio/gpio167/direction root@tinkerboard:/home/nafa# gpio readall | grep 167 | 167 | 3 | GPIO5B7 | IN | 0 | 15 || 16 | 0 | IN | GPIO5B2 | 4 | 162 | root@tinkerboard:/home/nafa#
Larry Bank Posted December 12, 2017 Posted December 12, 2017 Try my ArmbianIO project, it provides a simple C interface for GPIO and supports the Tinkerboard: https://github.com/bitbank2/ArmbianIO
patrick-81 Posted December 12, 2017 Posted December 12, 2017 Is it usable with other user than root ?
Tido Posted December 12, 2017 Posted December 12, 2017 @patrick-81 - all your questions should get answered here, but you need to fiddle a bit to get it to work which is the fun, right ?
patrick-81 Posted December 13, 2017 Posted December 13, 2017 @Tido- I agree, tested it but got a "Problem initializing ArmbianIO library". Looks like this solution is not reliable too.
Tido Posted December 13, 2017 Posted December 13, 2017 While testing, did you run everything as root ?
patrick-81 Posted December 13, 2017 Posted December 13, 2017 Tested both root and non root, none worked.
Tido Posted December 13, 2017 Posted December 13, 2017 And you followed the guides on a fresh 4.x Kernel install ?
Recommended Posts