Please visit the homepage for location and information on open hours


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Raspberry Pi LED Controller Build
10-04-2013, 02:23 PM,
#10
RE: Raspberry Pi LED Controller Build
Well summer is over so time to get back to LED controller, sorry for the overdue update. Here's a photo of the assembled PI board(s).

[Image: P1030427.jpg]

Well you can sort of make it all out but at the bottom is the Pi Plate which sits on top of the Raspberry Pi and connects via the GPIO. Soldered onto this is the 16 Channel Servo Drive (front of the photo) with the red, yellow and white wires coming off the pwm, 3 transistors (behind all the wires) for controlling the 12 volt RGB Lights and the Luminosity sensor (below the loop of wires).

I've been working on the python scripts to make it all functional combining a database of sunrise / set times but more on that later. Nate was helping me understand the PWM and we came across a rather fun frequency and phase control that I'd thought I'd show and try to explain since that is usually how I learn. So please correct me if I'm wrong about this concept.

We all know that you can blink an LED light by adjusting the hertz cycle (Frequency), around 25 hertz the eye can make out the on / off cycle, above that and the LED looks like it is on all time since it is blinking to fast for our eyes to detect. Well we can do this in the python script through the Adafruit_PWM_Servo_Driver with the command:

pwm.setPWMFreq(60)

Where 60 can be any Frequency of 25 hertz or more. But then we can also adjust the Phase of the Frequency so that within each cycle we are also cycling the 3 channels of lights (RGB).

pwm.setPWMFreq(25)
pwm.setPWM(2, 0, 25) #Blue Channel
pwm.setPWM(1, 2700, 2725) #Green Channel
pwm.setPWM(0, 4070, 4095) #Red Channel

We are taking each cycle of the Frequency and breaking it down into 4095 parts and then turning on each of the different colored lights at different times during each cycle. Kind of cool but unfortunately we aren't able to (at least not yet) set the Frequency below 25 to really show the individual lights turning on and off. I was able to shoot a grainy youtube video of this though and the camera FPS does pick up the effect.

[video=youtube]http://youtu.be/n6sfsuzNXj0[/video]

What you are looking at is the LEDs under a piece of paper and at first the Frequency is set to 25 hertz and a white bar runs up the video. Then the Frequency is kept the same but the phase shift turns on the line running up the video turns to red / green multiples. Yes sort of simple for ye engineers out there but interesting to a few of us. Here's the complete code:

pwm.setPWMFreq(25)
pwm.setPWM(2, 0, 25) # all lights on at the same time
pwm.setPWM(1, 0, 25) # 25 is a dim setting for the video
pwm.setPWM(0, 0, 25)
time.sleep(3)

pwm.setPWM(2, 0, -1)# all lights off
pwm.setPWM(1, 0, -1)
pwm.setPWM(0, 0, -1)

pwm.setPWM(2, 0, 25) #varying on / off times for each light
pwm.setPWM(1, 2700, 2725)
pwm.setPWM(0, 4070, 4095)
time.sleep(5)

Next time getting is all to work: combining databases, luminosity sensors, cron and some Halloween trickier to get it all to work.

John
John Woj
IdeaMakers Designs, LLC
"I'm on the the verge of something" Breaking Bad

Reply


Messages In This Thread
Raspberry Pi LED Controller Build - by IdeaMakers - 05-06-2013, 10:08 PM
Soldering - by IdeaMakers - 05-11-2013, 08:32 PM
Raspberry Pi LED Controller Build - by IdeaMakers - 05-20-2013, 07:34 PM
RE: Raspberry Pi LED Controller Build - by Pete - 05-21-2013, 08:12 AM
RE: Raspberry Pi LED Controller Build - by davidf - 05-21-2013, 06:22 PM
RE: Raspberry Pi LED Controller Build - by Pete - 05-22-2013, 07:59 AM
RE: Raspberry Pi LED Controller Build - by markspend01 - 07-31-2013, 01:28 AM
RE: Raspberry Pi LED Controller Build - by IdeaMakers - 10-04-2013, 02:23 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)