Page 1 of 2

Raspberry Pi GPIO

Posted: Wed Jun 04, 2014 6:40 pm
by bertherd
I wand to be able to send inputs and out puts via the Raspberry Pi's GPIO interface pins.
Does anyone know the LiveCode script/code that I need to write?

Re: Raspberry Pi GPIO

Posted: Thu Jun 05, 2014 1:32 pm
by [-hh]
..........

Re: Raspberry Pi GPIO

Posted: Sun Jun 08, 2014 3:14 pm
by skiplondon
I am interested in this as well. I have been doing quite a bit of work lately with my RPi.

Re: Raspberry Pi GPIO

Posted: Tue Jun 10, 2014 11:43 pm
by [-hh]
..........

Re: Raspberry Pi GPIO

Posted: Wed Jul 09, 2014 5:06 am
by hedgehao
check this!

ttp://hedgehao.blogspot.tw/2014/07/livecode-raspberry-pi-light-up-led.html
(add a 'h' at the front, the forums does not allow me to post a url :(


I've wrote a prorotype using C external in livecode to control GPIO and successfully light up the LED

Re: Raspberry Pi GPIO

Posted: Tue Jul 22, 2014 1:40 am
by buchacho
hedgehao wrote:I've wrote a prorotype using C external in livecode to control GPIO and successfully light up the LED
Very nice! :D Do you have more info on making a C external and its source code? I am not at all familiar with C externals.

Re: Raspberry Pi GPIO, stack with no externals, uses file i/

Posted: Sat Sep 13, 2014 11:31 pm
by ramav
Here is the stack that I demoed at RunRevLive2014 in San Diego. Uses "file" based GPIO (every bit is a file) and needs no externals. For convenience and speed, I put all the GPIO "file" (dev) calls in shell scripts, but this is not necessary. See documentation in stack. BTW, the hardware is also bare bones, just use 10K pull up resistors and also lights up LED output in parallel. I can also directly drive a 3.3V low current relay, the problem was to source these on the web--I found some Panasonics that work well. Will document all of this when I have some more time.
stack link of course add the h ---> ttps://drive.google.com/file/d/0B6_fSXet59hJMEJ0WjZiMkFTbHc/edit?usp=sharing
pdf of scripts of course add the h ---> ttps://drive.google.com/file/d/0B6_fSXet59hJR0x3ejlVRnJlSjA/edit?usp=sharing

Re: Raspberry Pi GPIO tutorial and clarifications

Posted: Sat Sep 13, 2014 11:37 pm
by ramav
Make sure you copy the full link address in my previous post and add the h before the ttps to form the complete url, downloads from Google drive.
Clarification: The stack uses shell commands that do Unix-based file i/o. For convenience and for my particular application, I put multiple Unix file i/o commands into a single shell script, but you could control each bit by using the appropriate shell command as an individual statement line in LiveCode.
Here are the steps;
Step 1: Creata a GPIO "device" corresponding to a pin, example pin 25
put shell("echo 25 > /sys/class/gpio/export") into dummy
Step 2: Set direction (input or output) ,in this example pin 25 is set to be output
put shell("echo out > /sys/class/gpio/gpio25/direction") into dummy (if the pin were to be set as input, use echo in ...)
Step 3: Read or write as appropriate. For output pin 25, write is appropriate!!
Write a 1
put shell("echo 1 /sys/class/gpio25/value") into dummy

or to read an input, (if pin 25 was previously set as input)
put shell("cat /sys/class/gpio25/value") into pVal

If you are curious about my stack, it was scripted for a practical application of Pi in an electrochemistry laboratory where we set up the Pi and LC to act as a coulometer, i.e., a device that passes electrical current for a known time interval through a solution.
We set up a stack with four timers, each one controlled by a push button connected to a Pi input pin.
When push button is closed, timer is started and a (corresponding) output pin connected to a 3.3 V low current relay is activated. The relay in turn switches on a constant current source (LMxxx current regulator chip!)
Thus, we used four input pins for timers and four output pins connected to relays.
The script is somewhat intricate because we had to run all the timer processes in the background so we can constantly check push buttons for (continued) closure in round-robin fashion. Also, we needed high precision timers and had to figure out ways to keep processing time to the minimum. All in all, we could get 0.1 to 0.2 second precision --read docs for details!

Re: Raspberry Pi GPIO

Posted: Thu Oct 09, 2014 7:03 pm
by mdoub
Is there anything you need to do regarding permissions?

I seem to be able to do step ! successfully, but I get a folder not found error when I attempt step 2. The interesting part is that when I do this from the terminal it all seems to work fine. I am just having difficult doing it thru livecode.

PS I don't have a lot of unix experience.

Re: Raspberry Pi GPIO

Posted: Thu Oct 09, 2014 11:06 pm
by ramav
This is indeed strange. Are you logged in as a standard user with standard permissions, not guest or some restricted entity? IF so, those "commands" should work.. I'll check when I next fire up my Pi -- on the road right now... best..

Re: Raspberry Pi GPIO

Posted: Fri Oct 10, 2014 2:13 am
by [-hh]
You could look into here: GPIO-library
This works perfectly. Easy to read for a LiveCoder. Could also be used via "shell".

Re: Raspberry Pi GPIO

Posted: Fri Dec 12, 2014 3:57 pm
by mdoub
I have added some routines that will do Raspberry Pi GPIO to my MasterLibrary. There are instructions for getting around the permissions issue in the comments.

Enjoy...

https://www.dropbox.com/s/3wpwn3hfbmpl7 ... ecode?dl=0

Re: Raspberry Pi GPIO

Posted: Wed Feb 14, 2018 10:07 am
by sphere
Hi,

how easy is it nowadays to use the GPIO pins in Livecode?
I'm evaluating if it is useful to use the Raspberry 3 with Livecode, so to have a user interface and be able to use the GPIO outputs to drive a few steppermotors via their drivers.

On a previous job we used Labview for it with another interface. Could also use Flowstone but that's a dead development tool unfortunately now.
For Arduino there seems many more support to do this kind of thing and there lots of python examples to do it.
But i like Livecode, so if it is reasonable to do with LC7.0.4 (that's the only version to be able to create executable for the Rpi? right?)
The pins need to send out pulses in different speeds and lengths.

Any suggestions?

Re: Raspberry Pi GPIO

Posted: Wed Feb 14, 2018 10:11 am
by FourthWorld
The above description still works. Michael Doub's Master Library includes convenient functions for it to make it even easier.

https://www.dropbox.com/s/3wpwn3hfbmpl7 ... ecode?dl=0

Re: Raspberry Pi GPIO

Posted: Wed Feb 14, 2018 12:49 pm
by sphere
Great!,
I will check it out.