Close

Use atmega328p internal comparator instead of external comparator.

A project log for Wind sensor using car reversing kit

A wind speed and direction sensor from an Ebay car reversing kit and an Arduino

kwikiuskwikius 10/05/2021 at 19:350 Comments

To get the project working originally I used an external comparator. The comparator is used first to measure the magnitude of the received pulse stream and then to detect zero crossing, by means of positive feedback which moves the trip level between the two levels dependednt on output state

I wanted to use the internal comparator and eleiminate theat extra component. One problem with the internal comparator is that the outout doesnt go to a pin, which means the traditional positive feedback cant be used. I originally decided to use a spare pin as an output and use it to set positive feedback to the input it in the comparator interrupt, but then I realised I could just use 2 different comparator channels and switch between them in the comparator interrupt.  After some headscratching  and layout issues this is now working well and I plan to stick with this option for the moment. This is actually a much nicer option since it doesnt put any load on the output and samples the filter ground directly rather than a voltage which is around the same level as I was doing with the external comparator. I also would hope that the settling time is much reduced since both of the negative outputs have constant values, one at filter ground and one at envelope detect voltage and the filter output is not loaded at all.

I also got v2 of the circuit working using the car reversing pcb in the videos, which is much neater than V1, so now need to do a new video about it all.

Discussions