Jump to content
ELFORUM - Forumul electronistilor

Muzica cu un PIC


vladutz2000

Recommended Posts

Salut Am facut un sistem de muzica cu unde ...patrate? (square waves in engleza , nu stiu daca traducerea e mot-a-mot in romana ..).Ruleaza pe un 16F88 (4Kb) @ 20 Mhz si l-am programat sa redea o anumita frecventa pe care o citeste din ROM (dupa programul propriu zis , am dat paste la un format compilat in hex pentru "muzica"pe care sa o redea).Un interrupt pe TMR0 modifica frecventa de 10 ori pe secunda , citind urmatorul word din memorie , si tot asa , pana la capat , dupa care o ia de la inceput. Softul isi face treaba foarte bine , am si scris un tracker pentru windows cu care sa creezi fisierul de muzica pentru chip.Dar vreau sa ii fac 3 canale , prin urmare sa fie 3 valori cu frecventa si interruptul sa citeasca din 3 in 3 word-uri , fiecare fiind frecventa pentru un canal separat , de exemplu WORD1,WORD2,WORD3,WORD1,WORD2....si tot asa pana la sfarsitul memoriei.asta pot sa fac .. dar nu stiu cum sa combin cele 3 canale intr-unul singur , sau cum sa le redau pe toate , pe pini diferiti , dar in acelasi timp ....aveti vreo idee ? stiti vreo tehnica cu care se face asta ? (da, 3 canale de unde pulsate/patrate)

Link to comment
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • vladutz2000

    4

  • Mikrosha

    1

Popular Days

Top Posters In This Topic

Daca procesorul merge la 20M n-ai avea problema sa reduci delay-ul la tmr0 sa zicem la...0,1ms? Asta-ti va permite o frecventa maxima de 10KHz. Se va citi din memorie 3 valori a,b,c. Se reseteaza un contor k. La fiecare intrerupere se vor intampla urmatoarele:

- decrementeaza a,b,c

- Daca a=0 atunci schimba pinul corespunzator (porta.x=|porta.x)

- La fel pentru b si c, fiecare pe cate o iesire

- incrementeaza k

- daca (k==1000) reseteaza k si citeste urmatoarele valori.

Sper ca-ntelegi ideea.

 

Si in legatura cu iesirea, faci un convertor digital-analogic simplu cu rezistente:

Posted Image

Link to comment

Am scris un program in BASIC folosind indicatiile tale.

E corect asta ? :

define OSC 20tick var wordstart var worda var wordb var wordc var worda1 var wordb1 var wordc1 var wordouta var byteoutb var byteoutc var bytepos var wordstart=408pos=startouta=1outb=1outc=1readcode pos,areadcode pos+1,breadcode pos+2,ca1=ab1=bc1=cOPTION_REG = $10     ' Set TMR0 prescalerOn Interrupt Goto myint ' Define interrupt handlerINTCON = $A0           ' Enable TMR0 interruptmain:'Main program goes heregoto main' Interrupt handlerDisable                    ' No interrupts past this pointmyint:  if a > 0 thena=a-1elsea=a1outa=!outaendifif b > 0 thenb=b-1elseb=b1outb=!outbendifif c > 0 thenc=c-1elsec=c1outc=!outcendifif outa == 1 thenhigh 0elselow 0endifif outb == 1 thenhigh 1elselow 1endifif outc == 1 thenhigh 2elselow 2endifif tick < 1000 thentick=tick+1elsetick=0if pos <= 4092 thenpos=pos+3elsepos=startendifreadcode pos,areadcode pos+1,breadcode pos+2,ca1=ab1=bc1=cendifINTCON.2 = 0        Resume                Enableend
Link to comment

mda, am testat programul ala din BASIC si nu e bun de nimic :| stiti si voi vreun compilator ( + IDE) .. de gen C ? in afara de MikroC , care nu imi compileaza niciodata proiectele ... :sparge:

Link to comment

Minune ! Dupa vreo 3 ore de incercari , mi-a mers ! O singura problema ... programul , chiar daca numara 10 000 de tickuri (o secunda ) , nu schimba tonurile o data la o secunda , e cam de vreo 3-4 ori mai rapid chiar ! Ce ar putea sa fie ?

define OSC 20tick var wordstart var worda var wordb var wordc var worda1 var wordb1 var wordc1 var wordouta var byteoutb var byteoutc var bytepos var wordtick=0start=512pos=startouta=1outb=1outc=1readcode pos,areadcode pos+1,breadcode pos+2,ca=5000/ab=5000/bc=5000/ca1=ab1=bc1=c              OPTION_REG = $0     ' Set TMR0 prescalerOn Interrupt Goto myint ' Define interrupt handlerINTCON = $A1           ' Enable TMR0 interrupt' Interrupt handlerDisable                    ' No interrupts past this pointmyint:  if a >= 1 thena=a-1elseouta=~outa if outa == 1 then  high 0 else  low 0 endifa=a1endifif b >= 1 thenb=b-1elseoutb=~outb if outb == 1 then  high 1 else  low 1 endifb=b1endifif c >= 1 thenc=c-1elseoutc=~outc if outc == 1 then  high 2 else  low 2 endifc=c1endifif tick <= 10000 thentick=tick+1elsetick=0 if pos <= 4092 then pos=pos+3 else pos=start endifreadcode pos,areadcode pos+1,breadcode pos+2,ca=5000/ab=5000/bc=5000/ca1=ab1=bc1=cendifgoto myintINTCON.2 = 0        Resume                Enableend
Nu mai am problema,am rezolvat-o !
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines