pic pwm feasible?

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

pic pwm feasible?

Post by Newz2000 »

Yes, I know there are PICs with built in PWM, but for the sake of argument, lets say I'm not using one of those.<p>There are plenty of circuits for creating PWM with a 555 timer. They usually have some type of variable resistor that adjusts the speed of the motor.<p>Would something like this work: What if I wanted to use 3 outputs on a pic to create a resistor network that increased or decreased resistence (instead of the variable resistor) as those 3 pins are turned on and off. If so, it seems like you could control the motor in 8 speed steps from off to full speed. Likewise, using two pins could give you four steps, off, low, med and high, which may be perfect for me and allow me to use only a few pins (not to imply that I would use 33%, 67%, 100% for speeds; it may be that 60%, 75% and 100% are right, but with 3 choices I could design resistence to get what I want, I think).<p>(My next question will of course be about resistor networks ;-)
rstofer
Posts: 115
Joined: Sun May 15, 2005 1:01 am
Contact:

Re: pic pwm feasible?

Post by rstofer »

So, you are just doing digital to analog conversion with parallel output.<p>There are more than 561,000 hits on Google for 'parallel digital to analog conversion', without the quotes.<p>No big deal but, for the number of pins and external components, you don't get anywhere near the resolution. Almost anything can be made to work...
Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Re: pic pwm feasible?

Post by Newz2000 »

Hey, thanks. I didn't realize that was what I was doing. Those keywords gave some excellent documents.<p>Your response indicates, "you *could* do it that way, but there's probably easier solutions..." I'm eager to hear about other options... No use re-inventing the wheel too many times in the same project.<p>I still haven't a great solution for switching into reverse.
Engineer1138
Posts: 458
Joined: Thu Feb 05, 2004 1:01 am
Location: Minneapolis, MN
Contact:

Re: pic pwm feasible?

Post by Engineer1138 »

Well, if the end goal is to produce PWM, why not just do it in the PIC? You don't need a PIC that has onboard PWM built in, you can do it yourself by turning on/off an output pin at the desired rate (assuming the required update speed isn't too high) in software.
Gorgon
Posts: 325
Joined: Wed May 04, 2005 1:01 am
Location: Norway
Contact:

Re: pic pwm feasible?

Post by Gorgon »

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by Matt Nuzum:
Hey, thanks. I didn't realize that was what I was doing. Those keywords gave some excellent documents.<p>Your response indicates, "you *could* do it that way, but there's probably easier solutions..." I'm eager to hear about other options... No use re-inventing the wheel too many times in the same project.<p>I still haven't a great solution for switching into reverse.<hr></blockquote><p>Why not give us at least a framework of details around your application? PWM frequency, power req., type of motor/ device to control? <p>Solutions is a result of requirements, and your requirements is a bit sketchy.. ;)
Gorgon the Caretaker - Character in a childrens TV-show from 1968. ;)
Newz2000
Posts: 507
Joined: Wed May 18, 2005 1:01 am
Location: Des Moines, Iowa, USA
Contact:

Re: pic pwm feasible?

Post by Newz2000 »

Requirements:
** Lofty End Goal **
To better understand human-machine interaction. My goal is to control a device that turns left-to-right like a stearing wheel from a computer.<p>My theory is that when using a joystick, people move the device far left if they want to move left quickly, and slightly left if they want it to move left slightly.<p>I want to create a device that moves an object in a way that is consistent with people's expectations. If (I mean when) this all works like I want I'll put it to use in some project where people use a computer to move things around (not sure on the exact details there yet).<p> ** Immediate Goals **
Turn several motors from a pic processor. Specifically, I want to create a motor that can go variable speeds so that for an object moving from point x to another point y the object will move at a faster speed the further it is from y. As the object aproaches y it will move slower.<p>This project is purely academic and I hope to re-learn what I used to know about electronics and in the process pick (or maybe 'pic') up some new skills.<p>I have a 12 volt motor, a pic 1f84a (and a 16f627, but no programmer for that yet), a breadboard and a whole box full of capcitors, resistors, LEDs and etc.<p>Sorry for not being more detailed in my initial description. I've been having trouble this week getting help on message boards and IRC and I wondered if it is because of my tendency toward verbosity.
rstofer
Posts: 115
Joined: Sun May 15, 2005 1:01 am
Contact:

Re: pic pwm feasible?

Post by rstofer »

Well, now you are doing PID control (Proportional, Integral and Derivative) although one or more terms may be omitted.<p>What you are asking for is an output that is proportional to the error (or difference) between a set point (stick position) and a control point (or current position). The larger the error, the higher the output, the faster the error is reduced.<p>All well and good but there are two problems. A very small error will never be reduced to zero. This may, or may not, be important. So, we introduce the integral term. This function adds up the error over a bunch of samples and if the accumulated error gets high the system moves to reduce it.<p>The other problem is that, to reduce a large error, the control calls for high speed. Great, until it is time to slow down. Slowing from a high speed is difficult. Derivative comes to the rescue. It controls the rate at which the control point approaches the set point and causes the output to reduce in anticipation of reaching zero error.<p>So, search with Google for PID control with a PIC, or whatever. Also, review the application notes at www.microchip.com. There are several PID control examples around.<p>One thing you have to decide with the joystick is whether stick position implies rate (move it hard over for a high speed change) or position (how far a steering actuator moves, how fast a motor turns). Think about what you want to happen to a steering system when you move the stick. Very probably you want the machine to turn until the steering matches the stick. To straighten the steering out you move back to the center.
Gorgon
Posts: 325
Joined: Wed May 04, 2005 1:01 am
Location: Norway
Contact:

Re: pic pwm feasible?

Post by Gorgon »

Hi Matt,
Rstofer gave you a very good advice on this. You need a PID regulation for this application. And just for the heck of it, you may also try to get som knowledge about Fuzzy Logic. I'm not sure if Microchip has done any proper application on this, but I found some papers when I searched their website.<p>When you start reading about PID-regulators you want to know the following. The Setpoint input is the position of your joystick. The process input is the position of your steering wheels. The regulator output is the motor control, both directions (+/-).<p>If you use the I-part, the integral part, please make some sort of maximum and minimum limits or zeroing of this value. If not you may wait forever before your steering is responding in special cases. (I've been there, not with steering but in controlling HVAC systems)<p>And, when you have programmed your PID-regulator, you'll have to tune it and so on.. Therefor, make all set variables easy to adjust! You will need to change them :D <p>Good luck!
TOK ;)
Gorgon the Caretaker - Character in a childrens TV-show from 1968. ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 59 guests