Hi to all - this is my first post. And, yes I am a beginner (so my apologies for any dumb questions).
With a BasicAtom Pro (and Bot Board), how should I approach the reading of:
-analog sensor input (gyros, accelerometers)
-PWM input (hobby receiver input)
-hobby servo output
-optical encoder input (like those from US Digital).
The basic programming language seem very sequential. And servo motion control, as well as the reading of PWM input appears to require a certain amount of waiting before processing can continue.
Is there a way to reading and write I/O “at the same time” ? What is the approach for coordinated reading and writing?
You have two options when driving servos asyncronously. You can either use an external servo controller(eg SSC32) or you can use the AtomPro’s hservo system. In the current release of the AtomPro software the hservo system is pretty processor hungry(up to 32%). In the new release(out in about a month) it is down to a max of 3.4% processor time). Both run in the background though so you can be doing other things. Handling PWM inputs is best left to hardware. Use the capture/compare hardware and interrupts to handle this. Note that this same hardware is used by the hservo system so it’s either/or, not both.
I’d strongly recommend using the SSC-32 for your servo control.
Even 3.4% is a lot of processor power to be using at any given time.
That number will get big, fast, though when you start controlling multiple servos.
If you’ve only got a couple to control, the Atom will work great for that, and still should be able to pull it’s weight in the analog realms.
However, any more than a couple servos being controlled starts becoming a waste of good processor power.
True multitasking (having two operations occur at the same exact time) on any single microcontroller is impossible.
If you truly need multitasking, then more than one micro is required.
However, the beauty of microcontrollers is their speed.
When you get into doing things at hundreds of thousands of times per second, very fast sequential execution starts looking a lot like multitasking.
I’m willing to bet that either Andy or Pete will be chiming in soon to explain programming with interupts and state machines (which I know diddly squat about).
Supposedly, that sort of program takes advantage of brief microcontroller idle periods to get a bit of processing done.
I should stop trying to explain it to you, though, because I’ve probably already lied about it.
Oh, by the way…
I believe that the Atom has only 3 A/D converters.
You’ll need to buy a seperate A/D converter IC if you want to be able to control a gyro, accelerometer, and read the reciever.
I’m sure that Acidtech (or someone else) can point you to one that works well with the Atom.
Hold on thar… the 3.4% is all there is. No matter how many servos are connected. It’s a backgraund processing thing. Use the SSC-32 or the hservo, no matter, but don’t decide becasue you think the 3.4% overhead will get worse depending on how many servos are connected.
Well, I’m not the best source of information on this… (as was proven above, hehe).
I believe, though that you can have one A/D converter for every I/O pin.
A/D converters have two main specifications: channels and precision.
Precision values are anywhere from 8-bit (256 “steps” of resolution, if you will) to 20-bits and above (2^20 “steps” of resolution).
I think I’ve even seen a 40-bit one.
The number of channels determine how many analog inputs you get out of each one.
The ones that I’ve bought operate on an SPI interface (I believe that’s supposed to be some sort of micro-to-micro chat interface), so you can pick which channel you’re reading from at any given time.
More than that, I can’t help you with, since I haven’t gotten these bad boys in my hot little hands, yet.
The atom pro 28 has 3 A to D’s with a ref voltage input, or 4 A to D’s using 5vdc as the ref. These are built in and do not require any additional chips. The Bot Board is a carrier for the 28 pin Atoms and allow you to connect things easily to the A to D’s.
Take a look spec sheets for the gyro’s that your considering too. Many of the cheap ones are designed for R/C helis to sit between your receiver and the tail rotor. So the interface is set up such that it outputs a PWM that is an additive correction to the PWM signal coming from the receiver. So to drive many of them, you need to output a PWM and read back a PWM, comparing the difference to read the values. A more straightforward analog output is desireable from an interface point of view.
Andy - I agree with what you are saying. I too would much rather work with the direct output from a non-hobby style gyro.
Thanks to everyone for the responses. 8 A/D’s should be a good start. Now I have to learn how to put all of these components together and make it work!