Archive

Posts Tagged ‘pic16F628’

Frecventmetru V2 by Phil Rice VK3BHR

March 16th, 2013 8 comments

Frecventmetru V2 by Phil Rice VK3BHR

Frequency Meter v2 PIC16F628

Frequency Meter v2 PIC16F628

This version features a much simpler front end, an extended frequency range and a coarse calibration function implemented in software. It retains the ability to add or subtract one of three IF offsets, making it suitable as a frequency display for a direct conversion or superhet receiver (also for transmitters using “on frequency” VFOs or using mixing). Resolution remains at 10Hz and accuracy is in the order of 100Hz.

How it works:
A self biased common emitter amplifier produces a pseudo-TTL driving signal. The 10uH inductor in the collector lead helps extend the high frequency response. Any “fast” NPN transistor should be suitable. I used a BFR91, but you may substitute a transistor scrounged from an old TV tuner or a VHF receiver.

The amplifier’s quiescent Vce is set to 1.8 to 2.2 volt by the resistor marked * on the diagram. It is nominally 10K, but you may need to change it. The collector voltage is applied to the PIC’s counter/timer via a series 470 ohm resistor.The PIC is able to short this signal to ground via an internal pull-down transistor to disable counting. It is crude, but quite effective.

The PIC implements a 32 bit counter, partly in internal hardware and partly in software. Counting is enabled by turning off the internal pull-down transistor for “exactly” 0.4 second. At the end of this time, the PIC divides the count by 4, then adds or subtracts the appropriate IF frequency to get the actual frequency. The resulting count is converted to printable characters and delivered to the display.

Setting up!
Before the frequency meter will work properly, it must be calibrated. This may be as simple as connecting a known frequency source and adjusting the trimmer capacitor so the correct value is displayed. If you are unable to adjust the displayed frequency, then a “coarse calibration” is required.

This involves starting with the power off. Pin 10 is connected to ground and the power is then turned on (and held on). The PIC will measure and display the input frequency, followed by the letters CAL. If you can’t adjust the indicated frequency to the correct value (by adjusting the 33 pF trimmer), then coarse adjustments can be made by briefly connecting pin 12 or pin 13 to ground. It may take several tries, because the program only checks these pins once each measurement (0.4 second). Once you are happy with the adjustment, remove the ground from pin 10 (while power is still applied). This will cause the PIC to store the calibration in non volatile internal memory.

Normally pin 10 is floating at turn on, but may be grounded later to “program” the Intermediate frequency offsets. The next few paragraphs, copied (with amendments) from the September 2002 article describe how this is done.

To program the intermediate frequencies, connect the BFO to the the counter then set up the PIC as follows:

Ground pins 12 and/or 13 of the PIC to select one of three IF offsets. Pin 12 when pulled low, indicates the BFO is on its lower frequency. Pin 13 when pulled low, indicates the BFO is on its higher frequency. Alternatively, you can pull both pins 12 and 13 low to use the third offset. If both pins 12 and 13 are left floating, the PIC will not actually store anything!

To store the measured BFO in the selected internal EEPROM, just ground pin 10 of the PIC for at least 0.5 second, then release it.

For normal operation, the RF input of the counter is connected to the receiver VFO and the PIC uses the stored IF offsets to calculate the actual frequency. If neither BFO selection pin (12 and/or 13) is pulled low, the PIC uses the average BFO frequency. If no IF offset is required, just measure and store 0Hz for both offsets. Alternatively, you can pull both pins 12 and 13 low to use the third offset (which must also be programmed to 0Hz.)

Pin 11 when held low, indicates that the selected IF is to be added to the measured VFO frequency to give the indicated frequency. If pin 11 is floating, then a subtraction is done (VFO-IF or IF-VFO, whichever is appropriate).

Some LCD displays are configured as “8 character by 2 line” but with all the characters displayed on the one line. To cater for these displays, the PIC tests pin 18 occasionally. If it finds this pin grounded, it it inserts a “move to line 2″ command after the eighth character. If your display only shows eight characters, then try grounding pin 18 of the PIC.

Frequency Meter V2 By Phil Rice VK3BHR_1

Frequency Meter V2 By Phil Rice VK3BHR_2

Getting the software:

Click this link for the assembler source code!

Here is the hex code for PIC16F628

Generator PWM cu PIC16F628 v1.2

September 9th, 2012 4 comments

Generator PWM cu PIC16F628 v1.2

Pulse-width modulation (PWM), or pulse-duration modulation (PDM) is a modulation technique that conforms the width of the pulse, formally the pulse duration, based on a modulator signal information. Albeit this modulation technique can be used to encode information for transmission, its main use, actually, is to allow the control of the power supplied to electrical devices, specially to inertial loads like motors.

The average value of voltage (and current) fed to the load is controlled by turning the switch between supply and load on and off at a fast pace. The longer the switch is on compared to the off periods, the higher the power supplied to the load is.

The PWM switching frequency has to be much faster than what would affect the load, which is to say the device that uses the power. Typically switchings have to be done several times a minute in an electric stove, 120 Hz in a lamp dimmer, from few kilohertz (kHz) to tens of kHz for a motor drive and well into the tens or hundreds of kHz in audio amplifiers and computer power supplies.

The term duty cycle describes the proportion of ‘on’ time to the regular interval or ‘period’ of time; a low duty cycle corresponds to low power, because the power is off for most of the time. Duty cycle is expressed in percent, 100% being fully on.

The main advantage of PWM is that power loss in the switching devices is very low. When a switch is off there is practically no current, and when it is on, there is almost no voltage drop across the switch. Power loss, being the product of voltage and current, is thus in both cases close to zero. PWM also works well with digital controls, which, because of their on/off nature, can easily set the needed duty cycle.

PWM has also been used in certain communication systems where its duty cycle has been used to convey information over a communications channel.

Schema completa:

PWM_Simulare

Fisierul .HEX pentru 16F628A @ 6MHz (XTAL)

PWM_16F628A@6MHz

 

Categories: electronica Tags: ,

Frecventmetru 1Hz – 50MHz cu PIC16F628 Freq-02

February 20th, 2012 2 comments

Frecventmetru 1Hz – 50MHz cu PIC16F628 Freq-02

Etajul de intrare (amplificator)

Etajul de intrare (amplificator)

Vederea cablaj – 3D

Categories: electronica Tags: , ,

LED controlat cu impulsuri modulate in durata – 16F628

February 21st, 2011 1 comment

Fisier HEX pentru Schema_PWM_LED 16F628_CCP1

Fisier HEX pentru Schema_PWM_LED 16F628 INT_RB0