\главная\р.л. конструкции\...

Marker generator with PIC 16F84

      This program uses a 16F84 PIC microcontroller to generate accurate square waves at frequencies of 100, 50, 25, 10 and 5 KHz. When the output is coupled via a very small value cap to a receiver, the odd and even harmonics of these markers can be heard all the way through to 30 MHz.  The markers are selected via a momentary push button switch closure to ground on pin 1. At powerup, the PIC will output a 100 KHz signal to pin 6. If the momentary switch is pressed and released (PAR), the the output will change to 50 KHz - subsequent PARs will advance down to the 5 KHz marker and then wraparound back to the 100 KHz marker.

If pin 2 is grounded, the marker will be gated (turned on and off at a regular interval). The frequency of the gating will increase as  the user changes the markers to allow easy identification of the marker. The 100 KHz marker has a slow on/off tone while the 5 KHz marker will have a very rapid buzz.

If pin 18 is grounded, the duty cycle will change from the normal 50% square wave to a 10% square wave. The idea was to even out the even and odd harmonic amplitudes, however, this isn't really accomplished but decided to leave it in anyway. It may (depending on the frequency) increase the amplitude of the even harmonics slightly.

Programming notes:

 The program is basically a timed loop. The 100 KHz loop is the tightest, executing in 10 microseconds (us). With a 4 MHz clock the PIC executes all instructions in either 1 or 2 us. This makes it quite easy to simply count the cycles of the loop to allow for exactly the correct time delay - the PIC output is then set to a 1 or 0 as needed. Seperate loops are used for all 5 markers and duty cycles - there are undoubtedly more efficient ways to do this, but this method does work.

The gating of the markers is accomplished with the use of the watch dog timer (WDT) feature of the PIC. The WDT is a seperate RC on-chip oscillator with a period of about 18 ms. The prescaler is used to count an integer number of WDT periods - after the prescaler overflows, the chip is reset, then a matching period of silence is generated using a timed loop. The loop to be executed is determined from the bits of the FSR register - the FSR register was used because it is left alone during a reset of the chip.

 Hardware notes:

 I built a prototype on perf board - I had a little trouble with  adjusting the 4 MHz oscillator to be right on frequency - the value of  the caps or something else may need to be changed - one of the two 33 pf caps connected to the crystal should be variable trimmer cap to allow this adjustment. It should be possible to use an external 4 MHz oscillator to drive pin 16 instead of using a crystal although I haven't actually tried this.

 
Click here for  schematic , sourse code 
Spectrum display of 25 KHz markers on 10M, 10% duty
Spectrum display of 25 KHz markers on 10M, 50% duty 


PIC pinout:

Pin Name Function / Connection
1 ra2 marker select, pulled up to +5V with a 10K resistor
2 ra3 gate select, pulled up to +5V with a 10 k resistor
3 ra4 no connect
4 MCLR pulled up to +5V with a 10K resistor
5 Vss Ground 
6 rb0 marker output
7 rb1 no connect
8 rb2 no connect
9 rb3 no connect
10 rb4 no connect
11 rb5 no connect
12 rb6 no connect
13 rb7 no connect
14 Vdd +5V
15 osc2 connected to one side of 4 MHz xtal, also 33 pf cap to gnd
16 osc1 connected to other side of 4 MHz crystal & 33 pf cap to gnd
17 ra0 no connect
18 ra1 duty cycle select, pulled up to +5V with a 10 k resistor

 


© 2001 - YO5OFH, Csaba Gajdos

Возврат