Open bengtssk opened 3 months ago
Putting the 2n2 cap between the base of the BC847 and ground may be a better solution. Frequencies counter now works well below 5mV RMS at frequencies up to 65 khz. The duty cycle of the square wave is no longer 50%, but I think it should be enough for the micro controller to trig any way.
1 khz, 2 channel at FREQ:
65khz, 2 channel at FREQ:
Thanks for the clear scope pictures! I experienced the same problems, the 2n2 cap is probably too much, with the 47k base resistor, it effectively creates a LPF of around 1.5 kHz. If you want to see 200 kHz as cut-off frequency, you need something like 15 pF, maybe try 100 pF and see what it does? I am working on the issue at the moment, I tried to make the calc_freq() function more robust, but there's definitely a HW issue here.
Regarding item 1) and 2): Looks like you have the old firmware, maybe stm8flash gave an error? Check if you have the Vpp option, if not, you have the old firmware. I updated the ADC full-scale values and SW now works with the 4k7 value without problems.
I had the old firmware. Flashed the a new uC using STM8flash and the wrong hex-file. The new version hex-file is located in debug/ExeCB, the comments are wrong btw.
Flashing it with the new firmware solved item 1 and 2. And I like the new firmware too, thanks!
Recently finished building PCB 4 version 0.20, and flashed the PIC using the hex-file from /Debug/exe. And it seems to to what it should to (have only tested it with PCB1 so far) and the frequency counter performs better now. But there are some issues what I've discovered;
Didn't notice any changes in the software for the micro controller and the LCD still says v0.14. Is is possible that it's the wrong hex file uploaded?
Had to change R24 from 4k7 to 6k8 in order to get the RMS reading right.
The frequency counter still have problem with signal levels under about 200mV RMS. This was a surprise, cause the detector circuit worked so well in theory, and I'm still not sure why. Looking at the scope pictures below (channel 1 is sync and channel 2 i FREQ) it it clear that at very low input levels the square wave at FREQ i a bit "interrupted". Thus causing the micro controller to trig more than once every cycle. Pictures below is at about 5 mV RMS input. It is not so very visible at higher levels, but I think it's the same phenomena that occurs until about 200mV (but my scope can't show it clearly enough to be sure).
Putting a cap of at least 2n2 or so between freq and ground solves the problem, and the frequency counter works again. Problem is that at high frequencies, the output becomes to saw tand-shaped and it stops working again cause the amplitude isn't enough to trigger the input of the micro controller. Below is with a 2n2 cap from FREQ to ground at 5 mV 1khz input.
For some reason the counter works better at higher frequencies. I have no idea what causes this "interruption" of the square wave, interference? And nor that the solution may be, some sort of filtering, changing the BC847 to MOSFET? Or are there any software engineering trick to get around this, like increasing the triggering time for the micro controller at low frequencies?