Sunday, March 9, 2014

How I Got Started Building My Own Controller

26 Jan 2014.  I obviously haven’t made an entry in a long time, for several reasons.  Partly, I’ve been putting everything on Astrobin and have tended to record my observations in AstroPlanner.  But more importantly, my mount has been non-functional since about October.  I took it to a BYU Astronomy Club star party and in the dark plugged the handbox into 12 V instead of the 6 V supply I should have used.  This fried the RA tracking in the handbox.  At first I thought I had a bad RA motor, so I got in touch with George Cushing, who sold me the mount in the first place, and got it replaced.  However, that didn’t solve the problem.  At that point it looked like I would need to shell out $150 to get a new handbox and controller from Orion, but George made me aware of a website that had a design for the handbox based on PIC microcontrollers  (http://telescope.marford.me.uk/Projects/PICcontroller.htm). He also was interested, so the plan was he would buy enough parts to build two and send me what I needed.  George had problems getting it all to work.  In the meantime, I got impatient and priced everything out at Mouser, and eventually I pushed the button to order the parts.  

I started soldering over Christmas vacation, but had to also buy a PIC programmer to load the code into the chips.  Eventually I got that to work, but the circuit didn’t work at all.  After much pondering and study of the code, I realized the wiring diagram for the switches was all wrong (or at least I had interpreted it incorrectly).  In addition, I had no information about how the coils of the stepper motors were configured, so I pretty much had to do that by trial and error.  Once I wired it right and powered it up and got rid of all the bad soldering joints and solder bridges and various problems caused by my inexperience with all of this, I got the RA circuit working.  For a while the LED on the RA circuit wouldn’t flash (eventually I figured out I had wired it in backward!).  

DEC, however, would only drive the motor in one direction and I could not for the life of me figure out what was wrong.  I had the problem narrowed down to either bad wiring on two of the switches or errors in the code or compilation.  I took my board into the lab and put it on an oscilloscope, which allowed me to verify that the correct pulses were definitely coming out of the chips.  I came home and wired up a new connector for the motor and presto, everything was working.  There was one more problem when I installed everything for testing on the mount: the RA drive was running backward.  Fortunately that was easy to fix with all the understanding I had gained in my previous troubleshooting; I just had to swap the connections to the coils so the stepper coils would be energized in the correct order.  As of tonight, everything appears to be working.  

I’ve pondered out where the GPUSB connections should be and have installed the interface, but haven’t tested it yet, so I guess there’s a good chance I’ll still have problems with that too, but overall I’m happy I’ve done this even though it has cost me months of imaging.  The RA half-step algorithm this circuit uses should be superior to that of the old box, and I now have a circuit with overvoltage and reverse voltage protection so I won’t be able to blow it the same way I did the old one.  I understand what all the components do, so I could easily repair this box.  It has much faster slew speeds than the old box, so some limited goto capability might be possible if I work out how to talk to the GPUSB.  I’ve learned a little about how to program PIC microcontrollers and have the hardware needed to do it, so I could modify the code or build other things if I want to.  I’ve also learned a bit about how stepper motors work.  All in all, I learned a lot from this experience.  

So next I need to test the autoguider capabilities and then try guiding on some real stars.  It will be nice to be back in business.  George still hasn’t sent the parts and I haven’t had the gumption to tell him I jumped the gun on him.  I’m not out anything really; the motor swap cost $40 if I remember correctly and I did get what I paid for even though it didn’t solve the problem.  One of these days maybe I’ll get a second set of components to play with some additional circuit design ideas.  

27 Jan 2014.  Still no good.  The GPUSB drives the DEC continuously.  I’m going to have to install some relays to emulate the button presses.  

16 Feb 2014.  The relays worked fine.  I have a fully functional motorized mount system including a GPUSB interface, but I haven’t yet been able to test it on the sky because the weather has not cooperated.  

Having completed the building of the new handbox, something George Cushing mentioned resonated with me.  He said that it isn’t far from this box to full goto, then he attached some schematics from the PICGOTO project.  I had heard of this some time ago back when I was trying to roboscope my mount with the Meade DS motors and Autostar system, but I was scared off for several reasons.  First, the PICGOTO people do all their work in Spanish.  Second, the circuit looked daunting to build.  Well, I started digging a little and found out that Google Translate works reasonably well, especially if you use the Chrome browser.  In addition, the PICGOTO people speak English reasonably well and will answer questions in English with no problems.  Looking over my handbox, I realized it was actually harder to build than the Picgoto Simplificado (the simplified version of the PicGoto circuit).  In building the handbox I’ve learned how to use Veroboard and how to do PIC programming, so suddenly building the circuit didn’t seem so intimidating.  

So I started looking at George Cushing’s Veroboard layout for the Simplificado, and found free software online for doing layouts.  I copied George’s layout into the Do-It-Yourself Layout Creator, compared it with the printed circuit board diagrams of the Picgoto Group (which I joined), and started tweaking.  I realized I could output an image of the board in PNG format, then flip it to get the correct view of the solder side, which should help tremendously.  Then on my own I did a layout for the L293D driver board, which actually runs the motors.  I’ve ordered the parts and asked a few questions on the Picgoto Group, so I’m going to try to build this thing.  The parts with shipping cost less than $35!  So again, this ought to be some fun.

18 Feb 2014.  I am delighted to note that my PIC-based handcontroller works very well for astrophotography!  I finally got out last night (it has been cloudy every night for about a month it seems) around 10 PM and started getting set up.  I deliberately chose a target that would use the AT8IN+coma corrector combination (focal length about 880 mm), as that is about as challenging a setup as I ever use.  Hence, I looked at M46 (a new target!), an open cluster that has a nice planetary nebula in the same field of view (but it just happens to be in the line of sight; it isn’t actually in the cluster).  My skills feel a little bit rusty, and I had trouble with my FCUSB focus controller (the tension is not set correctly, so I couldn’t get it to run consistently).  I’m having some trouble maintaining a good USB connection (the cable and the Mac’s ports make a sort of loose hookup so I’ll lose my camera and mount connections every once in a while).  But the mount controller with its GPUSB interface works at least as well as the stock one did (and probably better).  I’m sure I’ll get better with it as I learn to use it and especially as I get the mount balanced correctly.  

2 Mar 2014.  I’ve finished assembling the PicGoto Simplificado and have it talking through my RS232-USB adapter to both Cartes du Ciel and PHD2 via ASCOM.  Of course this is all under Windows 7 (that’s the only down side so far-I'm a Mac guy :) ).  I’ve tested it on the bench with one motor at a time and it drives the motors as expected.  It is very cool to watch a reticle move across the star map as commanded by this interface.  The next step is to put this on the fully-configured mount and verify that I have enough torque to move the telescope and that things are moving in generally the right direction.  Then I’ll have to get a night when I can see some stars so I can actually test the goto capabilities.


Here are my stripboard designs (I have them in Do-it-yourself Layout Creator too, so they can be edited easily).  These are both component-side:  



























And here’s a picture just prior to putting it in its box:























6 Mar 2014.  I finally got the PicGoto on the sky last night.  I had some issues with the RA motor getting warm even at tracking speed, but I realized that might be from running the system at 12 V rather than the 6 V I have used in the past.  A question to the PicGoto Yahoo Group was quickly answered; PicGoto can run down to 7 V, and there’s also a simple circuit that can switch between 6 V at tracking speed and 12 V at slew speed (it ingeniously uses the output to the LED, which only comes on at the higher speeds, to do the switching).  My variable power supply has a 7.5 V setting, and it seems everything is happy there or at least the RA motor no longer gets hot.  I have all the software talking, after a scare caused by an incorrect prescaler factor in the PicGoto EEPROM.  Another question on the PicGoto Yahoo Group got that fixed; I learned the correct value and how to reset it.  However, when I finally got on the sky last night I quickly found that the motor settings I was using were wrong.  I tried thus:

Condition        Gear        Red.        Step/Rev    Result
1                        180            6            4000            Too slow; stars drift west
2                        360            6            8000            Tracks RA well, but poor gotos
3                        144            120            48            Way too slow
(Set 1 is the settings in the English PicGoto manual, Set 2 is from trial and error, and Set 3 was what I understood from the text of the manual (obviously I understood it incorrectly).  I believe the manual as far as it is translated correctly, but it is certainly outdated and incomplete and I have doubts about the translation!)

Clouds rolled in and ended the session, which wasn’t really going anywhere anyway.  I did find that my backlash is not horrible, in that I could center on a star, do a goto (which of course did not find what I was looking for because the motor settings were wrong), then do another goto back to the star and find it in the field of view of the 880 mm focal length camera (I would have been satisfied to get it back in the guider).  So I posted yet another question to the PicGoto Group and got the following settings for the CG-5 from Ángel Caparros, the chief instigator of PicGoto:

Gear Red. Step/Rev
144   120    960

Ángel has been extremely helpful and patient with me.  I’m still not sure how I could have figured this out (I need some equations!), but I’ll try these settings next time I can see some stars.  

7 Mar 2014.  I put the new motor/mount settings in last night and played with the slewing indoors (it was raining outside).  The tracking rate feels correct, though of course I won’t know until I really get to look at the stars.  I was able to slowly slew and visibly see the motion of the scope.  I learned that at 7.5 V, the maximum slew rate was about 20x sidereal, but at 12 V I could get 35-40x (if you try to go faster than the motors can handle at a given voltage, they stall or obviously run too slowly; I was timing how long it took for a full rotation and checking to see that doubling the speed in the software actually doubled the rotation rate).  Again, I won’t be able to tell for certain until I get on the sky and try some gotos.  But based on my testing last night I ordered the parts for the 12 V / 6 V switching circuit mentioned in the 6 Mar 2014 entry.  

2 comments:

  1. Hi DVD
    I'm also trying to built the controller from James Hardy, but I run in the same issue as you before. The wiring and code is just copied from Hardy, but after connecting the second coil to the L293D, the LED stops flashing and the motor is not turning at all. It looks like there is a input/output mismatch or some kind of a loopback from the L293 to the PIC.
    If you still can remember what your modification to this diagram was, it would be very helpful.
    Best
    Robert

    ReplyDelete
  2. Robert,
    Thanks for your question. I'm afraid I'm probably not able to be much help. I only used the James Hardy box once or twice before deciding to build the PICGoto Simplificado, and don't remember what I did to get the box working. I do remember I was about to give up until I put the box on an oscilloscope and saw what looked like the proper signals coming out. I looked through my notes, and I did find the stripboard layout I used. I would be happy to send that to you if you think it might be helpful; drop me an e-mail at david_dearden@byu.edu and I can reply and send it as an attachment. Unfortunately I don't remember how I hooked up the motors. Looking this over reminds me how much more difficult building that PIC box was than doing the focusing stepper motors I've built recently. In all of these projects, the biggest problems I have had have been with solder bridges and bad trace cuts. I guess I'm just not great with a soldering iron, but eventually I have been able to get things to work. Good luck!
    David

    ReplyDelete