Découvrez notre Chaîne YouTube "Ingénierie et Projets"
Découvrez notre Chaîne Secondaire "Information Neuronale et l'Ingénierie du Cerveau"

Fréquencemètre numérique à base du microcontrôleur

Analyse de fonctionnement du montage convertisseur (1) de fréquence <> tension à base du circuit LM331 

Fréquencemètre numérique à base du microcontrôleur PIC16F877A 1  

Fréquencemètre numérique à base du microcontrôleur PIC16F877A 3

 Caractéristiques électrique du circuit LM331 (Tension <> Fréquence)

Le LM331 est un circuit convertisseur tension <> fréquence dans une bande de fréquence basse (<100KHz) et à faible cout.
Le LM331 Utilise un circuit de compensation de la température dans la bande de la fréquence du circuit de référence, pour fournir une excellente précision dans la gamme de la température de fonctionnement. Le circuit de précision a des courants de polarisation faibles sans dégrader la réponse rapide nécessaire à 100 kHz.

  • Linéarité maximale 0.01%
  • Mono alimentation 5V
  • Bonne stabilité en température 50ppm/°C
  • Faible consommation 15mW à 5V
  • Large bande de fréquence 1Hz – 100KHz

Fréquencemètre numérique à base du microcontrôleur PIC16F877A 2

Datasheet du circuit LM331 : LM331

Analyse de fonctionnement du montage convertisseur (2) de fréquence <> tension à base du circuit RC 

Fréquencemètre numérique à base du microcontrôleur

La cellule C4.R8 est montée en dérivateur, il permet de convertir un signal carré en un signal impulsionnel (Dirac), le temps d’amortissement de l’impulsion dépend de la fréquence du signal d’entrée.

L’intérêt de cette étape de conversion et de convertir une transition bas ou haut du signal carré à un temps de mente ou de descente, la surface d’intégration du Dirac dépond de la fréquence. La diode D1 en direct permet d’enlever la partie négative du signal.

R7.C5.R9 est un filtre de lissage/ moyenneur il sert à réduire les ondulations et extraire la valeur moyenne du signal. La résistance R7 permet d’agir sur la valeur moyenne du signal (pont diviseur avec R9).

L’amplificateur à un gain de 101, amplifie la tension du circuit de la cellule afin de gagner en précision de mesure de l’ADC du microcontrôleur (environ 6 bits de plus !)

Fréquencemètre numérique à base du microcontrôleur PIC16F877A 5

 

La tension de sortie en fonction de la fréquence d’entrée : 

Les valeurs de la tension correspondent aux valeurs moyenne calculées par le microcontrôleur par un filtre de taille 256 échantillons. Le pas de fréquence est de 200Hz (0, 200, 400…10KHz).

s=[4.88e-3,8.95e 2,0.18,0.2688,0.3601,0.4496,0.5376,0.6273,0.7184,0.81133,0.8944,0.972,1.075,1.1632,1.25122,

1.33918,1.42716,1.51514,1.6032,1.6911,1.78,1.867,1.9562,2.0576,2.1309,2.2189,2.3069,

2.394,2.48,2.566,2.6539,2.7566,2.848,2.9423,3.005,3.09,3.177, 3.26001, 3.34746, 3.4388,

3.519, 3.607,3.6902,3.777,3.8628,3.9589,4.061,4.13977,4.2375,4.3238,4.3988].

On constate que la courbe de transfert est bien linéaire dans une bande de fréquence 200-10KHz.

Fréquencemètre numérique à base du microcontrôleur PIC16F877A 6

On prend les ‘échantillons 10 et 20 du tableau de mesure pour calculer la pente P (V/Hz), ces valeurs correspondent successivement aux fréquences 1800Hz et 3800Hz. D’où : P= (s(20)-s(10)) / (f(20) – f(10)) ~ 4.3989e-04 V/Hz (1/P = 2.2733e+03 Hz/V) .
Pour déduire la valeur de la fréquence d’une tension Vout donnée il suffit de deviser par la pente P !

Ex : Pour Vout = 4.3988 (la tension mesurée au borne de la cellule pour la fréquence 10KHz) alors le micro va afficher la valeur Vout/p ~ 4.3988/4.3989e-04 = 9.9999e+03HZ !

  1. La méthode de mesure de la pente n’est pas suffisante pour gagner en précision, car la courbe est supposée linéaire qui n’est pas le cas dans le cas réel ! Donc pas de panique si vous avez des valeurs légèrement décalées par rapport à la valeur idéale 🙂 . Pour remédie à ce problème vous prouver effecteur une compensation par le soft de la non linéarité du circuit ou utiliser un circuit de haute précision.
  2. Le circuit 1 menu d’un potentiomètre RV1 pour calibrer la valeur de la tension pour une fréquence donnée.
  3. Le temps de réponse du circuit dépend de la taille du buffer du filtre de lissage (voir programme)

Programme MikroC

/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                   Fréquencemètre Numérique                  %%%%
%%%%                     à Base du PIC16F877A                    %%%%
%%%%                          14/06/2015                         %%%%
%%%%               https://www.electronique-mixte.fr              %%%%
%%%%          https://www.facebook.com/ElectroniqueMixte         %%%%
%%%%                                                             %%%%
%%%%                                                             %%%%
%%%%      Possibilités du projet                                 %%%%
%%%%                - Mesure de la fréquence                     %%%%
%%%%                - Asservissement de la fréquence             %%%%
%%%%                - Mesure de vitesse                          %%%%
%%%%                - ...                                        %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

*/

#define                 Ref_ADC           5.0
#define                 Max_ADC           1023.0
#define                 Buffer_Length     1024
#define                 Pas_us_Mean       100

#define                 RL                400.0e3
#define                 RS                12.0e3
#define                 RV1               1.0e3
#define                 Ct                0.01e-6
#define                 Rt                6.81e3

/* LCD pinout settings */
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;

// Pin direction
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;


double            Mean_Volt=0.0;
double            Freq_HZ=0.0;
double            Mean_value=0.0;
double            Somme_ADC=0.0;
unsigned int      Data_ADC=0;


long              i=0;
char              Freq_HZ_Char[16];
char              Mean_Volt_Char[16];

const double      Coef_Corr=23.9577;
const double      Coef_Corr1=2.2733e3;

void main()
{
   // Initialisation LCD, ADC
   Lcd_Init();
   ADC_Init();
   Lcd_Cmd(_LCD_CLEAR);
   Lcd_Cmd(_LCD_CURSOR_OFF);

   Lcd_Out(1, 16, "V");
   Lcd_Out(1, 1, "0.000");
   Lcd_Out(2, 16, "HZ");
   Lcd_Out(2, 1, "0.000");


   TRISA =  0xFF;
   TRISB =  0x00;

   PORTB=0x00;
   PORTB=0x00;
   
   ADCON1=0x00;
   
   while(1)
   {
       // Calcul de la valeur moyenne
       
       for(i=0;i<Buffer_Length; i++)
       {
          /* Uncomment DAC0 OR DAC1 */
          //Data_ADC = ADC_Read(0);
          Data_ADC = ADC_Read(1);
          delay_us(Pas_us_Mean);
          Somme_ADC+=(double)Data_ADC;
       }
       Somme_ADC=Somme_ADC*Ref_ADC/Max_ADC;
       Mean_Volt=Somme_ADC/Buffer_Length;

       /* Uncomment for DAC1 */
       //Freq_HZ =Coef_Corr*Mean_Volt/(2.09*Rt*Ct*RL/(RS+RV1));
       Freq_HZ =Coef_Corr1*Mean_Volt;

       // Convert Char to String
       FloatToStr(Mean_Volt, Mean_Volt_Char);
       FloatToStr(Freq_HZ, Freq_HZ_Char);
       
       // Display
       Lcd_Out(1,1,"               ");
       Lcd_Out(1,1,Mean_Volt_Char);
       Lcd_Out(1, 16, "V");

       Lcd_Out(2,1,"               ");
       Lcd_Out(2,1,Freq_HZ_Char);
       Lcd_Out(2, 16, "HZ");
       
       // Mise à jour des paramètres
       Somme_ADC=0.0;
       delay_ms(100);
   }

}

La version #V2 du fréquencemètre numérique aura la possibilité  de régler le problème de linéarité ainsi que la largeur de la bande utile. La gamme de fréquence estimée est de quelques Hz  à quelques MHz ! De plus le nombre des composants utilisés est optimal ! 

 

Télécharger gratuitement le fichier du projet : Fréquencemètre numérique à base du microcontrôleur PIC16F877A

  1. Fréquencemètre numérique à base du microcontrôleur :  ISIS
  2. Fréquencemètre numérique à base du microcontrôleur :  Code MikroC

 

Si vous avez une question, encouragement ou critique. vous pouvez poster un commentaire en bas de la page. 

Tout les projets microcontrôleur

Click to rate this post!
[Total: 1 Average: 5]

3 commentaires

Youssef El Handa · 2022-01-05 à 2:15

Thank You , I have a question , I have to do the same project but using a raspberry pi and microcontroller , with automatic frequency range change , so how can we make a frequency-voltage converter with raspbeery pi ?

    admin · 2022-01-06 à 2:43

    You welcome. Use same IC or KA331 IC Frequency to voltage converter with ADC circuit, i’m not sure if raspberry pi have analog pin. If not, use external ADC with SPI or I2C interface.

fourat · 2015-07-04 à 7:51

Bon projet!
Merci pour le savoir faire 🙂

Laisser un commentaire

Avatar placeholder

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Anti-Robot *

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Privacy Policy

What information do we collect?

We collect information from you when you register on our site or place an order. When ordering or registering on our site, as appropriate, you may be asked to enter your: name, e-mail address or mailing address.

What do we use your information for?

Any of the information we collect from you may be used in one of the following ways: To personalize your experience (your information helps us to better respond to your individual needs) To improve our website (we continually strive to improve our website offerings based on the information and feedback we receive from you) To improve customer service (your information helps us to more effectively respond to your customer service requests and support needs) To process transactions Your information, whether public or private, will not be sold, exchanged, transferred, or given to any other company for any reason whatsoever, without your consent, other than for the express purpose of delivering the purchased product or service requested. To administer a contest, promotion, survey or other site feature To send periodic emails The email address you provide for order processing, will only be used to send you information and updates pertaining to your order.

How do we protect your information?

We implement a variety of security measures to maintain the safety of your personal information when you place an order or enter, submit, or access your personal information. We offer the use of a secure server. All supplied sensitive/credit information is transmitted via Secure Socket Layer (SSL) technology and then encrypted into our Payment gateway providers database only to be accessible by those authorized with special access rights to such systems, and are required to?keep the information confidential. After a transaction, your private information (credit cards, social security numbers, financials, etc.) will not be kept on file for more than 60 days.

Do we use cookies?

Yes (Cookies are small files that a site or its service provider transfers to your computers hard drive through your Web browser (if you allow) that enables the sites or service providers systems to recognize your browser and capture and remember certain information We use cookies to help us remember and process the items in your shopping cart, understand and save your preferences for future visits, keep track of advertisements and compile aggregate data about site traffic and site interaction so that we can offer better site experiences and tools in the future. We may contract with third-party service providers to assist us in better understanding our site visitors. These service providers are not permitted to use the information collected on our behalf except to help us conduct and improve our business. If you prefer, you can choose to have your computer warn you each time a cookie is being sent, or you can choose to turn off all cookies via your browser settings. Like most websites, if you turn your cookies off, some of our services may not function properly. However, you can still place orders by contacting customer service. Google Analytics We use Google Analytics on our sites for anonymous reporting of site usage and for advertising on the site. If you would like to opt-out of Google Analytics monitoring your behaviour on our sites please use this link (https://tools.google.com/dlpage/gaoptout/)

Do we disclose any information to outside parties?

We do not sell, trade, or otherwise transfer to outside parties your personally identifiable information. This does not include trusted third parties who assist us in operating our website, conducting our business, or servicing you, so long as those parties agree to keep this information confidential. We may also release your information when we believe release is appropriate to comply with the law, enforce our site policies, or protect ours or others rights, property, or safety. However, non-personally identifiable visitor information may be provided to other parties for marketing, advertising, or other uses.

Registration

The minimum information we need to register you is your name, email address and a password. We will ask you more questions for different services, including sales promotions. Unless we say otherwise, you have to answer all the registration questions. We may also ask some other, voluntary questions during registration for certain services (for example, professional networks) so we can gain a clearer understanding of who you are. This also allows us to personalise services for you. To assist us in our marketing, in addition to the data that you provide to us if you register, we may also obtain data from trusted third parties to help us understand what you might be interested in. This ‘profiling’ information is produced from a variety of sources, including publicly available data (such as the electoral roll) or from sources such as surveys and polls where you have given your permission for your data to be shared. You can choose not to have such data shared with the Guardian from these sources by logging into your account and changing the settings in the privacy section. After you have registered, and with your permission, we may send you emails we think may interest you. Newsletters may be personalised based on what you have been reading on theguardian.com. At any time you can decide not to receive these emails and will be able to ‘unsubscribe’. Logging in using social networking credentials If you log-in to our sites using a Facebook log-in, you are granting permission to Facebook to share your user details with us. This will include your name, email address, date of birth and location which will then be used to form a Guardian identity. You can also use your picture from Facebook as part of your profile. This will also allow us and Facebook to share your, networks, user ID and any other information you choose to share according to your Facebook account settings. If you remove the Guardian app from your Facebook settings, we will no longer have access to this information. If you log-in to our sites using a Google log-in, you grant permission to Google to share your user details with us. This will include your name, email address, date of birth, sex and location which we will then use to form a Guardian identity. You may use your picture from Google as part of your profile. This also allows us to share your networks, user ID and any other information you choose to share according to your Google account settings. If you remove the Guardian from your Google settings, we will no longer have access to this information. If you log-in to our sites using a twitter log-in, we receive your avatar (the small picture that appears next to your tweets) and twitter username.

Children’s Online Privacy Protection Act Compliance

We are in compliance with the requirements of COPPA (Childrens Online Privacy Protection Act), we do not collect any information from anyone under 13 years of age. Our website, products and services are all directed to people who are at least 13 years old or older.

Updating your personal information

We offer a ‘My details’ page (also known as Dashboard), where you can update your personal information at any time, and change your marketing preferences. You can get to this page from most pages on the site – simply click on the ‘My details’ link at the top of the screen when you are signed in.

Online Privacy Policy Only

This online privacy policy applies only to information collected through our website and not to information collected offline.

Your Consent

By using our site, you consent to our privacy policy.

Changes to our Privacy Policy

If we decide to change our privacy policy, we will post those changes on this page.
Save settings
Cookies settings

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

FPGA | Arduino | Matlab | Cours will use the information you provide on this form to be in touch with you and to provide updates and marketing.