Hi all, first time user here (got my hands on a diecimila yesterday).
As a first project, i wanted to modify the standard pot-controlled led flashing tutorial so that
1: it reacted pretty much straight away, and
2: the timing was scalable.
My idea was to loop a polling command and have a delay which is then used to scale the maximum delay. The program works well (the flashing rate scales quite linearly), but I seem to hit a wall around 100microseconds or so. After this point, the slowest flashing rate (maximium reading, or 100*1023 microseconds) does not increase.
I think I may be hitting the processing limit of the cpu here, and would like to find a better way to poll an input (and react accordingly) every x microseconds.
The wall you are hitting is the time it takes analogRead to return the pot value. Changing the sampling rate of the analog to digital converter (ADC) was covered in a thread recently so you may want to do search to see how to do that.
All working well now, want to reduce the amount of cycles needed for an analogRead() further! How do you go about getting this info direct from the ADC? Arduino Reference - Arduino Reference is nice, but... someone needs to spell it out for this dumbo <---- :-[ 16microseconds is too long!
One of the pleasures of the arduino environment is that it insulates newcomers from the complexity of accessing the low level chip registers. The Arduino abstractions like analogRead and digitalWrite sacrifice execution speed for ease of use. If you are out to squeeze the maximum performance out of the ATmega168 chip you may find more information on this topic in the avrfreaks forum: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index
You will find there is a significant learning curve if you delve under the Arduino covers, is your goal to learn about this technology or just to realize a specific project.
I must admit that by nature I tend to grab tendrils and wring them for all that I can get
My main goal at the moment is to get a handle on running programs in a finite state machine kind of way, so that I can process multiple inputs and outputs in as near to real time as possible. One goal is to drive more than 1 stepper motor from more than 1 individual input. Will see how far I can get
Thank you for the link It is nice to know that if i ever get stuck or sick of complexities; the arudino will let me go back to nice and easy. I am certainly very impressed with how easy it is for a new comer to get up and running with this!