/*This project measures the period of any frequency applied to the Mic การแปล - /*This project measures the period of any frequency applied to the Mic ไทย วิธีการพูด

/*This project measures the period


/*

This project measures the period of any frequency applied to the Microcounteroller.
Pin INT(external interrupt) is used to detect each rising edge of the wave.
Timer1 is used the calculate the time of the wave period(Ton + Toff).
This is how it works:
1 - First rising edge is detected using INT(external interrupt).
2 - Timer1 will start counting.
3 - Second rising edge is detected using INT(external interrupt).
4 - Timer1 will stop counting because from first rising edge to the second rising edge is a complete wave which means the period(Ton + Toff).
5 - Calculate period.
6 - Display results on LCD.


Author: Sameer Semmoor
*/





// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections


unsigned int timer1_register; //stores timer1 register value
unsigned int overflow_number=0; //stores timer1 overflow number
unsigned long counter=0; //stores coutner value
char counter_text[11]; //sotres counter value converted to string
float period; //stores the periodic time
char period_text[20]; //stores the periodic time converted to string

unsigned short edge_counter=0; //edge counter, will be used to determine fisrt & second rising edges of the pulse
bit flag; //will be set if two edges are detected, so freguency & period can be calculated



void CONFIGURE_CAPTURE()
{
trisb.b0 = 1; //B0(INT0) as input
INTEDG_bit = 1; //Interrupt on rising edge of RB0/INT pin
INTE_bit = 1; //enable INT0 external interrupt

//Timer1 configurations---------------------------------------------------------
//prescaler 1:8
T1CKPS1_bit = 1;
T1CKPS0_bit = 1;

TMR1IE_bit = 1; //enable timer1 overflow interrupt
TMR1ON_bit = 0; //stop timer1 at the beginning
TMR1H = 0; TMR1L = 0; //reset high & low bytes of timer1
//------------------------------------------------------------------------------

//enable all interrupts
PEIE_bit = 1;
GIE_bit = 1;
}

void get_print_timer1()
{
timer1_register = (TMR1H
0/5000
จาก: -
เป็น: -
ผลลัพธ์ (ไทย) 1: [สำเนา]
คัดลอก!
/*This project measures the period of any frequency applied to the Microcounteroller.Pin INT(external interrupt) is used to detect each rising edge of the wave.Timer1 is used the calculate the time of the wave period(Ton + Toff).This is how it works:1 - First rising edge is detected using INT(external interrupt).2 - Timer1 will start counting.3 - Second rising edge is detected using INT(external interrupt).4 - Timer1 will stop counting because from first rising edge to the second rising edge is a complete wave which means the period(Ton + Toff).5 - Calculate period.6 - Display results on LCD.Author: Sameer Semmoor*/ // LCD module connectionssbit LCD_RS at RB2_bit;sbit LCD_EN at RB3_bit;sbit LCD_D4 at RB4_bit;sbit LCD_D5 at RB5_bit;sbit LCD_D6 at RB6_bit;sbit LCD_D7 at RB7_bit;sbit LCD_RS_Direction at TRISB2_bit;sbit LCD_EN_Direction at TRISB3_bit;sbit LCD_D4_Direction at TRISB4_bit;sbit LCD_D5_Direction at TRISB5_bit;sbit LCD_D6_Direction at TRISB6_bit;sbit LCD_D7_Direction at TRISB7_bit;// End LCD module connectionsunsigned int timer1_register; //stores timer1 register valueunsigned int overflow_number=0; //stores timer1 overflow numberunsigned long counter=0; //stores coutner valuechar counter_text[11]; //sotres counter value converted to stringfloat period; //stores the periodic timechar period_text[20]; //stores the periodic time converted to stringunsigned short edge_counter=0; //edge counter, will be used to determine fisrt & second rising edges of the pulsebit flag; //will be set if two edges are detected, so freguency & period can be calculatedvoid CONFIGURE_CAPTURE(){ trisb.b0 = 1; //B0(INT0) as input INTEDG_bit = 1; //Interrupt on rising edge of RB0/INT pin INTE_bit = 1; //enable INT0 external interrupt //Timer1 configurations--------------------------------------------------------- //prescaler 1:8 T1CKPS1_bit = 1; T1CKPS0_bit = 1; TMR1IE_bit = 1; //enable timer1 overflow interrupt TMR1ON_bit = 0; //stop timer1 at the beginning TMR1H = 0; TMR1L = 0; //reset high & low bytes of timer1//------------------------------------------------------------------------------ //enable all interrupts PEIE_bit = 1; GIE_bit = 1;}void get_print_timer1(){ timer1_register = (TMR1H<<8) + TMR1L; //get high & low bytes of timer1 //get counter value + number of overflow of timer1, so we can store values greater than 65536, because timer1 can only count up to 65536. counter = ( overflow_number * 65536 ) + timer1_register; //calculate period period = (float)(counter + 1); period = (float)period * (4); period = (float)period * 1/20000000; period = (float)period * 8; //convert counter & period values to string LongWordToStr(counter, counter_text); FloatToStr(period,period_text); //display timer1 & period values lcd_out(2,1,"counter: ");lcd_out(2,9, counter_text); lcd_out(4,1, "T: ");lcd_out(4,5, period_text); lcd_out_cp("S"); //reset Timer & counters TMR1H = 0; TMR1L = 0; overflow_number = 0;}void interrupt(){ if(TMR1IF_bit == 1) //if Timer1 overflowed { TMR1IF_bit = 0; //reset timer1 interrupt flag overflow_number++; //increment every timer1 overflow } if(INTF_bit == 1) //if INT0 interrupt occured (rising edge detected) { INTF_bit = 0; //reset INT0 interrupt flag TMR1ON_bit = 0; //stop timer1 edge_counter++; //increment by 1 if(edge_counter == 1) //if cnt incremented by 1 , this means first rising edge is detected { TMR1ON_bit = 1; //timer1 start counting } if(edge_counter == 2) //if cnt incremented by 1 again menas 2, this means second rising edge is detected { //disable all interrupts PEIE_bit = 0; GIE_bit = 0; TMR1ON_bit = 0; //stop timer1 flag=1; //set this flag, to indicate that timem of the pulse is counted } }}void main() { Lcd_Init(); // Initialize LCD Lcd_Cmd(_LCD_CLEAR); // CLEAR display Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off CONFIGURE_CAPTURE(); lcd_out(1,1, " CAPTURE TIMER1"); while(1) { if(flag == 1) //if this flag is set { get_print_timer1(); edge_counter=0; //reset rising edge counter flag = 0; //reset this flag //reenable all interrupts PEIE_bit = 1; GIE_bit = 1; } }}
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 2:[สำเนา]
คัดลอก!

/ * โครงการมีขนาดระยะเวลาความถี่ใด ๆ ที่นำไปใช้กับ Microcounteroller. พิน INT (ขัดจังหวะภายนอก) ถูกนำมาใช้ในการตรวจสอบแต่ละขอบที่เพิ่มขึ้นของคลื่น. Timer1 ถูกนำมาใช้คำนวณเวลาของรอบระยะเวลาคลื่น (ตัน + Toff). นี้ คือวิธีการทำงาน: 1 - ขอบขาขึ้นครั้งแรกที่มีการตรวจพบการใช้ INT (ขัดจังหวะภายนอก). 2 - Timer1 จะเริ่มนับ. 3 - ขอบขาขึ้นประการที่สองมีการตรวจพบการใช้ INT (ขัดจังหวะภายนอก). 4 - Timer1 จะหยุดเพราะนับจากครั้งแรกที่เพิ่มขึ้น ขอบถึงขอบที่เพิ่มขึ้นสองคือคลื่นที่สมบูรณ์ซึ่งหมายถึงระยะเวลา (ตัน + Toff). 5 - คำนวณระยะเวลา. 6 - ผลการแสดงผลบนหน้าจอ LCD. ผู้แต่ง: เมีย Semmoor * / // การเชื่อมต่อโมดูลจอแอลซีดีSBIT LCD_RS ที่ RB2_bit; SBIT LCD_EN ที่ RB3_bit; SBIT LCD_D4 ที่ RB4_bit; SBIT LCD_D5 ที่ RB5_bit; SBIT LCD_D6 ที่ RB6_bit; SBIT LCD_D7 ที่ RB7_bit; SBIT LCD_RS_Direction ที่ TRISB2_bit; SBIT LCD_EN_Direction ที่ TRISB3_bit; SBIT LCD_D4_Direction ที่ TRISB4_bit; SBIT LCD_D5_Direction ที่ TRISB5_bit; SBIT LCD_D6_Direction ที่ TRISB6_bit; LCD_D7_Direction SBIT ที่ TRISB7_bit; // สิ้นสุดการเชื่อมต่อโมดูลจอแอลซีดีที่ไม่ได้ลงชื่อ timer1_register int; // timer1 ร้านค้าลงทะเบียนค่าint ไม่ได้ลงนาม overflow_number = 0; // ร้านค้า timer1 ล้นจำนวนที่ไม่ได้ลงชื่อเคาน์เตอร์ยาว = 0; // ร้านค้า coutner ค่าcounter_text ถ่าน [11]; // Sotres ค่าตัวนับแปลงสตริงระยะเวลาลอย; // เก็บเป็นระยะเวลาperiod_text ถ่าน [20]; // เก็บเป็นระยะเวลาที่แปลงเป็นสตริงedge_counter ได้ลงนามสั้น = 0; // ขอบเคาน์เตอร์จะถูกใช้ในการกำหนด fisrt และขอบที่เพิ่มขึ้นที่สองของการเต้นของชีพจรธงบิต // จะถูกตั้งค่าถ้าสองขอบมีการตรวจพบดังนั้น freguency และระยะเวลาที่สามารถคำนวณเป็นโมฆะ CONFIGURE_CAPTURE () { trisb.b0 = 1; // B0 (INT0) เป็น input INTEDG_bit = 1; // ขัดจังหวะบนขอบที่เพิ่มขึ้นของ RB0 / INT ขาINTE_bit = 1; // ช่วยให้การขัดจังหวะภายนอก INT0 // การกำหนดค่า Timer1 ---------------------------------------- ----------------- // prescaler 1: 8 T1CKPS1_bit = 1; T1CKPS0_bit = 1; TMR1IE_bit = 1; // ช่วยให้ล้น timer1 ขัดจังหวะTMR1ON_bit = 0; // timer1 หยุดที่จุดเริ่มต้นTMR1H = 0; TMR1L = 0; // ตั้งค่าไบต์สูงและต่ำของ timer1 // --------------------------------------- --------------------------------------- // ช่วยให้ขัดจังหวะทุกPEIE_bit = 1; GIE_bit = 1; } เป็นโมฆะ get_print_timer1 () { timer1_register = (TMR1H << 8) + TMR1L; // รับไบต์สูงและต่ำของ timer1 // ได้รับค่าเคาน์เตอร์ + จำนวนล้นของ timer1 เพื่อให้เราสามารถเก็บค่ามากกว่า 65,536 เพราะ timer1 สามารถนับได้ถึง 65536 เคาน์เตอร์ = (overflow_number * 65536) + timer1_register; / / การคำนวณระยะเวลาระยะเวลา = (float) (เคาน์เตอร์ + 1) ระยะเวลา = (float) ระยะเวลา * (4) ระยะเวลา = (ลอย) * ระยะเวลา 1/20000000; ระยะเวลา = (ลอย) * ระยะเวลา 8; // แปลงและเคาน์เตอร์ ค่าระยะเวลาสตริงLongWordToStr (เคาน์เตอร์ counter_text); FloatToStr (ระยะเวลา period_text); // แสดงผล timer1 และระยะเวลาค่าlcd_out (2,1 "เคาน์เตอร์"); lcd_out (2,9, counter_text); lcd_out (4, 1 "T:"); lcd_out (4,5, period_text); lcd_out_cp ("S"); // ตั้งค่าตัวจับเวลาและเคาน์เตอร์TMR1H = 0; TMR1L = 0; overflow_number = 0; } ขัดจังหวะเป็นโมฆะ () { if (TMR1IF_bit == 1) // ถ้า Timer1 ล้น{ TMR1IF_bit = 0; // รีเซ็ต timer1 ขัดขวางธงoverflow_number ++; // เพิ่มล้นทุก timer1 } ถ้า (INTF_bit == 1) // ถ้า INT0 ขัดจังหวะเกิดขึ้น (เพิ่มขึ้นขอบตรวจพบ) { INTF_bit = 0; // การตั้งค่า INT0 ขัดขวางธงTMR1ON_bit = 0; // หยุด timer1 edge_counter ++; // เพิ่มขึ้นโดย 1 ถ้า (edge_counter == 1) // ถ้า CNT เพิ่มขึ้นโดยที่ 1 นี้หมายถึงการเพิ่มขึ้นครั้งแรกที่ขอบมีการตรวจพบ{ TMR1ON_bit = 1; // Timer1 เริ่มนับ} ถ้า (edge_counter == 2) // ถ้า CNT เพิ่มขึ้นทีละ 1 อีกครั้ง Menas 2 นี้หมายถึงการที่สองขอบที่เพิ่มขึ้นมีการตรวจพบ{ // ปิดการใช้งานทั้งหมดขัดจังหวะPEIE_bit = 0; GIE_bit = 0; TMR1ON_bit = 0; // หยุด timer1 ธง = 1; // ตั้งธงนี้เพื่อแสดงให้เห็น timem ของพัลส์ที่นับ} } } เป็นโมฆะหลัก () { Lcd_Init (); // การเตรียมจอแอลซีดีLcd_Cmd (_LCD_CLEAR); // แสดงผลที่ชัดเจนLcd_Cmd (_LCD_CURSOR_OFF); // เคอร์เซอร์ออกCONFIGURE_CAPTURE (); lcd_out (1,1 "จับ Timer1"); ในขณะที่ (1) { if (ธง == 1) // ถ้าตั้งค่าสถานะนี้{ get_print_timer1 (); edge_counter = 0; // ตั้งค่าที่เพิ่มขึ้นขอบเคาน์เตอร์ธง = 0; // ตั้งค่าสถานะนี้// เปิดใช้ทั้งหมดขัดจังหวะPEIE_bit = 1; GIE_bit = 1; } } }




















































































































































การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 3:[สำเนา]
คัดลอก!

/

งานนี้มาตรการช่วงความถี่ที่ใช้กับ microcounteroller .
ขา INT ( ภายนอกนะ ) จะใช้ในการตรวจสอบแต่ละขอบที่เพิ่มขึ้นของคลื่น
ไทเมอร์ 1 จะใช้คำนวณเวลาของช่วงคลื่น ( ตัน คนชั้นสูง ) .
นี่คือวิธีการทำงาน :
1 - ก่อน ขอบที่เพิ่มขึ้นถูกตรวจพบใช้ INT ( ภายนอกนะ )
2
- ไทเมอร์ 1 จะเริ่มนับ
การแปล กรุณารอสักครู่..
 
ภาษาอื่น ๆ
การสนับสนุนเครื่องมือแปลภาษา: กรีก, กันนาดา, กาลิเชียน, คลิงออน, คอร์สิกา, คาซัค, คาตาลัน, คินยารวันดา, คีร์กิซ, คุชราต, จอร์เจีย, จีน, จีนดั้งเดิม, ชวา, ชิเชวา, ซามัว, ซีบัวโน, ซุนดา, ซูลู, ญี่ปุ่น, ดัตช์, ตรวจหาภาษา, ตุรกี, ทมิฬ, ทาจิก, ทาทาร์, นอร์เวย์, บอสเนีย, บัลแกเรีย, บาสก์, ปัญจาป, ฝรั่งเศส, พาชตู, ฟริเชียน, ฟินแลนด์, ฟิลิปปินส์, ภาษาอินโดนีเซี, มองโกเลีย, มัลทีส, มาซีโดเนีย, มาราฐี, มาลากาซี, มาลายาลัม, มาเลย์, ม้ง, ยิดดิช, ยูเครน, รัสเซีย, ละติน, ลักเซมเบิร์ก, ลัตเวีย, ลาว, ลิทัวเนีย, สวาฮิลี, สวีเดน, สิงหล, สินธี, สเปน, สโลวัก, สโลวีเนีย, อังกฤษ, อัมฮาริก, อาร์เซอร์ไบจัน, อาร์เมเนีย, อาหรับ, อิกโบ, อิตาลี, อุยกูร์, อุสเบกิสถาน, อูรดู, ฮังการี, ฮัวซา, ฮาวาย, ฮินดี, ฮีบรู, เกลิกสกอต, เกาหลี, เขมร, เคิร์ด, เช็ก, เซอร์เบียน, เซโซโท, เดนมาร์ก, เตลูกู, เติร์กเมน, เนปาล, เบงกอล, เบลารุส, เปอร์เซีย, เมารี, เมียนมา (พม่า), เยอรมัน, เวลส์, เวียดนาม, เอสเปอแรนโต, เอสโทเนีย, เฮติครีโอล, แอฟริกา, แอลเบเนีย, โคซา, โครเอเชีย, โชนา, โซมาลี, โปรตุเกส, โปแลนด์, โยรูบา, โรมาเนีย, โอเดีย (โอริยา), ไทย, ไอซ์แลนด์, ไอร์แลนด์, การแปลภาษา.

Copyright ©2024 I Love Translation. All reserved.

E-mail: