Raspberry Pi GPIO

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

bertherd
Posts: 3
Joined: Sun Dec 15, 2013 4:29 pm

Raspberry Pi GPIO

Post by bertherd » Wed Jun 04, 2014 6:40 pm

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?

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1782
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Raspberry Pi GPIO

Post by [-hh] » Thu Jun 05, 2014 1:32 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 11:12 am, edited 1 time in total.
shiftLock happens

skiplondon
Posts: 16
Joined: Mon Nov 25, 2013 8:35 pm

Re: Raspberry Pi GPIO

Post by skiplondon » Sun Jun 08, 2014 3:14 pm

I am interested in this as well. I have been doing quite a bit of work lately with my RPi.
Skip Kimpel - Magicgate Software

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1782
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Raspberry Pi GPIO

Post by [-hh] » Tue Jun 10, 2014 11:43 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 11:12 am, edited 1 time in total.
shiftLock happens

hedgehao
Posts: 6
Joined: Wed Jul 09, 2014 4:59 am

Re: Raspberry Pi GPIO

Post by hedgehao » Wed Jul 09, 2014 5:06 am

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

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Raspberry Pi GPIO

Post by buchacho » Tue Jul 22, 2014 1:40 am

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.

ramav
Posts: 20
Joined: Tue Jan 06, 2009 4:56 am

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

Post by ramav » Sat Sep 13, 2014 11:31 pm

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

ramav
Posts: 20
Joined: Tue Jan 06, 2009 4:56 am

Re: Raspberry Pi GPIO tutorial and clarifications

Post by ramav » Sat Sep 13, 2014 11:37 pm

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!

mdoub
Posts: 14
Joined: Sun Jan 07, 2007 5:47 pm

Re: Raspberry Pi GPIO

Post by mdoub » Thu Oct 09, 2014 7:03 pm

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.

ramav
Posts: 20
Joined: Tue Jan 06, 2009 4:56 am

Re: Raspberry Pi GPIO

Post by ramav » Thu Oct 09, 2014 11:06 pm

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..

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1782
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Raspberry Pi GPIO

Post by [-hh] » Fri Oct 10, 2014 2:13 am

You could look into here: GPIO-library
This works perfectly. Easy to read for a LiveCoder. Could also be used via "shell".
shiftLock happens

mdoub
Posts: 14
Joined: Sun Jan 07, 2007 5:47 pm

Re: Raspberry Pi GPIO

Post by mdoub » Fri Dec 12, 2014 3:57 pm

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

sphere
Posts: 701
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth

Re: Raspberry Pi GPIO

Post by sphere » Wed Feb 14, 2018 10:07 am

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?
:D :o :) :shock: 8) :lol:

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6173
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Raspberry Pi GPIO

Post by FourthWorld » Wed Feb 14, 2018 10:11 am

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
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

sphere
Posts: 701
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth

Re: Raspberry Pi GPIO

Post by sphere » Wed Feb 14, 2018 12:49 pm

Great!,
I will check it out.
:D :o :) :shock: 8) :lol:

Post Reply

Return to “Raspberry Pi”