A PIC based frequency counter kit - part 2:changing the firmware

Поделиться
HTML-код
  • Опубликовано: 13 сен 2024
  • This video is about changing the firmware of a PIC frequency counter and crystal tester in kit form sold on the internet under many names, for example "1Hz-50MHz Digital LED DIY Kits Crystal Oscillator Frequency Counter Tester". I explain briefly how the firmware works and 4 modifications that I made to improve the resolution in the 10-100Khz range and fix some display annoyances.
    Part 1 described how to modify the unused crystal testing part of the circuit into a pre-amplifier for the input circuit. This video can be found here:
    • A PIC based frequency ...
    Note that part1 and 2 are completely independent. You can only change the firmware or only add a pre-amp or do both (as I did).
    The kits on the internet "forget" to mention that the original counter circuit and firmware were developed by Wolfgang "Wolf" Büscher, DL4YHF
    www.qsl.net/dl4...
    Wolf's original source and hex files are at
    www.qsl.net/dl4...
    My modified version (source and hex for variant 2) are at
    github.com/The...
    Microchip's development environment can be downloaded from:
    www.microchip....
    They also sell programmers, including PICkit 3

Комментарии • 57

  • @liberty9043
    @liberty9043 2 года назад

    Dear, this tester works well in the function of crystal testing. The frequency counter (meter) does not work at all. I don't know what the problem is. The voltage level of the frequency is 3-4V.

    • @TheHWcave
      @TheHWcave  2 года назад

      I am travelling at the moment and can't check but I believe the crystal tester output is connected by a capacitor. If it is directly connected it would interfere. The oscillator of the crystal tester also has a too large signal level. Btw if the crystal test works the frequency measurement works as well. The problem is to make sure you can feed external signals without being messed up by the crystal circuit. This is why I did not implement the crystal measurement circuitry. The PIC expects a TTL compatible input that swings from 0 to 5V. I uses a Schmitt-Trigger input so it does not need to be rectangular. but it must go below about 1 V and above 3 V to be recoginized

  • @hunter_pasha
    @hunter_pasha Год назад

    Hii thank form sharing , good job..The device I have is 2-stage ....1. It sends 3.3 Hz at the stage, we want to receive a signal (buzzer, LED flashing) when there is a frequency of 3.6 to 4.6 at the place it sends. In the 2nd stage, we are sending 5.2 frequencies, and we want to receive a signal in the range of 5.5 to 6.5 Hz.

  • @tinmachine722
    @tinmachine722 Год назад

    Can I read 32768Khz crystals with this modification?

  • @Mordaur
    @Mordaur 6 месяцев назад

    Would the 22pf capacitor on the back of the board still be needed/recommended for measuring low freq with this fw?

    • @TheHWcave
      @TheHWcave  6 месяцев назад

      Not sure what you mean. There are supposed to be 2 x 22p caps for the xtal tester which have nothing to do with the counter and I never built that part. In fact I used the location for a freq. counter pre-amp that has a 470nf cap to support low frequencies (especially for RPM measurements, see later videos). There is another 22p cap that is for the counter's own XTAL which is very much needed.

    • @Mordaur
      @Mordaur 6 месяцев назад

      ​ @TheHWcave This (ruclips.net/video/lcbxG18FfOs/видео.html) assembly video has a assembly PDF in the comments, and it suggests adding the extra 22pf capacitor on the back of the PCB (which is supplied with the kit, and most assembly videos I have seen think it is unneeded, and extra), for more stable low freq measurements.

    • @TheHWcave
      @TheHWcave  6 месяцев назад

      @@Mordaur oh I get it. This is to improve the crystal tester part of the circuit to make it work (oscillate) with xtals for lower frequencies. Since I have never built this part, I can't say if that helps or not but general opinion of the quality and usefulness of the crystal testing part of this kit are not great. If you are seriously into testing crystals. you might be better of building your own better oscillator for the frequencies you are interested in, add a socket for crystal swapping and then use just the counter part to read the frequency AC coupled.

    • @Mordaur
      @Mordaur 6 месяцев назад +1

      @@TheHWcave thx for the replies. I actually got this kit to easily test crystals ffrom dead circuits, so for my usecase it doesn't need to be bang on, just give a general indication that the crystal is good. Found this video that gives quite a indepth explanation of the circuit, and its shortcomming. Was an interesting watch.: ruclips.net/video/q31unvowJe4/видео.html

  • @klazing
    @klazing 3 года назад

    @TheHWcave Can the frequencies of the Si5351 clock generator be measured with this circuit? I just want to measure between 10Hz-20Khz.

    • @TheHWcave
      @TheHWcave  3 года назад

      Should be no problem, but make sure that the Si5351 output voltage is high enough >2V. If you build a pre-amp (as described) then the output voltage is less critical.

  • @vhm14u2c
    @vhm14u2c 5 лет назад

    Hi, thanks for sharing your great work on adding corrections and add-on/rpm to PIC/firmware. Can you do another add-on? Just a simple counter for counting revolutions made for winding a transformer coil using a hand-crank grinding wheel. I tried using a mechanical counter, and is not working out so well.since the counter has moving parts.

    • @TheHWcave
      @TheHWcave  5 лет назад +1

      That sounds simple, but because of the way the program works, it isn't so easy to implement. One straight forward way would be to simply add successively the measured "frequency" just before passing it to the display routine. The trouble with that approach is that you would see updates only once every second and if you spin your coil at 600 RPM or 10 pulses per second, you may miss your target by 10 counts. Need to think about this a bit more...

    • @TheHWcave
      @TheHWcave  5 лет назад +1

      The good news is that I got it basically working. The bad is that I think there is still one bug in the program and just when I found it, my programmer broke so I can't verify. This means it will take a bit longer until I can either fix the programmer (PicKit3) or get a replacement..

    • @vhm14u2c
      @vhm14u2c 5 лет назад

      TheHWcave great!, thanks for trying, sorry to hear your pic programmer is having issues. I have done your mod, first. Could not get it to power up, checked with VM, found out the voltage regulator is bad, I was going to put a 7805 in there instead, but bought a bunch off 7550s on eBay, did not arrive yet, so in the interim, tied off from another un-modded freq generator from the output of the 7550(sure gets hot for a cmos component) onto the modded board regulated output, and am showing frequencies, don’t think they are accurate though, going to do some more TS to make sure it’s showing something close to being correct, may use a YT vid doing a 1khz sine wave or 440hz, and playback into counter, see if it shows something close. My only other freq generators are those low cost kits from eBay. I have two of them, so I could hook them up to a scope using x-y mode to show lisajous(sp) patterns

    • @TheHWcave
      @TheHWcave  5 лет назад

      Vince, can you try the new version at github.com/TheHWcave/PIC-freq.counter-modification/tree/master/HiRes_Freq_RPM1234_Event_counter
      and let me know what you think?

  • @andrewscott2974
    @andrewscott2974 5 лет назад

    Great video! Your fixed firmware is a lot more usable. I'm using the frequency counter as a tachometer for my lathe. What needs to be changed to report the count as cycles per minute instead of Hz? I tried my hand at modifying the assembly but my coding at this level is pretty weak.

    • @TheHWcave
      @TheHWcave  5 лет назад

      Hmm, interesting problem... I am almost tempted to give this a go myself. Just to be sure that I understand what you want to do. If the input frequency is, say 100 Hz you want the counter to show 6000 instead of 100, correct?

    • @andrewscott2974
      @andrewscott2974 5 лет назад

      @@TheHWcave Exactly. I looked for someplace to multiply by 60 but it is beyond my skills as a Delphi programmer. The lowest speed on my lathe is around 625 rpm and the display bounces between 10 and 11. Doing the math is no problem but it would be nice to display the correct values.

    • @TheHWcave
      @TheHWcave  5 лет назад

      Yep, multiplying the frequency readout is not the solution for that. All you would get is a display jumping between 600 and 660. Instead of counting pulses in a fixed time window (say 1 second), the software must be changed to measure the time (in high res) between two pulses. Unfortunately, this means a complete rewrite of the front-end measuring routine. I'll have a look but it will take some time.

    • @andrewscott2974
      @andrewscott2974 5 лет назад

      I understand. The sampling rate needs to change to maintain the resolution. I appreciate the work you put into this already and I don't want to presume that you don't have better things to do. But...if you are able to add a select-able RPM branch to the code I'm sure quite a few people besides myself would find that useful.

    • @TheHWcave
      @TheHWcave  5 лет назад +1

      Andrew, a new firmware is now available on my github page that hopefully does what you need. Can you let me know what you think of it?

  • @Steven_Bennett_YT
    @Steven_Bennett_YT 3 года назад

    Very interesting video, can you supply pre-programmed MCU with your new firmware, if so what would be he cost to the UK? Thank you

    • @TheHWcave
      @TheHWcave  3 года назад

      Hi Steven,
      Not sure if it doesn't become too expensive. You see, I am not a seller and have not stock, nor do I have much hope selling many more ... you are the first one to ask in almost 2 years. RS sells the chips in min qty of 5 for £2.05 each (inc VAT) + £4.95 shipping. I may consider keeping the other 4 for other projects and only charge for one, pro-rated £3.04 Shipping via Royal Mail 1st class large letter is £2.45 (signed for). That's £5.50 now. For my time in programming, testing and handling, I would probably round that up to £10. Let me know through my email (see about..) if that sounds reasonable.

    • @ewiemann
      @ewiemann 3 года назад

      @@TheHWcave I wouldnt mind buying one too.

    • @TheHWcave
      @TheHWcave  3 года назад

      @@ewiemann No problem. Can you contact me through my email (see the about-page on the channel)

  • @stevec5000
    @stevec5000 3 года назад

    On my counter all it does is show -.-.-. at first, there is no single zero, then it goes to 8.8.8.8. Would the new firmware fix that?

    • @stevec5000
      @stevec5000 3 года назад

      NO! as it turns out! I got one of those worthless Pickit 3 programmers and it doesn't work either!

  • @viktorlajtercuk2206
    @viktorlajtercuk2206 4 года назад

    Hi, I have this tester, but I have problem with test some xtals, for example 20.000000Mhz, original xtal from shop not measure. where can be problem ? What is range of mesure xtals ? I know some about harmonic frequency, can be that 20MHz have low basic freq that this tester do not know measure ? THX

    • @TheHWcave
      @TheHWcave  4 года назад

      Hi Viktor, the oscillator circuit (built with that one transistor) is really terrible as a front end for the frequency counter and it is no surprise that it doesn't work with many crystals. One issue is that the oscillator is very sensitive to the supply voltage. You'll notice that it is driven directly from the DC input socket and not from the 5V regulator that feeds the rest of the circuit. This is to allow higher voltages for the oscillator. So your 1st problem could be that the oscillator needs more than 5V to work with that particular crystal, but if you increase the voltage on the DC input to >5V and the oscillator starts working now, its high output level can very easily overload the input pin of the PIC micro controller , so the counter doesn't detect it. The PIC input pin expects the low part of the signal to be 1V or less and the high part to be between 4 and 5V. Basically TTL level. If the oscillator signal is too large and swings for example between 2V and 7V it won't be recognised at all. Same problem if it is too low and never gets above 4V. The two parts of the circuit, the oscillator and the frequency counter were simply never designed to work together and whoever combined them, really did not know what he was doing. My recommendation is to forget the crystal testing part. To test your 20Mhz crystal, build an oscillator separately and make sure its output stays in the allowed range for the PIC. Have a look at a CMOS crystal oscillator circuit (www.electronics-tutorials.ws/oscillator/crystal.html has lots of xtal oscillator circuits and good explanations)

    • @viktorlajtercuk2206
      @viktorlajtercuk2206 4 года назад

      @@TheHWcave Hi, thanks for advice, so I need test many different crystals from little for watch , calculators, remote controllers to big crystal for old radiostation , receivers .
      This looks to need find other better crystal tester with more adjustable parameters :(
      About power source I test with internal 9V battery and also from external power source and with change input voltate from 5 to 9V but any effect to better measure some crystals.

  • @docmaker-italy
    @docmaker-italy Год назад

    I, sorry to bother, just a weird thing, my tester reads all xtals but the 4Mhz ones (and has problems with 4.333 too) especially with the 4mhz it seems it doesn't even has a glitch, no reading at all, I heard from a fellow he has the same problem, do you think it could be a firmware related problem or circuit? tnx a lot

    • @TheHWcave
      @TheHWcave  Год назад

      My guess (I never used or even built the xtal part), its a mix of both. The xtal oscillator is not great (or so many people say) and the original firmware has definitely a problem around 4 MHz. I explained this all in this video: ruclips.net/video/HVVcTv75RFs/видео.html

    • @docmaker-italy
      @docmaker-italy Год назад

      @@TheHWcave thnx a lot, so may i reflash the pic with your modified firmware leaving the circuit as it is originally from ebay?

    • @TheHWcave
      @TheHWcave  Год назад

      @@docmaker-italy As I said I never tried it with the xtal test part but it should work anyway.

  • @RepairRadioLab
    @RepairRadioLab 2 года назад

    and i want to know how to add display variant .... mentioned inside the code ......... "Error, Must define DISPLAY_VARIANT_1, .._2, or .._3 under project options"
    ; With MPLAB: Project..Build Options..Project..MPASM..Macro Definitions..Add
    #endif
    #endif
    #endif

  • @kd5ozy
    @kd5ozy 5 лет назад

    the input sensitivity of the counter sux! 887,400uv

    • @TheHWcave
      @TheHWcave  5 лет назад

      Well, yes, the PIC input is a schmitt-trigger but still essentially TTL level. The 1 transistor amp helps but its not great, especially since the transistor that came with the kit (for another purpose) isn't anything special. There are plenty of pre-amp circuits for frequency counters out there. Have a look at webzone.ee/radioman/counter/ for a pre-amp for this counter using a NE592. I don't need any more sensitivity as this counter is used as a display for an (old) function generator which has plenty of signal to drive the counter.

  • @igorkoloskov1123
    @igorkoloskov1123 6 лет назад

    Tested modified firmware by crystal 16Mhz it shows 16009 )

    • @TheHWcave
      @TheHWcave  6 лет назад +2

      Hi Igor, the modification would do nothing in the Mhz range. It is only effective in the

  • @RepairRadioLab
    @RepairRadioLab 2 года назад

    sir, can you please guide me how to generate .hex file from .asm file using mplab ide.... or please make a video regarding this, this could be so helpful for learners like me,....

    • @TheHWcave
      @TheHWcave  2 года назад

      that is hard because I have a very particular setup in an old virtual machine using an ancient version of mplab that you can't download anymore. I would have to basically create a new setup using whatever is currently available. Unfortunately I am maxed out with other stuff so this will be a while and I can't promise anything. Sorry

    • @RepairRadioLab
      @RepairRadioLab 2 года назад

      @@TheHWcave thank you, yes finally i able to generate hex file from other source. Now i want to know how to add display variant .... mentioned inside the code ......... "Error, Must define DISPLAY_VARIANT_1, .._2, or .._3 under project options"
      ; With MPLAB: Project..Build Options..Project..MPASM..Macro Definitions..Add
      #endif
      #endif
      #endif

    • @TheHWcave
      @TheHWcave  2 года назад +1

      @@RepairRadioLab You must have turned-off all display variants. There has to be one and only one that is enabled and all others are disabled. The error is generated when no display variant has been selected.
      an #if 0 .... #endif encapsulates a display option that is disabled. To enable it you can either change the #if 0 to #if 1 or disable the whole, if - endif by commenting it out, that is: //#if 0 ... //#endif

  • @clausfritzen7105
    @clausfritzen7105 6 лет назад

    Hello, thank a lot for charing your mods. I found it very usefull. I'm not so familiar with PIC programming. Could you please help me to add the prescaler menu in your new firmware? This menu was made by Krzysztof as mentioned in Wolfgang's article. Krzysztof firmware is at www.qsl.net/dl4yhf/freq_counter/DL4YHF_freq_mod_SQ3NQJ.7z
    Best regards, Claus.

    • @TheHWcave
      @TheHWcave  6 лет назад

      Claus, I just had a quick view and without checking what the difference between mine and Krzystof's firmware is, the crucial section of the code looks very similar to the one I used. So rather than reverse-engineering Krzystof's code, I suggest you simply reapply my changes into his. All you have to do is follow the changes in my video although the line numbers have slightly changed. In my code I used conditional compiling (the DISP_VARIANT checks) to make sure the code remains usable for people with other displays, but if you are the only user, you don't need to be so formal if you don't want to. So, here is what to do in Krzystof's code: out-comment the instructions in lines 1619 and 1620 (the testing for Range2), then out-comment the instructions in lines 1342, 1343 and 1344 (the formatting), then go to line 1865 and change the instruction to "movlw BLANK" and in line 1867 to "movlw 0". Basically you are swapping these two instructions. Then in lines 1884 change to "movlw BLANK" and in line 1886 change to "movlw CHAR_E", again you are swapping the two instructions. That's all. If it works, please let me know and also Krzystof if you can (and mention my video ;)

    • @clausfritzen7105
      @clausfritzen7105 6 лет назад +1

      Hello, TheHWcave. Thanks a lot for your answer and tips. I did just like you told me to and it worked very well. If you want I can send you the new FW and I will try to let "Wolf" knows about this mods. Once again, thanks a lot for your help. Claus

  • @aurelioslaceme66
    @aurelioslaceme66 3 года назад

    Als Powerpoint Präsentation zum Download Super. Als Video kriegt man Kopfschmerzen.

  • @medreda8807
    @medreda8807 3 года назад

    Two problems with this video: ONE, it should have specified physically AT THE BEGINNING what is an OLD KIT and what is the NEW KIT, either ID by date or by revision level inscribed on the PCB or the microcontroller itself, SECOND: not too many folks out there have the means to alter a "complicated lengthy code" as the author himself recognized. Not helpful at all, despite the offered apologetic comments I doubted their relevance.