Searching \ for '50MHZ Freq Meter translation(soon to be: stealing' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=stealing
Search entire site for: '50MHZ Freq Meter translation(soon to be: stealing'.

No exact or substring matches. trying for part
PICList Thread
'50MHZ Freq Meter translation(soon to be: stealing '
1998\02\11@020144 by Bob Blick

face
flavicon
face
With apologies to Simone Benvenuti and Andrea Geniola, here is a crude
electronic translation of the text for the 50MHZ frequency counter.

------------------------------------------------------------------------
Digital Frequenzimetro with visualization to four figures
Author: Simone Benvenuti & Andrea Geniola
The circuit introduced here carries out the digital function of
frequenzimetro avvalendosi of a microprocessore of family PIC and of little
others external members. For practical reasons it has been used PIC 16C84,
but more economic models can be used also, like the 16C54, provided that
they arrange at least 12 piedini of I/O + 1 of access to the " Timer module
". Program FMETER concurs with the device to measure frequencies in the
range 050 MHz visualizing the result on 4 display to 7 segments (in the
ingegneristico format: " x,yzEn " Es. 5,75*10^6) piloted directly from the
escapes of the microprocessore taking advantage of the multiplazione to
time division. The circuit has been developed to pure didactic scope and
for this it does not introduce characteristics from instrument of elevated
quality, also being exceptionally precise, much economic and particularly
easy to use.
The system, whose outline electrical worker is shown in the rows
fmeter.gif, is composed from a PIC 16C84, a quartz from 4 MHz, 2
condensers, 7 resistances, 4 transistors and 4 display to seven common
cathode segments.

The listato one of the program, enriched of comments for facilitarne the
reading, is brought back in the rows fmeter.asm and efmeter.asm (version
with comments in English)

Introduction: the lines guide continuations during the planning of the
circuit have been directed to the realization of one economic, versatile
instrument and of simple use. The economization has been pursued trying to
limit the most possible number and the cost of the external, allineandosi
members therefore to the philosophy continuation from the engineers of the
Microchip in the planning of microprocessori PIC which, exactly, for their
operation, only need of an external quartz. The versatilit2a is given from
the possibility of uses on a wide range of frequencies; in fact, thanks to
I use of contatore TMR0 and to the possibility to operate divisions of
frequency through the inner Prescaler, 50 frequencies can be measured until
MHz. Finally the semplicit2a of use that is derives from that one that it
is the more interesting characteristic of the instrument, the function "
car-range ", that the fast reading of the measure without the necessity of
some regulation from part of the operator concurs. An other characteristic
of which the instrument it is equipped is that one to enter automatically
in stand-by (the PIC goes in sleep-mode and the display they are
extinguished) when the income is not sped up in order more than 10 second
(this time is easy variable via software) and to riaccendersi, without need
of the participation of the operator, not as soon as it comes applied a
beacon in income.
As far as the precision of the instrument, having opted for a visualization
to three meaningful figures, in the development of the program has adopted
a position an algorithm that approximates the figure to visualize with one
precision of 0.5%. Only if the frequency is under 256Hz the visualized
figure flashes, to signal that the error can be greater of the previewed
one. The final error of the instrument depends but also, and in marked way,
>from the precision with which it is succeeded to set up the frequency of
the clock inner of the microcontroller on the 4MHz; it is necessary
therefore that the external quartz to the PIC has Q much elevating.
Holding present that the plan is to didactic scope it is avoided as an
example to enrich the instrument of ulterior sagacities like the
memorization of the measure or the verification of out of the range.
Moreover the circuit is lacking in an income stage that can be realized in
varied ways (preamplifier to FET, squadratore with buffer CMOS,
fotoaccoppiatore, etc.) to second of the requirements of the customer. If
however the source to measure has an amplitude between the 3 and the 6 Volt
peak-peak and is able of sopportare the effect loading with the instrument,
then the circuit can be used also without an ulterior stage of income.

Description of the circuit: device PIC16C84 is equipped of 13 piedini of
I/O subdivided in the following way: accessible 8 piedini through the
Port-b registry and the remaining 5 through the 5 bits less meaningful of
the registry Door; the nomenclature of the pins is of the Rxn type, where x
report the door To or the door B and n indicates the number of order of the
bit to the inside of the Port-x registry. You notice yourself that to the
inside of the PIC16C84 piedino the RA4 is collegabile to an able
asynchronous contatore to find transitions of beacons that they have a
duration at least 10 nSec of their levels (in the PIC16C54 contatore inside
TMR0 is accessible from piedino the T0CKI that always corresponds to n the
3). The maximum noticeable frequency is therefore of 50 MHz.

In order to pilot the 7 segments of the four display the 7 bits have been
used more meaningful of the Port-b of the microcontroller, while bit RB0 is
used for the control of the piedino of income. The cathode of every display
comes connected to mass through a BJT of control which it must be able to
sopportare the current of 7 segments. The bases of every BJT come commant,
through one resistance from 2,2 KW, the four bits less meaningful of the
door To (RA0-RA3). The choice of the BJT is not critical in how much they
comes used like logical switches; using of the transistors to high gain as
the BC548 obtain one better brightness of the segments. In case they are
wanted to be used of the display to common anode is sufficient to adopt of
transistors PNP you mail between feeding and anode, commanding then is the
segments that the bases of the BJT with tensions " denied " regarding those
current ones. The connection through the resistance from 470 Ohm of piedini
RA4 and RB0 to the source to measure concurs of and to carry out the
sampling of the beacon on RA4, for a period of time established from the
program, simply placing in high stiffness (that is settando in income)
piedino the RB0. During the phases in which not it wants that the contatore
proceeds he is sufficient to hold piedino the RB0 set up in escape. Others
external members are: the resistance from 10 KOhm mails between income and
mass that serves not to leave the piedino sensitive " floating " RA4 and
therefore to disturbs, the resistance from 180Ohm that it concurs with the
decimal point of before number to always remain ignited, one or two
stabilization condensers on the feeding (100nF and 22mF they are adequate
values). This last one must be comprised between 3 and i 6 V: this allows
to the device of being fed also with two simple batteries " stilo " from 1,5V.

Description of the program:

1. General notes

The PIC16C84 reserves an area of memory of 36 Bytes for the implementazione
of general registries (GPR). In the operations between registries these
goes reported with just the numerical address, but the programming language
previews the possibility to associate, through the directive " equ ", a
name to one constant numerical, so that more intuitiva becomes the reading
of the program inizializzando the given mnemonic names to the registries
with their address. In program FMETER.ASM they have been introduced of the
labels for the general registries, the more important di.le which we bring
back of continuation:

name addr. function

joined 0Ch      ;unit2a for the display
tenth 1Dh       ;decimi for the display
cents 1Eh       ;centesimi for display
esp 1Fh         ;esponente for display the high
H_byte 10h      ;byte of the counted number (n)
L_byte 11h      ;byte low of the counted number (n)
tmr 01          ;asynchronous contatore
fsr 04          ;registro of indirizzamento
number 13h      ;parametro for the procedure " segments "
U 14h           ;unit2a
D 15h           ;decine
H 16h           ;centinaia
M 17h           ;migliaia
DM 18h          ;decine of migliaia
CM 19h          ;centinaia of migliaia
Door 05h        ;I/O port A
Door 06h        ;I/O port B

For one more immediate understanding of the program has acquired knowledge
the temporal evolution of the algorithm through a diagram of flow in which
the procedures are evidenced and the parts of the program that carry out
various functions; to the inside of every block it is brought back, in the
cases of greater interest, also the employed time to carry out the
indicated operation. To flank or the inside of every block the more
important registries are marked that they endure variations. Finally,
evidenced from the cerchiatura, are present some meaningful labels of jump.
The diagram of flow of the program fmeter.asm is contained in the rows
diag1.gif

Great part of the elaboration analytics of the result comes carried out
>from the procedure calculation, of which it has been thought useful to
bring back the outline of temporal evolution. Also in this case they have
been brought back the useful indications taking advantage of the same
convention. The diagram
of flow of the procedure calculation is contained in the rows diag2.gif.  

2. Operation of the program

The instrument carries out a frequency measure counting the number of
foreheads of climb of the income beacon that arrive on piedino the RA4 in
the interval in which piedino the RB0 it is placed in high stiffness. The
measurable maximum frequency is, like has said, of 50MHz, therefore, having
a " contatore registry to 16 bits " (formed from the union of set up
contatore TMR0 and the prescaler on the division for 256), the time of
suitable sampling to the measure of the maximum frequency turns out of
1mSec; in fact in 1mSec they would arrive to more the 50.000 impulses,
rappresentabile number on 16 bits. Leaving as only time of sampling that
one of 1mSec the measurable minimal frequency would be 1KHz and however the
error store clerk counting less than 100 impulses (100KHz) it would become
high too much. In order to render versatile and precise the instrument a
second period of sampling has been introduced that concurs to measure lower
frequencies containing the error;  several considerations have carried to
choose like interval a time of 0.5 second ones: therefore making in fact
maximum the frequency measurable it is of 131KHz (2*216), that it concurs
to discard made inferior measures to 128KHz with the sampling of 1mSec.
Moreover the time of 0.5 second ones allows to find a minimal frequency of
2Hz, but wanting to limit the error to the same value store clerk on the
scale of 1mSec, every measure under 128 impulses (that is 256Hz) comes
shown with flashes that the operator perceives who the error could be
greater. Finally 0.5 Sec corresponds just to the chosen interval in order
to renew the measure and concurs therefore one easier determination of the
times in game in the program. Wanting to realize an instrument that it
contains the error also for frequencies many lowlands, it is necessary to
set up a various type of algorithm in which, only if the frequency of the
income beacon is under a sure value, the number of cycles of clock is
available that they elapse between two, they count the number of cycles of
clock that they elapse between two consecutive foreheads of climb of the
income beacon, measuring therefore the period, and calcolandone then the
mutual one in order to go back to the frequency. In order to pilot the 4
figures without having to employ a PIC that arranges at least 28 (7
segments x 4 figures) piedini of I/O the technique of multiplazione TDM is
used feeding in sequence the display for a time of approximately 1.25/100
of second everyone. Necessary E' that to the term of the cycle of
refreshment of visualization, than hard 12.5 x 4 = 50 mSec, a new cycle has
beginning in the arc of little milliseconds waves to avoid lampeggiamenti
of the display. For this reason Sec is unthinkable not to carry out the
cycle of refreshment  of the display during the measure of 0.5, while it is
possible interromperlo in order to make the sampling of 1mSec. These last
and previous observations are deductible easy observing the diagram of flow
of the program, which the extension as to the start of the device it comes,
like first operation, carried out the initialization of the registries. In
particular, to the aim to test the perfect functionality of the 4 display,
they come loaded the registries that support the visualization operation
(unit, tenth, cents, esp) with value " 8 ", so as to to ignite number
8,88E8 in successive the twenty calls of the procedure of refreshment
(Refresh). Finished to this operation the program it carries out the
sampling for a 1mSec setting up in income pin the RB0. This operation comes
carried out settando the bit0 of the TrisB registry which, being mappato in
Bank 1, it needs, for being addressed, of the estimate settaggio of bit5 of
the registry the Status. To the end of the sampling the counted number of
impulses is memorizzato on sixteen bits to the inside of the brace of
registries tmr and prescaler. This last one is not but accessible neither
in writing  neither in reading and therefore it has become necessary to
carry out the operation of extraction of the value in it obtained through
the Prescaler procedure that, once saved the content of tmr in the Hbyte
registry, it sendes through piedino of control RB0 a series of impulses on
RA4 until unit of the value contained in tmr does not find the increment of
one. To this point the number contained in the prescaler is deductible
carrying out the difference between 256 and the number of impulses sent
through RB0 and comes memorizzato in the Lbyte registry. Subsequently the
program operates the control of the content of  Hbyte and Lbyte in order to
decide if to carry out a new sampling on the 0.5 interval of Sec or if to
be able to proceed to the visualization. In this last case the hundred
registries of of migliaia are annulled, tens of migliaia, etc while esp
place to 3 comes realizing therefore the multiplication for 1000. The
procedure of Calculation carries out, to this point, the conversion in base
ten on 6 figures of the binary number on 16 bits passatogli in Hbyte_Lbyte
(first two blocks of the diagram of flow of the procedure Calculation); it
executes an eventual approximation on the quarter number meaningful
(successive 4 blocks) and it is taken care to copy in the registries units,
the tenth and cents first three figures useful and to add to esp the
opportune value, represented from the number of divisions for ten necessary
ones in order to have a single figure before the virgola (last block).
Finally an opportune jump filler to the procedure of Refresh (loop1),  than
reads the value to visualize in the registries unit, tenth, cents and esp.
If the content of Hbyte_Lbyte turns out instead to the smaller control of
128, must be carried out a sampling on 0.5 Sec; therefore it is proceeded
to the zero setting of the registry tmr and the RB0 is placed in high
stiffness pin. The time of 0.5 Sec is counted calling for 20 times the
procedure of Refresh (with opportune adjustments). To fine sampling one
repeats the extraction of prescaler and the control on Hbyte_Lbyte. In case
the value is greater of 127, then must be multiplied for two before calling
the procedure Calculation: this operation comes carried out making to
shiftare to the left of a bit the content of Hbyte_Lbyte, after to have
added the single figures of number 65535 to containing the registries the
value in base ten if the bit more meaningful than Hbyte it was settato.
Also in this case the jump is to the label loop5 and the visualization will
happen in all probability after that the sampling of 1mSec will have failed
the measure. If instead to the control the number he turned out smaller of
128, then it comes made an ulterior test on the value contained in
Hbyte_Lbyte: if the program is greater of zero, before executing the
multiplication for two it arrests for twenty calls of the procedure delay
(approximately 0.25 second ones), creating therefore a " effect I flash ".
If instead the contained value of Hbyte_Lbyte he is equal to 0 come
annulled the figures to visualize, decrementa of a content of the Zeri
registry taking place itself if this last one has arrived to 0: if the test
gives to positive outcome the processore comes sent in sleep-mode, in
attended that a forehead of climb on the income ne concurs the awakening,
otherwise it is jumped to the label loop5 from which new measure begins one
on the time of 1mSec. Verosimilmente number 0,00E0 on the display will come
visualized to the beginning of the new cycle of sampling to 0.5 Sec.  The
program previews an easy participation on the parameter that regulated the
time of attended before that the function enters in execution stand-by
(enough to modify the value given to the Zeri registry to the beginning of
the program and the beginning of the procedure Calculation); moreover it is
possible to exclude this function completely and to qualify the control of
the flow of the program from part of the watchdog, in how much however they
have been predisposed in the program the opportune commandos of zero
setting of this contatore.

3. Notes on the procedures

Others two interesting procedures, beyond to the " calculation " of which
already it has been spoken, are the ruotine of delay and that one of
ignition of the segments. In the drawing up of before account of the fact
has been kept that the microcontroller, being a device of type RISC, has
following the main characteristics:  
* The phase of fetch operates of the successive instruction during the
execution of the previous one, therefore the instructions of jump have a
double duration, in how much us it must be the time in order to unload the
fetch of the immediately successive operation and to load the destinataria
instruction with the jump (comes executed one NOP). Conditioned jumps
(BTFSS, BTFSC, DECFSZ and INCFSZ) can that is have a duration of two cycles
if the jump comes effectively executed, if have taken place the condition
demanded or of a single cycle if it does not come discarded the successive
instruction.
* The instructions to disposition of the programmatore are in number rather
reduced (only 35 operations) but they have the pregio of having a fixed and
equal duration for all, excluded the jumps.  The acquaintance of these two
property facilitates the calculation of the times of execution of the
several sections of the program, whose felt precision is generally a lot in
the software of management of instrumentations. In our case the delay
ruotine, with to ulterior adjustments to the inside of the program, has
allowed to realize a wait of 0.5 second exact ones in the sampling of the
lower frequencies (is noticed that draft of 1,250,000 cycle-instruction).
The procedure " segments " adopts artifice that concurs, using instruction
RETLW X opportunely (return from procedure with value X in W), to attribute
a value to W scegliendolo simply through a number of progressive order (in
our case " number ") in one prefixed table. This is possible adding to PC
(the contatore registry of program) the number of chosen order and making
therefore a jump of variable length.

4. Conclusions

The program has been assembled and simulated using appropriate software
(MPASM.EXE and MPSIM.EXE), and has been realized in more than a copy with
great satisfaction for the perfect resolution of the plan; the solo exactly
that it has been moved regards the light one to abbassarsi of brightness of
the figures to regular intervals (for the nearly imperceptible truth). This
defect probably would disappear using a faster microprocessore, like the
PIC16C54 to 20MHz, that it would employ very little time to carry out the
several procedures of calculation and bringing back, limiting therefore
little more than 1mSec the time in which the Refresh is not executed. In
order to use a frequency of clock various from 4MHz it is but necessary to
replace in the variable ones used for several the cycles of attended the
ricalcolati values for the new one clock. The device has been planned and
realized in the within of the plan of examination of Systems of Elaboration
of the bachelor course in Engineering Electronic held from the Prof. Luigi
Rizzo, which it has allowed us to render public our job inserendolo in the
list of the plans for PIC, accessible on INTERNET to page WEB:
http://www.iet.unipi.it/~luigi/pic.html
>From which it is also possible to unload the listato one of the program.

Simone Benvenuti,                       Andrea Geniola,
Via Damiano Chiesa  n¡ 9              Via Francesco Pardi  n¡ 3
56123 Pisa,        ITALIA               56100 Pisa,       ITALIA


http://www.bobblick.com/

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...