Greetings to the Freakin' Crew....
Straight away this is an existing commercial product I designed several years ago that a new feature has been asked to be added.
Background, I have an air pressure sensor that outputs a 14 bit reading via I2C. These readings are stored in an AVR until the host polls the device and once the transfer is done it sits in a holding pattern waiting to be polled again. Nothing to impressive.....
When the customer needs to change the air pressure in the line, they have to connect a gauge and then turn a small screw in my device to change the inline pressure. Problem is that this is sometimes not so simple as the gauge is not nearby.
The solutions is to load the desired pressure reading in EEPROM and flash a small LED I have on the unit in response to the setscrew point. Once the pressure is within a certain 'window' the led will illuminate solid and when the pressure goes above the window, the blinking will continue faster and faster.
My thought was to blink the LED at a frequency between 0Hz and 10 Hz. The blink rate does not need to be entirely linear as long as the led blinking goes faster and faster as the pressure climbs higher and higher. Still sounds simple enough, Since this is a window comparator type thing, I will have the upper and lower limits stored in the CPU to compare the pressure readings to.
Heres the thing, the sensor is taking readings faster than the led can blink. Meaning that a simple timer compare setup toggling the led will not respond fast enough to the user turning the screw and the sensor sending out the data. Even though there is a 'window' its not very large and it would be very easy to miss one of the limits.
So I am looking for some suggestions on how to tighten the LED blink rate update to the sensor read speed. Waiting for the LED blink to finish a cycle before taking a reading is not practical. I have thought about using multiple:
if((pressure > x) and (pressure <= y)){Blink this fast}
But thats a lot of if() statements.
Another option I am toying with is to either Vary TCNT or OCRx.
Any suggestions are certainly welcome.
JIm