For my Dragon detector project I was interested in activating some kind of attached "defence" when a dragon was detected. For this I intend to use the GPIO pins, the 96Boards GPIO library only has basic functionality at the moment, digital read and write so I need to find something else. Specifically I am looking for interupt based inputs so that my IR sensor can trigger the camera to take a photo. I'm also looking to drive a servo or two.
After reading some of the blogs from 96Boards, I thought that the Intel MRAA library would work well as it supported interrupt based inputs and PWM outputs.
Shell control of GPIO
Before getting involved in libraries, I though it best to test using simple shell commands.
I ran through the example in the low speed I/O application note and found a couple of things. Firstly, and not surprisingly you need to be root to
configure the GPIO. Switching to super user made this easier. Secondly there was a mention of adding 902 to the GPIO number, I did not find this to be the case.
To enable a pin you "export" it and then configure for output. Sending 1 turns the pin on.
sudo su echo 36 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio36/direction echo 1 > /sys/class/gpio/gpio36/value
and then to turn it back off again, send a 0.
echo 0 > /sys/class/gpio/gpio36/value
Once my red LED (note that some colours of LED have a forward voltage > 1.8v so don't light up) was working correctly I thought I'd check the inputs. That's just a case of repeating the export command and reading the value. I used a jumper wire to set the input high as I did not have any switches to hand.
echo 12 > export echo in > /sys/class/gpio/gpio12/direction cat /sys/class/gpio/gpio12/value
Further investigation into libraries
When I looked into MRAA in more detail I saw that the PWM functionality was just a wrapper for existing device level functionality. A simple "ls /sys/class/pwm*" showed that there was no such function on my board.
I cross checked this by looking at the mraa_pincapabilities_t setup for the board.
So in conclusion it does not look like PWM is supported by this library/board. Looking at Libsoc the other library mentioned in 96boards blog that too uses the pwm class so that does not help either. The Libsoc library has a wrapper for I2C which I think I'll be using to connect up an I/O board which does support PWM, so I'll go for that library.
There are some notes on the 96Boards blog but those did not seem to be up to date. So I used the instructions from the libsoc github and that compiled successfully.
For my next post I'll switch into Python and hopefully get OpenCV detecting things from the webcam.
Bringing Standardization to Linux GPIO for 96Boards - 96Boards
How do you install 96BoardGPIO, libsoc and libmraa on a new image? - 96Boards
Using GPIOs on low speed connector on DragonBoard 410
DragonBoard 410C controlled RC Car
I also found this extra reference article from Qualcomm https://developer.qualcomm.com/blog/dragonboard-410c-maker-month-contest-tools-you-need