Page 1 of 1

Controlling the LED

Posted: 30 Jul 2018, 14:17
by lms
Hi,

I can't find any information how to control the LED's.
Can you give me a hint?

Re: Controlling the LED

Posted: 31 Jul 2018, 09:05
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/

Re: Controlling the LED

Posted: 31 Jul 2018, 09:32
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.

Re: Controlling the LED

Posted: 09 Aug 2018, 10:11
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?

Re: Controlling the LED

Posted: 09 Aug 2018, 12:54
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

Re: Controlling the LED

Posted: 09 Aug 2018, 15:24
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.

Re: Controlling the LED

Posted: 12 Aug 2018, 21:00
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?

Re: Controlling the LED

Posted: 13 Aug 2018, 06:48
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.

Re: Controlling the LED

Posted: 03 Apr 2019, 15:02
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)
    

Re: Controlling the LED

Posted: 11 Dec 2019, 17:53
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.