Was the flow meter still connected to it's normal circuit? If not, are you missing a pull-up resistor?Had some time to work on the rate control. Tapped into the sprayer pressure and flow signals, and attempted some code. Also ran an oscillascope on the flow signal and wow. Much messier than I was expecting! See attached pic. Center is with the flow at "0", the taller spikes are the meter pulses....and they only reach about 200mv reliably. Amplitude scale on left side is -500mv to +500mv.
Arduino needs roughly 4v for an input to consider it "high" so some voltage amplification will be necessary. Probably some filtering as well......
My other thought is maybe the o-scope was "zoomed" out to far?Yeah flowmeter was connected to its usual circuit, and I "tee'd" into that. I was expecting a much cleaner signal so its entirely possible that that was the issue. Was hoping to run parallel with AOG until the code is completely working but that may not be an option. I can give it a whirl tomorrow with the flow sensor only going into my code and see if that and/or a pullup resistor fixes it.
Only had enough time to tap and grab some readings before my sister showed up with a blown wheel bearing -_-
That's possible (i.e. x-axis of scope). Another problem is that the digital IO pin connected to sensor has too high of impedance. The IO pins of the AVR have very high impedance if you don't add any extra circuity. That means they draw hardly any current from the line connected to them. With such low current, noise can become a big problem, especially if you have a long wire going to the sensor. That is why in industrial settings they often don't use voltage for sensors but "4-20 mA current loops". Having a current in that range makes the sensor much less susceptible to noise (e.g. magnetic fields inducing voltage in the cable).My other thought is maybe the o-scope was "zoomed" out to far?
ppm = (uint16_t)( TICKS_PER_CALC * /* convert microseconds to minutes */ 1000000 * 60 / /* divided by microseconds passed */ (now - last_times[last_time]) ); last_times[last_time] = now; last_time = (last_time + 1 ) % TICKS_PER_CALC;