CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pid and dc motor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nasbyc



Joined: 27 Apr 2009
Posts: 50

View user's profile Send private message AIM Address

pid and dc motor
PostPosted: Tue Jun 07, 2011 12:43 pm     Reply with quote

I need to design position control for 10 dc motor to work simultaneously which I use potentiometer as feedback. Thus each motor will have different speed as different desired angle needed for each motor at one time which I suppose it need me to use pwm. As I need the position the be accurate, I intend to use pid. Moreover H bridge is needed in order to make the motor moves forward and reverse direction. My problem, is it possible to control 10 dc motor by using only 1 pic (for ex 16f877a). I also noticed that this pic only has 2 pwm, is there any other way to generate pwm signal (software or hardware). Lastly the pid controller, I see there a lot example using coding rather than contruct the circuit using amplifier. Is there any advantage/disadvantage. Any ideas/helps will appreciated.
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Tue Jun 07, 2011 1:41 pm     Reply with quote

You can always use 1 PWM, connect all H-bridge inputs to transistors whose bases are controlled by 10 seperate 1/0 ports and the emitters are fed by the pwm output (amplified?), then write an algorythem to control each motors speed by pulsing the pwm to each h-bridge input x/times per second.

Or, if you can take turns on which motor you're controlling then you can use the above method and also control the PWM speed specific to the motors which you're controlling at that moment. You would be controlling all motors at the same time still, just in a smart way that allows them all to share 1 PWM.

It all depends on your application. I can come up with a number of ways to work around this type of problem if I knew a little more about your limitations and restrictions.
_________________
Vinnie Ryan
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 07, 2011 3:32 pm     Reply with quote

For years(12-15) I've used LM12CLKs to power servo motors with encoders for feedback as it only uses 2 I/O pins for motor control.
Pots for feedback work as well, using the ADC inputs, but I like the reliabilty and repeatability of the digital encoders.

Just don't think internal PWM is the ONLY way to control motors! There are other options.

The 16F877 will easily control 4 motors /encoders for CNC work.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Jun 07, 2011 7:28 pm     Reply with quote

Controlling 10 motors with 1 processor is insane. I would use 1 tiny PIC for each motor, and maybe another to manage the herd.

PICs are cheap, you can use a single clock, and writing code for 1 PIC to control 1 motor will be very easy. Controlling 10 motors with a single processor will require an expensive processor, take a long time to write the code, and probably have mysterious bugs that will take forever to fix. Don't do it!
_________________
The search for better is endless. Instead simply find very good and get the job done.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jun 07, 2011 7:54 pm     Reply with quote

aw come on....where's the 'challenge in one PIC = one motor', that 's way too easy ! or is it ?

4 axis with the 877 was fairly easy afterall once you've cut code for 1 'system', you just 'clone' the other 3,4,5..?

If you go the One PIC- One motor, you actually need 11 PICs. Number 11 has to be the 'master controller' and tell the others what to do and when.If it's also connected to a PC or other 'remote' master(for data),add another serial port.Decision now is to use either a LAN approach using RS485 or dedicate 12 or 24 I/O pins for 'slave 'communications.

Cost could be a factor,10x18pin PICs vs 1x40 pin PIC ?,10 pcbs vs 1 ?,etc.

Perhaps cut code for 1 PIC - 1 motor and see how tight and small you can make your code then decide whether designing a LAN is easier than using just one big PIC for all 10 subsystems.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Jun 07, 2011 11:55 pm     Reply with quote

Quote:
I need to design position control for 10 dc motor to work simultaneously which I use potentiometer as feedback.(...)
is it possible to control 10 dc motor by using only 1 pic (for ex 16f877a).

Besides other features, the processor of your choice would need at least 10 analog inputs. But that's a more
simple point. More important, even a dedicated motor control dsPIC doesn't expose 10 PWM channels.

So if the intended 1 PIC/10 motor channels solution can work, it has to rely on software PWM. I won't say
it's impossible, but the dynamic behavior will be limited.

Requirements may be quite different, the first step would be to specify the controller behaviour in terms of
response time and acceptable position error.
nasbyc



Joined: 27 Apr 2009
Posts: 50

View user's profile Send private message AIM Address

PostPosted: Wed Jun 08, 2011 11:19 am     Reply with quote

Thanks for those responded to my questions. I really interested to learn how can I achieved this by only using one pwm. I use 10 motor with the same spec: max vol 12V an max current 0.788A. My vehicle works at 1Hz and in 1 seconds it has 8 steps (position). Thus 0.125s for each step. I already run this through simulation (matlab) and acquired acceptable result (slightly underdamped). Other idea about using one pic for each motor don't seem applicable to me as I have limited space to work with. Just to mention this 10 dc motors just one part of the vehicle. I still need to connect the pic to other sensors (accelerometer and gyro)
n-squared



Joined: 03 Oct 2006
Posts: 99

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Jun 08, 2011 4:07 pm     Reply with quote

Both PIC18F67K22 and PIC18F67K90 have 10 CCP modules, each capable of providing a 10 bit resolution PWM.
I have been using the PIC18F67K90 for a while now.
You cannot use PICkit2, have to use PICkit3. Don't know if ICD2 can handle this part.

BR
Noam
_________________
Every solution has a problem.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group