From our › Theremin Project I derived this Frequency Counter Library. The library makes it possible to measure frequencies with a high resolution and accuracy.
The Frequency input is fixed to digital pin 5. This pin is mapped to the alternate port function T1 which is the input 16 Bit Hardware Counter1. To obtain a higher resolution than 16 Bit, the counter overflows are counted also and are calculated with the counter value to the final long integer result. The Frequency Source output must have a digital level so that weak Signals have to be amplified for instance by an single transistor or a 74HC14 inverter. The maximum input frequency is about 8 MHz when signal duty cycle is 50%.
If you like to measure higher frequencies you have to use an prescaler or divider circuit which can be used from other counter projects published in the web. The Gate Time for the counting period can be chosen in the start() function where values of 10, 100 or 1000 ms are practicable for a resolution of 100, 10 and 1 Hz but any value can be used. The internal resolution of the gatetime is 2 ms so that the time can be varied in the increment of 2. If you wish to minimize the indication error the value of FreqCounter::f_comp variable can compensate slight gatetime errors. Compared to an commercial ACECO counter it is possible to trim the deviation to almost zero over the whole range. For gatetimes of 10,100,100 the values 1, 10 and 100 where found to be good for our Duemilanova boards.
จากของเรา> แดมินโครงการที่ผมได้รับมานี้ความถี่เคาน์เตอร์ห้องสมุด ห้องสมุดที่ทำให้มันเป็นไปได้ที่จะวัดความถี่ที่มีความละเอียดสูงและความถูกต้องป้อนความถี่ถูกกำหนดเป็นดิจิตอลขา 5 ขานี้แมปไปยังฟังก์ชั่น T1 พอร์ตอื่นซึ่งเป็นอินพุทที่ 16 บิตฮาร์ดแวร์ Counter1 เพื่อให้ได้ความละเอียดสูงกว่า 16 บิตล้นเคาน์เตอร์จะนับและยังมีการคำนวณมูลค่าที่เคาน์เตอร์เพื่อผลจำนวนเต็มยาวสุดท้าย เอาท์พุทที่มาความถี่จะต้องมีระดับดิจิตอลเพื่อให้สัญญาณอ่อนแอจะต้องมีการขยายตัวอย่างโดยทรานซิสเตอร์เดียวหรือ 74HC14 อินเวอร์เตอร์ อินพุตความถี่สูงสุดคือประมาณ 8 MHz เมื่อรอบการทำงานสัญญาณคือ 50% หากคุณต้องการที่จะวัดความถี่สูงที่คุณต้องใช้ prescaler หรือแบ่งวงจรซึ่งสามารถใช้จากโครงการเคาน์เตอร์อื่น ๆ ที่เผยแพร่ในเว็บ ประตูเวลาสำหรับระยะเวลาการนับสามารถเลือกฟังก์ชั่นเริ่มต้น () โดยที่ค่าของ 10, 100 หรือ 1,000 มิลลิวินาทีที่ทำได้สำหรับการแก้ปัญหาของ 100, 10 และ 1 เฮิร์ตซ์ แต่ค่าใด ๆ ที่สามารถนำมาใช้ ความละเอียดภายในของ gatetime เป็น 2 มิลลิวินาทีเพื่อให้เวลาที่สามารถแตกต่างกันในการเพิ่มขึ้นของ 2 หากคุณต้องการที่จะลดข้อผิดพลาดในการแสดงค่าของตัวแปร FreqCounter :: f_comp สามารถชดเชยข้อผิดพลาด gatetime เล็กน้อย เมื่อเทียบกับ Aceco เคาน์เตอร์เชิงพาณิชย์ก็เป็นไปได้ที่จะตัดค่าความเบี่ยงเบนไปเกือบเป็นศูนย์ในช่วงทั้ง สำหรับ gatetimes ของ 10,100,100 ค่า 1, 10 และ 100 ที่พบว่าเป็นสิ่งที่ดีสำหรับบอร์ด Duemilanova ของเรา
การแปล กรุณารอสักครู่..
