ronpbaker

I do not know if you found you solution or not but I always prefer to use stepper motors over servos if at all possible. Here is how I would overcome the issue you have.

Using a stepper motor in this manner has two drawbacks. When fist applying power to your instrument the needle is pointing to where you last turned it off and begins working from that point and after prolonged use it can start to miss a step or two making it inaccurate.

The feature you are looking for in a stepper motor is called "Closed Loop", this is typically found in servos but is available in higher end stepper motors. This translates in to expensive. But then again the closed loop only solves the prolonged "real time" accuracy issue. What you truly need is a HOME function.

When you first apply power to your stepper motor your controller will run a series of codes making the steeper motor turn until it hits a predefined degree. There is several ways to locate this but I have found using a bipolar motor (has a drive shaft coming out both sides) with an Optical Slotted Switch works best. You can use a reed switch to do the same thing. Point in fact there is dozens of ways to achieve this but we will stick with the (Optical Slotted Switches) because once you understand how this works you can translate this into any sensor you are familiar with.

The Optical Slotted Switche can be set 2 ways, when the field of light is broken or when the field of light is opened. I use it then the field of light is opened to identify home. Simply put a disk (like a pulley) on the back shaft of the stepper motor and place a tiny hole on the outer edge. As the stepper motor spins the solid parts of the disk prevent the light from registering on the optical slotted switch. But, once the hole passes in between, the optical slotted switch light goes thru and the micr-ocontroller reads this and understand this is home.

Now that you have a "Home" point you can start your stepper motor out in exactly the same place every time at power up. The accuracy issue is a small one, lets say you are building a gauge for something that will run for weeks on end. In this event I would code my micro-controller to do a "self diagnosis" once every 24 hours.What it would do is simply go until it hits home then advance back to the appropriate reading. This event would take milliseconds and just look like a twitch on the needle to the human eye.

OTHER ISSUE STATED ON THIS POST!!People have mention gear boxes on your stepper motor. These are useful for accuracy and torque but not needed to control the speed of the motor. Your (pwm)pulse width modulation does that for you already. Gearing does slow it down but that is a side affect of it's intended use. Stepper motors have a maximum RPM but you can slow it down with your coding to resemble grass growing.

***NOTE*** If you want to have the motor point to 360 positions with an accuracy of +/- .01 degrees then you need a 5/1 gear box for the 1.8 stepper. I would not recommend using a .9 stepper because the math doesn't work for your case. These gear boxes are readily available, just make sure you get one for your shaft diameter.

I built one of these for DCS and recall that only certain points on the gauge were Compass symbols N,S,W,E with 2 definitive headings between each symbol for a total of 8 numbers and the in between numbers were hash marked and a I did not need a gear box, just some creative coding.

So, if you printed all 360 marks on your gauge how are you able to read them and how big is this gauge?

4-8 wire stepper motors. The smaller the number of wires your stepper motors has the less accurate they will be. Do not let that make you run out and buy the 8 wire motors because I built a CNC for etching SMD PCB's (smd = cell phone like tiny circuit boards) and I only use the 4 wire function. I bought the 8 wire stepper motors but bridged the additional wires essentially making them 4. so 4 wire is extremely accurate and you would need a very specific need for the 8 wire. As it happened the distributor that sold me my NEMA 23 425oz steppers only had 8 wire. The number of wires does affect the speed as well tho, My nema 23 425oz will run max 600rpm on 4 wires and about 400rpm on 8. But the only time I use the MAX RPM is for the homing feature so does this really matter? For a CNC application, YES! / For a dash gauge, HELL NO!

1.8 and .9 degree stepper motors. Here is how this works. 360 degrees is a full circle, so if you took that and divided it by 1.8 you get 200 and if you did it by .9 you would get 400. That is the number of pulses you would need to send to the stepper to get it to turn one complete turn. I have never needed a .9 stepper motor. 200 individually controlled positions has always been more than enough. The most detailed gauge I have ever made was for a motorcycle. A car needs maybe 4-9 thousand rpm's but the motorcycle goes all the way up to 20, 000. But we can easily do the math here and see that you need exactly 200 points of movement to achieve this. I could have done it with way less but used all the points BECAUSE I CAN.

425oz? OZ, this is a unit applied to stepper motors. This identifies the holding torque of a particular motor. Basically stepper motors do not turn freely and require a bit of pressure to get them to move to the next position. Get a large stepper motor and try to turn that shaft with your fingers and you will most likely not be able to. So, when building things with stepper motors you have to consider the weight of the objects your motor will be turning. Gauges do not really matter much here, the needles are insignificant. The same type of stepper motors you would use for your gauge are capable of turning web cams. I find these on Ebay for a couple bucks (shipping included) and they come with a drive board.

optical slotted switch - you should youtube these. some great videos available from the Arduino fans.http://www.google.com/imgres?imgurl=http://www.futurlec.com/Pictures/OptoSwitch.jpg&imgrefurl=http://www.futurlec.com/LEDOptoSwitch.shtml&h=150&w=200&sz=24&tbnid=CJJu_8JdOQCcMM:&tbnh=95&tbnw=127&zoom=1&usg=__nxthd8CdQjDnV4Mprjywdpnue6M=&docid=XP3vVsIbs8LDcM&sa=X&ei=IX0KUeOfAbC10AGD4oGgCw&ved=0CGUQ9QEwBQ&dur=335

ronpbaker

I would like to point out that if I were to build another flight sim, I would simply go to the junk yard and salvage old gauges from junk cars. You can reverse engineer these things to suit your needs and only spend maybe a couple bucks. Free if the junk yard doesn't check your tool box completely.

I filled a 5 gallon bucket once with gauges and switches of all sorts and the guy charged me like 10 bucks. Just stay away from classic junk yards. Find one in your area that cares more about volume of scrap metal and they could care less about those damn parts.

Thanks for all the input. Several weeks back I ordered a 0.9 stepper motor, a Seeed motor shield, and an optical sensor. I have the basic code started and I'm fabricating a heading wheel to mount on it that will also trip the optical sensor at a calibration point.

The wiring of the motor is basic enough and I have that taken care of. Likewise the wiring of the optical sensor. The basic code to run the motor is easy enough as is the code to do the calibration. I have almost everything either working on my test bench with one exception.

That exception being the continuous rotation past North in either direction. Not a show stopper, but I just haven't come up with a satisfactory way to deal with it yet. The flight sim software feeds me a compass bearing in the form of 1 to 360 degrees. I am reading the changes and doing the simple math to move the stepper from prior read to current read by the calculated number of steps. In most cases the step is no more that 1 or 2 degrees in either direction, but on occasion either do to high rates of turn or program lag the steps can be slightly bigger.

So I am trying to come up with the best way to deal with crossing North where the prior read might be 359 and the current read is 001, or in the other direction, the prior read might be 002 and the current read 360. I need the first to calculate +2 and the second to calculate -2.

Thoughts?

As for gauge or part sources, I have purchased several parts from bone yards, but not gauges. My sim is somewhat generic and will emulate about 6 different aircraft. As such the variation in operating ranges needed on the gauges makes hardware based gauges somewhat problematic unless I can come up with easily interchangeable face plates. As such I am only looking at mechanical gauge builds for a very limited portion of the sim, the Wet Compass being one of them.