{"id":196,"date":"2012-08-18T00:00:45","date_gmt":"2012-08-17T22:00:45","guid":{"rendered":"http:\/\/majek.mamy.to\/?p=196"},"modified":"2018-03-17T22:13:22","modified_gmt":"2018-03-17T21:13:22","slug":"frequency-meter-up-to-100mhz","status":"publish","type":"post","link":"https:\/\/majek.sh\/en\/frequency-meter-up-to-100mhz\/","title":{"rendered":"Frequency meter up to 100MHz"},"content":{"rendered":"<p>Short story: I needed frequency meter, so I made it \ud83d\ude42<\/p>\n<p>Why my own? I found few frequency meters over the internet, but most of them was based on PIC microcontroller (and I hadn&#8217;t experience with this type of UC), had range up to 40-50MHz and not so accurate. But making frequency meterer based on well known AVR was difficult because maximum frequency that this chip could count directly is only half of CPU frequency which is 20MHz maximum. So, I needed divider or prescaler. Looking for right prescaler was difficult, all good looking solution was unavailable for purchase or very expensive. At the end I looked into my stock of &#8216;nice to have&#8217; parts and I surprisingly found 74HC393 chip which have maximum frequency of 100MHz! And from that point everything became easy:-)<br \/>\nFrom my junk I also digged small, cheap LCD display with serial (SPI) interface, made prototype, and surprisingly everything worked \ud83d\ude42<\/p>\n<p>Schematic:<br \/>\n<div id=\"attachment_199\" style=\"width: 650px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/schemat.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-199\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/schemat-640x337.png\" alt=\"Frequency meter - schematic diagram\" width=\"640\" height=\"337\" class=\"size-medium wp-image-199\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/schemat-640x337.png 640w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/schemat.png 912w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-199\" class=\"wp-caption-text\">Frequency meter &#8211; schematic diagram<\/p><\/div><\/p>\n<p>Prototype:<br \/>\n<div id=\"attachment_204\" style=\"width: 650px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/prototyp.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-204\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/prototyp-640x260.jpg\" alt=\"Frequency meter - prototype\" width=\"640\" height=\"260\" class=\"size-medium wp-image-204\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/prototyp-640x260.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/prototyp.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-204\" class=\"wp-caption-text\">Frequency meter &#8211; prototype<\/p><\/div><\/p>\n<p>Design of PCB:<br \/>\n<div id=\"attachment_198\" style=\"width: 386px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-198\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb-376x480.png\" alt=\"Frequency meter - PCB\" width=\"376\" height=\"480\" class=\"size-medium wp-image-198\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb-376x480.png 376w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb.png 612w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/a><p id=\"caption-attachment-198\" class=\"wp-caption-text\">Frequency meter &#8211; PCB<\/p><\/div><\/p>\n<p>Making PCB:<br \/>\n<div id=\"attachment_208\" style=\"width: 567px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-208\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb1-557x480.jpg\" alt=\"Frequency meter - PCB after termotransfer\" width=\"557\" height=\"480\" class=\"size-medium wp-image-208\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb1-557x480.jpg 557w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb1.jpg 1024w\" sizes=\"(max-width: 557px) 100vw, 557px\" \/><\/a><p id=\"caption-attachment-208\" class=\"wp-caption-text\">Frequency meter &#8211; PCB after termotransfer<\/p><\/div><\/p>\n<div id=\"attachment_209\" style=\"width: 650px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-209\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb2-640x371.jpg\" alt=\"Frequency meter - making PCB in high speed :-)\" width=\"640\" height=\"371\" class=\"size-medium wp-image-209\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb2-640x371.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb2.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-209\" class=\"wp-caption-text\">Frequency meter &#8211; making PCB in high speed \ud83d\ude42<\/p><\/div>\n<div id=\"attachment_210\" style=\"width: 650px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb3.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-210\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb3-640x438.jpg\" alt=\"Frequency meter - PCB almost ready\" width=\"640\" height=\"438\" class=\"size-medium wp-image-210\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb3-640x438.jpg 640w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb3.jpg 1024w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-210\" class=\"wp-caption-text\">Frequency meter &#8211; PCB almost ready<\/p><\/div>\n<p>Everything assembled:<br \/>\n<div id=\"attachment_212\" style=\"width: 535px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb5.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-212\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb5-525x480.jpg\" alt=\"Frequency meter - assembled, bottom side\" width=\"525\" height=\"480\" class=\"size-medium wp-image-212\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb5-525x480.jpg 525w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb5.jpg 1024w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/a><p id=\"caption-attachment-212\" class=\"wp-caption-text\">Frequency meter &#8211; assembled, bottom side<\/p><\/div><\/p>\n<div id=\"attachment_211\" style=\"width: 546px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb4.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-211\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb4-536x480.jpg\" alt=\"Frequency meter - assembled, top side\" width=\"536\" height=\"480\" class=\"size-medium wp-image-211\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb4-536x480.jpg 536w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb4-1024x916.jpg 1024w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/pcb4.jpg 1144w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><p id=\"caption-attachment-211\" class=\"wp-caption-text\">Frequency meter &#8211; assembled, top side<\/p><\/div>\n<p>Because I had problems with analog input not working as expected I left this part without elements, so I have only TTL\/CMOS input. As you can see below, it&#8217;s sufficient to me:-)<\/p>\n<p>Testing:<br \/>\n<div id=\"attachment_207\" style=\"width: 573px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/f-meter.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-207\" src=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/f-meter-563x480.jpg\" alt=\"Frequency meter - working\" width=\"563\" height=\"480\" class=\"size-medium wp-image-207\" srcset=\"https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/f-meter-563x480.jpg 563w, https:\/\/majek.sh\/wp-content\/uploads\/2012\/08\/f-meter.jpg 1024w\" sizes=\"(max-width: 563px) 100vw, 563px\" \/><\/a><p id=\"caption-attachment-207\" class=\"wp-caption-text\">Frequency meter &#8211; measuring RC controller frequency<\/p><\/div><\/p>\n<p>Software:<br \/>\nIt was quite easy to write first working version. But then appeared that even measuing itself, there was an error. After some checking I found a reason: delay between reading value from divider and internal counter, and clearing it. Error was exactly equal to number of clock cycles between these two operations. I added subroutine to correct this and it now works much more accurate. There is a possible hazard situation between reading and clearing counters as it couldn&#8217;t be atomic operation, so it requires also some fix, but maybe next time \ud83d\ude42<br \/>\nRight now it just works for me:-)<\/p>\n<p><strong>And one important additional feature I almost forgot to mention: it outputs current frequency value also via serial interface \ud83d\ude42<\/strong><\/p>\n<p>Eagle files and assembler source code you can download <a href=\"https:\/\/majek.sh\/f-meter.tgz\">here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<p>Short story: I needed frequency meter, so I made it \ud83d\ude42 Why my own? I found few frequency meters over the internet, but most of them was based on PIC microcontroller (and I hadn&#8217;t experience with this type of UC), <span class=\"excerpt-dots\">&hellip;<\/span> <a class=\"more-link\" href=\"https:\/\/majek.sh\/en\/frequency-meter-up-to-100mhz\/\"><span class=\"more-msg\">Continue reading &rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[24],"_links":{"self":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/196"}],"collection":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/comments?post=196"}],"version-history":[{"count":31,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/196\/revisions"}],"predecessor-version":[{"id":1707,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/posts\/196\/revisions\/1707"}],"wp:attachment":[{"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/media?parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/categories?post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/majek.sh\/en\/wp-json\/wp\/v2\/tags?post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}