LED CUBE 3X3X3 PIC16F84 CON MICROFONO INCORPORATO

09/02/2014

Un LED cube 3x3x3 costruito completamente a mano!

I LED cube sono matrici LED a tre dimensioni in grado di illuminarsi nelle più complesse animazioni; ne esistono di numerosi tipi tra cui 3x3x3, 4x4x4 e addirittura 8x8x8. Alcuni sono comandati via PC, altri sono provvisti di microcontrollore e quindi completamente autonomi.

Nel mio caso ho dotato il cubo di microfono e amplificatore per lampeggiare a tempo di musica (una specie di VU meter tridimensionale). L'ho realizzato con un semplice PIC micro 16F84, un amplificatore MAX9812, microfono e pochi altri componenti.

DSCN4392

Multiplexing

La griglia LED è composta da 3 piani di 9 LED ciascuno per un totale di 27 LED (3x3x3). Il micro prevede solo 13 GPIO, ovviamente non sufficienti a pilotare tutti e 27 i LED singolarmente; ho quindi realizzato un indirizzamento del singolo LED secondo la coppia piano/colonna. In questo modo per accendere un LED e' sufficiente specificare il piano (uno di tre, quindi 3 GPIO) e la colonna di afferenza (una di nove, quindi altri 9 GPIO) per un totale di 12 GPIO. Elettricamente cio' si traduce nel collegare tra loro i catodi dei LED di ogni piano e tutti gli anodi secondo le colonne.

Questa particolare configurazione purtroppo ci costringe ad accendere un solo piano alla volta: abilitare piu' di un piano contemporaneamente comporterebbe l'accensione di LED non desiderati. E' comunque possibile risolvere il problema avvicendando i 3 piani molto velocemente tra loro (tecnica display multiplexing): in sostanza il micro seleziona il primo piano, ne accende opportunatamente i nove LED, spegne il primo piano, accende il secondo, accende i nove LED del secondo piano, spenge il secondo piano, accende il terzo e cosi' via in loop il più velocemente possibile. L'occhio umano non e' in grado di percepire questo veloce cambiamento e la percezione finale e' quella di avere tutti i LED accesi contemporaneamente. Nel mio caso ho programmato il multiplexing ad una frequenza di circa 100Hz ottenendo cosi' un frame rate dell'intero pattern LED di circa 33,3Hz. Nell'immagine qui sotto mostro i collegamenti tra i GPIO del micro con alla griglia LED 3x3x3.

multiplex

Luminosita' variabile dei LED

In aggiunta al multiplex, il micro alimenta i LED tramite PWM cosi' da poterne modificare la luminosità. Il pic 16F84 non prevede hardware dedicato per il PWM ma e' comunque possibile realizzarlo via software togglando molto velocemente on/off i GPIO opportuni.

Animazioni

Il cubo e' in grado di mostrare fino ad 8 animazioni differenti, ognuna composta da un certo numero di frame (un frame è semplicemente una configurazione ON/OFF dei 27 LED). Le animazioni sono codificate nella flash del micro come semplici tabelle retwl di lookup.

Sincronizzazione con musica esterna

Ho dotato il cubo di un microfono amplificatore integrati. In questo modo e' in grado di mostrare le animazioni LED andando piu' o meno a tempo di musica. Il segnale analogico captato dal microfono viene amplificato, filtrato da un filtro RC passa basso e poi squadrato in un segnale TTL 0-5V. Il segnale cosi' ottenuto passa al piedino RB0/INT del micro. Il filtro RC è dimensionato per far in modo che passino solo le basse frequenze ad esempio la batteria di una musica o simili. Ogni volta che il microfono capta un segnale a bassa frequenza il piedino RB0 viene portato a livello logico alto il che scatena un interrupt nel microcontrollore. Il micro quindi seleziona casualmente una animazione (dalle 8 disponibili) e la sulla griglia LED, un frame dopo l'altro (e' possibile impostare da software la velocita' delle animazioni).

Schema elettrico

Questo lo schema elettrico completo:

ledcube - schematic

Il pic 16F84 è nella sua classica configurazione con oscillatore esterno da 4MHz e circuito di reset. I pin da RB1 a RB7 e RA2,RA3 indirizzano le 9 colonne LED tramite apposite resistenze limitatrici, i pin RA0,RA1 e RA4 attivano rispettivamente il piano alto, di mezzo e il basso tramite i 3 FET di potenza (2N7000). La sezione audio analogica è composta da microfono, integrato amplificatore MAX9812, filtro passa basso (R17,C7) e squadratore di segnale (i due BC547 a valle). Notare il pullup di 4.7K per il pin RA4: RA4 e' l'unico pin del 16F84 ad essere open-collector, occorre quindi il pull-up.

DSCN4394

DSCN4399

DSCN4397

DSCN4396

Il MAX9812 non viene commercializzato nel classico package DIL ma solo su TSOP: essendo un package estremamente miniaturizzato ho dovuto realizzare una basetta adapter apposita (vedi foto in basso a destra) sulla quale saldare a parte l'integrato.

Codice sorgente

Il codice sorgente è scritto interamente in assembler in quanto sia per il multiplexing dei 3 layer che per il PWM occorre un timing particolarmente accurato, dell'ordine dei microsecondi. Il codice si compone di tre sezioni principali:

Al power on viene eseguita l'inizializzazione delle varie parti del micro (direzioni dei GPIO, timer interno, variabili di programma etc...). Immediatamente dopo il cubo entra nella idle routine nella quale parte la modalità glowing (tutti e 27 i LED rimangono accesi e si aumenta e diminuisce ciclicamente la luminosità. Il cubo permane in questa modalità fino a che non subentra un interrupt esterno (dal pin RB0) corrispondente ad un beat del segnale sonoro captato dal microfono (una musica, un battito di mani, etc...). L'interrupt viene immediatamente servito dalla routine ISR: viene impostata la luminosità massima e viene scelta una animazione casuale (fra 8 disponibili) che viene mostrata sulla griglia led. L'animazione è mostrata sulla griglia LED un frame dopo l'altro, cicliclamente. Ad ogni giro viene decrementata la luminosità di un fattore 1. Quando la luminosità raggiunge lo zero il micro esce dalla ISR e si riporta in modalità attesa (cubo glowing).

Ecco il flowchart completo del programma:

flowchart

Codice sorgente

Il sorgente si compone di un singolo file .asm.

Download codice sorgente: ledcube asm

Download file HEX precompilato: ledcube hex

Per la compilazione e programmazione del micro e' sufficiente l'ambiente MPLab e apposito programmatore, ad esempio il "pickit 3".

ICSP40PICkit3PG

E' inoltre necessario impostare i bit di configurazione nel seguente modo (oscillatore al quarzo, no watchdog, power-up timer si, protezione del codice disabilitata)

configuration bits

Dettaglio codice sorgente

Nella prima parte del codice indichiamo il micro che andremo ad utilizzare (16F84) e la base per le costanti (base 16, hex):

;directives
PROCESSOR 16F84A RADIX HEX

passiamo poi a creare i define dei registri principali del micro

;defs

PCL EQU 0x02
OPTREG EQU 0x01
TMR EQU 0x01
INTCON EQU 0x0B
TMR0 EQU 0x01
TRISB EQU 0x06
TRISA EQU 0x05
PORTA EQU 0x05
PORTB EQU 0x06
STATUS EQU 0x03
FSR EQU 0x04
INDF EQU 0x00
Z EQU 2        ; Z flags
GIE EQU 7      ; GIE bit
INTF EQU 1     ; INTF flag

infine definiamo le variabili (parliamo sempre di locazioni a 8bit) del nostro programma, in particolare i 3 layer (LOWL, MIDL e HIGL) e il layer "extra" EXTL che andrà a contenere tutti i noni LED dei layer (useremo quindi solo 3 bit in EXTL). TIME sarà la velocità delle animazioni e BRIG il livello di luminosità:

LOWL EQU 0x20   ; bottom layer (8 bit pattern)
MIDL EQU 0x21   ; middle layer (8 bit pattern)
HIGL EQU 0x22   ; upper layer (8 bit pattern)
EXTL EQU 0x23   ; extra layer (9th led for each layer)
TIME EQU 0x24   ; current frame speed
TCONT EQU 0x25  ; frame speed counter
LSEL EQU 0x26   ; layer selector
BCONT EQU 0x27  ; brightness counter
BRIG EQU 0x28   ; brightness
CURL EQU 0x29   ; current layer

La primissima istruzione (locazione 0x0000) è un semplice goto alla routine di inizializzazione. Occorre mettere il goto in quanto il micro richiede che all'indirizzo 0x0004 parta la routine di gestione interrupt.

ORG 0x0000              ; start from address 0x0000
goto Init

A questo punto osserviamo il codice di inizializzazione:

Init:                   ; initialization
bsf     STATUS,5        ; select RAM bank 1
movlw   b'00000001'
movwf   TRISB
movlw   b'00000000'
movwf   TRISA
bcf     OPTREG,5        ; start the TMR module in counter mode
bcf     STATUS,5        ; select RAM bank 0
movlw   0x00            ; all leds off
movwf   PORTA
movwf   PORTB
clrf    LSEL            ; no layer selected
call    IdleCube

molto semplicemente impostiamo tutti i GPIO come output (bit di TRISB e TRISA a zero) tranne il primo bit di PORTB (RB0) che ci servirà invece come ingresso per triggerare l'interrupt (RB0 è collegato all'amplificatore audio esterno). Avviamo il timer interno in modalità conteggio ciclico, resettiamo gli output ed infine saltiamo alla funzione IdleCube.

Passiamo ora ad analizzare la funzione IdleCube:

per prima cosa impostiamo il pattern "full 27 led" ossia tutti e 27 i led accesi. Da notare che i noni LED di ogni layer sono mappati rispettivamente nel primo, secondo e quinto bit di EXTL (RA0, RA1 e RA4): osservare lo schematico per vedere questa corrispondenza.

;******** IDLECUBE ***********************************
;
; The cube is glowing and ready to trigger...
;
;*****************************************************

IdleCube:

movlw   b'11111111'
movwf   LOWL
movlw   b'11111111'
movwf   MIDL
movlw   b'11111111'
movwf   HIGL
movlw   b'00010011'
movwf   EXTL

Settiamo al minimo luminosità e velocità di animazione:

movlw   0x01
movwf   BRIG      ; smallest brightness
movlw   0x02
movwf   TIME      ; smallest pattern duration

Abilitiamo poi l'interrupt esterno dal pin RB0

bcf   INTCON,INTF
bsf   INTCON,4     ; enabling the interrupt from the RB0/INT pin
bsf   INTCON,GIE   ; enabling the interrupt service

passiamo poi ciclicamente a fare fadein e fadeout del ful-27-led pattern:

IdleCube_fadein:          ; fade in loop
callShowCube
incfsz  BRIG
goto    IdleCube_fadein
IdleCube_fadeout:         ; fade out loop
call    ShowCube
decfsz  BRIG
goto    IdleCube_fadeout
incf    BRIG,1
goto    IdleCube_fadein

Il micro rimane in questa condizione indefinitamente. Ecco il cubo durante la fase idle:

Non appena la sezione microfono/amplificatore emette un segnale sul pin RB0, viene triggerato un interrupt gestito immediatamente dal micro. Il micro inizia quindi ad eseguire il codice alla locazione 0x0004 (inizio della nostra routine ISR). La routine è abbastanza semplice e si compone di tre parti principali:

Per il valore random viene campionato il valore corrente del timer (un valore compreso tra 0 e 255) e viene messo in AND con la maschera 0x07 per prelevarne solo i 3 bit meno significativi. Questi 3 bit sono il nostro valore casuale 0-7 e vengono sommati al program counter per chiamare la funzione animazione corrispondente.

Interrupt:              ; interrupt service routine
bcf    INTCON,INTF      ; disable the interrupt service
bsf    INTCON,GIE
movf   TMR,0            ; pick a pattern at random
andlw  0x07
addwf  PCL,1            ; jump into jump table
goto   Pattern_treble
goto   Pattern_updown
goto   Pattern_twobars
goto   Pattern_buildframe
goto   Pattern_rotplane
goto   Pattern_rlplane
goto   Pattern_snake
goto   Pattern_fourface

Analizziamo ora la funzione principale, ossia ShowCube. ShowCube mostra sulla griglia led un singolo frame dell'animazione prescelta. Il frame è codificato nei 24 bit di LOWL, MIDL, HIGL e nei 3 bit aggiuntivi di EXTL per un totale di 27 bit (i 3x3x3 led della griglia). Il pattern completo è mostrato sulla griglia accendendo un layer alla volta ad una frequenza di circa 100Hz. I bit RA0, RA1 e RA4 abilitano il layer corrispondente (controllare lo schematico per le corrispondenze). Il singolo layer è mostrato invocando la funzione ShowLayer.

;******** ShowCube ***********************************
;
; Shows the cube pattern for 0.01 * TIME sec using
; brightness level BRIG. The refresh rate is 100Hz.
;
;*****************************************************

ShowCube:

; setup counter
movf    TIME,0
movwf   TCONT           ; TCONT 0
decfsz  TCONT,1
goto    ShowCube_loop
return

Per finire ecco la funzione ShowLayer utilizzata per illuminare un singolo layer della griglia. La funzione implementa un classico PWM per settare la luminosità del singoli LED ad un valore prescelto (variabile BRIG): per un tempo pari a (BRIG/255)% il layer rimane acceso, per un tempo pari a ((255-BRIG)/255)% il layer rimane spento. In sostanza la variabile BRIG codifica il duty cycle del PWM.

;******** ShowLayer **********************************
;
; Shows the layer encoded in W and EXTL for x msec.
; (BRIG/255)% of the time the layer is ON, the
; remaining (255-BRIG)/255)% of the time the layer
; is OFF. (this is a PWM controlled brightness)
;
;*****************************************************

ShowLayer:
; layer on for (255/BRIG)*x msec
; layer off for (255/(255-BRIG))*x msec
; where x depends on the osc used

; set the first seven leds (bit0 of PORTB is used to receive interrupts!)
movwf   PORTB           ; PORTB
; set/clear the 8th led
btfsc   CURL,0
bsf     PORTA,2

; test the 9th bit of the current layer and set
; the 9th led accordingly (9th led = bit3 of PORTA)
movf    EXTL,0
andwf   LSEL,0          ; W btfss   STATUS,Z        ; is the 9th bit clear (9th led off)?
bsf     PORTA,3         ; no, set the 9th bit

; set the 9th bit of the current layer and turn on
; the entire layer
movf    LSEL,0
xorwf   PORTA,1         ; PORTA
; wait (BRIG/255)%
movf    BRIG,0
movwf   BCONT
ShowLayer_loop_layeron:
decfsz  BCONT
goto    ShowLayer_loop_layeron

; turn off the entire layer
clrf    PORTA

; wait ((255-BRIG)/255)%
movf    BRIG,0
movwf   BCONT
decf    BCONT,1
ShowLayer_loop_layeroff:
incfsz  BCONT
goto    ShowLayer_loop_layeroff

return

Ecco il cubo all'opera:


Torna alla home

Commenti

39 commenti


watch test0r0r0 (Mardini492@gmail.com)
il 16 Marzo 2014 alle 09:38

I'm excited to discover this page. I want to to thank you for your time for this particularly fantastic read!! I definitely enjoyed every bit of it and i also have you book-marked to look at new information on your blog.

Rispondi


gada (lkglass@hotmail.com)
il 20 Marzo 2014 alle 12:26

Thanks,Gialuca.
I tried to put parts together of the LEDCUBE and tried to get it work,i didn't make it.first i connected wires of 16F84,if i use 5v to test the ledcube.it lights up.so the connection is OK.then i moved to programming.i didn't put resistor between PicKit 3 and VCC+5(pin 14).i used MPLAB and icprog and PIC stand along programmer.the MPLAB says 'BUILD SUCCEEDED' in MPLAB and generated a HEX file.after i load the HEX file to icprog without succeed and then i tried PIC stand along programmer, failed again.

please help.

Rispondi


Gianluca (Admin)
il 20 Marzo 2014 alle 13:21

Hi Gada,
try to use the PicKit3 stand alone programmer. Select PicKit3 and choose PIC16F84. Be sure to set the right configuraton bit pattern (WatchDog=off, OscillatorType=XT). Also, be sure to set the VDD PicKit3 "On" checkbox and set the voltage to 5V. In later versions of the programmer such option is called "Target Power".

Rispondi


gada (lkglass@hotmail.com)
il 21 Marzo 2014 alle 07:30

Dear Gianluca
Thanks for your reply,i tried as you instructed.While press the VERIFY of PICkit3 standalone programmer,it give me'verify operation failed'.while pressing 'read' and 'write' buttons.i found some of the led bulbs lights up.frustrated.

gada

Rispondi


Gianluca (Admin)
il 21 Marzo 2014 alle 09:48

ok,
before programming disconnect your PIC from any other device (external oscillator, power supply, LED matrix, all the stuff...) then connect it to the PicKit3 programmer (5 wires are required). You can found the correct wiring online or on the PicKit3 documentation. Did you set the "Target Power" checkbox?

Rispondi


gada (lkglass@hotmail.com)
il 21 Marzo 2014 alle 14:45

Hi,Gianluca,
Thanks for your kind reply,I did as you instructed,The 'Target Power' 'ON' checked at 5V,5 wires of PICkit pin1 to chip pin4,kit pin2 to chip pin14.kit pin3 to chip pin5,kit pin4 to chip pin13,kit pin5 to chip pin12. no resistors put in between.finally I got this'verify operation of program memory failed'

I found 'WatchDog=off, OscillatorType=XT' in my MPLAB IDE v8.56.tuned to what you directed before converting .asm to .hex.build success,
Make: The target "d:\ledcube.cof" is out of date.
Executing: "C:\Program Files\Microchip\MPASM Suite\mplink.exe" /p16F84 "ledcube\ledcube.o" /u_DEBUG /z__MPLAB_BUILD=1 /z__MPLAB_DEBUG=1 /o"ledcube.cof" /M"ledcube.map" /W /x
MPLINK 4.37, Linker
Copyright (c) 1998-2010 Microchip Technology Inc.
Errors : 0

Rispondi


gada (lkglass@hotmail.com)
il 21 Marzo 2014 alle 14:48

pin1---pin4
pin2---pin14
pin3---pin5
pin4---pin13
pin5---pin12
I connected the Pickit3 and the pic16f84 directly,I tried another chip,the result was the same.

Rispondi


Gianluca (Admin)
il 21 Marzo 2014 alle 16:25

Use the MPLAB built-in programming software. Connect first the PICkit 3 to the PC but DO NOT connect it to the board. Start Select a PIC16F84A as the current device, (configure menu) then select PICkit 3 as the programmer. It should update the firmware and tell you that no device is detected. If it hangs for more than 5 minutes, unplug the PICkit 3, restart MPLAB and try again.

At this point you are ready to connect the board and put a PIC in the socket. Before you do anything else, check the Status LED on the programmer is NOT lit yellow. Then go ahead and plug the programmer into the board and put a ciph in the socket taking great care to get it in the right place. With the multimeter check that the PIC is getting the right supply voltage and test the connections between the PIC pins and PicKit3 pin (conductivity test)

Rispondi


gada ()
il 22 Marzo 2014 alle 03:20

I tried to use IDE to set 5V power " Programmer
---Settings---Power------5V',

Then i got this'The overcurrent logic has detected a fault condition on
either VPP or VDD. Please disconnect your circuit check
MCLR or VDD for a short circuit and then reconnect. Also,
ensure that your target current requirements do not exceed
the specified limits.

PK3Err0021: Command not echoed properly. Sent 3f, received
40.

PK3Err0033: 4 bytes expected, 0 bytes received.

Rispondi


Gianluca (Admin)
il 22 Marzo 2014 alle 14:15

mmm... it seems that you're having some issue with the cabling. The pinout you showed me is correct. Maybe some lines are shorted. Don't trust any more the breadboard, go ahead and connect directly the pins of the PIC to the pins of the PicKit3.

Rispondi


gada ()
il 7 Aprile 2014 alle 14:54

Thanks,Gianluca,
I found the problem.I programmed the CHIP by using a ZIP board to work together with the PICkit3. although i have other obstacles like overheating of LM7805 and non-sensitive of 9812H.but anyway i am moving forward.

Rispondi


Gianluca (Admin)
il 7 Aprile 2014 alle 16:01

Ok, nice. The LM7805 should have a heat sink on its back or overheating could occur. If I remember correctly it should handle up to 500mA or 1A which is well enough. Try to measure the overall current drawn by the cube. We'll investigate the 9812H problem later...

Rispondi


Caitlin (Caitlin.m.swim@gmail.com)
il 19 Maggio 2014 alle 13:22

Hi there,

I'm finishing up my first 7x7x7 LED cube and want a smaller project to start for a few people as a "thank you" gift. I saw your audio LED cube and thought it would be perfect. I'm not new to soldering, but I am new to picking out the right parts for things and was wondering if you might be able to help me out. I've been staring at your schematics and pictures with Mouser.com opened and I just can't seem to figure out what Q1, the 4 MHz component is. Also, I assumed the resistance of the microphone was a factor (maybe it isn't?) and I'm not sure what resistance I need. I would really appreciate any tips or information you might have for me!

Thank you,
Caitlin

Rispondi


Gianluca (Admin)
il 19 Maggio 2014 alle 21:13

Hi Caitlin,
the Q1 component is a 4MHz quartz oscillator (XTAL). It provides a stable clock signal to the microcontroller. The microphone section requires more than one resistor: which one do you refer to? There are many breakout boards (i.e. smaller boards you can attach to your main project board) which include a microphone, pre-amplifier and all the ancillary resistors and capacitors so you don't have to build the huge audio section found in my schematics.

Rispondi


Jordan (jordan.deister@gmail.com)
il 14 Novembre 2014 alle 07:39

I was wondering if you would know how to set a different led color to a given musical frequency range. So for example green light might be emitted when for lower frequencies (bass) and yellow for slightly higher then blue for highest (treble)?

I'm also trying to do this with a PIC if at all possible (PIC16F88 or similar)

Awesome video by the way

Thanks!

Rispondi


Gianluca (Admin)
il 14 Novembre 2014 alle 11:08

Hi Jordan,
sure it is possible to do so!
First, a change to the audio section would be required in order to differentiate between high/mid and low frequencies. This could be done using a low-pass, high-pass and band-pass filters. The 16F84 isn't fast enough to do a realtime FFT nor it has ADC ports, so external filters are required. These filters should then trigger three different GPIOs, one for low frequencies, one for mid freq. and the last one for the high freq.

Now the real deal. All LEDs should be RGB type (4-lead per LED). This would imply that you have 3 "virtual layer" (the R-layer, G-layer and B-layer) of LEDs per physical layer so a grand total of 3x3x3x3=81 different LEDs. One way to light them up could be implementing multiplexing over the R,G,B layers very fast (100Hz should be ok).

Rispondi


Delia (3vl230827t@mail.com)
il 11 Marzo 2015 alle 09:38

Frankly I think that's abesultoly good stuff.

Rispondi


cheap levitra (8yz3xumf@yahoo.com)
il 14 Marzo 2015 alle 20:50

Great article but it didn't have everything-I didn't find the kitchen sink!

Rispondi


Unlocatelectron (elementalwattson@gmail.com)
il 16 Aprile 2015 alle 03:46

Hi. Can I use an amplifier with an LM358 instead of using the MAX981x? (There is no MAXIUM chips here for sale)

Rispondi


Gianluca (Admin)
il 18 Aprile 2015 alle 12:01

Hi, sure you can! Here a good place to start:
https://lowvoltage.wordpress.com/2011/05/21/lm358-mic-amp/

Using a plain lm358 you have to add some glue passive logic to it but it basically should work well.

Rispondi


Farias Ezequiel (farias.ezequiel.alejandro@gmail.com)
il 18 Aprile 2015 alle 17:43

Hi. If it's possible, I appreciate if you can send me the hex file of your project. I don't have the PICKIT3 and the source haven't the fuses. The pickit2 is not working at all in mplab with those u-controllers. Sorry the bothering and thanks in advance.

Rispondi


Gianluca (Admin)
il 18 Aprile 2015 alle 18:11

Hi Ezequiel, just add these lines to your source. Basically you want the watchdog to be disabled and the oscillator of type XT. You can generate the _CONFIG word with MPLAB-X under the "configuration bits" tab

; PIC16F84A Configuration Bit Settings
; ASM source line config statements

include "p16F84A.inc"

; CONFIG
; config 0xC009
CONFIG _FOSC_XT & _WDTE_OFF & _PWRTE_OFF & _CP_ON

Rispondi


Farias Ezequiel (farias.ezequiel.alejandro@gmail.com)
il 18 Aprile 2015 alle 18:16

I tried that but it's not working. The compiler takes .inc file trisa and trisb configurations and then the .asm configuration which produces an error and the message "Build Failed". The only way to make it work is this mod:

;directives
PROCESSOR 16F84A

RADIX HEX

__CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF

;defs

_XT_OSC EQU H'3FFD'

_WDT_OFF EQU H'3FFB'

_PWRTE_ON EQU H'3FF7'

_CP_OFF EQU H'3FFF'

Rispondi


Farias Ezequiel (farias.ezequiel.alejandro@gmail.com)
il 18 Aprile 2015 alle 18:20

Yay!!! Now it works!!! ^^

Rispondi


Farias Ezequiel (farias.ezequiel.alejandro@gmail.com)
il 18 Aprile 2015 alle 18:32

Now works! (see the answer on the next comment). I can't share the pictures. I made two diagrams: One is to connect a microphone and the other is to connect the cube directly to the output of the PC (Jack stereo). To connect a microphone, the best choice is an LM386 (x200 configuration).

Rispondi


Gianluca (Admin)
il 18 Aprile 2015 alle 18:33

Ok, so instead of relying on the external .inc file (which causes a clash in the defines so the build error) you can use directly the hex value for the config word: __config h'3ff1'

Rispondi


Farias Ezequiel (farias.ezequiel.alejandro@gmail.com)
il 18 Aprile 2015 alle 18:40

Right. This is exactly what it shows on Pickit2 software.

Rispondi


Mohammed A (m.althibyani@gmail.com)
il 9 Maggio 2015 alle 20:06

Thank you Very much Mr.Gianluca.

You helped me to try this project.

Wow , it's very interesting, Keep going.

Rispondi


Mohammed (M.althibyani@gmail.com)
il 11 Maggio 2015 alle 16:13

Just a small questions

For MAX9812H :

Is the output voltage of it (Ac or DC) ?
I think it's AC signal just i want to make sure i am right

Also, What is the maximum output voltage for MAX9812H, because it seems i cant control the gain ?

Is it the output 1V, 2V, or 5V ....etc ?

sorry, put i really need answers for these questions..

Thank you :))

Rispondi


Mohammed A (m.althibyani@gmail.com)
il 13 Maggio 2015 alle 20:12

I am waiting your reply :(

Rispondi


Gianluca (Admin)
il 13 Maggio 2015 alle 23:50

Hi Mohammed, since the MAX9812H is an audio amplifier the output is of course an analog signal (so definitely AC). The maximum output voltage is VCC, so if VCC = 5V then the maximum output voltage is 5V.

Rispondi


()
il 15 Maggio 2015 alle 18:01

Ok Mr.Gianluca

Can I use an amplifier with an LM324 instead of using the MAX981x? (There is no MAXIUM chips here for sale)

I mean this circuit :
http://xtronic.org/wp-content/uploads/2011/07/lm324_microphone_audio_amplifier.png

i changed R2 to 180K ( Feedback ) , then i got the maximum AC voltage is 1V

should i change the R2 again to get 5V AC ?

Rispondi


Gianluca (Admin)
il 16 Maggio 2015 alle 17:20

Hello,
sure u can,
any kind of analog amplifier will do the job. Be sure to clamp your output to 5v max because you are going to connect this output to an input gpio. You can use a very simple voltage divider to do it.

Rispondi


Mohammed A (m.althibyani@gmail.com)
il 16 Maggio 2015 alle 17:39

Thank you,

so the output of this circuit
http://xtronic.org/wp-content/uploads/2011/07/lm324_microphone_audio_amplifier.png

should be connect to the RB0 direct?

other words,

if i replace MAX9812H with LM324, should i cancel the LOW-PASS filter which is after MAX9812H and all section of MAX9812H ( BC546 ) ?

Rispondi


Mohammed A (m.althibyani@gmail.com)
il 16 Maggio 2015 alle 18:00

Thank you,

so the output of this circuit
http://xtronic.org/wp-content/uploads/2011/07/lm324_microphone_audio_amplifier.png

should be connect to the RB0 direct?

other words,

if i replace MAX9812H with LM324, should i cancel the LOW-PASS filter which is after MAX9812H and all section of MAX9812H ( BC546 ) ?

Also, in this schematic

http://www.gianlucaghettini.net/wp-content/uploads/2014/01/ledcube-schematic.png

Why did you connect R12 (4.7K) from the source to the Q2 (2N7000) ,what about Q3 (2N7000) and Q4 2N7000?

Rispondi


Gianluca (Admin)
il 16 Maggio 2015 alle 18:16

the low pass filter should be in place even if you use the LM324 as it will let pass through only the low frequencies (for beat detection that's what you want).

I used R12 because RA4 is the only open drain gpio inside a PIC 16F84! So it needs a proper pull-up resistor in order to polarize the Q2 transistor.

Rispondi


Mohammed A (m.althibyani@gmail.com)
il 16 Maggio 2015 alle 18:28

Ok if keep low pass filter the output voltage is almost 1V AC,

when i remove it i got 5V AC :)

what is the problem ?

Rispondi


Mohammed A (m.althibyani@gmail.com)
il 16 Maggio 2015 alle 18:43

Ok if keep low pass filter the output voltage is almost 1V AC,

when i remove it i got 5V AC :)

what is the problem ?

Also, for R13 ( Collector of T2 ) how much should be the max outout ?

is it 5V DC ?

Rispondi


Gianluca (Admin)
il 16 Maggio 2015 alle 21:44

using the low pass filter is perfectly fine, leave it in place. The maximum voltage should be 5V. You can't go more than 5V if our power supply is rated 5V. (there isn't any dc-dc converter in there)

Rispondi


Il tuo nome o email (Se usi l'email potrai essere notificato delle risposte)
Il tuo messaggio