- How to Adjust X and Y Axis Scale in Arduino Serial Plotter (No Extra Software Needed)Posted 3 weeks ago
- Elettronici Entusiasti: Inspiring Makers at Maker Faire Rome 2024Posted 3 weeks ago
- makeITcircular 2024 content launched – Part of Maker Faire Rome 2024Posted 3 months ago
- Application For Maker Faire Rome 2024: Deadline June 20thPosted 4 months ago
- Building a 3D Digital Clock with ArduinoPosted 9 months ago
- Creating a controller for Minecraft with realistic body movements using ArduinoPosted 10 months ago
- Snowflake with ArduinoPosted 10 months ago
- Holographic Christmas TreePosted 11 months ago
- Segstick: Build Your Own Self-Balancing Vehicle in Just 2 Days with ArduinoPosted 11 months ago
- ZSWatch: An Open-Source Smartwatch Project Based on the Zephyr Operating SystemPosted 12 months ago
The perfect Remote, Programmable, Controller for interactive LED strips
Since when white light emitting high brightness LED are available, the handover from traditional lighting bulbs to the solid-state lighting has become irreversible: LEDs have an efficiency (expressed in lumens/watt) higher than that of almost all the traditional lamps (except, at the moment, the large sodium vapor lamps used for street lighting, unusable in closed environments for the high power required and the chromatic aberration they produce) at a cost that is today less prohibitive than it was a few year ago. They are indeed very sturdy and have a very acceptable ratio of luminous flux and size.
In common with the traditional lamps, at least with fluorescent and neon, white LEDs have the characteristic to be produced to emit, depending on the model, a shade of white that ranges from warm (3,000 K) to cold (over 6,000 K). For this reason, when you want to create a lighting solution with light emitting diodes, you must be careful about what you purchase, if you just take the first lamp you can end up having a lighting that is not exactly what you want.
Another problem arises if you want to achieve lighting that can change the shade of the white according to the taste or mood of the moment, or even just to suit the needs of the guests; in this case you need a system which allows to vary the shade of the light emitted. Each LED, however, is made to give a certain color temperature and cannot be changed. Anyway there is a solution: use diodes both in warm and cold white, mixing the light in varying proportions.
This is what the system described in this article does: basically a controller for two groups of white LEDs or for strips consisting of warm and cold white LEDs, driven separately (we tried with this solution) in PWM mode, so to vary the individual luminous flux of the two components and obtain a light that is a mixture of warm and cold white, with the chosen shade.
The system consists of a control circuit for LED strips with remote control receiver, remotely controlled by a radio signal in the UHF band at 433.92 MHz using a standard TX; the transmitter is amplitude-modulated with four channels; with the buttons on the transmitter you can manage the channels individually: raise and lower the brightness of the different rows of LEDs with warm and cold light.
Since the transmitter is a standard commercial model based on the UMC UM3750 IC (an evolution of the classic MM53200 with 4.096 combinations with binary 12-bit encoding) we won’t describe it; we will focus, instead, on the receiver/controller of which we will publish and describe the circuit diagram in the next paragraphs.
Receiver diagram
The controller is a combination of a hybrid Aurel AC-RX2 receiver tuned on 433.92 MHz and a PIC16F876A microcontroller programmed to act as the decoder of the code of the button pressed on the remote control. It generates two independent PWM signals and controls with them the gates of two enhancement-mode MOSFET with N-channel, which must drive the two LED strips or, more generally, groups of white LEDs. Since the transistors are configured in common-source, the circuit is suitable to drive common anode LED strips: we’ll in fact make available on the appropriate terminal the positive power supply and the MOSFET drain so that the circuit can drive the diodes bringing the cathodes to ground, with the times and manner prescribed by the PWM.
Let’s take a look at the circuit diagram: after the power-on, the Microchip microcontroller initializes its I/O and sets RC3 as input without pull-up dedicated to capture the data coming from the radio receiver U2, while. always as inputs, but with internal pull-up, sets RB2, RB3, RB4, RB5, RB6, RB7, which will be used to read the dip-switch DS1; instead RB0 is set as the output for the command of the signaling LED during procedures and RC1 and RC2 are set as the output of the PWM signal that drives the gate of the MOSFET T1 and T2.
Before proceeding, it is better specify that the output OUT1 (i.e. T1) controls the cold light LED (cold white) while OUT2 acts on the warm light ones (Warm white).
The wireless U2 receiver module is an AC-RX2 Aurel equipped with antenna signal amplifier (which gives a sensitivity of -106 dB),a superregenerative tuning stage tuned at 433.92 MHz using calibrated compensator at the factory and equipped with RF filter and amplitude demodulator; completes the module equipment, a squaring with a digital signal comparator (TTL level) coming from pin 14 and an LF amplifier of the output signal from the AM demodulator.
When pressing one of the buttons on the transmitter, the radiated RF signal reaches the receiving antenna of the module AC-RX2, which demodulates the data component and sends it to the pin 14; hence, the microcontroller takes the TTL pulse, places them in RAM and analyzes them with an appropriate firmware routine that, first of all, discerns among many signals picked up from the ether, the one that is compatible with the format of the UM3750 encoding. If so, checks if the code is one of those stored during the self-learning procedure and, if not, deletes the data from the RAM and gets ready for a new analysis.
We will later see how to match the transmitter to the circuit, by using self-learning procedure; for now it is enough to know that the firmware expects to learn all four command codes, which are increasing and decreasing the brightness of the cold light LED and increasing and decreasing the brightness of the warm light LEDs. This choice allows you to adapt the system to both encodings UM3750 (or MM53200/UM86409) and Holtek HT-12, as well as to manage the circuit by means of two different transmitters, i.e. without the constraint of being linked to a single transmitter.
Now let’s see what happens if the received signal contains one of the codes learned and retained in the working EEPROM from the PIC16F876: in this case, a routine starts to managing the signal generated by the PWM module inside the microcontroller. The signal is, after the start of the main program, characterized by a 50% duty cycle (unless you have activated the recovery function, that will be explained a few paragraphs below). If the received code is recognized and matches the button learned as UP of the OUT1 (we recommend the one in the upper left corner of the remote control – channel 2), the PWM intended to control OUT1 has one increase in the duty cycle at once, which is proportional to the pressure time; if it matches the button learned as DOWN of OUT1 (we suggest the lower left one) decreases the duty cycle of the PWM connected with channel 2. Again, if it matches the code learned as UP of OUT2 (button at the top right of the transmitter ) causes an increase of the duty cycle of the PWM that drives OUT2 and finally, if it is the code learned as DOWN of OUT2, causes a reduction of the duty cycle of the PWM of OUT2. It is understood that this is the operation in dimmer mode; if the received code lasts for less than a second (as will be explained later) you get the switching on or off of the corresponding light. The verification of the length of the code is done by the firmware.
Each output has a LED light which indicates its activity: for OUT1 is LD2 and for OUT2 is LD3; each diode has a current limiting resistor (R5 for LD2 and R6 for LD3).
BOM
R1: 1 kohm
R2: 1 kohm
R3: 4,7 kohm
R4: 470 ohm
R5: 4,7 kohm
R6: 4,7 kohm
C1: 100 nF
C2: 470 µF 35 VL
C3: 100 nF
C4: 220 µF 16 VL
C5: 100 nF
C6: 22 pF
C7: 22 pF
D1: 1N4148
LD1: Led 3 mm green
LD2: Led 3 mm green
LD3: Led 3 mm green
U1: PIC16F876A-I/P
U2: AC-RX2
U3: 7805
Q1: 4 MHz
DS1: Disp-Switch 6 vias
T1: P36N06
T2: P36N06
Specifications
- Board Power: 12/24Vdc
- Strip Power: 12/24Vdc
- Current: 2A per channel
- RF Encoding: MM53200/HT12 with self-learning
- Resume state in the event of blackout
- Functions: Dimmer, On/Off
- Handling of two common anode strips (2 channels)
Firmware PBP
'**************************************************************** '* Author : Alessandro Sottocornola * '* Date : 20/02/2014 * '* Version : 1.0 '* : * '**************************************************************** INCLUDE "modedefs.bas" '************************** D E F . R E G I S T R O ************************* DEFINE OSC 4 DEFINE PULSIN_MAX 1350 DEFINE CCP1_REG PORTC 'Hpwm 1 pin port DEFINE CCP1_BIT 2 'Hpwm 1 pin bit DEFINE CCP2_REG PORTC 'Hpwm 2 pin port DEFINE CCP2_BIT 1 'Hpwm 2 pin bit OPTION_REG.7=0 'Abilita resistenze di pull-up su portb adcon0=0 adcon1=7 '************************** D E F . P I N P I C ************************** symbol LED = PORTB.0 SYMBOL SERIALE = PORTB.7 symbol DIP1 = PORTB.2 symbol DIP2 = PORTB.3 symbol DIP3 = PORTB.4 symbol DIP4 = PORTB.5 SYMBOL DIP5 = PORTB.6 SYMBOL DIP6 = PORTB.7 SYMBOL RF = PORTC.3 SYMBOL LUCE1 = PORTC.1 SYMBOL LUCE2 = PORTC.2 INPUT DIP1 INPUT DIP2 INPUT DIP3 INPUT DIP4 INPUT DIP5 INPUT DIP6 INPUT RF OUTPUT LED OUTPUT LUCE1 OUTPUT LUCE2 '************************* D E F . V A R I A B I L I ************************ TX_MAX CON 4 'Numero di TX memorizzabili TEMPO CON 30 'Aumentarlo se in monostabile il relè va ad intermittenza TEMPO_ONOFF CON 10 'Valore che imposta il tempo massimo entro il quale non si 'gestisce il dimmer, ma solo On/Off del canale CONTA VAR WORD 'Contiene la lunghezza dell'impulso ERRORE VAR BYTE '0:Nessun errore nel segnale - 1:Segnale non valido I VAR BYTE 'Varibile di comodo per i conteggi e accessi all'array TRENO VAR WORD[25] 'Contiene la lunghezza di tutti gli impulsi COD_A VAR BYTE 'Parte alta codifica RF COD_B VAR BYTE 'Parte bassa codifica RF COD_1B var byte 'Parte alta codifica RF letta da memoria COD_2B var byte 'Parte bassa codifica RF letta da memoria TROVATO VAR BIT '1:Dato in memoria corrispondete a quello ricevuto LOC VAR BYTE 'Locazione memoria RICEVUTO VAR BIT '1: segnale RF ricevuto CH VAR BYTE 'Identifica il pulsante (1,2,3,4) premuto CH_ONOFF VAR BYTE 'Identifica il pulsante (1,2,3,4) premuto PWM1 VAR BYTE 'Valore PWM strip WW (luce calda) PWM2 VAR BYTE 'Valore PWM strip CW (luce fredda) TEMPO_RX VAR BYTE 'Tempo trascorso dall'ultima ricezione codice RF TEMPO_PASSATO VAR BYTE TEMpO_RX=0 TEMPO_PASSATO=0 CONTA=0 ERRORE=0 TROVATO=0 RICEVUTO=0 PWM1=0 PWM2=0 CH_ONOFF=0 '********************************* I N I Z I O ********************************* CLEAR eeprom 0,[0,0,0,0,0,0,0,0] eeprom 101,[0,0,255,255] low led low luce1 low luce2 SEROUT SERIALE,T9600,[13,10,"LED RF Dimmer v1.1 13/12/2013"] 'Reset singolo canale desiderato if dip1=0 or dip2=0 or dip3=0 or dip4=0 then if DIP1=0 then high led write 0,255 write 1,255 endif if DIP2=0 then high led write 2,255 write 3,255 endif if DIP3=0 then high led write 4,255 write 5,255 endif if DIP4=0 then high led write 6,255 write 7,255 endif pause 2000 endif low led 'Inizializzo facendo lampeggiare il LED for i=1 to 10 TOGGLE LED PAUSE 200 NEXT I 'Lettura EEPROM PWM uscite read 101,pwm1 read 102,pwm2 if dip5<>0 then pwm1=0 endif if dip6<>0 then pwm2=0 endif HPWM 1,pwm1,250 HPWM 2,pwm2,250 write 101,pwm1 write 102,pwm2 '*********************************** M A I N *********************************** 'Lettura lunghezza impulso "0" e successivamente lettura treno di bit ricevuti MAIN: RICEVUTO=0 gosub CONTROLLO_RF if ricevuto=1 then high led pause 5 GOSUB COMPRIMI_CODICE GOSUB CERCA_SENSORE IF TROVATO=1 THEN IF TEMPO_PASSATO>TEMPO_ONOFF THEN IF CH=1 THEN IF PWM1<>255 THEN PWM1=PWM1+1 ENDIF HPWM 1,pwm1,250 ENDIF IF CH=2 THEN IF PWM1<>0 THEN PWM1=PWM1-1 ENDIF HPWM 1,pwm1,250 ENDIF IF CH=3 THEN IF PWM2<>255 THEN PWM2=PWM2+1 ENDIF HPWM 2,pwm2,250 ENDIF IF CH=4 THEN IF PWM2<>0 THEN PWM2=PWM2-1 ENDIF HPWM 2,pwm2,250 ENDIF write 101,pwm1 write 102,pwm2 write 103,pwm1 write 104,pwm2 ELSE TEMPO_PASSATO=TEMPO_PASSATO+1 CH_ONOFF=CH ENDIF SEROUT SERIALE,T9600,[13,10,"PWM1:",#pwm1," - PWM2:",#pwm2] tempo_rx=TEMPO ENDIF else if tempo_rx>0 then tempo_rx=tempo_rx-1 endif if tempo_rx=0 then 'Funzione On/Off e non dimmer perchè è stato premuto brevemente il pulsante IF TEMPO_PASSATO>0 AND TEMPO_PASSATO<=TEMPO_ONOFF THEN high led pause 300 low led IF CH_ONOFF=1 OR CH_ONOFF=2 THEN IF PWM1=0 THEN READ 103,PWM1 HPWM 1,PWM1,250 ELSE PWM1=0 write 101,pwm1 HPWM 1,0,250 ENDIF write 101,pwm1 ENDIF IF CH_ONOFF=3 OR CH_ONOFF=4 THEN IF PWM2=0 THEN READ 104,PWM2 HPWM 2,PWM2,250 ELSE PWM2=0 write 102,pwm2 HPWM 2,0,250 ENDIF write 102,pwm2 ENDIF CH_ONOFF=0 ENDIF TEMPO_PASSATO=0 endif gosub controllo_dip endif LOW LED CH=0 GOTO MAIN '************************** C O N T R O L L O _ D I P ************************** CONTROLLO_DIP: IF DIP1=0 or dip2=0 or dip3=0 or dip4=0 THEN high led if dip1=0 then ch=1 if dip2=0 then ch=2 if dip3=0 then ch=3 if dip4=0 then ch=4 gosub CONTROLLO_RF if ricevuto=1 then GOSUB COMPRIMI_CODICE LOC=CH - 1 loc=LOC * 2 write loc,COD_A loc=loc+1 write loc,COD_B SEROUT SERIALE,T9600,[13,10,"Memorizzato canale ", #CH] low led while DIP1=0 or dip2=0 or dip3=0 or dip4=0 TOGGLE LED PAUSE 100 wend low led endif ENDIF IF DIP1=0 or dip2=0 or dip3=0 or dip4=0 THEN goto CONTROLLO_DIP endif low led IF DIP5=0 THEN CH=0 ENDIF IF DIP6=0 THEN CH=0 ENDIF RETURN '*************************** C O N T R O L L O _ R F *************************** 'Decodifica il segnale RF ricevuto CONTROLLO_RF: for i=1 to 5 PULSIN RF,0,CONTA TRENO[0]=CONTA if conta>1000 then i=100 next i SELECT CASE CONTA ' CASE IS >1350 ' RICEVUTO=0 CASE IS >1100 FOR I=1 TO 12 PULSIN RF,1,CONTA IF CONTA<20 or CONTA>85 THEN GOTO FINE ENDIF TRENO[I]=CONTA NEXT I GOSUB CODIFICA_MM53200 ' SEROUT SERIALE,T9600,[13,10] ' FOR I=0 TO 12 step 1 'Visualizzo solo il dato identificativo del codice ' SEROUT SERIALE,T9600,["-",#TRENO[I]] ' NEXT I ' CASE ELSE ' RICEVUTO=0 FINE: END SELECT RETURN '************************** C E R C A _ S E N S O R E ************************** 'Controllo tra tutti i radiocomandi se c'è quello trasmesso CERCA_SENSORE: LOC=0 TRoVATO=0 CH=0 for I=1 TO TX_MAX CH=CH+1 read LOC,COD_1B LOC=LOC+1 read LOC,COD_2B LOC=LOC+1 ' SEROUT SERIALE,T9600,[13,10,#COD_A,"/",#COD_1B,"-",#COD_B,"/",#COD_2B] IF COD_A=COD_1B AND COD_B=COD_2B THEN TROVATO=1 goto FINE_CERCA ELSE TROVATO=0 ENDIF NEXT I FINE_CERCA: RETURN '********************* C O D I F I C A _ M M 5 3 2 0 0 ************************ 'Decodifica il segnale dei sensori MM53200/HT12 CODIFICA_MM53200: ERRORE=0 FOR I=1 TO 12 ' IF TRENO[I]<=28 or TRENO[I]>=80 THEN ' ERRORE=1 ' ENDIF ' IF TRENO[I]>=40 AND TRENO[I]<=58 THEN ' ERRORE=1 ' ENDIF ' IF TRENO[I]>28 AND TRENO[I]<40 THEN ' TRENO[I]=0 ' ENDIF ' IF TRENO[I]>58 AND TRENO[I]<80 THEN ' TRENO[I]=1 ' ENDIF IF TRENO[I]<=20 or TRENO[I]>=85 THEN ERRORE=1 ENDIF IF TRENO[I]>=45 AND TRENO[I]<=50 THEN ERRORE=1 ENDIF IF TRENO[I]>20 AND TRENO[I]<45 THEN TRENO[I]=0 ENDIF IF TRENO[I]>50 AND TRENO[I]<85 THEN TRENO[I]=1 ENDIF NEXT I IF ERRORE=0 THEN RICEVUTO=1 ELSE RICEVUTO=0 ENDIF RETURN '********************** C O M P R I M I _ C O D I C E ************************* COMPRIMI_CODICE: COD_A=255 COD_B=255 COD_B.0=TRENO[1] COD_B.1=TRENO[2] COD_B.2=TRENO[3] COD_B.3=TRENO[4] COD_B.4=TRENO[5] COD_B.5=TRENO[6] COD_B.6=TRENO[7] COD_B.7=TRENO[8] COD_A.0=TRENO[9] COD_A.1=TRENO[10] COD_A.2=TRENO[11] COD_A.3=TRENO[12] RETURN
Operation
The receiver provides for the control of the two channels by a 433MHz remote control with MM53200/HT12 encoding or a compatible one. Each channel is controlled by two buttons (also of distinct transmitters), hence to manage both channels four buttons are needed, i.e. a four-channel radio control transmitter or two two-channel transmitters, one used to control the brightness of the warm light and one for the control of cold one.
For example, for channel 1 must be recorded a button for the UP function and one for the DOWN function; the same is true for the second channel. The two UP and DOWN functions allow respectively to increase and decrease the brightness.
In the case of four-channel transmitter TX3750-4CS, we recommend to assign the left buttons to the OUT1 channel and the right ones to OUT2. Furthermore, in order to make the control more intuitive, it is better that the buttons at the top left and right correspond to the UP functions and those at the bottom to DOWN functions of the respective channels. It is understood that, as the system learns separately the codes for each function of each channel, you can also chose a different order for the buttons.
With regards to the normal operation mode i.e. what you get when the first 4 DIP are set to Off, the unit controls the brightness according to the radio commands given by the TX handheld. In this case, a short press (less than one second) of the button of the remote control, either UP or DOWN, allows to turn off or turn on the respective output based on the current brightness: so if the LED strip is turned on, by pressing one of two buttons of the channel, the strip itself turns off and pressing it again, it turns on again. If you want to adjust the brightness, press and hold the button for longer than a second, the original brightness will be automatically changed step by step, until it reaches the maximum or minimum brightness.
When an RF signal belonging to the accepted coding is received, the LED LD1 will light emitting short flashes to indicate the reception.
Each output has a LED (LD2 and LD3) that follows the status of the dimmer, so it can be useful to verify operation without any LED strips connected. The red LED is connected exactly to the output, so if the lights doesn’t light the mosfet might be burnt or the LED might have a reverse polarity.
The unit provides some settings of the operating mode, accessible via a 6-way dip-switch through which you can enter in the memorization procedure or enable/disable the resume function in case of blackout for the desired channel. The correspondence between the dips and functions is explicated in table.
Dip | State | Function |
1 | ON | Recording key“Up” output OUT1 |
2 | ON | Recording button“Down” output OUT1 |
3 | ON | Recording button“Up” output OUT2 |
4 | ON | Recording button“Down” output OUT2 |
5 | ON | Function restoreactiveon output OUT1 |
6 | ON | Functionrestoreactiveon output OUT2 |
To be able to store, for example, the TX button on a remote control and link it to the increase of brightness (UP) of the output OUT1 (brightness control of warm white), you must bring DIP 1 on ON (leave the DIP2, DIP3, DIP4 on Off): at this point the green LED LD1 will light up continuously. With the LED continuously lit, press the button you want to link and release it when the green LED will begin to flash, indicating that the recording has been correctly done. Recording a code will overwrite any previously recorded code. The same procedure must be carried out for the DIP2, DIP3 and DIP4 which allows to learn the codes assigned to the keys 2, 3, 4 of the radio remote control, i.e. those you who want to associate with the remaining UP and DOWN functions.
If you want to remove a button from the memory you can do both deleting all the buttons from the memory, or just the one you want. To delete, turn off the power, then bring to ON the one of the 4 DIP switches associated with the button whose code you want to remove (or even more than a DIP together, if you want to cancel many codes at once) then give power to the board. Once the circuit is powered, the LD1 LED will remain lit for about 2 seconds to indicate the cancellation of the button from the memory; after that the device will boot normally. When the circuit will enter in the normal operation mode, you must open the dip that you closed – disconnect the power supply then reopen the dip and, after at least ten seconds, give power again to the circuit.
Note that normally, when the controller/receiver is powered in “normal power” (i.e. with the first four DIP on Off, i.e. open), the LED LD1 will emit a series of flashes to indicate that the system starting correctly.
We conclude with DIP5 and DIP6, which allow to set the resume function respectively on the first and second output; resume means that in the event of power failure, when the circuits restarts, outputs are brought back to what it was before the power failure. This function is obtained by simply saving in a special area of the EEPROM of the PIC16F876A the status of each output whenever it is changed remotely, via the transmitter of the radio control. When it turns on again, after the initialization of the I/O, the main program of the microcontroller goes to check if the EEPROM has the restoration function flag on and, if so, looks for the data regarding the settings of the duty-cycle of the PWM and then resets the duty cycle as written in the memory. If it’s not the case (no resume function) it starts with the default value of 50%.
Remember that the resume function is activated if the corresponding DIP is set to On.
Connection
Remember that to “+” and “-“ PWR you must apply power drawn by a power supply (a switching is fine, also because it has a much higher return than a linear one, whose cleanliness and qualities of the voltage supply, in this particular application, are pretty useless…) capable of delivering 12 to 24 Vcc (depending on what is the rated voltage of the LED strips you used) and a current of 4 A (or less, depending on the absorption of the LED strip used) .
The strip must be connected to the outputs OUT1 and OUT2 making sure that the common positive (it is usually the red wire) goes to the “+ “ side of the terminal between OUT1 or OUT2 and that the other two wires are connected to the “-“ of the terminal of the OUT1 and OUT 2, recalling that the one corresponding to the warm light LEDs goes on “-“ of OUT1, while that of cold light LEDs must end on OUT2. If you reverse these two wires, the buttons of the OUT1 channel will control OUT2 and vice versa.
The connection described applies to the strip used in our tests, which has three wires; but if you find one with four, i.e. with the “+” and “-“ different for the warm light and cold light LED strips of LED, connect the “+” and “-“ to the corresponding terminals, separately.
We conclude by recalling that the circuit can also control groups of LEDs put together at will in a DIY fashion. Remember, however, the available voltage (so that the power supply) and bear in mind that the voltage fall on a white LED at full brightness exceeds 4 volts. With 12 V you can lit two LEDs in series (the rest should fall on the MOSFET and on the series resistor that will be connected). Otherwise with 13 V you can turn on 3 LEDS in series (always interposing a resistance calculated on the current in the LEDs) and with 24 V you will light up 5 (with the usual series resistance).
In addition, you can also connect more than two LED strips: it depends on their absorption; the important thing is that they don’t need more than a total of 4 amps (2 A for warm white and the same for cool white).
Go buy some leds!
5 Comments