| Electronics > Beginners |
| Measuring pulses, schmitt trigger advice? |
| (1/3) > >> |
| Bug2k17:
I'm using an arduino to count and/or measure pulses (still working on which) to calculate the speed of a bicycle wheel used on an indoor trainer. The roller the wheel spins has 4 equal spaced gaps on a cylinder that creates the pulses as it spins (3.3v peak). As I've found, in practice this works but is not a clean stable speed reading. This looks like it might be caused by the slow and noisy rise of the pulse, as when I've used a frequency generator to send nice relatively clean pulses to the arduino, the speed reads correctly and is stable. From what I've read a schmitt trigger sounds like a solution, but all the through hole parts seem to be 14 or 16 pin packages which seems overkill for just 1 signal. I'm really not an electronics guy, but have bodged a circuit together that seems to work for my needs, just looking for advice on a part which would be best suited for this. Thanks. |
| aheid:
The Atmega328p powering the Arduino has a built-in analog comparator. You could use it to trigger when pulse voltage rises above some threshold voltage given on a second pin. In addition the analog comparator can trigger the input capture unit of timer 1, to capture a timestamp of when this happens. I have some code for this, but I can't recall if I ever got around to testing it properly before having to move... |
| mvs:
--- Quote from: Bug2k17 on November 16, 2018, 06:55:40 pm ---As I've found, in practice this works but is not a clean stable speed reading. This looks like it might be caused by the slow and noisy rise of the pulse, as when I've used a frequency generator to send nice relatively clean pulses to the arduino, the speed reads correctly and is stable. --- End quote --- Add some debouncing code to your arduino application. --- Quote from: aheid on November 18, 2018, 10:47:17 am ---The Atmega328p powering the Arduino has a built-in analog comparator. You could use it to trigger when pulse voltage rises above some threshold voltage given on a second pin. --- End quote --- Why do you think, that CMOS threshold voltage (Vcc/2) is not ok for this application? |
| aheid:
--- Quote from: mvs on November 18, 2018, 01:57:19 pm ---Why do you think, that CMOS threshold voltage (Vcc/2) is not ok for this application? --- End quote --- First off, the threshold voltage is not Vcc/2. Second, using the digital input could work using some low-pass filtering (either in hardware or software). With the analog comparator however you could set the threshold voltage yourself, and with the input capture you get the timestamp and low-pass filtering "for free". |
| Bug2k17:
Thanks for the replies. I'm already using the comparator interrupt to sync a pulse with an incoming AC signal. I'm just trying to get a nice steady speed reeding. The cycle trainer I have has a magnetic braking unit, so I'm basically making a new control unit for this which has the ability to transmit it's data via ANT+. So when linked up to a PC or tablet can be used to simulate different gradients. This is an old unit that never had a USB or ANT+ connection. |
| Navigation |
| Message Index |
| Next page |