So far, I haven’t talked much about the hardware, and I tried to make due with whatever I had at hand:
Here is a Fritzing sketch:
Here’s how I set things up. I’m sure it can be done way way better - I encourage experimentation. Please report improvements in the comments.
If any of this is unclear, leave a comment.
One word of advice: test and calibrate the hardware before testing the software. I didn’t, and had multiple competing bugs in the angle calculation.
both servos were turning the wrong way I expected
I got some brain farts in the angle calculations.
Finally, the servos need to be calibrated to point exactly between 0 and 180 degrees. They actually do have a slightly wider range (varying from servo to servo), so I needed to take care of that also.
In order to be sure the servos did what I wanted them to do, I wrote a short script to show state on the tm1638 module, and use the keys to change angles. Super easy and helpful! Here’s how to use it:
% ampy -p /dev/tty.SLAB_USBtoUART put servo_callibration.py
% screen /dev/tty.SLAB_USBtoUART 115200
(may have to press CTRL-C)
>>> import servo_calibration
You should see the servos switching to angle 0, then you can use the switches to change them. BTW, you can leave screen by pressing [CTRL-A] [CTRL-\] and confirming with ‘y’.
I also added a script to print output of the servo to the console.
% ampy -p /dev/tty.SLAB_USBtoUART put servo_callibrationgps_test.py
% screen /dev/tty.SLAB_USBtoUART 115200
(may have to press CTRL-C)
>>> import gps_test
If the GPS is properly wired, you should see SOME updates. THe module might take a while getting a fix (minutes or more), and eventually it will update time and location.
Observation:
the servos tend to oscillate a bit (even more than a bit). In order to balance out the weights on the AZ servo arm, I added a counter weight on the end opposite to the one with the glued on ALT servo. Upon changes to the angle the servo can oscillate a few degrees for 10s of seconds before settling down. I have as of yet no good solution. Maybe I just need to add some rubber mounting for the counterweight, or add a larger weight immediately on the servo.
When crossing quarter spheres, either AZ or ALT angles will change 180 degrees instantly. This can jerk the pointer violently around. It would be better to run servo angle changes in an async routine and do them slower (limiting jerk is I think the technical term to use). Not a big problem moving a paper pointer around, but if I try to install an antenna instead, I could be causing problems.
Cabling came loose at least a couple of times. For a permanent installation need to think about how to properly install cables. My method of positioning means I don’t need a slip ring, but something to keep in mind for later.
In the next chapter, we’ll talk about the code to determine moon positions.
Written on July 20, 2020