Quantcast
Channel: LED Projects - PIC Microcontroller
Viewing all 387 articles
Browse latest View live

3D Printed Microcontroller Dice Roller

$
0
0

This is a just-for-fun project I did in the Digilent MakerSpace. Usually whenever I play board games I use a dice-rolling smartphone app since dice are so easy to lose. I thought I would try making my own hardware version though. It turned out really well and was a lot of fun. In this Instructable I will go over how I designed the circuitry, wrote the code for the microcontroller, made the housing, and put it all together!

I entered this project in several contests on Instructables. If you like this project, please vote for it by clicking the “Vote!” ribbon in the top right corner.3D Printed Microcontroller Dice Roller

Step 1: Materials

Here’s a list of the parts I used for this project.

  • chipKIT uC32 Microcontroller and USB cable
    • You can also use a lot of other microcontrollers such as the Arduino Uno, or chipKIT Uno32
  • 7 green 5mm LEDs
  • Push button (approx. 6mm wide)
  • 2 zUNO clips to hold the microcontroller board
    • You can order some or even 3D print your own zUNO clips for free at the link above.
  • 3D printed housing (file below)
    • Not everyone has access to a 3D printer, but there are plenty of other options here. A thick card stock or paperboard will work perfectly. Also, if you want a 3D printed version and don’t have access to a printer, there are several companies (such as i.materialise, Sculpteo, Ponoko, and Shapeways) that will print a design for you and mail it to you.
  • For putting everything together you just need some basic tools: wire cutters, a soldering iron, and some glue (hot glue and super glue both work well).

My 3D print design can be found at this link. From this page you can order a print from one of the companies I mentioned above. Or, if you will be printing it yourself, you can download the file here too. Tinkercad will also allow you to make a copy of the file so you can make your own edits. You can make changes to the design to use a different size of LEDs or a different button. You can also make it bigger and even add text or logos!
Now onto the design. I will start by explaining the circuitry in the next step. After that, I will talk about programming the microcontroller. And last but not least, putting it all together!

Note: If you are going to be printing the housing, I would start that now as you continue through the remaining steps. Then the print will be done when you’re ready to put everything together.

Step 2: The Circuit

The circuit for this project is very simple. We just need a power and ground connection to the LEDs and a few wires going to the button. Note: the “power” to the LEDs comes from the microcontroller’s Digital I/O pins.

I included a schematic view of the uC32 so you can see how everything will eventually be connected to the board.3D Printed Microcontroller Dice Roller schematicMicrocontroller's based Password Locker schematic 3D Printed Microcontroller Dice Roller schematic

Step 3: Programming the Microcontroller

I wrote my code in MPIDE. MPIDE is completely free and can be downloaded here. Note: MPIDE can program just about any microcontroller, including all chipKIT and Arduino boards. If you’re using an Arduino board and already have Arduino’s IDE that will work just as well too.

If you’re brand new to microcontrollers and programming in an IDE, here is a quick tutorial that explains how to install MPIDE and use it to communicate with your board: Intro to MPIDE.

The code I wrote for the microcontroller can be seen below. There are three main portions to this “sketch”:

  • The roll() function which makes it look as if the die is actually rolling. This is a function I created myself and it is included in the code below.
  • Generating a random number between 1 and 6 with the rand() function. (This function is predefined in the stdlib.h header file.)
  • And a series of if statements to light up the correct LEDs based on the random value that is generated.

This code can be copied directly from the box below and pasted into your IDE. Then you can upload it directly to your board from there. If you’re unsure how to upload the sketch, check out the “Intro to MPIDE” tutorial linked above.

Note: Sorry for the very space-consuming formatting for the code. It used to display in a nice little box that you could scroll through, but Instructables made some changes to their editing interface and I’m not able to do that anymore.

 

 

For more detail: 3D Printed Microcontroller Dice Roller

The post 3D Printed Microcontroller Dice Roller appeared first on PIC Microcontroller.


The perfect Remote, Programmable, Controller for interactive LED strips

$
0
0

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.

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 perfect Remote, Programmable, Controller for interactive LED strips

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
  

The perfect Remote, Programmable, Controller for interactive LED strips schematic

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

 

 

For more detail: The perfect Remote, Programmable, Controller for interactive LED strips

The post The perfect Remote, Programmable, Controller for interactive LED strips appeared first on PIC Microcontroller.

Electronic Heart (Flashing LEDs) – Mother’s Day Project

$
0
0

Mother’s Day was approaching, and I am getting my 8 year old son started with electronics. So why not combine the two? In the next few pages we’ll show you the project we did – a blinking heart with several effects, all driven by a microcontroller. Taught my son not only about how to make mommy happy (she LOVED the present), but also about project planning, prototyping, soldering, programming, and testing. Everything a budding little engineer needs!

By the way, if you like this project you may want to check out some other electronics design instructables I did:

http://www.instructables.com/id/DPScope-Build-Your-Own-USBPC-Based-Oscilloscope/

http://www.instructables.com/id/DPScope-SE-the-simplest-real-oscilloscopelogic-/

http://www.instructables.com/id/LCS-1M-A-Full-Featured-Low-Cost-Hobby-Oscillosc/Electronic Heart (Flashing LEDs) - Mother's Day Project

Step 1: Circuit design and assembly

As this was a learning project for my son, I wanted to keep everything as simple as possible. We started out breadboarding  some fundamental circuits – hooking up the microcontroller, blinking a single LED, and so on. Then we decided about the layout of the LEDs and went scavenging for the necessary components in my lab in our basement.

As for the microcontroller, we used a Picaxe 18A (see http://www.picaxe.com for more info). Picaxes are a line of very simple-to-use microcontrollers, perfect for our task. The 18A is actually a pretty old model, but was sufficient for the task. Apart from programming them in a simple version of Basic it also offers flowchart programming – this is what we ended up using since for an 8-year old I think it is way more intuitive. Nothing better than having a visual representation of the program flow.

The circuit schematic is shown above; nothing out of the ordinary. The circuit runs off two rechargeable batteries. The currents into the LEDs are low enough that the microcontroller can drive them directly. The pushbutton shown in the actual circuit ended up not getting used so I omitted it from the schematic. The Picaxe has a bootloader installed and is programmed through a simple serial interface – two resistors and a 3.5mm stereo jack is all it needs for that.

You may notice that there are always two LEDs hooked up to each output of the microcontroller, which means they aren’t independent. This was again to limit complexity – that way all LEDs can be driven from a single port. Using a larger microcontroller with more outputs would have been possible but I wanted to avoid the code bloat that would result – I rather have a smaller program that my son can actually understand and handle. The way that the LEDs are hooked up – the LEDs of each pair are sitting at opposite ends of the heart – still allows for lots of interesting patterns.

We built up the circuit on a standard prototype board. It was the first time my son did some soldering (under very close supervision by myself to be sure), he was very excited. Above you can see the final result.Electronic Heart (Flashing LEDs) - Mother's Day Project schematic

Step 2: Enclosure

Next thing was the enclosure (box). I had found a suitable one in my drawer which even had a battery compartment. The board fit pretty tightly.

In order do drill the holes accurately we got another protoboard where we marked the location of the LEDs on the “real” board. With a needle we could punch through the two mounting holes for each position and then drill the box right between each of these two marks. This worked pretty well and we were able to fit all the LEDs through the holes.

The batteries are standard rechargeable NiMH type AA cells, held in place with a battery holder.

 

For more detail: Electronic Heart (Flashing LEDs) – Mother’s Day Project

The post Electronic Heart (Flashing LEDs) – Mother’s Day Project appeared first on PIC Microcontroller.

Trippy RGB Color Mixing NightLight

$
0
0

Project is based on A Trippy Crystal Nightlight by Charles Platt in Make magazine volume 25, see URL below for additional details. A fun and simple project to get started with PICAXE microcontrollers.

http://www. makezine.com/25/electronics

In this version an inexpensive (> $2.50) AC USB charger provides a traditional plug-in-the-wall nightlight form factor.  I removed download circuitry from the main circuit board and instead program PICAXE 08M microcontrollers on a separate breadboard  – this simplified the main circuit board.  Two 2 Jell-O snack size containers and a little bit of Saran Wrap rather than a quartz crystal diffuse the light,

Total material cost about  $15.00.  The unit has been running constantly without problems for over  six months.  Electricity usage is almost too low to measure.  Watch YouTube video below to see nightlight cycle through its color changes.

 

Step 1: Parts & Tools List

(QTY) / Description / Source / Part No.
(1) 5MM Red LED high brightness Mouser 696-SSL-LX5093XRC/4  http://www.mouser.com
(1) 5MM Green LED high brightness Mouser 696-SSL-LX5093UEGC
(1) 5MM Blue LED high brightness Mouser 696-SSL-LX5093USBC
(20 inches) solid core hook up wire 24 gauge Mouser, Radio Shack or other
(2) 20 ohm 1/4 W resistor Mouser 66-RC07GF200J
(1) 100 ohm 1/4 W resistor Mouser 588-OD101JE
(3) 100K ohm 1/4 W resistor Mouser 291-100K-RC
(1) Perf Board  Radio Shack 276-148
(1) Strip Board 1″ by 5/8″ Mouser 854-ST3U
(3) PICAXE 08M IC  http://www.phanderson.com/picaxe/
(3) 8 Pin DIP IC Socket  Radio Shack 276-1995 or other
(1) Charger USB/AC for MP3 Players – White   http://www.amazon.com/gp/product/B000A2BLEC/ref=ox_ya_os_product

 Mechanical
(2) 3.5 oz Jell-O Snack cups Supermarket
(1) Saran Wrap Supermarket
(1) 1 1/4″ by 3″ sheet metal strip Home Depot or Hardware store
(1 ft) Double side foam tape Hardware store or Radio Shack
(1) scrap piece of cardboard about 3″ dia. Supermarket

Programming Tools
(1) Solderless Breadboard Mouser, Radio Shack or other
(1) AXE029 Breadboard Adapter  http://www.phanderson.com/picaxe/
(1) AXE0AXE026 – PICAXE Serial Download Cable http://www.phanderson.com/picaxe/
OR
(1) AXE027 – PICAXE USB Download Cable http://www.phanderson.com/picaxe/
(1) PICAXE Program Editor
http://www.picaxe.com/Software/PICAXE/PICAXE-Programming-Editor/

Misc Tools
Hot glue gun
Solder and Soldering Iron
Tin Snips

Step 2: Prepare Power Supply

Preparing the Power Supply

Cut a piece of stripboard a little more than 4 traces wide and about 3/4 inches long.

Sand or file down edges so it fits tightly in USB charger socket  with the 4 Traces centered within the socket so you’re making a good connection with left side +5 VDC pin & right side ground pin. Verify that you’re getting a good connection with a multi-meter.  Secure stripboard with hot glue.

If you don’t have another 5 VDC power supply to use for programming the PICAXE ICs in the next step

then you can now solder Red (+5VDC) and Black (ground) wires to stripboard. Make wires a little long so you can use it to power the PICAXE chip on the breadboard during programming.

Otherwise you can wait until after you have built the main circuit board to solder the power supply wires.

Tape over USB Charger’s “Power On” red LED to block its light.Trippy RGB Color Mixing NightLight schematic

Step 3: Program PICAXE 08M ICs

Program PICAXE 08M Chips

Build up solderless breadboard with PICAXE O8M IC and AXE029 breadboard adapter as shown in photographs.

For additional info – see link below, and/or the PICAXE Manual 1 available from the Programming Editor Help menu.

http://www.picaxe.com/docs/axe029.pdf

Download Programming Editor from PICAXE website and install on your computer.  Connect your PC using either Serial or USB cable, and download programs to PICAXE ICs.

For additional help with programming, see the Editor’s Help menu – Manual 1is the most helpful for getting started the first time.

http://www.picaxe.com/Software/PICAXE/PICAXE-Programming-Editor/

You need to program three PICAXE chips, one for each color LED – red, green, and blue. Program code is the same for each LED except for one line of code as shown below.

Red LED: Colorinc =17
Green LED: Colorinc =23
Blue LED: Colorinc =37

This provides an offset so as to get a pleasing mix of color variations.  To make it easier, I have attached three separate programs – one for each color of LED.

 

 

For more detail: Trippy RGB Color Mixing NightLight

The post Trippy RGB Color Mixing NightLight appeared first on PIC Microcontroller.

Mädchen Machen Technik using pic-microcontroller

$
0
0

The “Mädchen Machen Technik” workshop is designed to give high school students an introduction to microcontrollers. The students will build a flashing light pattern and/or a counter-timer. In the process of building this project, the students will learn about microcontrollers and digital electronics. Here is the parts list for the projects.

Introduction to some circuit elements
  1. The students will learn how to measure DC voltage and resistance using a multi-meter. They will measure the voltage of batteries connected in series and in parallel.
  2. The students are given the task to determine, using a voltmeter and wires, how the holes on a breadboard are connected. The students sketch the hole connections on a picture of the breadboard.
  3. Next, the students will be given several Light Emitting Diodes (LEDs), with an explanation on how they work. They are to connect the LED(s) to the breadboard so that one LED lights up, then two light up, etc. Do not put more than 3 Volts across an LED.

Mädchen Machen Technik

Blinking Lights Project
As a first project on the breadboard, we will program the microcontroller to produce a blinking pattern of up to five LED’s. We will start with one of the simplest microcontrollers: PIC12F629. First, we build the circuit on the breadboard, then we will program the PIC12F629 chip.

Building the Circuit

A schematic of the circuit is shown below:

 

  • he PIC12F629 has only 8 pins. Pin 8 is the ground pin, and Pin 1 is the positive voltage pin. In our applications, we will use two AA batteries in series which will give around 3 volts for Pin 1.
  • The other six pins (2-7) will be used as digital input/output. Pins 2, 3, 5, 6, and 7 will be output pins connected to LEDs. Pin 4 can only be set as an input pin. We will not connect an LED to pin 4. In the picture below, one can see the 5 LEDs connected to the appropriate pins.

Building the Programmer
After setting up the “blinking lights project” on the breadboard, we program the chip. To program the microcontroller, we will need to constuct a programmer circuit on a bread board. Each group of three students will use the same programmer, a pickit2. The programmer circuit is shown below

he programmer has 6 pins in a row. The ground on the programmer, pin 3, is connected to the ground of the chip (pin 8). The voltage (5V) of the programmer, pin 2, is connected to pin 1 of the chip. The other programmer pins are connected to the chip as shown in the two figures below:

The pickit2 is connected to a personal computer through a usb port. In the picture below, one can see where the microcontroller chip is connected in the programmer:

Finally, we program the microcontroller using the MPlab software from microchip.

Programming the Microcontroller

Mädchen Machen Technik

  1. The assembly code we will start with is the code: test12.asm. The only lines of the code the students need to modify for their desired blinking pattern are:loop
    movlw b’00100101′
    movwf GPIO
    call delay1
    movlw b’00010010′
    movwf GPIO
    call delay1
    goto loop
  2.  

    First, the binary number ‘00100101’ is placed in the working register. Then this number in the working register is transfered into the register GPIO. The GPIO register is directly connected to the pins of the chip. A “1” will put 3 volts on a pin, and a “0” will put zero volts on the pin. The last 6 bits are connected to pins 2, 3, 4, 5, 6, and 7 respecively. The number ‘00100101’ in register GPIO will result in 3 volts for pins 2, 5, and 7, and zero volts for pins 3 and 6. Pin 4 is not affected, it is only an input pin. The subroutine delay1 causes a delay of around 1/4 second.

 

for more detail: Mädchen Machen Technik

 

The post Mädchen Machen Technik using pic-microcontroller appeared first on PIC Microcontroller.

2-Channel IR Relay Controller for PIC10F200

$
0
0

Description

This project is a 2 channel infrared (IR) remote controlled relay driver with power saving.  It works with 12-bit SIRC IR signals as used by Sony remote controls.

The controller also features a power save feature which reduces the relay holding voltage to 50% of the relays nominal operating voltage once the relay has switched on.

IR Relay Controller

The board uses Microchip’s low cost PIC10F200 microcontroller along with a handful of easy to find  components making this possibly the lowest cost remote controlled relay driver around.  Everything you need to know to build this project, including the firmware code is right here on the project page.

Don’t forget to check out the accompanying mini IR remote control which can be used with this project.

Download schematic in PDF

Circuit Description

The board requires a 12 volt DC supply input.  This is fed through diode D5 which provides protection from a reversed connection of the power supply. Capacitor C2 is used for decoupling the supply.  The 5 volt supply needed by the microcontroller U1 and the IR receiver U2 is generated using a simple zener shunt regulator comprising R6 and the 5.1 volt Zener diode D4.

The relays are switched on by microcontroller U1 via driver transistors Q1 and Q4.  These are low power NPN transistors, in this case BC547 but virtually any small NPN transistor will work here as they only need to switch around 30mA – BC548 or BC549 would also work well.  Diodes D1 and D2 provide protection for the transistors against the back EMF voltage transient when the relays are switched off.

The controller also features a power saving control which reduces the power consumption of the relays by around 50% when they are on.  Relays of the type used here typically need 75% of their nominal voltage to “pull-in”, once on they will ‘hold’ with a lower voltage.  The datasheet for the Omron G5LE for example shows a must release voltage of 10% of rated voltage – for a 12V relay that’s around 1.2V.  This circuit uses a holding voltage of around 50% or 6 Volts.

Normally the supply voltage is fed to the relay coils via zener diode D3 which drops 5.1 volts leaving around 6 volts across the relay coil. In parallel with D3 is transistor Q2.  When this transistor is switched on, it bypasses D3 and provides the full supply voltage to the relays.  This ‘boost’ voltage is switched by the microcontroller with Q2 being switched on via Q3.  The firmware in the microcontroller detects when a relay is being turned on and applies the boost for a minimum of around 100mS, again the datasheet for the relays gives typical operate time of 10mS, so the 100mS boost guarantees the relay will pull-in before the voltage is reduced.  If you find the relay used doesn’t hold fully swap D3 for a 4.7 volt zener.

LEDs 1 and 2 are connected across the relay coils to give visual indication when the relays are on and can be omitted if not required.

The circuit is controlled by U1, a PIC10F200, the smallest and cheapest PIC available from Microchip.  The IR signal is detected and demodulated by U2 a TSOP4838 IR receiver IC.  This part was chosen because it has a low supply current requirement – typically around 1.5mA – making it ideal for use with the shunt regulator.  The output from the TSOP4838 is active low, when a signal is received the output goes to 0V, when no signal is received it is pulled high by an internal pull-up resistor.  The signal is decoded using the firmware programmed into the PIC10F200.  This has been written to decode the 12-bit SIRC protocol (see download section)

I recently had an email from someone asking why I used the TSOP4838 38Khz transceiver when the Sony SIRC protocol use a 40KHz carrier. It was a good question and the answer is that I source a lot of my parts from Rapid Electronics and they only stock the TSOP4838.   In practice this part will work just fine with a 40Khz IR signal.  However, if you can get hold of the TSOP4840 (40KHz variant) by all means use it.

For more information on the SIRC infrared protocol and codes see:

If you don’t want the power save feature, replace D3 with a wire link and omit R2,R3,R5,Q2 and Q3.

 

For more detail: 2-Channel IR Relay Controller for PIC10F200

Current Project / Post can also be found using:

  • onli pic lan com

The post 2-Channel IR Relay Controller for PIC10F200 appeared first on PIC Microcontroller.

make your own wearable LED display using pic-microcontroller

$
0
0

jump to a section:supplies

about LED arrays
design
construction
customizing/programming
washing and wearing
troubleshooting and FAQ

**NOTE** As of Fall 2007, skip the ugly microcontroller programming (don’t buy the STK500 or the AVR chip)… Get a LilyPad Arduino instead. It’s much easier to sew and to program! See my LilyPad Arduino tutorial for help on getting started with the LilyPad.
make your own wearable LED display

  • conductive thread
    (You can purchase conductive thread from SparkFun. Check out my materials link page for more information on conductive threads.)
  • surface mount LEDs, as many as you want to include in your display
    (I used a super intensity red LED from digikey. part #: 67-1695-1-ND )
  • a microcontroller of your choice.
    (Chose one with an internal oscillator. I used the AVRmega16. digikey part #: ATMEGA16L-8PC-ND)
  • an IC socket for your microcontroller.
    (You want be able to sew through the socket’s holes after minimal modifications. For a 40 pin micorcontroller, digikey part #: A9440-ND will work after you drill out the holes. I found the perfect socket, one that required no drilling, browsing my local electroics store, so try that first.)
  • a battery and holder. ***As of Fall 2007, get a LilyPad power supply instead. Much easier!
    (I used a standard 6 volt camera battery. part#: A544.
    You can purchase the holder for this battery from digikey part #: 108KK-ND)
  • an on/off switch ***Not necessary if you use a LilyPad power supply
    (Check out these slide switches and toggle switches from digikey.)
  • a 30 watt soldering iron and lead-free solder
    (You’re going to wear this so keep health hazards like lead in mind!)
  • a multimeter
  • a T-square or a ruler
  • an assortment of silver and brass crimping beads, at least twice as many as you have LEDs
    (These are available from your local bead shop, or from Michaels)
  • a garment or a piece of fabric and a pattern you can use to make your own garment.
  • a needle or two, a fabric marker, and a bottle of fabric glue
    (Needles, fabric markers, and Liquid Stitch, Sew-No-More, and similar products are available at your local fabric shop or Joann Stores)
  • a pair of scissors
  • a sewing machine

about LED arrays
The naive way to power an array of LEDs would be to allocate one I/O pin of a microcontroller for each LED, tying the anode lead (+) of each LED to the microcontroller, and the cathode lead (-) to ground. This arrangement would quickly become unwieldy, requiring a chip with 100 pins to run a 10 x 10 matrix. Thankfully, we can exploit the essential property of diodes to implement a much more efficient design which will only require 20 pins to run a 10 x 10 array.

Diodes allow current to flow in only one direction. LEDs emit light when current flows through them. By exploiting this property, we can use the design shown below to power N LEDs with square root (N) microcontroller pins. As can be seen from the schematic, the LEDs are arranged in an row-column array with the anode end of each LED attached to a row and the cathode end of each LED attached to a column. Each row and each column is then attached to a microcontroller pin. The microcontroller can then be used to control each LED individually. For example, suppose we want only the LED at row0 column0 (LED R0 C0) turned on. To accomplish this, we first turn all of the LEDs off by setting all of the rows to ground and all of the columns to +5 volts, applying a reverse voltage to all of the LEDs. Then, to turn on LED R0 C0, we set R0 to +5V and C0 to ground. LED R0 C0 is the only LED with current running through it so it will emit light.

The matrix architecture allows us to control each LED individually, but does not give us complete flexibility. For example, it is impossible to simultaneously turn on only LED R0 C0 and LED R1 C1. To display complex patterns and animations, we exploit the shortcomings of human vision. To make it appear as though LED R0 C0 and LED R1 C1 are on at the same time, we quickly flash first LED R0 C0 and then LED R1 C1 and repeat this cycle for as long as we want the illusion to appear. As long as our eye can’t detect the flicker, we perceive only the diagonal line of light.

For more information on LEDs check out:
How LEDs work from Howstuffworks
LEDs from Wikipedia

Now, on with the project…

design
1. Pick a garment to sew on, a pattern that will let you sew your own garment, or design your own pattern.

2. Design your display. decide on the number of LEDs you want and their general placement. This will depend on the garment you chose and the microcontroller you intend to use as well as how you’d like the display to look. I decided to sew a simple tank top and I chose to place the LEDs evenly across my tank top every 2″. Since my tank top is approximately 28″ around and 12″ tall I needed 84 LEDs. (Note! The pictures here show a different shirt with 140 LEDs spaced 1″ apart.)

3. Decide on the microcontroller you want to use. Choose one with an internal oscillator, and make sure you have enough i/o pins to control your matrix. It’s a good idea to pick a microcontroller you are familiar with and read the data sheet carefully! It can take some reading to discover that what you thought was a general purpose I/O pin is input only or an open drain output.
make your own wearable LED display
4. Decide on the power-source you want to use.

construction
0. If you’re sewing your own garment, cut out the pieces and partially or fully assemble them.

1. Package your LEDs into sequins. Get out the crimping beads and surface mount LEDs. Tip an LED on its side. Using a soldering iron with a very clean tip, place the tip of the iron into a bead. Tin the bead with lead-free solder; melt some solder onto the outside of the bead. With the soldering iron, drag the bead up to the LED as is shown in the photo below. When the melted solder touches the LED’s contact, the bead will adhere to the LED. Lift the soldering iron out of the bead. If your soldering iron tip is dirty, it will stick to the bead and make the job very difficult. If this is happening you should clean or replace your tip. Once you get the hang of it, this should go pretty fast. You should be able to solder 100 LEDs within an hour.

You may want to take some measures at this stage to distinguish the cathode from the anode lead of each LED. The cathode end is often marked with a green line on the front or back of the surface mount package. To distinguish the two, you can solder a brass crimping bead to the cathode lead and a silver bead to the anode lead for each LED.

 

For more detail: make your own wearable LED display

The post make your own wearable LED display using pic-microcontroller appeared first on PIC Microcontroller.

7 Segment LED display with PIC controller and Flowcode V5

$
0
0

First of all, if you have any questions, feel free to comment! I’d be more than happy to answer your question as good as possible!!

Materials used :

– PIC 18F452 Microcontroller ( any PIC microcontroller with enough pins will do )

– 7 Segment common anode LED display

– 24 Mhz Crystal

– A couple resistors

– Shitloads of jumper wire

– Flowcode V5 software7 Segment LED display with PIC controller and Flowcode V5

Step 1: Making the connections

For this, you will have to check the datasheet of your display,

This is the datasheet of the display i used :

http://www.kingbrightusa.com/images/catalog/SPEC/S…

As you can see, pin 8 and 3 connect to +Vdd

and all the other pins have to go to -Vcc

You could use a resistor on every individual led, but to save time and space i used a single resistor on the common anode or cathode pin.( I used a 220R resistor but it varies )

Now, the real connections

I will list which LED segment should connect to which port :

Segment A -> PORT B0

Segment B -> PORT B1

Segment C -> PORT B2

Segment D -> PORT B3

Segment E -> PORT B4
Segment F -> PORT B5

Segment G -> PORT B6
Segment DT (if you have a dot segment ) -> PORT B7

And your common pin should go to -> PORT A3

Step 2: On to flowcode

When you created a flowcode project

The first thing you should do is add a 7 segment display module

You can do that by going to ‘Outputs’ and adding a 7seg1 module.

When you added that, check if all the connections are right by right clicking the module and choosing ‘connections’

It should look like it does on the picture.

I wont go over the program in detail, but i will post a picture of a simple program that counts from 0 to 9 and then resets.7 Segment LED display with PIC controller and Flowcode V5 schematic

Step 3: Thank you

Thank you for reading my instructables, i really appreciate it.

I hope you learned something from this and make alot cooler stuff with it than i did in this tutorial

An example for the non creative people out there would be a digital clock :p

Have a nice day but most of all

Have fun creating!

 

 

For more detail: 7 Segment LED display with PIC controller and Flowcode V5

The post 7 Segment LED display with PIC controller and Flowcode V5 appeared first on PIC Microcontroller.


Expanding the number of I/O lines using Microchip MCP23008 using pic microcontoller

$
0
0
A microcontroller comes with a limited number of general purpose input and output (GPIO) ports. However, some applications may require more ports than are available on the microcontroller. In such a case, GPIO expanders can be used to increase the I/O capability of the microcontroller. MCP23008 is one such device (manufactured by Microchip Technology) which provides an easy I/O expansion using 2-wire serial interface. This tutorial illustrates how to add an extra 8-bit I/O port to PIC12683 microcontroller (which has only 6 I/O pins) using MCP23008. A seven segment LED display and a tact switch will be connected to the extended port. The PIC12F683 microcontroller will count the switch presses and display the counter value on the seven segment LED  module.
Expanding the number of I O lines using Microchip MCP23008.jpgTheory

The MCP23008 an I2C slave device that provides 8-bit, general purpose, bi-directional I/O expansion for I2C bus. If you are not familiarized with I2C protocol, read my article on Inter-Integrated Circuit communication. MCP23008 supports 7-bit slave addressing, with the read/write bit filling out the control byte. The four most significant bits of the slave address are fixed (0100 for MCP23008) and the remaining three bits are user-defined hardware address bits (pins A2, A1 and A0). This allows us to connect up to eight MCP23008 devices on a common I2C bus. The control byte format for MCP23008 is shown below.

Control and configuration registers

The individual bits of the 8-bit GPIO port can be configured as input or output. The port pins can also be enabled for internal pull up resistor and interrupt-on-change. These operations are controlled through a set of configuration and control registers. The table below shows the list of these registers, their addresses and the power-on reset values.

These registers are described in the datasheet of MCP23008. I am summarizing them here. We will talk about configuring these registers for our specific purpose in the software section.

I/O Direction (IODIR): It controls the direction of the data I/O. When a bit is set, the corresponding pin becomes an input. When a bit is clear, the corresponding pin becomes an output.

Input Polarity (IPOL): It allows the user to configure the polarity on the corresponding GPIO port bits. If a bit is set, the corresponding GPIO register bit will store the inverted value on the pin.

Interrupt-on-change Control Register (GPINTEN): It controls the interrupt-on- change feature for each pin. If a bit is set, the corresponding pin is enabled for interrupt-on-change. The DEFVAL and INTCON registers must also be configured if any pins are enabled for interrupt-on-change.

Expanding the number of I O lines using Microchip MCP23008.jpgInterrupt Control (INTCON): It controls how the associated pin value is compared for the interrupt-on-change feature. If a bit is set, the corresponding I/O pin is compared against the associated bit in the DEFVAL register (described in next paragraph). If a bit value is clear, the corresponding I/O pin is compared against the previous value.

Default Comparison Value (DEFVAL): The default comparison value is configured in the DEFVAL register. If enabled (via GPINTEN and INTCON) to compare against the DEFVAL register, an opposite value on the associated pin will cause an interrupt to occur. For example, if GPINT6 (in GPINTEN), IOC6 (in INTCON) and DEF6 (in DEFVAL) bits are all set, then an interrupt will be generated when the GP6 I/O pin is pulled low. Of course, the GP6 pin direction should be defined as input.

For more detail: Expanding the number of I/O lines using Microchip MCP23008

The post Expanding the number of I/O lines using Microchip MCP23008 using pic microcontoller appeared first on PIC Microcontroller.

Connecting multiple tact switches on a single input pin of a microcontroller

$
0
0
Normally one tact switch requires one digital input pin of a microcontroller. Some designs implement keypad style multiplexing to get multiple switches on fewer inputs. However, there exist other techniques that allow you to connect many switches on a single input pin of a microcontroller. This tutorial demonstrates one such technique as applied to PIC12F683 microcontroller. In this example, there are four LEDs and four tact switches connected to the PIC12F683 microcontroller. While each LED is controlled through an individual I/O pin, the four switches are connected to one ADC input pin of the PIC12F683 microcontroller.
Connecting multiple tact switches on a single input pin of a microcontrollerTheory

The theory of connecting multiple switches on a single ADC input channel is very simple. One end of each switch is connected to the power supply voltage through an individual pull-up resistor, whereas the other end is grounded through a common resistor. When a switch is pressed, it creates a voltage divider network between the power supply and ground terminals. The value of the divided voltage can be made unique for all four switches by selecting different values of pull-up resistors. The voltage is then measured with the ADC to determine which switch has been pressed.

The circuit diagram shown below will probably give you a more clear picture of this technique. There are four switches (SW1-Sw4) connected to the AN0 input pin of the PIC12F683 microcontroller. Their one end is grounded through a common resistor R (=470 ?), whereas the other end is pulled high through different value resistors (R1‘-R4‘), giving rise to different values of the voltage divider output. The voltage drop across the resistor R is thus unique for each switch press and is measured through the AN0 ADC channel. When no switch is pressed, the AN0 pin is pulled low through R, and the ADC should ideally measure 0 V.

There are four LEDs (LED1-LED4) connected to pins GP1, GP2, GP4, and GP5 of the PIC12F683 microcontroller. They will be toggled ON and OFF through the four switches.

Connecting multiple tact switches on a single input pin of a microcontrollerCalculation of resistor R’

The resistors R1‘ – R4‘ determine the value of the voltage divider output for each switch press. We know that each resistor value must be different to create an unique analog voltage output across R for each switch. But how should we select their values? You should keep in mind that the resistors do have certain tolerance values and their values also change with temperature. Therefore, you should provide enough gap between any two consecutive values of the voltage divider output to avoid any conflict. The best practice would be to implement an evenly spaced values of the voltage divider for all 4 switches. Remember that when you press a switch, you should not expect a precise value of the analog voltage across the resistor R. It would fluctuate little bit within a certain range which is defined by the resistors’ tolerance values, temperature, contact resistance of the switches, and the stability of the power supply voltage. So, in order to identify the switch, what you are actually looking at is a range of voltage that the voltage divider output falls in.

Current Project / Post can also be found using:

  • question answers based on pic 18f microcontroller

The post Connecting multiple tact switches on a single input pin of a microcontroller appeared first on PIC Microcontroller.

MikroElektronika’s “Ready for PIC” board talks to “Processing” using pic microcontoller

$
0
0
“Ready for PIC“ is one of MikroElektronika‘s compact prototyping boards for 28 and 40 pin PIC microcontrollers. The board comes with PIC16F887 microcontroller which is preprogrammed with an UART bootloader firmware and thus eliminates the need of an external programmer. The on-board USB-UART module allows the serial data transfer between the PIC and a PC using an USB cable. It has also got a reasonable size prototyping area to add more functionalities to the board as required. These features make this board an ideal candidate for doing embedded projects that require PC interfacing. This article first reviews the basic features of the Ready for PIC board and then demonstrates how to write a PC application in Processing (an open source programming language) to communicate with the board through the on-board USB-UART module.
MikroElektronika’s “Ready for PIC” board talks to “Processing” A brief review of Ready for PIC board

Ready for PIC is a compact development tool for 28/40 pin PIC microcontrollers. The board by default is equipped with PIC16F887 MCU placed in a DIP40 socket but it does provide connection holes to accommodate a 28-pin device. To program the MCU you can either use the pre-installed bootloader or an external programmer. For using an external programmer, you need to make a few adjustments on the board. Please read the User’s Manual for further instructions on this. Four 2×5 male header pins are available on the board for easy access to the MCU I/O pins. The on-board FT232RL chip provides a USB to asynchronous serial data transfer interface so that the MCU can communicate with a PC through a virtual COM port using a USB cable. The board has two LEDs marked with Rx and Tx which blink when data transfer via USB UART module is active. The board can also be used with a 3.3 V type PIC microcontroller. There is an on-board jumper for selecting between 5 V and 3.3 V supply voltage for the MCU.

Little about Processing

Processing is an open-source software development environment designed for simplifying the process of creating digital images, animations and interactive graphical applications. It is free to download and operates on Mac, Windows, and Linux platforms. The Processing Interactive Development Environment (IDE) has the same basic structure as that of the Arduino IDE and is very easy to use. The programming language is so simple that you can create an interactive graphics with just a few lines of code. Here we will not discuss much of the graphics capability of Processing. We will rather focus on the Processing Serial library that will allow to transfer data between the PC and the Ready for PIC board.

MikroElektronika’s “Ready for PIC” board talks to “Processing”We will write a simple program in Processing to create a graphics window that displays the current computer time, and will send the same information to the Ready for PIC board through the virtual COM port. The PIC microcontroller will then display the time on a 8-digit seven segment LED display module. The seven segment LED module used here is mikroElektronika’s Serial 7-Seg 8-Digit Board. It uses a MAX7219 chip to drive 8 seven segment LEDs. The chip receives the display data from a microcontroller through an SPI serial interface. An User’s Manual is available for the Serial 7-Seg 8-Digit Board that describes how to use it with mikroElektronika’s various development boards. The LED board comes with an IDC10 connector cable that can be plugged into one of the 2×5 male header connectors on the Ready for PIC board. I connected it to PORTC of PIC16F887 (as shown below) because the SPI data and clock pins are multiplexed with PORTC I/O pins.

 

For more detail: MikroElektronika’s “Ready for PIC” board talks to “Processing”

Current Project / Post can also be found using:

  • ic pic16f877a led using project
  • pic16f877 project simple led
  • pic16f877a led projects

The post MikroElektronika’s “Ready for PIC” board talks to “Processing” using pic microcontoller appeared first on PIC Microcontroller.

The ChromoDisk

$
0
0

When I saw the Aurora LED 9×18 Instructable, I was inspired.  However, it’s built on the PIC microcontroller while I am most familiar with the AVR microcontrollers.  Plus, I already have the development and programming environments for AVRs, so I set about a redesign as a personal challenge.  I wanted to make something (almost) just as nice, that did not require as many components, was less expensive, and could be soldered by hand (albeit maybe taking a lot of time).  The result is this Instructable, the ChromoDisk.

The ChromoDisk is very similar to the Aurora LED.  It has the same 9 rings of 18 LEDs and every ring has to be the same color and brightness due to the multiplexing approach.  This device uses pulse-width modulation (PWM) instead of resistors to limit the power fed to the LEDs, so while it takes less assembly time and components, you need to be a little careful about how you write the software.  This is a good illustration of the tradeoff you need to make when you design with microcontrollers.  You need to strike a balance between what you do in hardware and what you do in software.  I am NOT saying that LED Artist’s approach with all the resistors is bad, it’s just a design choice and this is one alternative.  More about this later.

The ChromoDisk

Let’s start with the design parameters:

 

    • Easily available, low cost components

 

    • Low component count

 

    • Fits within a low-cost tier for PCB manufacture

 

    • Hand-solderable

 

    • Multiple power supply options
  • Easily programmable

The design you see here has been through 4 generations.  You can make a lot of mistakes in PCB design and layout, and I did.  Little things like forgetting to mirror components (battery pack) to the back of the board, not accounting for total current loads on chips (overheated micro), and switching transients (turning all the LEDs on at once) wreck a design.  I ran into all of these and more.  I think this final version gets it about right though.
The components I’ve chosen barely fit into the tight space.  I picked the largest SMT components that I could to facilitate manual handling and ease of soldering. In the end, because of the limited real estate, I was not able to allow both battery pack and DC power jack, so you need to choose which one you’ll use.  Also, everything fits within a 100 mm square, a 4 inch disk, which is one of the pricing tiers typical of most PCB manufacturers.  Anything bigger bumps you to the next pricing tier.  Since area and cost goes up as the square of the radius, it’s a good idea to limit the size.   Routing out the circular shape is normally included in the board price.
The AVR micros are fairly easy to program.  The code I’ve provided is entirely interrupt-driven and written in assembly language.  It might be a bit less readable than C or some other language, but it’s about as efficient as you can get.  I don’t claim to be the best programmer, but it seems to work pretty well and I was able to derive some new modes using code from other modes.  It’s designed to be hacked!

Here is the list of parts for the ChromoDisk, with Mouser P/N, description, and quantity:

667-ERJ-3EKF1201V Thick Film Resistors-0603 1.2K ohms 1% 13
667-ERJ-3EKF6800V Thick Film Resistor-0603 680 ohms 1% 3
667-ERJ-3EKF1002V Thick Film Resistor-0603 10K ohms 1% Tol 1
81-GRM188R71H104KA93 Capacitor (MLCC)-0603 0.1uF 50volts X7R 10% 1
512-FDN338P MOSFET Small Signal SSOT-3 P-CH -20V 3
771-PMST2369115 Bipolar Small Signal NPN 15v 200mA 500MHz 12
556-ATTINY4313-SU Microcontroller AVR 4KB FL 256B SRAM 1.8-5.5V 1
612-TL3315NF250Q Tactile Switch LOPRO 250GF SMD 1
611-KSC741GLFS Tactile Switch 4.3mm IP67 3N Soft Actuator 1
798-DF1BZ-6DP-2.5DSA 2.5MM V DBL ROW HDR 1
Common cathode RGB LEDS 162
Custom PC Board 1
598-AVE227M16X16T-F Al Electrolytic Cap – 220uF 16V 85C Case 6.3 x 7.7 1
163-5030-E DC PWR JACK 2.0MM X 5.5MM SMT 0/1
12BH331P-GR Battery Holder 3 AA PC LEADS 1/0
In-System Programmer for AVR microcontrollers 1

 
A couple of comments here.  First, you’ll notice that you have to choose either the DC power jack or the solder-on battery pack (you can use one with wire leads if you like, but I designed it to use the version with pins).   There’s a mounting hole in the center for whatever you want, but the battery pack will obscure it.  I used it to secure battery packs before I added the PC mount pack.  Second, I don’t have a spec for the RGB LEDs.  It’s entirely up to you which ones you choose.  Since I eliminated the current-limiting resistors on the LEDs by using PWM in software, you can adjust the brightness of the LEDs over a wide range by adjusting a couple of simple parameters at the top of the code. This allows you to accommodate LEDs with various current specs as long as they can take the surge current of the PWM approach.

The pinout for the LEDs is red / cathode / green / blue.  I have tried assembling boards with diffused and water-clear LEDs.  Diffused give more uniform color and brightness; clear give brighter light that floods farther and they have interesting effects with angle of view, but non-uniformity in LEDs can result in color hot-spots.  The PWM approach has some limitations there.

I’ve ordered the parts in large enough quantities that I can provide the kit of parts and the custom board (but not the ISP programmer).  Let me know if you’re interested.  Given the time involved, I’m not going to make any money on it.  That wasn’t  really the point.  It was intended to be a challenge and something fun for people to exp

eriment with.

Step 1: The Build – Layer 1

There are five phases to the build:

– Solder on the small passive SMT components and transistors
– Solder on the larger SMT components
– Program the microcontroller
– Solder on the LEDs

– Solder on the power source

The idea here is to put on components that don’t interfere with each other in layers.  The board is very crowded, so it’s essential to do this to make the build as easy as possible.  Here’s a picture of the board you’re starting with.  Let’s go!

Layer 1 – SMD Components … Most of them

The passive components go on first because they are the smallest and easiest to lose if you tilt the board.  You need as much clear area as possible when you’re soldering these.  You can use the “skillet” / oven method, or hand solder them.  I did it all by hand.  SparkFun has a good tutorial on hand-soldering SMT components, so I won’t try to duplicate that here.  Solder on all of the resistors and the bipolar transistors first.  The MOSFETs are static-sensitive, so adding in the other components first will help protect them.  Don’t put on the microcontroller, the large electrolytic cap, the 6-pin connector, the LEDs, the power connector / battery pack, or the capacitor on the back yet.  Solder on

the MOSFETs last in this layer.

Step 2: Layer 2 – Large SMD Components

Now that you’ve got the small components in place, add in the two switches.  Put the large one on the pads labeled Mode, since it’s the one you might use the most.  The shape of the switch makes it a little harder to solder in place.  I found the key to be soldering one contact in place, with the switch centered on the pads.  If you heat up the other pads, and use good flux, the solder will wick in underneath pretty readily.  The other switch goes on the Reset pads.  It has more exposed contacts, so it’s easier to solder down.  Add in the large 220 uFd cap, the microcontroller, the small cap on the back opposite the microcontroller, and the 6-pin connector.  Note: the image here shows the LEDs installed.  If you’re following along while building one of these, they aren’t there yet!

Step 3: Layer 3 – Programming

At this point, you have everything on the board to program the microcontroller except the power connector.  You’ll need to jumper your power source to the two holes for the battery pack.  Make sure you respect the polarity!  Depending upon the ISP you’re using, you’ll need to connect the power before or after you connect the programmer to the 6-pin connector.  Check the instructions for your programmer.  An initial program is provided here, in both source and code formats.  The microcontroller does not come pre-programmed, so you’ll need to do that now.  The advantage of doing it here, rather than at the end, is that you can test as you go.  One of the modes in the code lights up each color in each ring.  This allows you to verify that your LEDs and other components are soldered in place correctlyas you progress through the build.  To do this, you can connect the power when needed.  I did this with the battery pack by inserting it in the holes without soldering it in place.  If you chose the DC power jack instead, it will be a bit more difficult.  You could solder that on, but it will make manipulating the board a little more difficult during the rest of the build process.  Here’s what it looks like with the battery pack in place.The ChromoDisk schematic

Step 4: Layer 4 – The LEDs

You would have thought that the surface-mount devices would be the hardest part of the build.  For me it was the LEDs.  The pins are close enough together that it’s easy to get solder bridges.  Plus there’s the sheer tedium of soldering 162 LEDs with 4 pins each.  One method that works for me is to insert all of the LEDs and verify that they are oriented properly.  You can get an inkling if you connect up the power and go to the test mode.  Not all of the pins will make contact without soldering, but if you press an LED to one side or the other, it will make contact on all of the pins and you can get it to light up as a quick test.  If any of the LEDs are inserted the wrong way, strange things can happen with all the others, because they are all connected into a big matrix.  Solder bridges do the same thing, so be prepared with a magnifying glass.  And use a quality solder and plenty of flux!

Here’s my approach to the order of soldering.  Once you’ve got all of the LEDs in place, solder one pin on each LED in the outer-most ring in place on the bottom side of the board.  Make sure that as you solder, the LED is fully inserted so they are all flush with the top side of the board.  You can also use the shoulders on the leads to space the LEDs up off the board, but this is a little more difficult to get consistent height.  The choice is yours.  Thicker overall board with the LEDs up off the board, or slightly thinner and more compact with them all flush.

Next, go around that outer-most ring and clip the leads, leaving a little nub for soldering the other leads later.  Then proceed to each of the rings, soldering one lead on each LED and clipping leads.  Once you’ve got all of the LEDs tacked in place, go around and solder all of the remaining leads.  This goes a lot faster.  Make sure you don’t miss any, or you’ll be trying to figure out why some of your LEDs are acting funny.

At this point, you need to test all of the LEDs and make sure they are working, because if you’re using the battery pack it will cover up some of the leads!  The DC power jack is not as problematic, since it does not obscure the pins.  It’s sometimes very difficult to find bridges, and I don’t have any wise words or troubleshooting steps for you.  However, I have found that the board is thin enough that you can shine a light through from the top and inspect the bottom side to find some bridges.  If you don’t see a complete ring of light around each LED on the bottom side, there’s likely a bridge there

 

For more detail: The ChromoDisk

The post The ChromoDisk appeared first on PIC Microcontroller.

Lucid Dream/Dream Recall Machine using infrared.

$
0
0

This is my first instructable, so I hope everything is clear and hoping you find it interesting, and would appreciate any feedback, so here I go. I am sill testing this device with other people,  but  personally I have found  my dream recall has improved dramatically, wow! some of the dreams are totally amazing.

WARNING. Because of the flashing Led this could pose a problem with people that are affected by epilepsy. One solution would be to connect a switch to the Led, therefore there would only be a sound as a dream trigger.

If any one is interested in this project I can sell a kit of parts or sell a complete and tested device. Please contact me for prices at.  jeffbarnes311@googlemail.com
Lucid Dream Dream Recall Machine using infrared.
Description.
The device will scan the closed eye using infrared and when movement is detected(REM) the PIC microcontroller will flash an LED and produce a sound on a piezo. This should wake one up into a dream. Useful for Lucid dreaming or if one wants to better their dream recall. I have found using this device, my dream recall has greatly improved.

Operation.
After switching on the device there will be a delay of approximately 60 seconds, to allow one to settle into bed. Then the device will scan the closed eye three times, to check functionality, after this the device will stop scanning for three hours. It will then go into a cycle of scanning the eye then delay for 15 minutes until the device is turned off or the push button is pressed. If button is pressed the LED will illuminate then flash once after which there will be a delay of 30 minutes then scanning is resumed. This is to allow you to interrupt the cycle eg. sleep was interrupted so as to allow you to go back to sleep or can be used for a nap.

Setup mode.
1/ Keep push button pressed then turn on and release button, the LED will flash and piezo will sound, this is to allow adjustment of the LED light intensity VR1 and piezo volume VR2,  also to check battery state of charge.
2/ Press button until LED only flashes and release, this will enter infrared functionality test.
3/ Pressing button again, the device will go into the main program or turn off device.

Summary of operation.
1/ When one is ready for sleep turn on device then count to 60(seconds approximately).
2/ Move the eyes under closed lids until the device has triggered three times. This is to test functionality.
3/ Device will go into a three hour delay until scanning starts.
4/ Then it will scan the eye, delay for 15 minutes and repeat until the device is turned off or the push button is pressed.
5/ If push button is pressed the Led will stay on until released then flash once, there will then be a delay of 30 minutes and continue as in 4/. The button can be pressed at any time.
6/Sweet dreams and or great lucids.
7/Turn off device with the slid switch. Good morning

Jeff Barnes

Step 1: PARTS LIST

Parts list.
R1 = 3K3 1/4 WATT
R2 = 10K
R3 = 5K6
R4 = 150R
VR1 = 5K PRESET
VR2 = 100K PRESET

C1 = 1000uF 6.3V ELECTROLYTIC
C2 = 100nF CERAMIC
C3 = 22pF CERAMIC

IC1 = 12F675 PIC MICROCONTROLLER
INFRARED PHOTO TRAN 3mm OR 5mm
INFRARED LED 5mm
5mm LED
PIEZO 20mm

SW1 = MINATURE SLIDE SWITCH
PB1 = MINATURE PUSH BUTTON

8 PIN DIL SOCKET
AAA BATTERY HOLDER FOR TWO AAA BATTERIES
SLEEP MASK
DOUBLE SIDED STICKY PADS X 2
STRIP BOARD 25 HOLES X 18 STRIPS
1mm HEAT SHRINK SLEEVING
TINNED COPPER WIRE FOR LINKS, 7 IN TOTAL.
SLEEP MASK

Jeff Barnes

Step 2: CONSTRUCTION

Construction.
Please refer to schematic and board overlay
For the circuit board I have used Vero/stip board and the tracks cut using a spot face cutter or a 3mm drill bit, as indicated by  X’s in the circuit board layout, 9 in total. I have also included a PCB lay out.

Construction of the board is pretty straightforward, just have to watch for the polarity of the electrolytic cap, IC1, infrared led, infrared tran(collector denoted by the short leg) and visible led.
Some things to watch out for:-
The push button legs will have to be straightened to fit into the correct position, as shown in the circuit board overlay.
The two white rectangles by the side of the piezo are the double sided sticky pads for securing the battery holder.
Piezo is glued to the circuit board with a small amount of adhesive.
The battery holder:-
Two lengths of tined copper wire are soldered onto the board at the points marked with a + and a _,  then pass them through the solder tags on the battery holder, stick holder in place after sewing to sleep mask with the two double sided sticky pads and solder wires to the solder tags, being careful not to use too much heat, are the plastic of the holder will melt.Lucid Dream Dream Recall Machine using infrared schematic
Led, infrared led and infrared transistor:- (infrared tran collector denoted by short leg)
Use 1mm sleeving on the legs of these components and try to keep them as long as possible when soldering to board. The short lead on the infrared transistor indicates the collector. Bend these components out from the board and bend the heads so as to be able to shine on the eyes. Next stitch board to sleep mask, as indicated on the board overly, mark the position of the Leds and transistor on the mask, then cut small holes using a leather hole punch or something simular, press the heads of these components through so the leds protrude approximately 3mm and the photo tran 2mm, making shore the infrared led is slightly angle towards the photo transistor and then glue into place using supper glue. There is a photo of the templates I used showing the position of these components, there is another photo showing the ideal position of the infra red led and photo transistor in relation to the eye.   WARNING, ALLOW AT LEAST 3 HOURS BEFORE PUTTING MASK ON FACE, BECAUSE  FUMES FROM THE GLUE CAN IRRITATE THE EYES.
The PCB software I am using is from  http://www.expresspcb.com/expresspcbhtm/download.htm

Jeff Barnes

 

 

For more detail: Lucid Dream/Dream Recall Machine using infrared.

 

Current Project / Post can also be found using:

  • pic12f675 led projects

The post Lucid Dream/Dream Recall Machine using infrared. appeared first on PIC Microcontroller.

Aurora 9×18 RGB LED art

$
0
0

*** Check out my blog for updated version of this project and more! ***

My obsession of LEDs has led me to this. Aurora 9×18 is a thing of beauty (if I can say so myself) – has 162 RGB-LEDs in a circular configuration. The color of each circle is controlled by a microcontroller using a twisted form of PWM.

The microcontroller (PIC24F08KA101) only has one PWM module, yet Aurora is capable of 27 (9xR,G,B) independent brightness control. This Instructable reveals the inner-working of Aurora 9×18 through the building process.Aurora 9x18 RGB LED art

Step 1: Concept

A RGB LED is nothing more than a LED that actually encases 3 small LEDs of primary colors inside. RGB LEDs can create wide range of colors by combining 3 primary colors – Red, Green, and Blue. By changing the ratio between the 3 colors, you get many in-between colors. RGB LEDs are often called full-color LEDs.

Most of brightness controlling circuit utilizes the method called PWM. Many of microcontrollers today have a PWM controller or more built in, however there are usually less than 4 or 5 of them in a controller. So if I were to control 9 LEDs, I needed to use multiple controllers or external circuits. If those 9 LEDs were RGB LEDs, then there would be 27 PWM controllers needed.

I’ve gone through a few approaches – multiple microcontrollers working together in various configurations – some are complex and exotic. I was trying to solve more than just the number of LEDs that I can control – I wanted to make the fades in/out of brightness as smooth as possible. Turned out, 8 to 10 bit PWM resolution that most PIC microcontrollers provide was not good enough to create smooth transition in the darker/dimmer part of the brightness change. When the brightness is low, the transitions look more like steps than fading. Due to human eye’s non-linear or exponential response to light intensity necessitates gamma correction of the brightness change curve, which requires at least 12 bits of PWM resolution to give smooth fades (in my conclusion).

If I simply design a circuit where each LED is controlled by it’s own PWM controller having 12 bit or more resolution, I’d have to use a speciality LED controller IC. While this solves the problem, the added cost and size to the final product did not appeal to me. (Those LED controller IC are not very small or cheap.)

So I came up with an idea of combining PWM with multiplex drive. I further broke up each PWM cycle into multiple pulses, so that multiple LEDs were lit multiple times within one PWM cycle. (Kind of hybrid between PWM and PDM, I guess.) This way, the average output of LEDs are the sum of the many pulses within the short period. By combining more than one PWM pulses increases effective PWM resolution.
This technique also helpes reduce the perceived flicker of the light out of LEDs. Aurora 9×18’s LED refresh rate is about 246 Hz, but LEDs blink a lot more often. This creates the illusion of much higher refresh rate.

Take a look at the timing chart. I picked 7 LEDs and R/G/B bus signals to present the concept.
As you can see, R/G/B buses go up momentarily, taking turns. These pulses control the actual duration that LEDs light up. Each common lead of the LEDs controls whether that LED will light during the period that R/G/B buses go high. The actual timing that LEDs light up are marked with the color on the chart.

The condition here is:
LED 1 is on level 1 red (the lowest brightness).
LED 2 is on level 2 green.
LED 3 is on level 3 blue.
LED 4 is on level 3 yellow (red + green).
LED 5 is on level 3 purple (red + blue).
LED 6 is on level 3 turquoise (green + blue).
LED 7 is on level 255 (maximum brightness) white.
* time scale is about 8.1 ms for the entire width of the chart.

Hope this explains the way Aurora controls the brightness/colors of LEDs.

References
PWM on wiki
PDM on wiki

Correction
LED refresh rate originally stated was wrong – it’s 246 Hz not 123 Hz.

Step 2: Circuit

Aurora 9×18 has 18 RGB-LEDs in each of 9 circles, total of 162 LEDs. Each circle is LEDs are connected in parallel, so there are 9 LED circuits (x3 because they are RGB) to control.

I chose PIC24F08KA101 as the controller. It needed to be powerful enough (16 bit), and requires minimum of external parts (no crystal needed to run at the max speed of 32 MHz) to save space.

The circuit itself is quite simple. The microcontroller is connected to a joystick like switch (5 switches in it) and there are 3 MOSFETs and 12 BJTs controlling the current that goes into LEDs. There’s a 3.3V linear voltage regulator to supply for the PIC as well. (The LED circuit is driven by 5V power.)

If you look at this circuit you might realize that it’s just like 9×3 matrix circuit, but instead 3 rows are replaced with 3 primary colors of RGB LEDs. So now you know that RGB channels are multiplexed – in other words those 3 colors turn on one by one, not together at the same time. In general I don’t like multiplexing, but I needed to compromise in favor for the simplicity and physical space.

Given that this microcontroller only has one PWM module (to control the brightness of LEDs), I had to come up with a way of extending that PWM signal into 3. I’m doing that with a simple “AND” logic utilizing the lower part of the R/G/B bus driving circuit. In short, R-BUS only turns on when PWM signal is high and R-DRV signal is low. For G-BUS, PWM -> high and G-DRV -> low, and so on. This circuit works remarkably well, saving my precious space on the board and a few dimes.
I’m using MOSFET on the high-side switch simply because BJTs that I can find in the small package do not handle the current drawn by 162 LEDs in parallel (about 3 A peak!). This MOSFET (DMP3098L) has a remarkable current handling capability. Highly recommended.

Low-side (column, or each LED) driver/switch circuit is very straight forward. NPN BJT in common emitter configuration.

There are 1k Ohm resistors connected to the output of each driver, which some of you wonder as to why. Those resistors help the transistors turn off quicker when there are no LEDs conducting (transistors turn off quicker when there is current going through drain or collector). Those transistors are switching at the timing in the order of nanoseconds, so turn on/off speed becomes critical.
In a nutshell, those resistors allow PWM to run at a higher speed (less visible flicker).

References
PIC24F08KA101 datasheet
DMP3098L datasheet

Step 3: PCB

I wanted to make this object as small as possible, so designing the PCB took some work. In reality, I went back & forth between the circuit design and PCB design, trying to reduce part count to the minimum.

I had the PCB fabricated by DorkbotPDX. They have a community based PCB program (kind of like BatchPCB) that I like. As you can see, the boards are beautifully manufactured (in the USA :). The solder mask is dark purple.

Links
DorkbotPDX PCB Order

Step 4: Parts

Here are the list of parts, or BOM. You can download BOM file that can be uploaded to Digi-Key for quick ordering.

162x 150Ohm (0603)
9x 220 Ohm (0603)
13x 1k Ohm (0603)
3x 470 Ohm (0603)
1x 10k Ohm (0603)
2x 10uF (0603)
1x 1uF (0603)
1x AP7333-33 or AP7313-33
3x DMP3098L
12x MMBT2222A
1x PIC24F08KA101
1x 4-way Stick Switch (Panasonic EVQQ7)
162x 5mm Tricolor LED (common-cathode) – AliExpress.com
1x 5V regulated power supply or 4 NiMH batteries & case

I source LEDs directly from China via AliExpress . Takes a few days for delivery, but the prices are great. Other parts are available at Digi-Key .

You can substitute transistors if you have something compatible. BJTs can be substituted by number of others, finding substitutes for the MOSFET might not be easy, however. Please let me know if anyone knows of a more economical devices here.

Step 5: Tools & Supply

  • Magnifier visor or other visual aid device
  • Solder paste in syringe
  • Tweezers
  • Electric hot plate
  • Soldering iron
  • Solder (flux core. go for the highest quality solder you can afford.)
  • Wire cutter (I recommend this one.)Aurora 9x18 RGB LED art schematic
  • Microchip PIC programmer (supports PIC24F08KA and capable of In-circuit programming through a standard 6-pin ICSP connector) and a computer

Step 6: Assembly

Due to the high number of part count (371 parts), and tight and unusual placements. The assembly requires excellent soldering skills and takes quite an effort.

As most of the parts are SMD (surface mount device), I use “paste, place & grill” method. If you have built a few things with SMD, you would know what I mean. There are many ways to solder SMD parts, and you are free to go with any method that you are comfortable with. I will show how I’ve done this one.

1. Count and prepare all SMD parts for the placement
I recommend prepping the SMD parts, so that they are ready to be placed on the PCB as soon as you dispensed the solder paste on it.

Step 7: Assembly 2 – Dispense solder paste on PCB

I wanted to use stencil for this step, but unfortunately due to the PCB layout I could not have made the stencil (low cost stencils can not contain non 90 degree angle parts). So I manually dispense microscopic dubs of solder paste using a syringe. This is a tortuous process.

 

 

For more detail: Aurora 9×18 RGB LED art

The post Aurora 9×18 RGB LED art appeared first on PIC Microcontroller.

Arduino controlled light dimmer

$
0
0

WARNING: Some people try to build this with an optocoupler with zerocrossing coz ‘that is better’ right? Some are even told in electronics shops it is better to use such an optocoupler. WRONG. This will only work with a random fire optocoupler: NOT igniting at zerocrossing is the principle of this dimmer.

Switching an AC load with an Arduino is rather simpel: either a mechanical relay or a solid state relay with an optically isolated Triac. (I say Arduino, but if you use an 8051 or PIC16F877A microcontroller, there is stuff for you too here.)

It becomes a bit more tricky if one wants to dim a mains AC lamp with an arduino: just limiting the current through e.g. a transistor is not really possible due to the large power the transistor then will need to dissipate, resulting in much heat and it is also not efficient from an energy use point of view.

Phase cutting
One way of doing it is through phase control with a Triac: the Triac then is fully opened, but only during a part of the sinus AC wave. This is called leading edge cutting.
One could let an Arduino just open the Triac for a number of microseconds, but that has the problem that it is unpredictable during what part of the sinus wave the triac opens and therefore the dimming level is unpredictable. One needs a reference point in the sinus wave.
For that a zero crossing detector is necessary. This is a circuit that tells the Arduino (or another micro controller) when the sinus-wave goes through zero and therefore gives a defined point on that sinus wave.
Opening the Triac after a number of microseconds delay starting from the zero crossing therefore gives a predictable level of dimming.

Pulse Skip Modulation
Another way of doing this is by Pulse Skip Modulation. With PSM, one or more full cycles (sinuswaves) are transferred to the load and then one or more cycles are not. Though effective, it is not a good way to dim lights as there is a chance for flickering. Though it might be tempting, in PSM one should always allow a full sinuswave to be passed to the load, not a half sinus as in that case the load will be fed factually from DC which is not a good thing for most AC loads. The difference between leading edge cutting and PSM is mainly in the software: in both cases one will need a circuit that detects the zero crossing and that can control a triac.

A circuit that can do this is easy to build: The zero crossing is directly derived from the rectified mains AC lines – via an optocoupler of course- and gives a signal every time the wave goes through zero. Because the sine wave first goes through double phased rectification, the zero-crossing signal is given regardless whether the sinus wave goes up through zero or down through zero. This signal then can be used to trigger an interrupt in the Arduino.

It goes without saying that there needs to be a galvanic separation between the Arduino side of things and anything connected to the mains. For those who do not understand ‘galvanic separation’ it means ‘no metal connections’ thus —> opto-couplers. BUT, if you do not understand ‘galvanic separation’, maybe you should not build this.

The circuit pictured here does just that. The mains 220Volt voltage is led through two 30k resistors to a bridge rectifier that gives a double phased rectified signal to a 4N25 opto-coupler. The LED in this opto-coupler thus goes low with a frequency of 100Hz and the signal on the collector is going high with a frequency of 100Hz, in line with the sinusoid wave on the mains net. The signal of the 4N25 is fed to an interrupt pin in the Arduino (or other microprocessor). The interrupt routine feeds a signal of a specific length to one of the I/O pins. The I/O pin signal goes back to our circuit and opens the LED and a MOC3021, that triggers the Opto-Thyristor briefly. The LED in series with the MOC3021 indicates if there is any current going through the MOC3021. Mind you though that in dimming operation that light will not be very visible because it is very short lasting. Should you chose to use the triac switch for continuous use, the LED will light up clearly.Arduino controlled light dimmer

Mind you that only regular incandescent lamps are truly suitable for dimming. It will work with a halogen lamp as well, but it will shorten the life span of the halogen lamp. It will not work with any cfl lamps, unless they are specifically stated to be suited for a dimmer. The same goes for LED lamps

If you are interested in an AC dimmer such as this but you do not want to try building it yourself, there is a somewhat similar dimmer available at www.inmojo.com, however, that is a 110 Volt 60Hz version (but adaptable for 220 50Hz), that has been out of stock for a while. You will also find a schedule here.

NOTE! It is possible that depending on the LED that is used, the steering signal just does not cut it and you may end up with a lamp that just flickers rather than being smoothly regulated. Replacing the LED with a wire bridge will cure that. The LED is not really necessary. increase the 220 ohm resistor to 470 then

STOP: This circuit is attached to a 110-220 Voltage. Do not build this if you are not confident about what you are doing. Unplug it before coming even close to the PCB. The cooling plate of the Triac is attached to the mains. Do not touch it while in operation. Put it in a proper enclosure/container.

WAIT: Let me just add a stronger warning here: This circuit is safe if it is built and implemented only by people who know what they are doing. If you have no clue or if you are doubting about what you do, chances are you are going to be DEAD! DO NOT TOUCH WHEN IT IS CONNECTED TO THE GRID

Materials
Zerocrossing
4N25 €0.25 or H11AA1 or IL250, IL251, IL252, LTV814 (see text in the next step)
Resistor 10k €0.10
bridge rectifier 400 Volt €0.30
2x 30 k resistor 1/2 Watt (resistors will probably dissipate 400mW max each €0.30
1 connector €0.20
5.1 Volt zenerdiode (optional)

Lamp driver
LED (Note: you can replace the LED with a wire bridge as the LED may sometimes cause the lamp to flicker rather than to regulate smoothly)
MOC3021 If you chose another type, make sure it has NO zero-crossing detection, I can’t stress this enough DO NOT use e.g. a MOC3042
Resistor 220 Ohm €0.10 (I actually used a 330 Ohm and that worked fine)
Resistor 470 Ohm-1k (I ended up using a 560 Ohm and that worked well)
TRIAC TIC206 €1.20 or BR136 €0.50
1 connector €0.20

Other
Piece of PCB 6x3cm
electric wiring

That is about €3 in parts

Step 1: Arduino controlled light dimmer: The PCB

You will find two pictures for the PCB: my first one, that I leave here for documentation purposes and a slightly altered new one. The difference is that I left out the zenerdiode as it is not really necessary and I gave the LED itś own (1k) resistor: it is no longer in series with the Optocoupler, that now has a 470 Ohm resistor. I made the PCB via direct toner transfer and then etched it in a hydrochloric acid/Hydrogenperoxide bath. There are plenty of instructables telling how to do that. You can use the attached print design to do the same. Populating the print is quite straightforward. I used IC feet for the opto-couplers and the bridge rectifier.
Download the print here.
Note: You need Fritzing for this. For the direct toner transfer, the printed side of the printed pdf file, goes directly against the copper layer for transfer. Once it is transferred, you will be looking at the ink from the other side and thus see the text normal again. I made slight alterations in thePCB: I removed the zenerdiode and the LED is no longer in series with the optocoupler.

I used a TIC206. That can deliver 4 amperes. Keep in mind though that the copper tracks of the PCB will not be able to withstand 4 Amperes. For any serious load, solder a piece of copper installation wire on the tracks leading from the TRIAC to the connectors and on the track between the two connectors.

In case it is not clear what the inputs are: from top to bottom on the second picture:
+5Volts
Interrupt signal (going to D2 on arduino)
Triac signal (coming from D3 on Arduino)
Ground

NOTE:
If you have an H11AA1or IL 250, 251 or 252 opto-coupler then you do not need the bridge rectifier. These have two anti-parellel diodes and thus can handle AC. It is pin compatible with the 4N25, just pop it in and solder 2 wire-bridges between R5 and + and R7 and -. The LTV814 is not pincompatible

Step 2: A word on inductive loads: theory

The presented circuit is suited for pure resistive loads such as incandescent lamps.
Should you want to use it for inductive loads, then a snubber circuit is necessary. The figure shows the modifications for use with Inductive loads. Mind you, this is not something I tried as I just wanted to dim lamps, but it is based on examples and theory available on the internet. You would have to adapt the provided PCB
The top figure shows the circuit as is, for dimming a lamp. It is in all its simplicity just a resistor to trigger the gate via the diac in the optocoupler. The value of 1k may be changed as discussed in the text before.
The bottom figure gives an omnipresent circuit for use in inductive loads.

It consists of an additional resistor and capacitor. The gate current is below 15mA. If you are using a less sensitive triac to control the inductive load, reduce the resistor from 2.4kΩ to 1.2kΩ, providing more current to drive the triac and increase the capacitor to 200nF. This snubber circuit is there to protect the triac from the high voltage generated from an inductive load. The feedback may cause some problem for non-inductive load. The small leakage can be significant enough to turn on small load (for example a lamp).

There are other snubber circuits, e.g. a resistor and capacitor in series directly over the load

Step 3: The software, a bit of theory

If you could care less about the theory, but just want the software, go to the next step

The way to use an AC dimmer/fader is quite simple once you understand the basics:

In AC the power fed to the lamp is directly related to the total surface of the sinuswave, the lamp can be regulated by only allowing a predictable part of that sinuswave to flow through the lamp.

As such we need a reference point on that sinus from where we calculate when the lamp has to be switched on.

The easiest reference point to use is the so called ‘zero crossing’: the moment that the light goes through zero.
After each zero crossing there is one full half of the sinuswave available to send through the lamp.

So what the software needs to do is to detect the zerocrossing, and then wait for a set amount of time on that sinuswave to switch on the TRIAC.

There are 2 major net frequencies in the world: 100Hz in Europe and most of Asia and Africa and 120 Hz in the America’s (and parts of the Caribean). There are 2 major voltages in the world: 110-120V and 220-240V but they are not important for the mathematics here.

For ease of use I will take the 50Hz frequency as an example:
50Hz is 50 waves per second.
Each sinuswave thus takes 1000ms/50=20ms (miliseconds)
As there are 2 sinuspeaks in a wave that means that after every zero detection there is a 10ms period that we can regulate.
Should we ignite the lamp directly at the beginning of that period, the lamp will receive full power, should we do it at the end of that 10ms period the lamp will receive no ower and should we do it halfway, the lamp will receive half power.
As we are using TRIACs, what the software needs to do is to wait for the zero point at the sinuscurve, take note of that and then wait a specified amount of time within that 10ms period to send a pulse to the TRIAC.
If it sends that pulse at 5ms, the lamp will only burn at half power.

In the Circuit, the zero detection is done by the biphase optocoupler and is available as the X-signal on the board.
There are basically 2 ways for a microcontroller to detect that signal:
1-a continuous ‘polling’ of the Zero Crossing pin
2-using an interrupt to tell the program that there was a zero crossing
The main difference between the two is that in ‘polling’ everytime the computer goes through it’s main loop it needs to check the pin. If your program is busy doing a lot of other things, it might be too late in checking the zero crossing pin, while when using an interrupt, it does not matter what the program is busy with. The interrupt is sort of ‘tapping it on the shoulder’ saying “Hey look, something came up that you need to attend to NOW”.

After the zero crossing is detected the program needs to wait for a specified amount of time and then switch on the TRIAC.
Also here, that waiting can be done in two different ways
1- by issuing a ‘wait’ command
2-by using a timer interrupt

Again, both these methods have their pro’s and con’s. The ‘wait’ command (‘delay’ in Arduino language) literally let’s the computer wait for the required time and it cant do anything else in the mean time. if the lamp is burning at low power by letting the computer wait say 9ms, that means that every 10ms the computer is told to wait 9ms: ergo it will be idle 90% of the time. That is fine if your controller is only used to control the lamp, but if it needs to do other stuff then little time is left.
Using a timer interrupt solves that. Basically what that does is that the program tells the timer: ¨Hey, I just heard we have a zero crossing, I got to do something else, but you just wait 4.5ms and then switch on the Triac” So the program goes on it’s merry way and 4.5ms (as an example) after it was given notice there was a 0-crossing, the timer switches on the TRIAC.

Polling: (note this is a rough example for illustration of polling, obviously it needs some enhancement)

int AC_LOAD=3; //   We use pin 3 to ignite the TRIAC
int state; // integer to store the status of the zero crossing

void setup()
{
pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
}

void loop()
{
state=digitalRead(AC_LOAD);
if (state=1) {
delayMicroseconds(5000); // =5 ms=half power
digitalWrite(AC_LOAD, HIGH);   // triac firing
}

Interrupt driven:
To use an interrupt, first we need to set that up. On the Arduino that is as follows:

void setup()
{
  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
  attachInterrupt(0, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
}

What this says is that the interrupt is attached to interrupt 0, it goes to a function called “zero_crosss_int” and it reacts to a rising flank on the pin.

In the Zero_cross_int function that the program jumps to after the interrupt we determine the time we need to wait before firing the TRIAC. We will also add a bit of functionality. We don’t just want one level set that the lamp burns on, we are going to add some functionality to regulate the light level in steps.
For that I have chosen the fully arbitrary amount of 128 steps. That means that every step is 10ms/128 = 10000us/128=75us (in fact it is 78, but I get to that later). The total dimtime then is calculated from 75x(1 to 128). The number between 1-128, which determines our level of dimming, we assign to the variable integer ‘dimming’

void zero_crosss_int()  // function to be fired at the zero crossing to dim the light
{
  int dimtime = (75*dimming);    // For 60Hz =>65   
  delayMicroseconds(dimtime);    // Off cycle
  digitalWrite(AC_LOAD, HIGH);   // triac firing
  delayMicroseconds(10);         // triac On propagation delay (for 60Hz use 8.33)
  digitalWrite(AC_LOAD, LOW);    // triac Off
}

What happens here is that the program first calculates the dimtime (=time to wait before the triac is fired)

It then waits that amount of time, subsequently waits that amount of time and fires the Triac. The Triac will switch off again at the following zero crossing, but we are going to already write a low on the TRIAC pin to avoid accidental ignition in the next cycle. We need to wait a bit however to know for sure the TRIAC is on, so we wait 10us. Now (10000-10)/128 is still 87 but i found 75 to work well. Feel free to use 78 though.

The only thing then left to do in the main program is to set the level at which we want the lamp to burn:

void loop()  {
  for (int i=5; i <= 128; i++){
    dimming=i;
    delay(10);
   }

What happens here is a simple loop that regulates the lamp up in a 128 steps. I have chosen not to start at 1 but at 5 because at that level there could be some timing issues that could cause the lamp to flicker.

The above program is only an example of how to control the lamp, obviously you want to add some other functionality rather than just have a lamp go up and down in brightness.

Using a timer:
If you want your program to be time efficient you will need to use an interrupt for the zero-crossing detection and a timer to determine the amount of time to wait.
Roughly a program would look as follows:

Initialize
Set up the various constants and variables you need and include the libraries used (such as the TimerOne Library)

Setup
Setp the pins and the 2 interrupts
The zero-crosssing interrupt points to a function and so does the timer interrupt

Zero-cross functie
Set a boolean indicating if a zero cross has occurred

Timer function
If we regulate the brightness again in 128 steps, then the timer function is set up to be called whenever the time of a step has passed (e.g. 75us) and then checks if the number of steps passed is equal to the number of steps set. If that is the case, the Triac is switched on

Step 4: Arduino controlled light dimmer: The software

As discussed in the previous theoretical page, the software is fairly easy.
If you want to develop your own software all you need to do is:
Wait for the zerocrossing
Wait a specific time between 0 and 9090 microseconds (9090=10.000-10)
switch on yr TRIAC
Wait for about 10us (that is the time you need to make sure the TRIAC is on)
switch off yr TRIAC (in fact, you only remove the triggersignal to the TRIAC, the TRIAC will stay on till the next zerocrossing)

I just briefly sketch the flow of the program that I used:

(make sure you read the ‘NOTE’ below)

The zero X-ing signal generates an interrupt.
At 50Hz that interrupt is every 10ms or 10.000uS
At 60Hz that interrupt is every 8.333 ms or 8333 uS
The interrupt routine then switches on the Triac after a specific time. That time is set in the main program loop.
As the program varies the dimming from Full to Off in 128 steps (that is just a choice that was made, could be 100 steps as well), at 50 Hz we need the steps to be 75 uS and at 60Hz they need to be 65 uS

It works as follows:
The interrupt function”zero_crosss_int” gets called every time a zero-crossing is detected, which is 100times/second. It’s only function is to set the time that the Triac is switched on to the value of the variable ‘dimming’
In the main loop of the program the actual value of that variable is set

/*

AC Voltage dimmer with Zero cross detection
Author: Charith Fernanado <a href="http://www.inmojo.com"> http://www.inmojo.com
</a>
Adapted by DIY_bloke
License: Creative Commons Attribution Share-Alike 3.0 License.
Attach the Zero cross pin of the module to Arduino External Interrupt pin
Select the correct Interrupt # from the below table 
(the Pin numbers are digital pins, NOT physical pins: 
digital pin 2 [INT0]=physical pin 4 and digital pin 3 [INT1]= physical pin 5)
check: <a href="http://arduino.cc/en/Reference/attachInterrupt"> http://www.inmojo.com
</a>

Pin    |  Interrrupt # | Arduino Platform
---------------------------------------
2      |  0            |  All -But it is INT1 on the Leonardo
3      |  1            |  All -But it is INT0 on the Leonardo
18     |  5            |  Arduino Mega Only
19     |  4            |  Arduino Mega Only
20     |  3            |  Arduino Mega Only
21     |  2            |  Arduino Mega Only
0      |  0            |  Leonardo
1      |  3            |  Leonardo
7      |  4            |  Leonardo
The Arduino Due has no standard interrupt pins as an iterrupt can be attached to almosty any pin. 

In the program pin 2 is chosen
*/
int AC_LOAD = 3;    // Output to Opto Triac pin
int dimming = 128;  // Dimming level (0-128)  0 = ON, 128 = OFF

void setup()
{
  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
  attachInterrupt(0, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
}

//the interrupt function must take no parameters and return nothing
void zero_crosss_int()  //function to be fired at the zero crossing to dim the light
{
  // Firing angle calculation : 1 full 50Hz wave =1/50=20ms 
  // Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle) 
  // For 60Hz => 8.33ms (10.000/120)
  // 10ms=10000us
  // (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65

  int dimtime = (75*dimming);    // For 60Hz =>65    
  delayMicroseconds(dimtime);    // Wait till firing the TRIAC
  digitalWrite(AC_LOAD, HIGH);   // Fire the TRIAC
  delayMicroseconds(10);         // triac On propogation delay (for 60Hz use 8.33)
  digitalWrite(AC_LOAD, LOW);    // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}

void loop()  {
  for (int i=5; i <= 128; i++){
    dimming=i;
    delay(10);
   }
}

  

About the software: theoretically in the loop you could let variable ‘i’ start from ‘0’. However, since the timing in the interrupt is a bit of an approximation using ‘0’ (fully on) could screw up the timing a bit. the same goes for 128 (Full off) though that seems to be less critical. Wether ‘5’ or perhaps ‘1’ is the limit for your set up is a matter of trying, your range may go from e.g. 2 to 126 instead of 0-128. If anybody has a more precise way to set up the timing in the interrupt I’d be happy to hear it.
Ofcourse it is not necessary to work with interrupts. It is also possible to keep polling the zero crossing pin for going to 0.

Though the software works with an interrupt to determine the moment of zero crosssing, it is still not so efficient because the time (dimtime) we need to wait after the zero crossing before the triac is fired is literally spent ‘waiting’ in the zero cross interrupt function.

It would be more efficient to set a timer interrupt to fire at the right moment so in the mean time the arduino can do something else. Such a program can be found in step

NOTE

Let me just reiterate the above statement: This program is a demo of how you can control the dimmer. It is NOT and efficient program as it spends most of its time waiting. It is therefore NOT the most suitable to combine with other tasks of the processor. If you need a more efficient program use a timer instead of delay

 

Step 5: Arduino Controlled Lightdimmer: The Software II

I found another piece of Software that allows controlling the lamp via the serial port. I have not tested it myself yet, but I see no reason why it should not work. It triggers on the falling edge of the zero-crossing signal, so the timing is a bit different.

int AC_pin = 3;//Pin to OptoTriac
byte dim = 0; //Initial brightness level from 0 to 255, change as you like!

void setup() {
  Serial.begin(9600);
  pinMode(AC_pin, OUTPUT);
  attachInterrupt(0, light, FALLING);//When arduino Pin 2 is FALLING from HIGH to LOW, run light procedure!
}

void light() {
  if (Serial.available()) {
    dim = Serial.read();
    if (dim < 1) {
      //Turn TRIAC completely OFF if dim is 0
      digitalWrite(AC_pin, LOW);
    }

    if (dim > 254) { //Turn TRIAC completely ON if dim is 255
      digitalWrite(AC_pin, HIGH);
    }
  }

  if (dim > 0 && dim < 255) {
    //Dimming part, if dim is not 0 and not 255
    delayMicroseconds(34*(255-dim));
    digitalWrite(AC_pin, HIGH);
    delayMicroseconds(500);
    digitalWrite(AC_pin, LOW);
  }
}
void loop() {
}


Even more software <a href="http://wiki.dxarts.washington.edu/groups/general/wiki/4dd69/AC_Dimmer_Circuit.html" rel="nofollow">here</a>

 

Step 6: Arduino controlled light dimmer: The software III

The code below has been confirmed to work on the Leonardo

/*
AC Light Control
 
 Updated by Robert Twomey 
 
 Changed zero-crossing detection to look for RISING edge rather
 than falling.  (originally it was only chopping the negative half
 of the AC wave form). 
 
 Also changed the dim_check() to turn on the Triac, leaving it on 
 until the zero_cross_detect() turn's it off.
 
 Adapted from sketch by Ryan McLaughlin 
 <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230333861/30" rel="nofollow"> <a rel="nofollow"> http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1...</a>>
(now here: <a rel="nofollow"> http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1...</a>
 
 */

#include  <TimerOne.h>          // Avaiable from <a href="http://www.arduino.cc/playground/Code/Timer1" rel="nofollow"> <a href="http://www.arduino.cc/playground/Code/Timer1" rel="nofollow"> http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1...</a>
</a>
volatile int i=0;               // Variable to use as a counter
volatile boolean zero_cross=0;  // Boolean to store a "switch" to tell us if we have crossed zero
int AC_pin = 11;                // Output to Opto Triac
int dim = 0;                    // Dimming level (0-128)  0 = on, 128 = 0ff
int inc=1;                      // counting up or down, 1=up, -1=down

int freqStep = 75;    // This is the delay-per-brightness step in microseconds.
                      // For 60 Hz it should be 65
// It is calculated based on the frequency of your voltage supply (50Hz or 60Hz)
// and the number of brightness steps you want. 
// 
// Realize that there are 2 zerocrossing per cycle. This means
// zero crossing happens at 120Hz for a 60Hz supply or 100Hz for a 50Hz supply. 

// To calculate freqStep divide the length of one full half-wave of the power
// cycle (in microseconds) by the number of brightness steps. 
//
// (120 Hz=8333uS) / 128 brightness steps = 65 uS / brightness step
// (100Hz=10000uS) / 128 steps = 75uS/step

void setup() {                                      // Begin setup
  pinMode(AC_pin, OUTPUT);                          // Set the Triac pin as output
  attachInterrupt(0, zero_cross_detect, RISING);    // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
  Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
  Timer1.attachInterrupt(dim_check, freqStep);      
  // Use the TimerOne Library to attach an interrupt
  // to the function we use to check to see if it is 
  // the right time to fire the triac.  This function 
  // will now run every freqStep in microseconds.                                            
}

void zero_cross_detect() {    
  zero_cross = true;               // set the boolean to true to tell our dimming function that a zero cross has occured
  i=0;
  digitalWrite(AC_pin, LOW);       // turn off TRIAC (and AC)
}                                 

// Turn on the TRIAC at the appropriate time
void dim_check() {                   
  if(zero_cross == true) {              
    if(i>=dim) {                     
      digitalWrite(AC_pin, HIGH); // turn on light       
      i=0;  // reset time step counter                         
      zero_cross = false; //reset zero cross detection
    } 
    else {
      i++; // increment time step counter                     
    }                                
  }                                  
}                                   

void loop() {                        
  dim+=inc;
  if((dim>=128) || (dim<=0))
    inc*=-1;
  delay(18);
}

Arduino controlled light dimmer schematic

Step 7: Software To set level using up and down buttons

Below a code to set the light level with up and down buttons. It uses a timer that checks for the time necessary to trigger the TRIAC, rather than wait in a delay loop

/*
AC Light Control
Uses up and down buttons to set levels
makes use of a timer interrupt to set the level of dimming
*/
#include <TimerOne.h>           // Avaiable from http://www.arduino.cc/playground/Code/Timer1

volatile int i=0;               // Variable to use as a counter of dimming steps. It is volatile since it is passed between interrupts
volatile boolean zero_cross=0;  // Flag to indicate we have crossed zero
int AC_pin = 3;                 // Output to Opto Triac
int buton1 = 4;                 // first button at pin 4
int buton2 = 5;                 // second button at pin 5
int dim2 = 0;                   // led control
int dim = 128;                  // Dimming level (0-128)  0 = on, 128 = 0ff
int pas = 8;                    // step for count;
int freqStep = 75;              // This is the delay-per-brightness step in microseconds. It allows for 128 steps
                                // If using 60 Hz grid frequency set this to 65

 
void setup() {  // Begin setup
  Serial.begin(9600);   
  pinMode(buton1, INPUT);  // set buton1 pin as input
  pinMode(buton2, INPUT);  // set buton1 pin as input
  pinMode(AC_pin, OUTPUT);                          // Set the Triac pin as output
  attachInterrupt(0, zero_cross_detect, RISING);    // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
  Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
  Timer1.attachInterrupt(dim_check, freqStep);      // Go to dim_check procedure every 75 uS (50Hz)  or 65 uS (60Hz)
  // Use the TimerOne Library to attach an interrupt

}

void zero_cross_detect() {    
  zero_cross = true;               // set flag for dim_check function that a zero cross has occured
  i=0;                             // stepcounter to 0.... as we start a new cycle
  digitalWrite(AC_pin, LOW);
}                                 

// Turn on the TRIAC at the appropriate time
// We arrive here every 75 (65) uS
// First check if a flag has been set
// Then check if the counter 'i' has reached the dimming level
// if so.... switch on the TRIAC and reset the counter
void dim_check() {                   
  if(zero_cross == true) {              
    if(i>=dim) {                     
      digitalWrite(AC_pin, HIGH);  // turn on light       
      i=0;  // reset time step counter                         
      zero_cross=false;    // reset zero cross detection flag
    } 
    else {
      i++;  // increment time step counter                     
    }                                
  }    
}                                      

void loop() {  
  digitalWrite(buton1, HIGH);
  digitalWrite(buton2, HIGH);
  
 if (digitalRead(buton1) == LOW)   
   {
  if (dim<127)  
  {
    dim = dim + pas;
    if (dim>127) 
    {
      dim=128;
    }
  }
   }
  if (digitalRead(buton2) == LOW)   
   {
  if (dim>5)  
  {
     dim = dim - pas;
  if (dim<0) 
    {
      dim=0;
    }
   }
   }
    while (digitalRead(buton1) == LOW) {  }              
    delay(10); // waiting little bit...  
    while (digitalRead(buton2) == LOW) {  }              
    delay(10); // waiting little bit...    
           

  dim2 = 255-2*dim;
  if (dim2<0)
  {
    dim2 = 0;
  }

  Serial.print("dim=");
  Serial.print(dim);
  Serial.print("     dim2=");
  Serial.print(dim2);
  Serial.print("     dim1=");
  Serial.print(2*dim);
  Serial.print('\n');
  delay (100);

}

 

 

For more detail: Arduino controlled light dimmer

The post Arduino controlled light dimmer appeared first on PIC Microcontroller.


Computer Controlled Star

$
0
0

In this instructable I am going to show you how to build a Star with 64 LEDs. The Star operates by itself but the operation mode can be changed when connecting it to a computer via a serial (RS232) interface. After reconfiguring the Star via the computer, the Star will use the new operating mode as the new default.

The Star can of course be used during the Christmas period but it can also be used as a night light on a children’s bedroom since the stars has various modes that could help kids to go to sleep. This has not been proven by research :-).Computer Controlled Star

To summarize, the star has the following main features:

  1. Control 64 LEDs individually with different brightness. The brightness can be set from 0 (off) to 15 (maximum). The Star uses an initial pattern when switched on but this pattern can be changed via the serial interface.
  2. Blinking mode, which is changing the brightness of the individual LEDs to create a blinking Star effect. A variant to the blinking mode is the sparkling mode. See the attached document in one of the next steps for more info on this.
  3. Test mode. This mode can be used to see if you build the star correctly.
  4. Flashing Star mode. In this mode you can program your own sequence of LEDs that the Star will then use to switch these LEDs on and off one after another with the given brightness.
  5. Random mode. The random mode can be used in various ways, e.g. for generating random Star patterns but also to create a random flashing Star pattern.
  6. Auto off mode. When activated, the LEDs are slowly turned off. This is a nice feature when you use it in a children’s bedroom (‘You have to sleep before the star is off :-)”.

My hobby is in electronics and software development and I am not an expert in mechanical constructions so feel free to create your own variants. The housing is built using 8 mm and 4 mm MDF, glued with wood glue. The electronics is based on a PIC microcontroller.

See the following video in which the various functions are demonstrated. Since the LEDs are multiplexed, it may sometimes be a bit difficult to see the exact changes in operation but I think that in most cases it is visible.

Star Demo Video

Step 1: Step 1: Star ingredients

So you need to have the following to create this Star:

  1. 8 mm MDF panel
  2. 4 mm MDF panel
  3. 1 strip of wood of 4 mm by 9 mm
  4. Wood glue
  5. 1 bread board for assembling the electronics
  6. Paint. I used Silver colored paint
  7. 64 * White LEDs (in fact I only mounted 63 LEDs)
  8. 1 * Yellow LED
  9. 1 * Fuse of 200 mA/Slow + fuse holder
  10. 1 * 9 pin Female D-Connector
  11. 1 * PIC microcontroller 16F1825 + 14 pin IC socket
  12. 1 * MAX232 RS233 driver IC + 16 pin IC socket
  13. 2 * 74HC595 shift registers + 16 pin IC sockets
  14. 1 * LM2940 Low drop 5 Volt regulator
  15. 1 * 1N5819 Shottky diode
  16. 1 * 33 k resistor
  17. 5 * 1 uF/25 Volt electrolytic capacitor
  18. 1 * 47 uF/16 Volt electrolytic capacitor
  19. 1 * 470 uF/16 Volt electrolytic capacitor
  20. 5 * 100 nF ceramic capacitor
  21. 8 * BC557 transistor
  22. 8 * BC639 transistor
  23. 8 * 2k resistor
  24. 8 * 1k resistor
  25. 9 * 220 Ohm resistor
  26. 1 * 16 pin female header (I used 17 pins but that is not mandatory)
  27. 1 * 16 pin male header (same remark about the 17 pins)
  28. 1 * DC adapter, 6 Volt/200 mA

Step 2: Step 2: Building the Electronics

See the attached schematic diagrams that show the following parts:

  1. Power supply with PIC microcontroller and RS232 interface
  2. Shift registers
  3. LED output drivers
  4. LEDs in an 8 by 8 matrix

The first three parts are assembled on a bread board. The LEDs are mounted on a front panel as described in the next step.

LEDs and bread board are connected using a female header on the bread board and a male header for the connection with the LEDs on the front panel.

With the attached Intel Hex file you can program the PIC microcontroller.Computer Controlled Star schematic

Step 3: Step 3: Creating the front panel with the LEDs

The front panel is made with 8 mm MDF and contains the holes for all 5 mm LEDs. Before I mounted the LEDs, I first sprayed the front panel with Silver paint. Note that only 63 LEDs were mounted because otherwise it would not give a symmetrical layout.

The LEDs are connected in a matrix of 8 by 8 according to the schematic diagram given in the previous step. I used Kynar wire to connect the wires. It is recommended to use different wire colors as much as possible. The wires are finally connected to the 16 pin Male header. The order of the wires is not important. It is only important to remember which wires are the scan lines and which wires are the return lines. Note that the Male header has to be mounted after the wires have gone to the back panel, see the next step.

For the front panel to be connected to the back panel you need a small trip of wood that is glued around the edges of the front panel as shown in the photo.

 

 

For more detail: Computer Controlled Star

The post Computer Controlled Star appeared first on PIC Microcontroller.

How to Create an Eye Catching Display (LED Style)

$
0
0

This is not as much an instructable as a record of how I made a school project. While repeating exactly what I did will probably not help y

ou, this project can be modified to make almost any display more eye-catching.

How to Create an Eye Catching Display (LED Style)

Step 1: Come up with an Idea

I know this sounds stupid but it is necessary to know at least roughly what you are trying to do. In this case, I wanted to somehow incorporate astronomy and draw attention to my poster. With this in mind, I came up with a cheesy saying and a plan for the placement and animation of the LEDs.

Step 2: Generate a poster design

The next step is to create a conventional poster, either by writing/drawing it out on paper or posterboard or by using a program such as Jasc Paint Shop Pro or Adobe Photoshop. Be sure to do a good job here as a great electronics display can only help a crappy poster so much.

Step 3: Gather tools and materials

Now the fun begins.
You will need:
-Clamps
-A saw
-Some sort of marker or sharpie
-A straight edge
-Tape (scotch or other clear variety)
-Soldering iron
-Solder
-Desoldering bulb
-Wire cutters
-Needle nose pliers
-Vice grips
-Wire strippers
-Electrical tape or heat-shrink tubing
-A backer for the poster (I used masonite but stiff cardboard or sheet PVC should work)
-Sandpaper (medium grit)
-A microcontroller
-A power source
-LEDs
-Resistors
-Jumper wires
-A breadboard to test it all
…and a partridge in a pear tree.

Don’t worry, it sounds like more than it actually is.How to Create an Eye Catching Display (LED Style) schematic

Step 4: Make backer

While you probably have a very beautiful poster at this point it is not nearly thick enough to support the electronics. Using the straight edge, mark a piece of the backer board the same size as the poster and cut it out.

Step 5: Sand down the edges

When you cut the masonite it will probably have rough edges. Five minutes with a piece of sandpaper can go a long way towards making your display look nice.

 

For more detail: How to Create an Eye Catching Display (LED Style)

The post How to Create an Eye Catching Display (LED Style) appeared first on PIC Microcontroller.

Remote Control mood light[/jar]

$
0
0

I wanted to play around with something IR remote-controlled, so I decided to make a remote-control mood light. There were two parts to the project: making the remote and making the light. For the remote, I tore down a remote control for a floor fan, removing all its insides, and replacing it with mine. I used a PIC12F1840 micro for the remote, mostly since I have a lot of these lying around. For the receiver, I used the same microcontroller. The enclosure for the mood light? a glass jar with some paper to diffuse the light (I am not too much into making enclosures). There were some interesting issues along the way, but now the project pretty much works. It has 4 high-brightness LEDs in it: White, Red, Green, and Blue.

Remote Control mood light

Features? Currently the device has 2 modes, switchable using the “Mode” button. “On/Off” turns the device on and off, as expected. Settings are backed-up in EEPROM, so after any power loss, device comes back to the same mode and settings as it was in when it was last on. Fade mode fades between colors randomly, with adjustable speed and brightness. Adjustment is made using the “up”/”down” buttons. What is adjusted is selected using the “O” button. Increasingly bright white blinks after pressing the “O” button mean you’re in brightness adjustment mode. White, Red, Green, Blue flashes after pressing the “O” button mean you’re adjusting speed. Solid mode is a solid color, each of whose WRGB components is adjustable up/down using the “up”/”down” buttons. Current component is selected using the “O” button – when pressed, it flashes just that color for half a second to indicate what you’re adjusting. Selected color is saved when you switch modes, and restored when you re-enter solid mode. When in off mode, you can anter diagnostic mode by entering on the remote: “Up Down Up Down O O”. This shows some values using LEDs. Each value is preceded by a color to indicate the meaning. Then decimal digits of the value are sent, one at a time, using dimwhite blinks. The end of each digit is signified by a bright white blink. So to send 102 we’d see a dim white blink, a bright white blink, another bright white blink, two dim white blinks and a bright blink. For now only two vales are shown. Software version (color code green) and remote battery voltage (color code blue). The code is very modular, so adding new modes is dead easy.

The remote has 5 buttons, with black labels on grey background. I used a sharpie to color the background black, hiding the labels, except “on-off” and “mode.” Outlines of arrows were left grey next to two buttons and a circle next to third. So now the buttons are “Mode”, “Up”, “Down”, “O”, “On/Off”. Internally, the PIC reads the buttons by connecting them to pins RA0 – RA4, with internal pullups enabled and the other end of buttons grounded. This is where I hit the first snag. I was expecting to use Interrupt-On-Change to wake the PIC from low-power sleep when a button is pressed. No matter what I did, this feature would not work. I had used it on previous models of PIC devices successfully, and I’ve been through the doc over and over, with no results. I am now reasonably convinced that this must either be a mistake in the docs, or a silicon problem. Now this was a major problem. No low power sleep means no way to not run through another set of batteries every week. After some thoughts, I decided to measure the power consumption of the PIC while running on its LFINTOSC oscillator at 31KHz. It was less than 0.01mA. I guess this is low power enough. So now whenever I need to wait for button presses, I switch to LFINTOSC, and repeatedly read the port pins and look for changes.

Remote Control mood lightI would love to have a working sleep mode, but sadly that appears impossible with this chip. The chip switches to 4MHz HFINTOSC-generated speed when sending a signal, and then back to low power mode when it is done with that.

The physical layer of the communication on the remote side is a single 940nm IR LED with a 38.6 KHz carrier frequency (generated by the CCP/PWM module). Data is sent in 8-bit bytes, MSB first. Each bit is a sequence of 0.5ms of modulated light, followed by 1 or 1.5 ms of darkness. 1.5ms means bit is 1, 1 ms means bit is 0.

 

For more detail: Remote Control mood light[/jar]

The post Remote Control mood light[/jar] appeared first on PIC Microcontroller.

Interactive LED Beer Pong Table 2.0 (BPT X5)

$
0
0

The nice thing about building one of these tables from a kit is that the more difficult parts of the project have been completed (Electronic Design, PCBs made, etc.) but more importantly, you can fully customize the table to your liking. The photos that I posted above are of the version that I created, but you can completely change the layout of your table. Add more LEDs to the unused PWM channels, maybe you’ll switch out the LED rings for small LED signs/logos, completely omit the LED grid and just add LED strips, etc etc. There are a lot of extra PWM channels that aren’t aren’t in use on the master PCB and can be put to use!

If you do plan to swap out certain LED modules (like the LED rings), you must take care not to exceed the maximum ratings of the transistors that are driving those devices. This is all listed in detail later in the Instructable. For now, just take a moment to come up with a new layout for the wickedest beer pong table this world has ever seen. Once you’re done that, continue through the Instructable and assemble it!

Note
The source code, CAD files, schematics and bill of materials are all included in the downloadable zip file in this step.

Step 2: Preparation: Project Overview

Version 2.0 of the beer pong table has many added features that the original table never had. On top of that, this Instructable will show how to build a 2’x8′ table instead of the 3’x8′ size of the first table (I did this as I wanted to create a table with a smaller footprint. I.e. less space needed for it and cheaper to ship). You will also notice that the PCBs and wiring is completely encased inside of the table, whereas the other table j

ust had an open bottom.

This new table has 1122 total LEDs on it, it is capable of controlling up to 608 individual channels (96 of which are capable of 16-bit PWM), it only has one master PCB and the 20 RGB pod PCBs, it can read and write to an SD card, it has a 16×2 LCD display, an IR receiver built into the table so that it can be controlled with a remote, a breakout connector for VU meter capabilities, a bluetooth module and a couple more features. The breakdown of the features are listed below.


LED Grid

In the center of the table we can create any animation that will fit into a 32×12 pixel grid. We are able to display scrolling text across it, watch a pong animation, display a sine wave, display the score of the game, etc. There is a huge amount of possibilities! Since we are able to detect when a cup is removed from the table we can make specific animations that trigger exactly when that happens. We’ll get more in-depth with that later. The table actually supports a maximum display size of 32×16, however I have made it only 32×12 to span further across the table.

 

Interactive LED Beer Pong Table 2.0 (BPT X5)

20x RGB Pods w/ Infrared Sensors
At each end of the table you will see 10 pods. The 16oz cups that are used for beer pong are placed over top of these pods. Each pod contains 6 RGB LEDs and 1 infrared sensor and we are able to light up the pods with any color that we would like. The infrared sensor will detect whether or not a cup is over top of the pod, so if a cup is removed we can change the color of the pod, begin an animation on the LED grid, run an animation on the RGB pods, etc.


Air Baths

There is an air bath on each side of the table. The purpose of the air bathes are to blow any debris off of the ping pong balls, thus cleaning them. When a player drops a ball to their left into the “IN” hole of the air bath, it detects the ball and starts a fan. This fan will move the ball down a pipe, removing debris and blowing it out the “OUT” hole to the right of the player. The player then grabs the ball and the air bath shuts off. Players can also dunk the ping pong balls in a cup of water before putting them into the air bath to get a better clean.


LED Rings

There are a total of 12 LED rings on the beer pong table. The outer edges of the table contain 4 LED rings each and the air baths make up the other 4. Much like the 32×12 LED grid, the LED rings are just used for animations. They can be set to go in accordance with music (VU Meter feature must be turned on), fade in and out, flash rapidly or any other cool animation that you can think of. Beer cups can be set inside of the LED rings on the railing which provides a cool effect on the upper lip of the cup. This table can support up to 16 LED rings on the specified PWM channels and the LED rings can be swapped out for many other LED circuits, such as small LED logos.


VU Meter

A user can add a VU meter module to the master PCB and set up the table to dance to different frequencies in the music around it. One can use the AUX input to feed the audio directly into the microcontroller or opt to use the built-in microphone to detect audio around it. The VU Meter can be set up to activate any LED lights to any of the 7 available frequencies that the microcontroller can detect. This is a really neat feature and the animation possibilities with it are endless.

Bluetooth Module
This beer pong table contains a bluetooth module which allows it to communicate wirelessly with PCs or mobile devices. This is still in the alpha stage, but in the future it will allow the beer pong tables firmware to be updated wirelessly. This is a huge plus as it allows even greater hackability for users. On top of that, we can use it to send the score of the game or control individual features on the table.


Micro-SD Card

“Why would a beer pong table ever need an SD card”, you ask? It’s simple. I want users to be able to design animations on their PC with custom built software, save it to a file, load that file onto an SD card then insert it into the table where they can display their own custom animations! More than anything, this is storage space for custom user animation files. I plan to make it so that the SD card doesn’t need to be pulled out of the table and that files can be copied to it over the bluetooth link from a PC. This feature is also in an alpha stage.
 RGB Underlighting
We have so many lights on top of the table, why not put some on the bottom too! This table has three dedicated 16-bit PWM channels solely for the use of RGB underlighting. I mean, with all of the other lights in the room, we may as well change the color of the floor too.


16×2 LCD Display

A small 16×2 LCD display has been added to the new table so that we have a quick way of changing table settings, viewing score or accessing menu options.


IR Receiver w/ Remote

Sometimes it is just too much of a hassle to control the table over bluetooth with a PC or mobile device and we want a faster way to do it. Enter the 24 button infrared remote. Want to display a different animation? Dim the brightness of the RGB pods? No problem, grab the remote and do it instantly. You can also use the 16×2 LCD display to change menu settings in conjunction with the remote.


EEPROM Memory

The master PCB does contain an EEPROM chip which has not been implemented quite yet (I still have to write the code for it). This chip is used to save any user settings between power cycles and may hold the button codes for future IR remotes.


Extra PWM Channels

Now if all of the LED features listed above aren’t enough and you yearn for more lights, you’re in luck. With a small breakout PCB, you can control up to twelve more 16-bit PWM channels. That means more fading animations, more LEDs and more excitement! In all reality, you may be hard-pressed to find enough room on the table for all of the LED features! 😉

Step 3: Preparation: Fully Assembled Kit Walkthrough

This kit contains all of the electronic components that the “Unassembled Kit” contains and has them already soldered on the PCBs. The LED grid does not come pre-assembled seeing as it has to be built into the table itself, but all of the LEDs and wiring for it are included in this kit and can be assembled when the table is built.

All of the PCBs are fully operational and tested before being shipped out and the microcontroller is pre-programmed with the bootloader so that the firmware can be updated over bluetooth. All of the connectors and wiring harnesses are assembled and have been tested with their respective parts. With this kit you don’t need a lot of technical know-how as it is pretty much plug and play except for the LED grid which has to be soldered together. If you can wield a soldering iron to make the LED grid and have the skills to build the table, this kit might be a good choice for you.

Step 4: Preparation: Unassembled Kit Walkthrough

This kit contains all of the parts that are included in the “PCB Only” kit as well as all of the electronic parts and components needed to assemble the PCBs and LED features. As the name of the kit states, the PCBs and connectors come unassembled and have to be put together by the backer. This kit requires advanced soldering skills for the various types of SMD components that have to be populated on the PCBs. You will also need a PIC programmer to get the initial bootloader programmed into the microcontroller, after that initial programming, you can then program over bluetooth.
Each component has to be soldered onto each PCB, meaning that this kit requires good soldering skills and a decent soldering iron. There are some really small SMD parts that only have 0.28mm between pins, so you need a steady hand. I do provide video instructions later in the Instructable that shows how to solder some of these small components.

Step 5: Preparation: PCB Only Kit Walkthrough

This kit comes with all of the PCBs that are required to create your own Interactive LED Beer Pong Table. It contains 1x Master PCB, 20x RGB pods, 1x 50-Pin Breakout Header for the LED grid and 1x LCD Display Breakout PCB which makes it easier to connect up the LCD to the X5 board. It also includes an IR remote along with the custom air bath motor mounts and sensor brackets.

This is the most advanced kit, as none of the electronic components are included in this kit and they have to be purchased separately. The bill of materials and other information for this kit can be downloaded from the main zip file in step #1.

Each component has to be soldered onto each PCB, meaning that this kit requires good soldering skills and a decent soldering iron. There are some really small SMD parts that only have 0.28mm between pins, so you need a steady hand. I do provide video instructions later in the Instructable that shows how to solder some of these small components.

Step 6: Preparation: Skills and Software Required

If you look at this project as a whole it may seem very intimidating. The trick is to break each part down into ‘mini’ projects and integrate them together. You don’t build the whole project, wire everything together and then turn it on hoping that it will all work because chances are that it won’t. Instead, we take baby steps and separate the project into smaller sub-projects, testing the workings of each sub-project before moving on to the next one. By doing it this way you can work out any issues one at a time as you progress.
If you plan to use a fully assembled kit where you only have to do minimal soldering (LED grid), hook up the RGB pods to the main PCB and if you are using a table that you purchased from somewhere, you will only need the following skills to be able to build your own table:

  • Basic soldering skills (soldering a wire to an LED)
  • Ability to operate power tools (Mostly a drill to secure parts to the table)
  • Ability to follow basic instructions

If you plan to use a PCB Only kit or a kit where you have to assemble the PCBs/connectors and you’re building your own table, you should possess the following skills:

  • Advanced soldering skills (SMD parts)
  • Ability to operate power tools (Drill, table saw, mitre saw, jigsaw, etc.)
  • Ability to program PIC microcontrollers
  • How to crimp ends and create cables (Molex, RJ45 and IDC connectors)
  • Ability to follow instructions
  • Basic understanding of C Programming & digital electronics (not absolutely needed, but will help)

If you order a PCB only or an unassembled kit and are bad at soldering, you may want to get
somebody who is good at it to help you. Some parts only have a 0.28mm space between pins.


Software

All of the software for the beer pong table has been written in C. You will need to download the MPLAB IDE and install it, as well as the C30 or XC16 compiler to go with it. This project has been set up with the free versions of those compilers and either compiler will work. The XC16 compiler is the newer one of the two and is the one that I use. The MPLAB IDE can be downloaded here, while the XC16 compiler can be downloaded here. You can see a large portion of Microchips software downloads here.

Step 7: Preparation: Electronic Components

There are 21 PCBs that are required to create this project. Now, 20 of those PCBs are actually single RGB Pods that are placed under the cups (10 on each side). The other PCB is the main control board and is the brains of the operation. There is also a small 50-pin breakout PCB that is included with each kit. That PCB is used when creating the LED grid and connects the LED grid to the main PCB (more instructions on that later).

I have added a component list for each of the PCBs, as well as a list for the cables/connectors. The majority of these components can be found on eBay but there are a select few which may prove more difficult to find. I have added a BOM to the zip file in step #1 which has each component, the required quantity, the price and the vendor where the component(s) can be purchased.

Step 8: Preparation: Required Materials

Now we need to acquire the materials that go along with the electronics. Here is a list of the materials needed to complete this project. Where I’m from, stock measurements on materials are still in imperial units so I do switch back and forth between metric and imperial units in this instructable. When I cut the material for the table I use imperial units, when I am modifying the table and drilling holes I use metric (as you will see on my CAD drawings).

I bought all of my plywood from Home Depot and had them do the large cuts for me for $1 per cut. Use a combination of a table saw and a mitre saw to cut the rest of the pieces down to the sizes that you need if you choose to do it yourself. As for the acrylic sheet, just find a local plastics supplier and get a quote from them. My 24″x96″x1/8″ acrylic sheet cost me $60, which was $23 cheaper than the Lexan sheet that I put on my original table.

Step 9: Preparation: Tools Needed

We’re almost ready to start building! The last thing that we need to do is gather up some tools. If you don’t feel comfortable using a table saw, talk to a local carpenter and have them cut the wooden rail pieces for you. They are really basic cuts so I would imagine that it would be a relatively cheap price. Below is a list of tools that we will use to construct the table and the PCBs (if you are not building your own table, you will not need the majority of these tools).

Tools

  • Drill
  • Jigsaw
  • Table Saw
  • Mitre Saw
  • Hole Saw
  • Soldering Iron
  • #2 Robertson Screwdriver
  • #1 Robertson Screwdriver
  • Wire Cutters
  • Wire Strippers
  • Molex Crimpers
  • IDC Crimpers
  • RJ45 Crimpers
  • Glue Gun
  • Rotary Tool
  • Router (Optional)

Those are the tools that I had used to complete this project. You may be able to get away without some of the tools there, but it gives you a rough idea of what kind of work is involved.

Step 10: Construction: Assembling The Master PCB

Applies To
PCB Only Kit
Unassembled Kit


Doesn’t Apply To
Fully Assembled Kit (This step is already done for you)

Before we begin constructing the physical table, lets get the electronic aspect of this project in order. There are a total of 163 parts that need to be soldered onto the Master PCB, 661 SMD pads that need to be soldered and 355 through-hole pads. It may seem daunting, but just remember, you only have to do this once! Even if it takes you three hours to complete, it’s a one time deal.
The biggest caveats on this PCB are the small SMD components. In particular, the PIC, the two TLC5955’s,the 74LVC2G125DCUR and the twelve 0603 network resistors. You will need to perform one extra step for the TLC5955’s in order to solder the heatsink pads underneath them to the PCBs. The best way to explain how to do it is with a video, so watch away!

I do have a reflow station on hand and that is what I use, but I wanted to show in the video that it can be done with a heat gun or a hairdryer for those who don’t have reflow stations (It can also be soldered by heating up the thermal vias with a soldering iron. See the last two photos in this step). As for soldering the 64-pin PIC microcontroller, that’s even easier than the TLC5955’s. The soldering process of the video below has been sped up 2x but you’ll get the idea. Lots of flux, a small soldering iron tip and thin soldering wire are pretty crucial though.

The schematics, bill of materials and the parts list are all located in the zip file in step #1.

Step 11: Construction: Assembling The RGB Pods

Applies To
PCB Only Kit
Unassembled Kit

Doesn’t Apply To
Fully Assembled Kit (This step is already done for you)
The RGB pods are quite simple to assemble, whether you assemble them with the reflow method or by hand soldering, they aren’t difficult. There are twenty of them to do though, so it may take you an hour or two. The PCBs that I have used in the photos above were the first production run of the new RGB pods, I have since changed the PCB color of the RGB pods to black which you can see in the last few photos.

Parts List For All 20 Pods

  • 120x – RGB 5050 SMD LEDs
  • 100x – 270Ω SMD 0805 Resistors
  • 60x – MMBT2907A Transistors
  • 40x – 330 SMD 0805 Resistors
  • 20x – 18k SMD 0805 Resistors
  • 20x – TCRT5000 IR Sensors
  • 20x – IDC 2×4 Shrouded Headers

There are a total of 19 components per RGB pod, 17 of those components being surface mount packages. They are quite simple to assemble whether you use the reflow method or do each pod by hand. The reflow method is really only necessary if you are assembling a large amount of RGB pods or have access to cheap solder stencils. After you’re done assembling the RGB pods, we’ll start on the IDC cables to connect them up to the Master PCB!

Step 12: Construction: Assembling the 2×4 IDC Cables

Applies To
PCB Only Kit
Unassembled Kit

Doesn’t Apply To
Fully Assembled Kit (This step is already done for you)
Now that we have the PCBs assembled, we need to assemble the cables to connect the RGB pods to the Master PCB. When I designed this kit, I specifically decided to use 2×4 IDC cables because of the simplicity to crimp the connectors to the cable. With these cables, we can crimp all 8 connections in the connector at once, instead of doing it one by one for each wire like many other connectors. This saves an enormous amount of time as there are 40 connectors that need to be crimped for all 20 RGB pods.

The crimping tool that I use for my IDC connectors can be bought here on eBay for around $20. If you don’t want to buy the proper tool, one can get away with using a pair of vice grips or an actual vice itself to crimp the connector to the cable.

Crimping IDC Connectors

  1. Get all three parts of the connector. Piece #1 is the main connector with the crimp tabs sticking out of it, piece #2 is the middle part with grooves on the inside to hold the ribbon cable in place and piece #3 is the strain relief.
  2. Sandwich the 8P ribbon cable between piece #1 and piece #2. Take note of which wire is connected to pin #1 on the connector (Pin #1 is denoted by an arrow on top of the connector).
  3. Once the cable is lined up between the two pieces, insert the connector into your crimping tool and apply steady pressure to the connector until the two pieces snap together.
  4. Fold the cable down the back of the connector, pulling it tight.
  5. Insert piece #3 into piece #2 and snap them together with your thumb. This will create a strain relief for the connector.
  6. Now repeat the exact same process for the connector on the other end of the cable, making sure that pin #1 connects to the same wire on each connector.

Step 13: Construction: Assembling The LED Rings

Applies To
PCB Only Kit

Doesn’t Apply To
Unassembled Kit
Fully Assembled Kit (This step is already done for you)

We’re going to make the LED rings right now as we need to use them in the next few steps (for the layout of the table). First, cut out a 71mm diameter wooden cutout for each LED ring that you will be installing on the edge of the table (not counting the ball washers). For this table that number is eight.

Now grab your 24 LED strip and go to the end of it where the wire is sticking out. Remove a small piece of silicone just below the wire and route the wire through that channel so that it is sticking out the bottom of the strip. Form the LED strip around one of the wooden cut-outs and tighten a zip-tie around it, creating a LED ring.

If you don’t like the look of the ring with a zip-tie around it (even though it will be hidden under a diffuser on the finished table), put superglue on each end of the strip and form it into a ring (use a heatgun or hair-dryer if it gives you trouble forming it. Heating up the silicone allows it to form easier). Once it dries in place, fit it over top of one of the wooden cutouts and glue the underside of the LED ring to the cutout, ensuring that they are one piece right now. Whichever option you choose to do, repeat it for the other 7 LED rings.

I sprayed a diffuser over top of each of my LED rings, but that may not be needed as I decided to put a diffuser over top of the whole table anyways. So it’s completely optional.

For the ball washer LED rings, cut off 3 LEDs from the end of each strip. There are 4 LED rings which are used with the ball washers. The LEDs in the LED strips are wired in threes, if you cut off just one LED then the other two LEDs that are wired in series with it won’t work anyways.

Don’t add a wood cutout to each ball washer LED ring as they will be fitting around a small piece of ABS pipe used with the ball washer. Just set them to side once you have them made.

Step 14: Construction: Building The Table

Applies To
PCB Only Kit
Unassembled Kit
Fully Assembled Kit
If you are just going to modify a table that you purchased somewhere else, you can skip these instructions. These are just the instructions for how I built my table, one could actually just buy a plastic table from Wal-Mart and modify that to suit their needs.

I don’t have a lot of pictures showing my table build so I will resort to using my Sketchup CAD drawings to better explain how the table goes together. The Sketchup drawing does not show where each screw hole is, but I’m going to assume that if you’re building this table that you can handle that (otherwise just ask and I’ll draw up a quick sketch!). Make sure to drill pilot holes before threading in each screw or you will probably end up cracking the wood! I used a 1/8″ drill bit for a pilot hole with #8 1.5″ Robertson screws.

It’s a pretty basic table, the overall size of it will come out to 24″x96″x4″ without the legs, railing and acrylic sheet. Here is a list of the following parts that are needed:
Parts (Imperial Measurements)

  • 2x – 24″x96″x1/2″ Pieces of plywood
  • 2x – 3″x96″x1/2″ Pieces of plywood
  • 5x – 3″x23″x1/2″ Pieces of plywood
  • 1x – 72″ Hinge


Parts (Metric Measurements)

  • 2x – 609.6mm x 2438.4mm x 12.7mm Pieces of plywood
  • 2x – 76.2mm x 2438.4mm x 12.7mm Pieces of plywood
  • 5x – 76.2mm x 584.2mm x 12.7mm Pieces of plywood
  • 1x – 1828mm Hinge

Following the photos above, attach all 4 sides to the 24″x96″ bottom base of the plywood.Secure each piece with multiple screws from the bottom of the table up into each side piece of the table. Make sure to drill pilot holes or you will crack the side pieces. After drilling the pilot hole and before putting the screw in, use a countersink bit (or just a large drill bit) and countersink the hole so that the head of the screw is not sticking above the surface of the wood.

Now add the braces. Take the remaining three 3″x23″x1/2″ pieces and put three 1″ holes into each brace. We will use these holes for routing the cabling. Install these braces inside of the table at 609.6mm intervals from end to end. Put a strip of weatherproof tape on each piece of wood that makes up the top of the base.

Once you’ve got the base of the table built, you need to attach the 72″ long hinge across the top and bottom of the table. I recommend drilling out the ball washer holes on the lid prior to installing the hinge but it can be done either way. Measure 12″ in from one end of the table, line up the hinge with the lid and base of the table, drill a pilot hole for each screw and then thread each screw in and secure the hinge. Once the hinge is on, open the lid up to a point just before it is perpendicular to the base, then secure a strong piece of wire (I used silicone tubing so that it has give) between the base of the table and the lid. This ensures that the table lid won’t over extend and fall to the other side, possibly causing damage.

I plan to swap out the hinge with some cupboard like hinges that will be hidden on the inside of the table and still allow it to open up. This hinge is an eyesore but it gets the job done for now.

Step 15: Construction: Adding The Supports

Applies To
PCB Only Kit
Unassembled Kit
Fully Assembled Kit
Parts (Imperial Measurements)

  • 2x – 1″x96″x½” Plywood Pieces
  • 2x – 1″x22″x½” Plywood Pieces
  • 4x – 1″x19¾”x½” Plywood Pieces (These have to be angled)


Parts (Metric Measurements)

  • 2x – 25.4mm x 2438.4mm x 12.7mm Plywood Pieces
  • 2x – 25.4mm x 558.8mm x 12.7mm Plywood Pieces
  • 4x – 25.4mm x 492mm x 12.7mm Plywood Pieces (These have to be angled)

In this step we will be adding supports for the acrylic sheet. This ensures that the sheet does not bend or bow on the table. We also have to cut out four notches on each side rail to accommodate the size of the LED rings. The photos above are pretty much crucial to this step and will explain how to do this much better than I can through text. Use the CAD drawings above and measure out four LED rings, marking all four spots on one side of the table.

Attach the rail to the table (temporarily) and then take one LED ring and go over top of each location. Trace around the portion of the ring that intersects with the rail with a pencil. Do this for all four LEDs on the rail and then take the rail over to your drill press. Use an 89mm (3.5″) hole saw bit in the drill and line the notches of the rail up with the bit. Put a piece of scrap wood underneath the rail and clamp the rail to it once the first notch is lined up. Proceed to cut out the notch. Do this for the other three notches on the rail, taking care to keep the rail supported as it will get weaker with each notch cut out.

To save time on the second rail, take the one you just completed and set it on top of the uncompleted rail. Line them up together, clamp them together and trace each notch onto unfinished piece. Then repeat the process at the drill press to cut out the rest of the notches on the second piece. Once finished, attach each side rail and end rail to the table. Install each LED ring, drilling a small hole to fit the connector and wire underneath the lid. Now we just have to finish the supports on the inside of the table.

Use the CAD drawing above and cut out four pieces for the RGB pod supports. If you are painting your table, now is a good time to paint the supports. Measure in 17.51mm from one egde of the table, put the support in place, then put the mirrored support up against it. Measure the mirrored support to the edge and ensure that it is centered. Secure each support to the table and countersink each hole. I ended up adding these supports when I finished my table which you will see in the photos above.

Step 16: Construction: Creating The LED Grid

Applies To
PCB Only Kit
Unassembled Kit
Fully Assembled Kit (This is the only electronic assembly required from this kit as it has to be built into the table)

Note:
I will be updating this step with more information soon. I provide many options to lay out the LED grid but I will cut down on some of the photos and make things more clear.


EDIT

I have added a 3rd option in regards to wiring up the LED grid. It is similar to option #1 where you have to mount each LED into the tables lid but it also utilizes the capabilities of a router. Instead of spending a ton of time wire wrapping each LED lead, you can just cut out straight tracks in a grid-like formation and lay copper tape in each track. The row tracks are cut deeper into the table than the column tracks, allowing us to separate the copper tape from each column/row intersection and prevent shorting. I found this to be the fastest way for me to create this painstaking LED grid. Use the last of the photos to get a clearer understanding of option #3.

Wiring Up the LED Grid
In my opinion, this is the most tedious part of the table. The 32×12 LED grid consists of 384 LEDs (the circuit can control up to a 32×16 LED grid actually) that can be individually controlled. It is, arguably, the coolest feature of the table but also the most boring to build.
In this step, I will show three options to build the LED grid. The first option requires drilling a hole into the table for each LED, setting it into the table and gluing it in place. Then underneath the lid of the table, we have to solder each row and column connection for each LED. We then finish off the grid by connecting the grid to the 50-pin breakout PCB so that it can be interfaced with the master PCB. This is by far the cheapest way to do in terms of parts, as it costs less than $15 worth of LEDs and wire to create. However, it will take you a few hours to complete (less time than option #2 though).

The second option is what I chose to use with this particular table. This step is similar to the first option except we create a jig to hold the LED grid instead of actually attaching the LEDs to the table. We then wire up the whole grid in the jig, attach the connector and then pour liquid silicone around the connections to completely encase the wiring of the LED grid. This allows us to be able to remove the LED grid from the table or fold up the LED grid so that it has a smaller footprint and can be shipped easier. This way is more expensive and more difficult as one has to purchase the liquid silicone from a supplier (I found mine on AliExpress), have the required equipment to degas the silicone and then spend the extra time prepping and pouring the silicone. I used about 3Kg of liquid silicone which comes out to $60 with shipping included. This option can be done for around $70 and it makes the LED grid portable and shock-resistant.

In this step I will explain how to do the second option but if you choose to use the first option, just copy the following instructions except instead of mounting your LEDs in a jig, drill out the grid on the lid of your table and superglue or hot-glue the LEDs in place on the lid. Then flip the table over and do the exact same wiring as I explain in this step. Complete the wiring and connector and then you’re done. You obviously will stop short of pouring any silicone.

You need the following pieces to make the jig:

  • 2x – 1116.67x25x12.7mm Pieces of plywood
  • 2x – 163.5x25x12.7mm Pieces of plywood
  • 1x – 400x25x12.7mm Piece of plywood
  • 1x – 1116.67x400x12.7mm Piece of plywood

Pick one corner of the bottom piece of plywood and measure in 41.67mm from each side. Mark the location and then measure straight across from that mark 33.33mm and make another mark. Keep going at 33.33mm intervals for the rest of the 30 columns. Repeat the same process for the rows and you’ll have your grid drawn out. Take a 5mm drill bit and make a hole for each LED in the jig. Take each 25mm border and arrange them flush along the outer edge of the jig. One end will have a space in the middle for the 50-pin PCB connector. The jig is now made.

Next, place the first column of LEDs in the jig and take care to ensure that they are all placed in the jig with the same orientation. Bend down each anode lead one each of the 12 LEDs and then take some solderable enamel coated wire and wrap it around the anode of the first LED two times (a wire wrap tool works great for this). Leave some slack in between each LED and continue doing this for each LED. Repeat the process for each column and then do the same for the twelve rows (connecting cathodes on the rows). It is critical that you put a bit of slack in the wire between each LED, otherwise the wires can break if the silicone LED grid is rolled up. With about a 1/2″ of slack wire between each LED it allows the wire to stretch inside of the grid without breaking.

Once the grid is completely wired, we will need to get some wire to hook up the 50-pin breakout PCB to the grid. I used 3-pair phone cable but any wire will do. Solder a piece of wire to each column and route the wire to the opening on the front of the jig where we will mount the breakout connector. Repeat the same process for the columns. Once all of the wires are there, connect the grid to the breakout PCB as follows: 1234

PCB -> Signal

1 -> COL0

2 -> COL1

3 -> COL2

….

32 -> COL31

33 -> ROW0

34 -> ROW1

….

43 -> ROW10

44 -> ROW11
Wiring up the grid with the 2×25 LED grid cable

The last 6 connections on the breakout PCB are left blank as we are only using a 32×12 LED grid. Next we will assemble the Master PCB so that we can test out the LED grid. After verifying that all of the LEDs in the grid are working, we will encase it in silicone.

Step 17: Construction: Pouring The Silicone Into The Grid

Applies To
None, unless you choose to create the LED grid this way instead of building it into the table. This is just here for general knowledge.
This step is only applicable to you if you are using option #2 to make your LED grid. I don’t recommend this method as it is far more expensive, time consuming and messier than option #1. In fact, the only reason that I tried it was to see if I would be able to make a portable LED grid that I could ship with the kits.

I eventually decided against making these and selling them for the following reasons:

  • It is very time consuming
  • It is expensive to get the raw material shipped here
  • It is expensive to ship out each finished LED grid (~3Kg)
  • It is difficult to hide all of the wires in the thin mat of silicone; It looks kind of archaic

As with most products, cost is the limiting factor for this LED grid that is encased in silicone. However, I still wanted to post the process and results in case anybody does choose to do it this way and just for general knowledge.

The silicone was purchased on AliExpress and is labeled as an RTV Silicone for those who are interested. The photos above explain the process to create your own silicone LED grid.

Step 18: Construction: Installing The RGB Pods

Applies To
PCB Only Kit
Unassembled Kit
Fully Assembled Kit
In this step we will secure each RGB pod to the table, but first we have to mark the placement of each pod as well as drill out a hole that is large enough to fit the 2×4 IDC connector through to the bottom of the table. Use the photos in this step and measure out the center location of each RGB pod on the table. Make a small 1 – 2mm pilot hole at each location so that it will be easier to thread a screw into place to secure the pod once we are finished.

There are two ways that once can use to measure out the location of each 2×4 connector in reference to the center of its respective pod. First, you can just use the CAD drawings above to measure out the location of each connector hole and then drill them out with a 11/16″ (18mm) spade bit, or second, you can use the attached PDF file and print a pod stencil which contains the exact locations of both the center and connector holes. If you use the template, you must make sure that you set it to print out at “Actual Size” and don’t use the scale to fit option in the Adobe Reader print section. Once you have the template printed out, you line up the center hole on the template with the pod location on the table and then make a mark where the connector hole should go and the pilot hole should go. Then drill out the connector hole first followed by the 2mm pilot hole.

Once you have all of the holes drilled out, insert each pod into its location and use #1 1/2″ screws to secure them to the table. Now you’re ready to connect them up!Interactive LED Beer Pong Table 2.0 (BPT X5) schematic

Step 19: Construction: How To Crimp Various Connectors

Applies To
PCB Only Kit
Unassembled Kit

Doesn’t Apply To
Fully Assembled Kit
In this step, I will show you how to use a crimping tool for the various connectors on the Master PCB. The crimper that I find most useful can be purchased here (Model: PA-09) for around $40. Although it is more expensive than some other crimpers, I would definitely recommend it as I have used some other cheaper ones and they don’t do as nice of a job when crimping (or crimp as wide of a variety of connectors as this one does). As with most of this Instructable, follow the photos above to get a good understanding of the process.

If you didn’t get a fully assembled kit, you will have to crimp all of the pins for the XH_2.54 connectors on the LED rings. Not a big deal, just follow the instructions above as the instructions are the same for that type of connector.

Step 20: Construction: Building The Ball Washer Sensors

Applies To
PCB Only Kit
Unassembled Kit

Doesn’t Apply To
Fully Assembled Kit
To make two ball washer sensor assemblies for your table, you will need the following:

4x – TCRT5000 IR Sensors
8x – 2-conductor CAT5 Wire Sections (6′ – 8′ length)
16x – 1″ Lengths of heatshrink (2mm diameter)
2x – RJ45 Connectors

First, bend over each lead of the TCRT5000 and trim them. Use the diagram in the photos and connect up each lead on the sensor to its respective wire. You will have to do this for both the entry and the exit sensor. Once you have wires connected up to each sensor, align the eight CAT5 wires in the correct order and crimp an RJ45 connector on to them. Repeat the same process to make the sensor assembly for the second ball washer.

As you will see with lots of parts in this Instructable, I tend to use CAT5 wire for longer wire runs as it is very common and cheap to purchase. Just strip away the outer PVC sheath to expose the four pairs of wires inside.

 

 

For more detail: Interactive LED Beer Pong Table 2.0 (BPT X5)

The post Interactive LED Beer Pong Table 2.0 (BPT X5) appeared first on PIC Microcontroller.

Mirror “Tube”– LED Optical illusion

$
0
0

One day, looking for interesting schemes with light effects to construct, came across this wonderful effect. Quite liked the idea but did not know how to accomplish is, until one day found the way. Subsequently construct my own mirror that had to not only try out my skills in electronics but and processing of wood (to create a frame). In this article I will share all the difficulties faced by all subtleties and found that while it is constructed. Many experimented with different windows and mirrors until desired effect is achieved. To facilitate lovers of electronics and in particular light effects as I would describe it as detailed. I will apply the schemes and boards and everything that I constructed. Of course I designed mirror frame on my taste and choice, but everyone has a different look beautiful, and you can use your imagination instead of myne in his own choice. I guess that schemes are found here will facilitate the development of such a mirror to your liking.

You can buy kit for assembling and see another interesting projects in my website: www.kukata86.com

Step 1: What is the mirror “Tube”?

The device is constructed as a mirror that creates the optical illusion of a tunnel formed by the LEDs. The effect is quite interesting and very hot right lately. Its true effect observed especially impressive when viewed in a dark room or in a room with not very strong light (then you really see the entire depth of the tunnel and the effect of changing colors), a during daylight hours drive takes the role of a simple mirror .Mirror Tube LED Optical illusion

Step 2: How is made and how it creates the illusion?

The device consists of a frame and two electronic units.

  • Some wood frame (size and shape of your choice) on the inside and countries are LEDs. The rear of the frame is a regular mirror and the front – glass with mirror properties. Thus the light emitted by the LEDs is reflected in the rear mirror and the windshield with mirror properties and that multiple internal reflection creates the illusion of a tunnel. The ability to see with my own eyes the effect comes from the glass with mirror properties repeatedly missed out internal reflection, and this allows us to glimpse what is happening between the two glasses. This gives the illusion of multiple meter tunnel from the device until between 5-10 cm thick
  • Controller, which sets different modes of RGB light boards, control the LEDs. This controller manages separate each color of RGB LEDs (red, green, blue), thus achieving different shades of colors formed by combining these three colors.
  • Another important element is the board with RGB LEDs or LED Strips (I designed the 3 different sizes of boards / 8.7 cm X 1.5 cm X 0.7 cm / / 19.5 cm X 1.5 cm X 0.7 cm / / 39 cm X 1.5 cm X 0.7 cm / whose number of LEDs also depends on appropriate / 4 / / 9 / and / 19 / LED) boards can be combined so that they are comfortable length for your purposes. When use LED strips, keep in mind that it is cut in a certain size, amount mostly through 3 LEDs.

You can buy kit for assembling and see another interesting projects in my website: www.kukata86.com

Step 3: Construction of mirror “Tube”

The first thing needed to create such a mirror is to focus on the shape and size that we like. I personally stopped a regular hexagon.

Step 4:

Each inner sides will work out dimensions of 40 cm (in order to be able later to mount LED board size 39 cm)

I worked six equal square battens with dimensions 5 cm X 5 cm X 20 cm.

Step 5:

For a regular hexagon is formed by six corners of 120 degrees. To achieve proper form the end of each piece of wood finishes with a slope angle of 60 degrees and 40 cm high plateau of the trapezoid.

Step 6:

IMPORTANT!

Remember to follow the length of the plateau of the trapezoid. As I mentioned in my case it is 40 cm so I can mount the PCB with LEDs with a length of 39 cm. In your case it may be a different size but, comply with what length card or combination of boards to use. If you use  LED Strip is not required to comply with such factors, only inside tour of the frame.

Gathering all the shingles to each other on the mirror frame shape – regular hexagon.

Step 7:

Each of them has an internal groove which to place the board with LEDs sizes / 39 cm x 1.5 cm /. Flap is 7 mm deep (as the height of the LED board). If you use LED Strip, flap is not binding or it may be quite shallow – about 1 mm (almost enough to hide the double sided tape on the back of the strip), but not deep enough to hide the LEDs.

Edge to the back of the mirror can save it if you find a better way to attach the mirror, but in any event not glued to the frame because the windshield will be stuck in this case if you need to replace or repair any of boards with LEDs opening the mirror becomes impossible.

Step 8:

Once you paint them all with plain black spray glued with glue all 6 mounting rails to form a hexagon. Boards tucked in groove provided them solder each other with short wires observing the colors of buses R with R, G with G, B with B and + with +. From one of the sides of the hexagon idrilled hole to lead the LED power cable circuits which will later connect to the controller. If you use LED Strip simply glue the runners made earlier for this purpose and bring out the frame cables.

View of adhesive frame without glass – front
In yellow visible groove provided for LED circuits.

Step 9:

View of frame – rear
In yellow visible groove provided for LED panels and “nest” provided a mirror on the back of the frame.

Step 10:

I ordered to a glass company to cut a hexagon of my mirror glass for glass packs (without excessive color / brown or green /). He ordered a glass 5 mm larger in diameter than the outside of the frame to have a good overlap with the side mirrors that will put more later.

I glued glass mirror mounting adhesive on the front of the frame

View of mirror – front:

Step 11:

View of mirror – rear
In the mirror glass side of the glass is noticeably better properties mirror (mirror coating is applied on the country) on the other. Experimental realized that this was it’s better to be on the inside of the mirror to the LEDs. To reinforce mirror properties and took the outside mirror foil for car windows and taped on the outside of the glass. This reinforced the ability to look at myself in the mirror during the day and svetodeodite properties to reflect better at night.

And mirror cut to size appropriate to enter the nest that predicted. Once I put it in its cradle on the edge between the glass and frame it taped with duct tape. Thus strengthened it does not fall and I opened it without difficulty have an ace.

Step 12:

Before you close the mirror finally cleaned both windows so that no dust to close between the two glasses. Emphasize the fact that visible dust is not visible during the day can be seen very clearly in the mirror tunnel.

Finally, cut out five mirrors the size of the external frame pages and pasted them from outside the country and to hide the visible wooden part. At the top of the frame does not put a piece of glass as there put two D shaped brackets which attached the mirror hanging on the wall. Side mirrors have given quite finished mirror and made really good-looking aesthetic.Mirror Tube LED Optical illusion schematic

Step 13: Preparation and assembly of LED boards

I designed three types of LED boards.

  • 8.7cm % 1.5cm % 0.7cm – 4 LEDs
  • 19.5cm % 1.5cm % 0.7cm – 9 LEDs
  • 39cm X 1.5cm % 0.7cm – 19 LEDs

Number of LEDs of each depends on the length her LED boards can be combined according to your needs and depending on the chosen framework, but their number should not exceed 300. This is the maximum count that mirror’s controller (discussed below) can handle without risking damage.

You can buy kit for assembling and see another interesting projects in my website: www.kukata86.com

Step 14:

Led Board 8.7cm % 1.5cm – 4 LEDs

Board Top-PDF
Board Top with white masK-PDF
Board Bottom (mirrored)-PDF

Led Board 19.5cm % 1.5cm –  9 LEDs

Board Top-PDF
Board Top with white mask-PDF
Board Bottom (mirrored)-PDF

Led Board 39cm X 1.5cm – 19 LEDs

This board is divided into two parts. To be printed in real size is divided into two A4 sheets.
Board Top:
Part 1-PDF
Part 2-PDF
Board Top with white mask:
Part 1-PDF
Part 2-PDF
Board Bottom (mirrored):
Part 1-PDF
Part 2-PDF

The accompanying drawings boards are life-sized. For the preparation of PCB important to use methods of amateur laser printer or photo-method.

You can buy kit for assembling and see another interesting projects in my website: www.kukata86.com

In the attached file the top of the board is flipping to be suitable for carrying laminated after printing.

 

 

For more detail: Mirror “Tube” – LED Optical illusion

The post Mirror “Tube” – LED Optical illusion appeared first on PIC Microcontroller.

Viewing all 387 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>