Friday, December 16, 2016

Barndoor Tracking Mount Part 4

I have been having some problems with the stepper motor and the Sparkfun stepper driver and have finally gotten it all straightened out. The motor was having periods when it would sputter, misstep, and sometimes not even run at all. I finally reached the conclusion that the motor or the controller was bad. Since the motor was from surplus, I decided to replace it. It was not very expensive and I was able to find an exact replacement online so I did it. The new one seemed to work better, for a while, but then I started having similar problems. I was looking into replacing the controller but, in doing this, I found some documentation on the board that I had not seen before. In the margin notes, I found the recommendation that some of the inputs that were not being used in control be either connected to ground on Vcc (+5vdc). The ones that were listed included one to put the controller to sleep and another that was a reset. The third was called PFD and I did not examine its function closely but, I had not seen anything in the sample hookup documentation about these pins. However, I tied all three to Vcc and now everything is working fine.

Now I have a nearly completed mount. I just have to put on the part that will hold the camera and I will be ready for some field testing. However, first some more bench testing was in order. I attached a limit switch to allow the door to have a seekable home position. This ties to one of the Arduino inputs and, by doing a little testing. I found this to be a highly repeatable location even though the button I used seemed to have a lot of play to it. A second button was attached to be a command switch. The command button switches the program between the different modes: STANDBY, which is the default start mode and where the controller is just waiting for input, RETRACT, where the door is seeking the home position, READY, where the door is home and waiting to start tracking, and TRACKING mode.Home button (left) and Command button (right)

After installing the home position switch, I had to repeat some of my measurements to determine the lead screw leg distance for the home position (see the last installment to see where this measurement is used in the calculations). I then went back and ran the test to measure the angles of individual steps that should each open the door in one degree increments. I got much better measurements, although still not as perfect as I would expect. More testing and measuring might be in order.

Next, I created a test for the command button. The button throws an interrupt to the Arduino board. This sets a flag that is then detected and reset in the program. Everything checked out fine so I incorporated the command button into the final Barndoor program and implemented each of the modes of operation. Finally, I was able to run the door through its paces. The flowchart follows. Click on it for a bigger view.

Flowchart

Next, I will have to finish up the packaging for moving to the field. I think I will mount the circuitry on the bottom of the mount and then route the cabling so it does not get snagged. I will likely also mount the lighting where it is easily viewable. My power supply for the field will be an automotive jump starter and tire inflator which has both a USB power port and a 12V power port. The USB port will power the Arduino through its USB port and 12V will power the stepping motor circuit. I have already tested the door using this power source and it is robust enough for use in the field.

Monday, December 05, 2016

Barndoor Tracking Mount Part 3

So I had to back up on something I posted last time. I showed the stepper motor with an 8mm screw and two intervening shaft couplers. Well, after ruminating on it a bit I realized that the shaft coupler that was flexible would not work with my design. I needed one that was ridged, otherwise too much play would be added into the system and accuracy would suffer. I knew that the motor shaft is 1/4 inch and the lead screw is 8mm so I looked for a coupler that would match those sizes and, surprise, there is such a thing. $6 later I have one. So now I was ready to start building the mount. The two “doors” are 3/4 inch oak and there are three hinged areas that hold the two doors together and also allow the motor and lead screw nut to stay aligned as the door is opened and closed. I showed a picture of this design in the last post so I took to building. The RV resort where we live in the winter has a nice woodworking shop so I had everything I needed.

I started cutting and shaping and, with a couple of restarts due to misplaced components and the purchase of another piece of wood to make the hinges, I was able in a few days to have put together the mount. Here are some pictures of the components and the final assembly.

Motor and mounting block Fixed leg bottom view
Moving leg top view Motor with screw and blocks
Hinged door Assembly bottom view
Assembly top view Assembly end view

Next came a test of this set up. I created a program for the Arduino to move the door in one degree increments from the closed position to the maximum open position. I immediately found a problem. Measurements showed it to be opening too far, about 1.3 degrees per increment. I did some modeling of my code in an Excel spreadsheet and it looked good. After some more testing I finally discovered that the lead screw, which I could have sworn was a three-start thread, was actually a four-start thread. This meant that instead of moving 6mm per revolution, it was really moving 8mm per revolution. This made a big difference and I was able to just change a variable in the program to correct it.

I forgot to mention that a crucial part of getting the door to open correctly was making accurate measurements of the finished device. I need to know the exact dimensions from the main door hinge center to the motor block hinge and the lead screw nut hinge. I also need to know the distance from the lead screw hinge center to the center of the screw and the same from the motor hinge to the center of the motor shaft. With all of those dimensions I can there create a formula that gives me the angle between the two door halves and can compute how far the lead screw nut has to be pushed out to open that angle by a specific amount. The same formula then can be used to determine the rate at which to step the motor to get the door to match the sidereal angle of the earth.

Now, examine this diagram:

triangle

If the vertex of a-b is the main door hinge, the vertex of a-c is the lead screw nut hinge, and the vertex of b-c is the hinge of the motor block, then the angle C is defined by the formula:

formula

So “a” and “b” are measured constants and “c” is variable as the lead screw moves. However, the screw does not pass thru these points so there is another formula to find “c” for different steps on the lead screw. The geometry of the lead screw with respect to “c” is described in the following diagram and formula:

diagram2

formula2

The lead screw nut (“n”) leg and the motor base (“m”) leg are always at right angles to the lead screw (“L”). Note: this is the reason the flexible motor shaft coupler was not appropriate. So the Pythagorean Theorem is used to determine the length of “c” depending on the position of the nut on the lead screw. By combining these two formulas the angle “C” can be determined for any particular step of the motor and can be matched then to the sidereal angle of the earth starting at the home or closed position of the door.

Next, I have to attach a switch to mark the home position and program the tracking algorithm for the Arduino. More on that in the next installment.