by Tony Kathro August 2000 [anthonyk at netspace.net.au] A few notes about the hardware.
2 pic16f84a-20/p 1 20 mhz ceramic resonator 12 470 ohm resistors
decoupling caps, as required.
Construct on perfboard or similar. Plug boards will not do for these frequencies.
White noise generator. Use 20 MHz resonator. Wire MCLR high. +5 volts to VDD. Noise output is taken from any PORTB pin and wired direct to the pinking filter chip PORTA,4. That's all.
Pinking filter. Clock this chip from OSC/OUT of white noise generator. Wire MCLR high. +5 volts to VDD. Connect 470 ohm resistors from each of PORTB pins and from each pin of PORTA,0 1, 2, 3. PORTA,4 is used as the noise input pin. Bring the free ends of the twelve resistors to a common point. This is the pink noise output. Done.
The faint of heart may wish to use some decoupling capacitors here and there.
Install software to each Pic (perhaps mark them for ID ) and power up.
To evaluate performance I used an excellent Freeware program called Spectrogram obtained from www.monumental.com/rshorne/gram.html In particular, this program has a one third octave display which is ideal for pink noise. Using this feature, the flatter the line, the pinker the pink.
The software actually creates a series of steps, each one 3db down from the previous one. This works well in practice for most requirements. Purists may not agree with this and should think about dithering to create steps on steps to smooth the noise spectrum. Understanding the way the software works will show a way or two to achieve this effect.
A word of warning. The pinking filter Pic is working pretty near flat out to do its thing. Almost any thing you add will slow the software execution and reduce the high frequency performance. This should not deter you from improving my software however.
The white noise generator Pic has a little headroom for some extra tasks, but not much. I initialy used it to fill in below 70 Hz but the extra software brought it right to the edge. Out with extra software.
Over clocked 10 MHz Pics show performance changes ranging from the negligible to the gross. As you can see this directly on Spectrogram you could use this to select those Pics that will stand a little over clocking. Just for fun of course. See PS below for other uses.
I came to the conclusion that I would need a 100 MHz Pic in order to do the whole thing on one chip. I am interested to see if there are better ways of generating pink noise, so don't be shy to let me know.
Yes, I know there are faster micro's, but I set out to do it on a Pic and this old fart is stubborn.
By changing the software to RC from HS and implementing a variable oscillator from 1 MHz down, the slowed pink output displayed on a white led has all the appearance of a candle flame.
For those truly random Christmas lights, use a slow RC oscillator and treat the port pins as a 7x4 matrix (or 6x5) and drive numerous strings of lights via suitable drivers.
; pinkfilt.asm ; Pinking filter by Tony Kathro. August 2000. ; +/- 0.5db 60hz to 17,000 hz plus ; Requires 20 Mhz Pic 16f84 plus a white noise ; source flat to beyond 20Khz. Use of whitegen.asm ; recommended. ; Programme is sample and hold of white noise bits. ; Each port bit is held twice the time of the previous bit. ; All bits (12) are added by commoned 1K ohm resistors. ; Common point is output. See pink.txt for extra info LIST p=16F84 ; PIC16F84 is the target processor #include "P16F84.INC" ; Include header file __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC count1 equ 41 count2 equ 42 count3 equ 43 count4 equ 44 count5 equ 45 count6 equ 46 count7 equ 47 count8 equ 48 count9 equ 49 count10 equ 4a count11 equ 4b MAIN: bsf STATUS, RP0 movlw b'00010000' ;PORTA,4 is input from Noisegen movwf TRISA movlw b'00000000' ;all outputs movwf TRISB bcf STATUS, RP0 start bit0 bcf PORTB,0 btfsc PORTA,4 ; Test white noise sample bsf PORTB,0 ; Copy to bit0 pin btfss PORTB,0 ; equal path length nop ; ditto incf count1,f ; Advance counter btfss count1,1 ; To bit1 if set goto start ; Round again bit1 bcf PORTB,1 ; Repeat as above for each bit. btfsc PORTA,4 bsf PORTB,1 btfss PORTB,1 nop clrf count1 incf count2,f btfss count2,1 goto start bit2 bcf PORTB,2 btfsc PORTA,4 bsf PORTB,2 btfss PORTB,2 nop clrf count2 incf count3,f btfss count3,1 goto start bit3 bcf PORTB,3 btfsc PORTA,4 bsf PORTB,3 btfss PORTB,3 nop clrf count3 incf count4,f btfss count4,1 goto start bit4 bcf PORTB,4 btfsc PORTA,4 bsf PORTB,4 btfss PORTB,4 nop clrf count4 incf count5,f btfss count5,1 goto start bit5 bcf PORTB,5 btfsc PORTA,4 bsf PORTB,5 btfss PORTB,5 nop clrf count5 incf count6,f btfss count6,1 goto start bit6 bcf PORTB,6 btfsc PORTA,4 bsf PORTB,6 btfss PORTB,6 nop clrf count6 incf count7,f btfss count7,1 goto start bit7 bcf PORTB,7 btfsc PORTA,4 bsf PORTB,7 btfss PORTB,7 nop clrf count7 incf count8,f btfss count8,1 goto start bit8 bcf PORTA,0 btfsc PORTA,4 bsf PORTA,0 btfss PORTA,0 nop clrf count8 incf count9,f btfss count9,1 goto start bit9 bcf PORTA,1 btfsc PORTA,4 bsf PORTA,1 btfss PORTA,1 nop clrf count9 incf count10,f btfss count10,1 goto start bit10 bcf PORTA,2 btfsc PORTA,4 bsf PORTA,2 btfss PORTA,2 nop clrf count10 incf count11,f btfss count11,1 goto start bit11 bcf PORTA,3 btfsc PORTA,4 bsf PORTA,3 btfss PORTA,3 nop clrf count11 goto start end
whitegen.asm ; White Noise Generator by Tony Kathro. Aug 2000 ; 24 bit shift register with max. length feedback taps ; per the Art of Electronics. (second edition) ; Output is from any PORTB pin. (yes, any.) LIST p=16F84 ; PIC16F84 is the target processor #include "P16F84.INC" ; Include header file __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC sr1 equ 21 sr2 equ 22 sr3 equ PORTB MAIN: bsf STATUS, RP0 movlw b'00000000' ;all outputs movwf TRISA movlw b'00000000' ;all outputs movwf TRISB bcf STATUS, RP0 movlw b'10101010' movwf sr1 ;seed for noise gen. start movlw 0 btfsc sr3, 1 xorlw 0xFF btfsc sr3, 6 xorlw 0xFF btfsc sr3, 7 xorlw 0xFF addlw 1 rlf sr1, f rlf sr2, f rlf sr3, f goto start end
|file: /Techref/microchip/pinknoise.htm, 7KB, , updated: 2001/2/22 14:04, local time: 2022/6/26 13:26,
|©2022 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://piclist.com/techref/microchip/pinknoise.htm"> PIC Microcontoller IO Method </A>
|Did you find what you needed?|
PICList 2022 contributors:
o List host: MIT, Site host massmind.org, Top posters @20220626
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
Welcome to piclist.com!