Cov txheej txheem:

Lub Hwj Huam Mov Zis thiab Kev Ntsuas Hluav Taws Xob Siv Arduino: 6 Cov Kauj Ruam
Lub Hwj Huam Mov Zis thiab Kev Ntsuas Hluav Taws Xob Siv Arduino: 6 Cov Kauj Ruam

Video: Lub Hwj Huam Mov Zis thiab Kev Ntsuas Hluav Taws Xob Siv Arduino: 6 Cov Kauj Ruam

Video: Lub Hwj Huam Mov Zis thiab Kev Ntsuas Hluav Taws Xob Siv Arduino: 6 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Lub Hwj Huam Mov Zis thiab Kev Ntsuas Hluav Taws Xob Siv Arduino
Lub Hwj Huam Mov Zis thiab Kev Ntsuas Hluav Taws Xob Siv Arduino

Taw qhia:

Lub hom phiaj ntawm txoj haujlwm no yog ntsuas ntsuas zaus thiab qhov hluav taws xob, uas yog nruab nrab ntawm 220 txog 240 Volts thiab 50Hz ntawm no hauv Is Nrias teb. Kuv siv Arduino txhawm rau ntes lub teeb liab thiab suav qhov zaus thiab qhov hluav taws xob, koj tuaj yeem siv lwm yam microcontroller lossis pawg thawj coj uas koj muaj. Lub Circuit Court xav tau ib feem me me ntawm cov khoom siv thiab yog qhov raug rau txhua lub hom phiaj ua haujlwm.

Kauj Ruam 1: Cov Cheeb Tsam Yuav Tsum Tau

  • Arduino Ib
  • TSI LM358
  • Kauj ruam qis transformer (220V rau 12V)
  • Capacitors:

    • 0.1 ua
    • 2 x1fv
  • Resistors:

    • 3x1 kwm
    • 2 x 100 kOhm
    • 1.5k hmo
    • 3.3k hmo
    • 6.8k hmo
  • 3 x 1N4148 diode
  • Mov ci Board thiab Jumper xaim (xaiv tau)

Kauj ruam 2: Schematic Daim duab

Schematic Daim duab
Schematic Daim duab
Schematic Daim duab
Schematic Daim duab

Hauv qhov Circuit Court saum toj no, lub tshuab hluav taws xob thawj zaug txuas nrog lub zog hluav taws xob thiab thawj qhov txuas nrog peb lub ntsuas ntsuas

Kauj Ruam 3: Nkag Siab Lub Circuit Court

Kev nkag siab txog Circuit
Kev nkag siab txog Circuit
Kev nkag siab txog Circuit
Kev nkag siab txog Circuit
Kev nkag siab txog Circuit
Kev nkag siab txog Circuit

Raws li qhov ua haujlwm tau zoo, qhov Circuit no tuaj yeem faib ua plaub ntu:

A: Zero Hla Hla Ntes Circuit Court

Lub voj voog no tsim tawm 5V square mem tes thaum twg sinewave mus los ntawm qhov zoo mus rau qhov tsis zoo. Resistor R1 ua ke nrog D1 thiab D2 txwv cov khoom siv hluav taws xob viav vias ntawm qhov sib txuas ntawm diode rau -0.6V txog +5.6V (piv txwv tias diode rau pem hauv ntej kom muaj zog yog 0.6V). Tsis tas li ntawd, koj tuaj yeem nce qhov input voltage ntau ntawm Circuit Court los ntawm kev nce tus nqi R1.

Tus tiv thaiv R2 thiab R3 tsim qhov faib hluav taws xob txhawm rau txwv qhov tsis zoo qhov viav vias mus rau -0.24Volts raws li kev siv hluav taws xob ntau hom LM358 txwv rau -0.3Volts.

Tus tiv thaiv R4, R5, capacitor C1 thiab op-amp (ntawm no siv los ua tus sib piv) tsim Schmitt Trigger Circuit qhov twg resistor R4 thiab R5 teeb tsa hysteresis ntawm kev nkag mus +49.5mV saum toj saud. Cov txiaj ntsig ntawm Schmitt Trigger tau pub rau Arduino PIN2 rau kev ua ntxiv.

B: Kev rho tawm thiab qhov hluav taws xob nqis qis

Raws li lub npe qhia qhov no cais tawm thiab nqis qis dua qhov kwv yees li 12Vrms. Cov hluav taws xob qis qis tau ntxiv rau cov khoom siv hluav taws xob.

C: Peak Detector Circuit

Qhov Circuit Court no txiav txim siab qhov siab tshaj qhov siab tshaj ntawm cov teeb liab nkag mus. Resistor faib R6 thiab R7 txo qhov hluav taws xob nkag los ntawm qhov tseem ceeb ntawm 0.23 (12Vrms raug txo qis rau 2.76Vrms). Lub diode D3 tsuas yog ua haujlwm ib nrab ntawm lub teeb liab. Qhov hluav taws xob hla C2 nce mus txog qhov siab tshaj ntawm qhov hloov pauv lub teeb liab, uas yog pub rau Arduino analog pin A0 txhawm rau suav ntxiv qhov hluav taws xob.

Ib qho ntxiv, koj tuaj yeem hloov qhov Circuit Court no nrog qhov ntsuas qhov siab tshaj qhov ntsuas hluav taws xob zoo li cov hais hauv no. Tab sis rau kuv lub hom phiaj ua qauv qhia, cov lus hais los saum toj no yuav txaus.

D: Arduino

Hauv ntu no, Arduino ntes cov plaub fab uas tsim los ntawm Schmitt Trigger Circuit thiab nyeem cov hluav taws xob sib piv los ntawm qhov ntsuas hluav taws xob siab tshaj. Cov ntaub ntawv tau ua tiav txuas ntxiv txhawm rau txiav txim siab lub sijhawm (li qhov zaus) ntawm cov mem tes square (uas yog sib npaug rau tus neeg siv lub sijhawm AC) thiab qhov hluav taws xob ntawm cov khoom siv.

Kauj Ruam 4: Xam Zaus thiab Voltage

Xam qhov zaus:

Nrog kev pab los ntawm Arduino, peb tuaj yeem ntsuas lub sijhawm T ntawm lub teeb liab. Cov xwm txheej nthwv dej pulses los ntawm qhov ntsuas hla-hla tau pub rau tus pin 2, los ntawm qhov ntawd peb tuaj yeem ntsuas lub sijhawm sijhawm ntawm txhua qhov mem tes. Peb tuaj yeem siv Arduino tus timer sab hauv (tshwj xeeb Timer1) los xam lub sijhawm nyob nruab nrab ntawm ob qho nce ntawm ntug kev ntawm lub plawv mem tes nrog kev pab cuam tshuam. Lub sijhawm ua haujlwm nce ntxiv los ntawm 1 rau lub voj voog moos (tsis muaj prescaler = 1) thiab tus nqi raug khaws cia hauv npe TCNT1. Li no lub 16Mhz moos nce lub txee los ntawm 16 txhua txhua microsecond. Zoo ib yam rau prescaler = 8 lub sijhawm tau nce ntxiv los ntawm 2 txhua txhua microsecond. Yog li lub sijhawm sijhawm nruab nrab ntawm ob qho nce ntxiv

T = (TCNT1 tus nqi) / sijhawm siv rau txhua qhov suav

Qhov twg, sijhawm siv rau txhua suav = prescaler / (Arduino moos ceev (16MHz)

Li no, zaus f = 1 / T = (Arduino moos ceev (16MHz) / (Prescaler * TCNT! Tus nqi)

Li no lub sijhawm ntsuas (Hz) tau muab los ntawm = (Arduino moos ceev (16MHz)) / prescaler

thiab zaus ntawm lub teeb liab yog muab los ntawm = (Arduino moos ceev

Raws li, peb tuaj yeem xam zaus f los ntawm kev sib raug zoo f = 1/T.

Xam qhov hluav taws xob:

Onboard ADC ntawm Arduino muaj kev daws teeb meem ntawm 10 khoom (qhov muaj txiaj ntsig zoo = 2^10 = 1024), rov qab qhov txiaj ntsig hauv thaj tsam 0-1023. Txhawm rau suav qhov sib piv analog voltage V peb yuav tsum siv cov hauv qab no sib piv

V = (ADC Nyeem Ntawv) * 5/1023

Txhawm rau xam qhov hluav taws xob muab hluav taws xob Vs (rms) peb yuav tsum coj mus rau hauv tus account Transformer Ratio, Resistor divider R6R7 thiab lub ncov ntsuas pom hluav taws xob. Peb tuaj yeem yooj yim ua ke sib txawv ntau yam/piv raws li:

Transformer piv = 12/230 = 0.052

Resistor divider = R7/(R6 + R7) = 0.23

Ntawm qhov ntsuas hluav taws xob siab tshaj = 1.414

Vs (rms) = V/(1.414*0.052*0.23) = (ADC Nyeem)*0.289

Nws yuav tsum raug sau tseg tias tus nqi no nyob deb ntawm tus nqi tiag tiag, feem ntau yog los ntawm kev ua yuam kev hauv qhov piv txwv hloov pauv thiab lub diode rau pem hauv ntej qhov hluav taws xob poob. Ib txoj hauv kev los hla qhov no yog txiav txim siab qhov teeb meem tom qab sib dhos lub Circuit Court. Qhov ntawd yog los ntawm kev ntsuas qhov ntsuas hluav taws xob thiab qhov hluav taws xob hla lub capacitor C2 cais nrog lub ntsuas hluav taws xob, tom qab ntawd suav Vs (rms) raws li hauv qab no:

Vs (rms) = ((Muab Voltage *5)/(Voltage hla C2 *1023)) *(ADC Nyeem)

hauv kuv rooj plaub, Vs (rms) = 0.33*(ADC Nyeem Ntawv)

Kauj ruam 5: Arduino Code

#define volt_in A0 // analog voltage nyeem tus pin

volatile uint16_t t_period; uint16_t ADC_value = 0; ntab volt, freq; void isr () {t_period = TCNT1; // khaws TCNT1 tus nqi hauv t_period TCNT1 = 0; // pib dua Timer1 ADC_value = analogRead (volt_in); // nyeem analog voltage} ntab get_freq () {uint16_t timer = t_period; yog (timer == 0) rov qab 0; // kom tsis txhob faib los ntawm xoom lwm qhov rov qab 16000000.0/(8UL*timer); // zaus muab los ntawm f = clk_freq/(prescaler*lub sijhawm ua haujlwm)} tsis muaj teeb tsa () {TCCR1A = 0; TCCR1B = ntsis (CS11); // teem prescaler rau 8 TCNT1 = 0; // pib dua Timer1 tus nqi TIMSK1 = ntsis (TOIE1); // pab Timer1 txeej cuam tshuam EIFR | = me ntsis (INTF0); // tshem tawm INT0 cuam tshuam tus chij Serial.begin (9600); } void loop () {attachInterrupt (0, isr, RISING); // pab kom cuam tshuam sab nraud (INT0) ncua (1000); detachInterrupt (0); freq = tau_freq (); qhov = ADC_value*0.33; Txoj hlua buf; buf += Txoj hlua (freq, 3); buf += F ("Hz / t"); buf += Txoj hlua (volt); buf += F ("Volts"); Serial.println (buf); }

Kauj Ruam 6: Xaus

Xaus
Xaus
Xaus
Xaus

Koj tuaj yeem sib sau ua ke hauv kab ntawv hauv kab ntawv thiab hloov kho tus lej thiab ntxiv SD Card los khaws cov ntaub ntawv, uas tom qab tuaj yeem tshuaj xyuas. Ib qho piv txwv yog, koj tuaj yeem txheeb xyuas qhov hluav taws xob thiab zaus ntawm lub sijhawm ua haujlwm siab.

Lub Circuit Court kuv tau teeb tsa hauv lub khob cij siv LM324 (quad opamp) hloov LM358 (dual opamp) vim tias kuv tsis muaj IC nyob rau lub sijhawm ntawd thiab kaw lub tebchaws vim tias COVID-19 muaj thoob qhov txhia chaw ua rau nws nyuaj rau kuv kom tau txais IC tshiab. Txawm li cas los xij, nws yuav tsis cuam tshuam rau kev ua haujlwm ntawm Circuit.

Ua siab zoo los tawm tswv yim hauv qab no rau ib qho lus qhia thiab lus nug.

Pom zoo: