Newbie help with 3.1 Teensy and servo's

Status
Not open for further replies.

raflyer

Well-known member
Hi all,
First off I am totally new to the Arduino world. I purchased 3 books on Arduino's and I have read 2 of them.
I recently purchased a Teensy 3.1 to try out and test for possible use in my project. This project is building a 737-200 sim using real instruments and X-plane 10. The instruments will driven by servo's and or stepper motors, and pwm output to simple coil movements. Hence the reason on going with the Teensy is direct com support to X-plane and 12 bit or higher resolution on inputs and servo outputs.

I have been searching the web for examples on how to run the servo's and Analog inputs at 12 bit resolution 0-4095 This precision is necessary to drive my gauge's accurately.

All I find is 10bit 0-1022 and analog in of 0-255

1) I want to read a potentiometer at 12 bit and tell a DC motor to go to the position in 12 bit resolution position output. (closed loop motor control)

2) Read x-plane data and command servo to that position in 12 bit (all examples are 10 bit)

3) Stepper motors is really tough find. I need it to know how to set home location or start spot then be commanded like the motor/servo example above with high accuracy. In a different interface i have worked with in the past you put optical interrupter on the stepper, on start up it did 2 360deg turns to determine step count and home or start position based on the optical interrupt. Then it was simple to program it follow the commanded position similar to a servo, Example,compass info from x-plane All the info I have found so far via google has come up empty on precise positioning of a stepper.

Right now it looks like I'll using 20+ steppers, 20+ servo's and 20+ pwm outputs to drive simple coil movements.

I am open to paying someone to help code all this as well.

I really appreciate any help on this endeavor.

Rob
 
Well I guess judging from the response and lack thereof, either the Teensy 3.1 can't do this or nobody needs money!?? So anyone interested in buying a 3.1 Teensy, 15.00 shipped. No use to me Going back to Pololu that has great support.
 
With all due respect Raflyer -and I'm new to forums also- but I believe you'll get the most help when your post suggests you've spent at least several hours digging around online, and have discovered the basics of what you are trying to accomplish. You might try getting a few servos going first and doing your own brainstorming on the problems you might face... Then share your insights and ask for help...

If you really just want to through money at the problem you could check-out fiverr.com, but expect massive communication issues! Or hell, maybe craigslist if you live in a big enough city!
 
Teensy is about DIY (do it yourself) electronics. I can give you some basic pointers to resources, and if you get stuck, you can usually post your code and circuit details here for some specific help. But I can't get personally involved in the engineering design of your project, even on a paid consulting basis.

You can get 12 bit input and 12 bit PWM output with analogReadResolution(12) and analogWriteResolution(12). Easy.

RC servo motors are controlled with a special pulse signal. There are 2 libraries available, Servo and PulsePosition. Even if you use PulsePosition (which gives the very best possible performance), those little RC servo mechanisms are rarely that accurate. Maybe you can find a really good one? I've only purchased RC servos a couple times, but the ones I've looked at only had specs for things like torque, power consumption, etc. Does anyone really even spec them for positional accuracy or repeatability?
 
12 Bits, 2^12 means 4096. Assuming, the servos can do 180°: 180 / 4096 means a resulution of 0.04°. I don't think, that this is possible with servos. And even if it was possible: Are you able to see any difference between the positions 3075 and 3076...??
The same with the 4096 Potentiometer positions. Maybe possible this time, but pointless.

...you mentioned coils: Why don't you use them ?
 
Last edited:
If the servo is moving an analog dial indicator that's 3 inches in diameter, movement by 0.04 degree moves the outside edge by approx 0.00105 inch (which is 0.027 mm).

Unless these dials an absurdly large, I would have to agree than 12 bit resolution is somewhere between "overkill" and "pointless".

Even though electrical interfaces exist with that sort of resolution, insisting on that level of mechanical performance moves a project from fairly cheap and easy hardware that's readily available into the difficult and expensive realm of highly accurate positioning systems typically used on machine tools.


Earlier, the idea of stepper motors was mentioned. But most steppers are designed for 1.8 degree step resolution. Half stepping is the finest res that's cheap and easy, and 1/16th step can be done with fancy drivers. With with a special micro-step driver, you'd need a 3:1 mechanical reduction to get to 0.04 degrees resolution. Adding a gear or belt mechanism is possible, but really adds a lot of mechanical complexity, on top of using a micro-step driver circuit. Worst yet, steppers have limited speed, so with micro-stepping and a 3:1 reduction, the maximum speed could turn out to be too slow.

For stepper home position, again, this is about DIY electronics. You have to build that, if you want it. Just look at the many 3D printer projects. They all use sensors to detect position, and a startup process to establish the home position. If you go the stepper route, you have to do that too. You can certainly use the AccelStepper library and monitor the sensor while the library is moving the motor. Like all DIY projects, some assembly is required....
 
I think, the easiest are coils like in "voltmeters" (hope my english translation is correct). He mentioned coils, so this would be the cheapest !
They only need analog outputs, at any resolution he wants. PWM can be used too. Or DACs.
 
Last edited:
Let me see if I can answer your questions,
First, I have been learning and will post code soon as I will need help. :) 12 bit on the following gauges is critical for accuracy and does make a big difference.
1)
Altimeter. I have a dc motor that turns gears to move the pointer. It used synchro's originally but I removed them and installed a 10 Turn precision pot. Now I have my Dc motor, my pot, and H-bridge driver and it all = homemade servo. I was thinking of trying the PID library, thoughts? 5K foot = 1 turn on the pot so that is 0-40K feet and 8 turns. Yes, with the gearing you can see a diff of a few feet with every couple of number changes ie; 4000 4002 etc.

2)
HSI which acts like a compass, 0-359 and I need 1 deg resolution accuracy. Could be driven with a stepper but it has a dc motor already installed and I want to use it. 2 options as i see it, 2 pots 180deg offset, summing them for position feedback, or a 360 magnetic encoder thru serial data.

3)
Airspeed indicator is a 4" size display, 0 to 450knots with approx 340deg arc. Same as above, DC motor turns it all.

So these 3 instruments need very high precision and repeatability in positioning. The rest I could get away with 10bit i'm sure.

As a side note, using the teensy and the adafruit 16 12bit servo/pwm board, 12 bit pwm at 400Hz makes my meter movement gauges work very very smoothly and accurately.

Thoughts?

Thanks
Rob
 
I am familiar with the syntax below which I have used in the past, it is called SIOC and acts as an interface between all the sims and your hardware. Problem with it is their hardware is large and only 8 bit Here are a couple of examples of code I wrote

Var 3009, name TaxiSW
{
IF &TaxiSW = 0
{
&TaxiLt = 10000
}
ELSE
{
&TaxiLt = 0
}
}


Var0056 // CHT temp
{
L1=V0056/1000 // converts to deg in Fahren... from integer
L2=L1-32 // convert to celcius step 1
L0=L2/1.8 // convert to celcius step 2

L1=L0 * 1.170 // calculate servo slope
L2=1064-L1 // Calculate intercept

v0013 = L2
}

v0013 // servo motor

I am familiar with some C programming, very familiar with electronics and mechanical's of real aircraft guage's , just zero knowledge of arduino. I want to use Teensy for its size and power. I was envisioning a teensy in each large gauge and several running the smaller gauges. Then I have all the overhead modules which have 4 to 13 switches and annunciators.

Rob
 
Hi, just some thoughts on the servos.

Having built a laser pointer mounted on pan and tilt servo's can say the basic hobby type gets you 0.3 degree accuracy at best, but include inbuilt hysteresis to reduce power consumption and wear. So starting from zero, 100 and 103 would give different results, but if you are already at 100 going to 103 results in no motion but going to 105 gives a jump.

Ended up with a state machine tracking previous direction of motion, but your solution of building your own controller for real hardware will give a better outcome.

Will say that you may find the A/D accuracy of reading off the multi turn pot may be a problem and it's unfortunate there isn't a way to easily interface electronics to the original Syncros, since they still seem to be the goto choice for absolute position detection. If the pot turns out to be too noisy an option may be the rotary encoders plus a limit switch you mentioned, but this will complicate the project by needing a bootup traverse to height zero, at a speed low enough to not damage anything when it gets there. Will also need to find the max speed your H bridge can PWM, since that may also constrain traverse speeds and min resolution.

When it comes to achieving control you may not need a full PID loop since you the inertia should be relatively low and the load fixed. So just doing WHERE I WANT TO BE-WHERE I AM, Constrain to limit top speed and maybe adding a dash of backlash reduction fixed offset based on direction of motion will probably get you there.

That said, using PID would be the right choice for achieving precise control of a mechanical system, and should be computable fast enough to not overshoot it's mark.

Compass is going to be an interesting challenge. A 1/2 step driven stepper plus home switch may be the simplest solution, but means removing the existing DC motor.

Will be a lot of fun when you get it done.
 
Status
Not open for further replies.
Back
Top