Digital Electronics project - servos and more

In my DE class, we’re required to select a project we would like to do for the rest of the year. I had a fun idea, but I’m not exactly certain how to implement it, so I need help.

What I would like to do is make a robotic arm, and a “dummy”. Both would look exactly the same, perhaps the robotic arm would be 2-4x bigger. Anyhow, when the dummy is moved, the other arm would mirror it (I’m looking to have 2 joints, and a turret).

So, the design. In essence, I would be creating three custom servos. I would have 3 pots as inputs (2 joints and 1 rotation), and 3 pots as feedback. I’ve looked through the web, and I’ve come across a couple sites with ways to make servos, H-Bridges, and servo pulse to PWM converters.

I’m not exactly sure how much of the circuitry I would have to make, but I’m certain my teacher won’t let me use an IFI RC or Hi-tech servos.
I would like to use PID control for the servos I create; but I would definitely need a micro controller for that.

So, I’ve got a few questions.

  1. Is there a better way to approach this, or a better design / what would you use?
  2. What would be a decent micro controller that would fit my needs (6 analog inputs, 3 PWM, or 3 pulse outputs, cheap ~$30)
  3. Have you done something similar to this, or worked with programming micro controllers?
  4. Any solid advice before I start?

thanks!
-e.foote

Back when I was on FRC #0181, we created a (scaled down) replica of our 'bot’s arm for our OI, using pots at each joint and a button for the actuator, to control our actual arm. We won the control award for this.

It really is pretty simple. If you have pots on the controlling arm, and pots on the big arm, you just have to write a relational equation to convert the two values (example: big_pot_1 = mini_pot_1 * .86 + 28)

Then you can pick a micro-controller to handle the job. A PIC16, like we used to use with the PBASIC bots, should work just fine. Get a protoboard (total, the controller, board and cable are usually together in a package in the $50-80 range.) You can then have your pots from your controller arm input into this, and have your output to your motor controllers.

Lets assume you are using motors that you only want to control with on/off/backwards type movement. You could then get some relays (from radioshack, less than a buck a piece), and run your motor voltage through them, with your control signal running back to your micro. Attach your motors to the relays.

Finally, you need to write some code. I hope that you aren’t being forced to write in assembly, although this could be done. If not, make sure that when you pick a microcontroller, you pick one in a language that is easy for you to pick up. The PBASIC and C ones should work fine. Simply read in your inputs, convert to your output theoretical value, compare to the actual arm pot value, and drive your motors in the correct direction until they match.

Hope this helps!
Jacob

http://www.ecircuitcenter.com/Circuits/op_pid/op_pid.htm

Alright, so there is a way to do it without a micro controller, but I don’t want to try to tune an analog PID

I think what I need to know is how much of this circuit I would build myself, and how much I would buy just in chips (make my own H-bridge vrs. buying one, make my own analog to digital converter or getting it on board with the PIC, etc.)
Any thoughts?

(Sorry for the double post, but I’m going to answer a few of my own questions)
I do not have to build any part of the circuit myself if it is available, for instance, the H-bridges, I can just buy as is, or the analog to digital converter can be embedded in the PIC, as well as the PWM outputs.

I’ve got a question as far as the PIC goes, which of the line have analog inputs, and pwm outputs? Which chips are able to be programmed in C?

Get onto Microchip’s website and dig into the manuals.

If you decide to use a PIC, you can either go with the PIC16 or PIC18 series.

PIC18:This is the same product family as the one in the RC, so you can use the same development environment (MPLAB + mcc18, but not IFI loader). Most of these come in non-DIP packages or are too large for what you need, but given your requirements the PIC18F1220 will work.

PIC16:These are generally smaller and less powerful than the PIC18, but still plenty powerful for your needs. The problem with PIC16 is there are no free fully featured C compilers for it (as far as I know), but there are some free limited ones you may be able to use. The assembler is free if you’re insane. There are too many PIC16s that match your requirements, so use Microchip’s product comparator to find the right one for you (get one with flash memory, ie 16F series, and at least one CCP for PWM). The PIC16F88 is a popular choice.

With any PIC you’ll need to find a programmer (to actually get the code onto the processor). You can buy one from microchip, but they can be pretty expensive. Or you can try to google some cheap versions you can build/buy (make sure to get the software you need too).

A good alternative to a PIC is an AVR. Unlike PICs, there is an AVR gcc C/C++ compiler that comes with a great set of tools. You can compare AVRs here, but I recommend the ATtiny44. You’ll also need a programmer for the AVRs. There are some cheap ones, but you’ll have to find one that works with a ATtiny.](http://www.avrfreaks.net/index.php?module=Freaks%20Devices&func=displayDev&objectid=140)

http://ladyada.net/make/mshield/index.html

  1. Your approach looks good. The only thing I would suggest is doubling up your “PWM” outputs on your microcontroller, so that you can signal your H-Bridge directly (you won’t need any intermediate circuits like a servo to PWM converter). Looking at the website you linked to for H-Bridges, the circuit has two signal inputs: A and B. Depending on which direction you’ll be spinning your motors, you’ll keep one signal input low, and pulse the other high. You’ll have to handle the logic to change directions in your micro now by swapping which one is kept low, and which one is pulsed high when you go in reverse. To me this is actually more elegant (and easier) than building an external circuit, at the cost of double the number of outputs - most micros can be had with at least 6 DIO anyway. By signalling the H-Bridge directly, you also won’t need specific PWM outputs. A simple digital output that’s turned on and off with some regularity should do. Precise carrier frequency timing of your signal is not important if you do this, which is what a “real” PWM output gives you. For your particular example H-Bridge circuit, they recommend a max 300Hz pulse frequency, so as long as you’re not pulsing your outputs faster than 300Hz, you’re good to go.

  2. Grab a sample of a PIC18F series, a PicKit 2, and download the student (60 day free) version of C18 and MPLAB. If you’ve already done some FRC programming, you can hit the ground running very quickly. The biggest difference will be the naming conventions and aliases. That’s how I’d do it, given my FRC experience, and assuming a student’s budget =).

  3. The experience we all have in common is FRC programming. Many don’t realize that even though everything’s been abstracted out nicely for us by IFI, the FRC programming experience is NOT that different than other C-based embedded programming environments. Outside of FRC, I have done embedded work on PIC18, 68HC11, 68332, and ATSAM7S in both assembly and C. The work has ranged from making blinky lights, to electricity meter user interface panels, to prototyped redundant automobile drive-by wire control systems.

  4. My advice? Be patient, “procure” an oscilloscope, order 3 more than you need of everything, and have fun =). A minor suggestion is that I think you can do all this without timers/interrupts. Timers and interrupts are great, don’t get me wrong, but if your target is to wrap up by the end of the school year, the last thing I’d want is to spend a week stamping out concurrency problems. A nice clever sequential while(1) loop is your ticket… This sounds like a great (and ambitious) project!