Author Topic: 8-channel led controller  (Read 5553 times)

Dern

  • Sr. Member
  • ****
  • Posts: 34
    • View Profile
8-channel led controller
« on: January 26, 2008, 01:31:30 PM »
In case anybody is interested:

the attached code turns an SBC68EC into an 8-channel led controller (using PCM). It will be used to control the color of the lights in my bathroom   :mrgreen:.  The level of the channels are controlled via UDP commands from my little linux-based server (which is also used to play music in the bathroom). The next step is to get the colors to change depending on the music and to make an LCD and/or IR interface to control everything. (If you happen to know where I can find a waterproof IR remote control with a decent number of buttons please let know  :wink: )

I have no doubt:

   - the code is badly written and could be improved in lots of ways;
   - there are lots of better/cheaper(?) ways to achieve this;
   - my code contains lots of bugs

If you don't like it, don't use it   :evil:  It's the first thing I wrote for my SBC68EC so don't expect too much anyway.  As the webserver code is made available for free I think it's only fair I will give back whatever I made with it.

Note: I used MPLAB IDE 7.50 and MPLAB C18 v3.10 Student Edition.

If you find this project any useful I'll be happy to hear from you

Nico

***

Below is an excerpt of the README:

--------------------------------------------------------------------------------------------------------------------------------------------------------

This firmware is intended for the SBC68EC board made by Modtronix (http://www.modtronix.com/).
It is based on the webserver 3.0.6 source code that is freely downloadable from the Modtronix
website. This program creates 8 PCM channels with 64 levels. You can use UDP commands to
control the channels.  It's intended to be used to drive RGB leds.

PCM is totaly done in software as the PIC on the SBC68EC only has 2 channels (the SBC65EC has 5)
but I wanted at least 6 channels to control the RGB leds in my bathroom. Port B is used to
connect to the leds although port F may have been a better choice as pin B6 also connects
to the SBC's status led. This can be changed in ledcontroller.h.

Note: to keep the leds from flickering the webserver is turned off as this would steal too
many cpu cycles.  PCM is done using timer 3. There are 64 different levels available for the
leds, this is defined in minitick.h. Increasing the number of levels means more interrupts
per second which means the board may stall or you may start seeing flickering during
network communication.  You can change the number of available channels in ledcontroller.h
if you don't need 8, this may improve performance and may allow you to raise the number
of levels.

Features:

  - UDP server: allowing you to control the RGB levels via the network. Every command is
confirmed
  - timer
  - serial debugging using mxdebug.xml

UDP commands

Channel modes

  0-7   copy channel 0-7
  F     randomize channel (not yet implemented, need to figure out how to get a random
        number on a pic)

UDP commands:  multiple commands can be separated by '&', answers will also be separated by '&'

  '?cx'   return value of channel X
                returns: xx   hex representation of value
  '?mx'   return mode of channel X
                returns: x    hex representation of mode
  '?x'    return max channel number
  '?e'    enabled?

  'cx=yy' set channel x value to 0xYY (HEX), max value = MINITICKS_PER_CYCLE=64 (0x40)
  'mx=0y'  set channel x mode to 0x0Y (HEX)

  '0'   turn all channels off
  '1'    turn all channels on (smooth transition to original values)

----------------------------------------------------------------------------------------------------------------------------------------------------------


D.Drody

  • Full Member
  • ***
  • Posts: 10
  • [url=http://tierussianwoman.w-ru.com/]russian bikini bride[/url]
    • View Profile
    • russia marriage dating
8 channel led controller
« Reply #1 on: October 23, 2009, 07:31:42 AM »
Greeting Sonsivri,

This is a PICBASIC-PRO Program that I wrote to control my pool lights.  I have hundreds of RED, White and BLUE LED's around the edge of the pool, and this controller - through three N-CHannel MOSFET's handles the 'blending' of the three colors in different patterns.

I use a 20Mhz Crystal, but you could easily use anything from about 4-20Mhz.  All three PWM Channels are used on the F767 for blending the colors.  True 10-Bit PWM Control is implemented rather than the 0-255 scheme that PICBASIC natively uses.

Interrupts are used which keep the fading of the colors VERY constant.

The entire fade can be shifted through 8 levels of brightness.

Here's the code
Code:

ConradDennis

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: 8-channel led controller
« Reply #2 on: July 29, 2013, 02:17:26 AM »
In case anybody is interested:

the attached code turns an SBC68EC into an 8-channel led controller (using PCM). It will be used to control the color of the led light in my bathroom   :mrgreen:.  The level of the channels are controlled via UDP commands from my little linux-based server (which is also used to play music in the bathroom). The next step is to get the colors to change depending on the music and to make an LCD and/or IR interface to control everything. (If you happen to know where I can find a waterproof IR remote control with a decent number of buttons please let know  :wink: )

I have no doubt:

   - the code is badly written and could be improved in lots of ways;
   - there are lots of better/cheaper(?) ways to achieve this;
   - my code contains lots of bugs

If you don't like it, don't use it   :evil:  It's the first thing I wrote for my SBC68EC so don't expect too much anyway.  As the webserver code is made available for free I think it's only fair I will give back whatever I made with it.

Note: I used MPLAB IDE 7.50 and MPLAB C18 v3.10 Student Edition.

If you find this project any useful I'll be happy to hear from you

Nico

***

Below is an excerpt of the README:

--------------------------------------------------------------------------------------------------------------------------------------------------------

This firmware is intended for the SBC68EC board made by Modtronix (http://www.modtronix.com/).
It is based on the webserver 3.0.6 source code that is freely downloadable from the Modtronix
website. This program creates 8 PCM channels with 64 levels. You can use UDP commands to
control the channels.  It's intended to be used to drive RGB leds.

PCM is totaly done in software as the PIC on the SBC68EC only has 2 channels (the SBC65EC has 5)
but I wanted at least 6 channels to control the RGB leds in my bathroom. Port B is used to
connect to the leds although port F may have been a better choice as pin B6 also connects
to the SBC's status led. This can be changed in ledcontroller.h.

Note: to keep the leds from flickering the webserver is turned off as this would steal too
many cpu cycles.  PCM is done using timer 3. There are 64 different levels available for the
leds, this is defined in minitick.h. Increasing the number of levels means more interrupts
per second which means the board may stall or you may start seeing flickering during
network communication.  You can change the number of available channels in ledcontroller.h
if you don't need 8, this may improve performance and may allow you to raise the number
of levels.

Features:

  - UDP server: allowing you to control the RGB levels via the network. Every command is
confirmed
  - timer
  - serial debugging using mxdebug.xml

UDP commands

Channel modes

  0-7   copy channel 0-7
  F     randomize channel (not yet implemented, need to figure out how to get a random
        number on a pic)

UDP commands:  multiple commands can be separated by '&', answers will also be separated by '&'

  '?cx'   return value of channel X
                returns: xx   hex representation of value
  '?mx'   return mode of channel X
                returns: x    hex representation of mode
  '?x'    return max channel number
  '?e'    enabled?

  'cx=yy' set channel x value to 0xYY (HEX), max value = MINITICKS_PER_CYCLE=64 (0x40)
  'mx=0y'  set channel x mode to 0x0Y (HEX)

  '0'   turn all channels off
  '1'    turn all channels on (smooth transition to original values)


----------------------------------------------------------------------------------------------------------------------------------------------------------

hello friend I know thread is very old but can you provide the exact codes of controller.. I am trying hard to search these codes so can you help me?Please reply thanks in advance:)
« Last Edit: July 30, 2013, 08:49:15 AM by ConradDennis »