Controlling the LED

Topics about the Hardware of Revolution Pi
Post Reply
lms
Posts: 6
Joined: 18 May 2017, 18:29
Answers: 0

Controlling the LED

Post by lms »

Hi,

I can't find any information how to control the LED's.
Can you give me a hint?
Timo
Posts: 44
Joined: 25 Jan 2017, 10:08
Answers: 0

Re: Controlling the LED

Post by Timo »

Hello,
if you mean the LEDs A1 and A2 on the RevPi Core, then take a look at: https://revolution.kunbus.com/tutorials ... -am-revpi/
User avatar
dirk
KUNBUS
Posts: 1924
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: Controlling the LED

Post by dirk »

Hi,
there is also a nice video tutorial available here at 6:15 it's getting hot ;)
And last but not least the LEDs of the brand new RevPi Connect are documented here.
lms
Posts: 6
Joined: 18 May 2017, 18:29
Answers: 0

Re: Controlling the LED

Post by lms »

Thank's for the answer. I will have a look at it.
I am running our on daemons on the Pi Core based on python and c code and will be controlling the LED to indicate if the unit is online or not on our trendlog.io platform.
On which address / port is the LEDs?
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

Re: Controlling the LED

Post by RevPiModIO »

If you are using Python with RevPiModIO, you can control the LEDs like:
https://revpimodio.org/en/homepage/

Code: Select all

#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""Will just flash LED A1 till SIGINT / SIGTERM."""
import revpimodio2

rpi = revpimodio2.RevPiModIO(autorefresh=True)
rpi.handlesignalend()

while not rpi.exitsignal.wait(0.5):
    rpi.core.a1green.value = not rpi.core.a1green.value

If you have just a Core/Connect which is configured via piCtory you will find the LED in Byte 6 of the process image.

Code: Select all

pi@RevPi0000:~ $ piTest -v RevPiLED
variable name: RevPiLED
       offset: 6
       length: 8
          bit: 0
Regards, Sven
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41
Answers: 1

Re: Controlling the LED

Post by volker »

@lms:
Think there is a misunderstanding: No ports, no direct addressing! On a RevPi System all IOs are operated by the kernel driver piControl, this includes the two bi-colour LEDs. You need to call this driver by opening it like a file and write to a certain offset your control byte which is setting the outputs. The kernel driver then does operate GPIOs (in case of the LEDSs) or any other system components to set or reset outputs and read inputs. The memory you are exchanging process data with is called "central process image" and is 4 KB of size. It always contains the actual state of all outputs and inputs of the overall system (including DIO or AIO modules).
If you are using C then please follow the example you find in your home/demo directory of the RevPi Core. If you are using python you may use the library Sven has pointed out to you which is wrapping the bits and bytes stuff so that it is more easy to be used.
Unser RevPi Motto: Don't just claim it - make it!
lms
Posts: 6
Joined: 18 May 2017, 18:29
Answers: 0

Re: Controlling the LED

Post by lms »

@vokler:
Thank you for the explanation. I installed a new image (Rasperian) on the RevPi Core. Can I still use the piControl driver?
User avatar
dirk
KUNBUS
Posts: 1924
Joined: 15 Dec 2016, 13:19
Answers: 4

Re: Controlling the LED

Post by dirk »

The original image from the Raspberry Pi foundation does not contain the piControl package. Also there is no real time patch applied to the kernel. You are free to use our GitHub repository to add this functionality by yourself. But it would be easier for you to use the images which are available in our shop.
terris871
Posts: 3
Joined: 03 Apr 2019, 15:00
Answers: 0

Re: Controlling the LED

Post by terris871 »

Hi,

Just went on trial and error basis trying all the GPIO ports out. Found that with python you can control the A1 and A2 leds with a small piece of code

Code: Select all

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

sleeptime = 0.2
while (True):
    #red A1
    GPIO.setup(6,GPIO.OUT)
    print "LED on"
    GPIO.output(6,GPIO.HIGH)
    time.sleep(sleeptime)
    print "LED off"
    GPIO.output(6,GPIO.LOW)
    time.sleep(sleeptime)
    
    #green A1
    GPIO.setup(30,GPIO.OUT)
    print "LED on"
    GPIO.output(30,GPIO.HIGH)
    time.sleep(sleeptime)
    print "LED off"
    GPIO.output(30,GPIO.LOW)
    time.sleep(sleeptime)
    
    #red A2
    GPIO.setup(33,GPIO.OUT)
    print "LED on"
    GPIO.output(33,GPIO.HIGH)
    time.sleep(sleeptime)
    print "LED off"
    GPIO.output(33,GPIO.LOW)
    time.sleep(sleeptime)
    
    #green A2
    GPIO.setup(32,GPIO.OUT)
    print "LED on"
    GPIO.output(32,GPIO.HIGH)
    time.sleep(sleeptime)
    print "LED off"
    GPIO.output(32,GPIO.LOW)
    time.sleep(sleeptime)
    
JewelHanda
Posts: 1
Joined: 11 Dec 2019, 17:43
Answers: 0

Re: Controlling the LED

Post by JewelHanda »

Hi...Multiplexed LEDS are indeed being switched on and off rapidly. Give the persistence of vision of your eyes you do not notice that.
Controlling and electromagnet is a different problem. Use different pins for that. You will need driver transistors, back EMF protection diodes, perhaps even opto-isolators, probably a separate power supply. Google will find hundreds of circuits an suggestions for doing that.
Post Reply