Hello,
I'm using an Uno board for an application which requires automatic feedback control.
The board is receiving speed pulses on a digital input pin. I can capture these, determine a speed value, and write the output to the serial monitor. That's the easy part.
The unit that I intend to have the Uno replace sort of acts like an automobile cruise control system: Based on the current speed, a throttle position setting is sent to the engine. It appears that this data is sent digitally. I have not yet determined the format or the exact timing.
So, I have input data on one pin arriving at a variable rate and output data leaving on another pin at a different, fixed rate. Do you all have any ideas on how to structure the code to accomplish this?
Here are some ideas:
Round-robin scheduling: In main loop, call procedure to use the PulseIn function to capture the speed input, call another procedure every xx milliseconds to output the position setting
Interrupt scheduling: In main loop, capture speed input in the same manner as the previous idea. Generate an interrupt every xx milliseconds to divert processing to code which outputs the position setting. (Is this even possible?)
Any suggestions you have will be greatly appreciated.
Thanks!
Scott