Digispark as multiple servo driver.

Arduino projects on the go
Posts: 326
Joined: 16 Feb 2018, 14:11
Location: Warwickshire

Re: Digispark as multiple servo driver.

Post by Martin » 06 Aug 2019, 18:42

Yes the rotating buffer should work just as fast. There are advantages both ways, but the main advantage of the method I outlined is that you don't need a buffer - only a total. So if you had a very noisy signal, didn't need a fast output and wanted to average say the last 1000 readings, you could do that without needing a 1000-element array. You'd probably choose 1024 rather than 1000 to allow the quick divide, and then you'd just need a total variable 'wide' enough to cope with up to 1024 times the highest possible reading.

Strictly the method doesn't average over the number (like 1024) of samples and actually takes more samples than that to reach a new steady state after a step change of the input value. The output follows a sort of exponential curve with the limit at the new steady input value - so the output changes faster to begin with and then changes slower and slower as it approaches the new level. Your rotary buffer method produces a straight line ramp response to a step input - and achieves the new stable value exactly after one buffer rotation.

Posts: 178
Joined: 31 Jan 2019, 11:48
Location: Boskoop, Netherlands

Re: Digispark as multiple servo driver.

Post by MaxZ » 06 Aug 2019, 19:19

Interesting stuff this, thanks guys. The trick will be to remember it when I need it :roll: , difficult for me as an occasional coder :?


Post Reply