-
The Right Answer
02/14/2021 at 01:33 • 0 commentsSo I looked into this project again recently and came to the sudden realization that I had not taken the next obvious step and put the Sweeper class into an independent library, like the Servo library! Wishing to learn from the excellent examples that exist, I spent some quality time digging into the Servo library. After some careful consideration, I devised a way to create a Sweeper class that could be a separate library - just what I wanted! Then I modified a couple of sketches to test out my shiny new library. A few tweaks later and it works great.
This led to an extensive revision of this project! Reading back over the entries I made for it, I now realize that most of it is moot. It just explained the process I went through to develop the library. The important point is that a Sweeper library has been created. Examples will show how to use it. Since I can't delete or modify the build logs, I will use to them mainly for the history of the development of the Sweeper Library. Very little more needs to be said about that. Note that the sketches I developed along the way using an inline Sweeper class definition are now gone. I have replaced these by examples which use the Sweeper Library. These examples are included with the Sweeper Library.
-
Class Improvements and Helper Functions
04/02/2017 at 19:37 • 0 commentsOK! Except for some tiding up, the desired functions are working. Uh, sort of. Now it's time to make the Sweeper class easier to use and to add some helper functions to do interesting things - like group moves perhaps. For those playing along at home, this will be the useful version!
Step 1: Fix the Sweeper class so that no arguments are required to instantiate a Sweeper object. Why? Because an array of Sweepers can now be created. This keeps the code for creating, initializing, and updating the servos nice and clean.
Step 2: Add some useful class functions. The code to initialize a move with destination and time is now separate from the function that enables the move. Doing this allows several moves to be set up, then all started at the same time, for a group move. Now it is likely that this is not necessary in most cases, but I thought it would be nice to have and would eliminate worries caused by starting moves at staggered times.
Step 3: Create a "group move" function. The idea here is to allow a group of servos to be easily defined (as an array), along with a corresponding array of target angles and an allowed time for the move.
Step 4: Time the worst case operation. Suppose all the Sweepers need to move on the same tick. Will there be time or will there be a timing conflict?
Still coming: video of a simple demo. Bonus: Lego link: Gear and Mount. -
Modifications for More Control
03/12/2017 at 00:57 • 0 commentsThe first (Adafruit) version of the code simply swept two servos back and forth over their full range at independent rates. While that makes a nice demo, it's not really what I wanted. So time to start hacking the code. As a first step, I wanted a servo to move to a specified position at the programmed rate, then stop until directed to a new position. A few simple changes to the Sweeper class, a bit of code in loop() to excerise it, and it was working. The results are shown in T2MultiServo2.ino.
If we can specify the desired position to sweep to, what else do we need? That's right, programmable sweep time. The Sweeper class functions need to know the time interval between incremental moves. But that's not really what I wanted to specify. I'd like to specify the time for the full move. So that's what I implemented! The code is in T2MultiServo3.ino. Again, the change is pretty straight-forward.
-
Inspiration and First Steps
03/12/2017 at 00:38 • 0 commentsThe seminal idea for this project came from a discussion at an Arduino Interest Group meeting in San Diego. One person mentioned that he had a kinetic sculpture and wanted to animate it with servo motors. He asked if anyone knew how to control the servos with an Aduino. We discussed his project needs and I said I'd see if I could find any useful info. When I started googling, I realized the problem didn't really have a good solution that I could find. Reason enough to see what I might come up with. Goal: Control 9 (min) to 12 (limit of Servo library) stepper motors independently to sweep to a desired position in a given time. Allow other functions to run simultaneously, if possible. Use minimal external components.
While I found no complete solution, I did discover a huge step in the right direction! Bill Earl at Adafruit shows how to create an Arduino program to sweep two servos back and forth (0 to 180 degrees) at a programmed rate. His program is interrupt driven so the sweep rates are independent. This struck me as the perfect place to start!