go away spammer

Author Topic: Have a PWM signal and a motor; how to make a servo.  (Read 5277 times)

0 Members and 1 Guest are viewing this topic.

Offline czwalga00gtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Have a PWM signal and a motor; how to make a servo.
« on: August 02, 2007, 10:28:09 AM »
I've searched and found a lot of semi-useful information, but still havent got a smoking gun.

What i have: FPGA that outputs a PWM signal, a standard DC motor that when on goes to 90 degrees open, and off is 0 degrees closed.


What i need: Basically i need the logic that can turn this into a servo, so I can basically hook up the power/ground, then my PWM signal and control the angle the motor blade is open. 


Is there pre-fabbed logic out there that I can buy or will this have to be completely custom.  Really i'm just trying to make a higher powered standard motor into a servo. 

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #1 on: August 03, 2007, 10:05:47 AM »
How about this?
http://homepages.which.net/~paul.hills/Circuits/PowerServo/PowerServo.html

You could also just put an encoder onto the DC motor.

Offline czwalga00gtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #2 on: August 06, 2007, 05:50:41 AM »
Thanks, i've seen that and it's pretty much where i've have most of my information.  I was just wondering if anyones actually done something like this.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #3 on: August 06, 2007, 07:31:02 AM »
Quote
Really i'm just trying to make a higher powered standard motor into a servo.
Just out of curiosity, why? Why not just buy a stepper motor or an industrial servo or use encoders?

Offline czwalga00gtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #4 on: August 07, 2007, 09:35:27 AM »
Quote
Really i'm just trying to make a higher powered standard motor into a servo.
Just out of curiosity, why? Why not just buy a stepper motor or an industrial servo or use encoders?


I really would like to... it would make my life a hell of a lot easier.  The problem is that this motor is already built into a specific housing with gearing.  There is a potentiometer already built into the housing as well.  I'd like to just change the motor out, but it would be too difficult.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #5 on: August 07, 2007, 11:11:18 AM »
You should have mentioned this before!

So all you really need is a control equation and a sensor for the pot, right?

Ok so here is how to do it . . .

Hook up the pot to the ADC of your microcontroller. Then rotate your motor 1 degree, and take a measurement. Jot down the ADC value and the angle into excel. Repeat this until the motor has rotated the entire allowed motion.

Plot it out in excel, then using excel have it derive an equation for you. It will have some exponential curve to it.

For example:
angle = ADC^2 +2.5*ADC + .5 or something like that

Finally, use traditional PID to have the current angle of the motor match the desired angle, using the ADC equation.
http://www.societyofrobots.com/programming_PID.shtml

Offline czwalga00gtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #6 on: August 07, 2007, 06:27:48 PM »
I'll read the PID controller article tomorrow when i'm at work.   ;)


Just restating what I said, The motor is in a housing that prevents the motor from spinning anymore than 90 degrees.  It also has a pot built onto the motor blade.  I have a seperate chip that is going to output a PWM signal (I already have created).  Also a few power op-amps.

You're saying that the PID controller will accept the PWM signal and then power the motor appropriately to hold certain angles provided I program the controller correctly.   

I believe the pot will be a linear voltage from 0-5v, 0v=0degrees  2.5v=45degrees  5v=90degrees or something similar. 



Any more help will be appreciated even simple things.  I've been reading in circles for what seems like 2 weeks.  Everytime I think i figure it out I feel like i take 10 steps backwards.  Most of the stuff i've been reading involves a motor controller that is creating a PWM signal, which doesn't help me because I already have the signal setup. 

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #7 on: August 08, 2007, 05:06:38 AM »
Quote
You're saying that the PID controller will accept the PWM signal and then power the motor appropriately to hold certain angles provided I program the controller correctly.
Well not exactly. The PID controller is supposed to determine what PWM signal you output. If you still have trouble after thinking about it for awhile, just ask . . .

Quote
Everytime I think i figure it out I feel like i take 10 steps backwards.
Welcome to robotics :P

Offline czwalga00gtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #8 on: August 08, 2007, 07:20:43 AM »

I think i've finally got the concept I was missing...  I already have a PWM signal, if i hook it up to a correctly sized power op-amp; varying the duty cycle will hold the motor at some particular angle?  Will not be accurate at all, because it has no control equation with a closed loop, but I will just add those in later.  Simple, but I was thinking something else had to be done circuitry wise to the motor.  Live and learn... i was thinking too much.  I can't test anything for another two weeks, so i've just been going over everything theoretically.

Anyways, do you have a suggestion on microcontrollers?  I'm using an FPGA right now, not a big fan of verilog/vhdl, which is what my code is written in right now (basically just has the capabilities to output a PWM signal with a duty cycle i choose).  I do have access to a picstart plus programmer so I could switch over to a pic chip?  I have programmed a robot with the pic before, although it was a lot simpler than what i'm doing now. (motor was in constant motion, forward or backward with a few pots)

I'm going to be dealing with a serial connection, sending a hex command out, then recieving a value back; if that makes a difference, I know it can be done with an FPGA not sure with a pic chip.



Thanks for the help!
Steve

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #9 on: August 11, 2007, 09:47:59 AM »
I think you understand now . . .

You can also use a MOSFET instead of power op-amps. Ive only once had a need for the latter.

Quote
Anyways, do you have a suggestion on microcontrollers?
http://www.societyofrobots.com/robotforum/index.php?topic=1413.0

Thats a question that has been asked like 20 times already on the forum, if you search for a bit you can find a lot of info.

My personal recommendation is to stay AVR based with an ATmega . . .

Offline czwalga00gtTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #10 on: August 14, 2007, 10:10:11 AM »
I've finally figured it out.  Thanks for the help.  Just one more question.


"The Complete PID Equation
Combining everything from above, here is the complete PID equation:

Actuator_Output = Kp*P + Ki*I + Kd*D "
-From your PID page


I've programmed the chip to do the following; minus the integral which i'm leavnig out as suggested.  For the actuator output, how do i translate that value into a percentage of the duty cycle.  Obviously if full power is needed then it will just be a straight dc voltage, but if 50% is needed then the duty cycle needs to be adjusted.  I'm just not sure how the sum of the values will correspond exactly to the duty cycle.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Have a PWM signal and a motor; how to make a servo.
« Reply #11 on: August 14, 2007, 08:58:36 PM »
Quote
For the actuator output, how do i translate that value into a percentage of the duty cycle.  Obviously if full power is needed then it will just be a straight dc voltage, but if 50% is needed then the duty cycle needs to be adjusted.
This is where the arbitrary constant comes in. The reason is because there are many complex things going on with your robot that no equation can handle - mass distribution, quality/torque of your motors, friction from the floor, etc.

Basically, just guess, then have your robot go. Now tweak the constant(s) until the robot moves satisfactory.

The only way to avoid this is to do a detailed model and simulation, which is too much effort for what you are doing . . .

 


Get Your Ad Here