|
|
View previous topic :: View next topic |
Author |
Message |
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
10 motors |
Posted: Mon Nov 07, 2011 1:21 pm |
|
|
Hi, I want to control the position of ten dc motors with potentiometers as feedback. I want to use pid algo to calculate the pwm. I already managed to position one of the dc motor to the desired angle.
I intend to use PIC16F1527 as it has 10 Capture/Compare/PWM (CCP) modules. I want the motor to move simultaneously. The problem is that how can I do that. The time base for each motor should be the same, the diff is speed(pwm). Is it possible for me to use one pid algorithm calc the pwm for all motor. what I mean is that, I executes the pid algo to motor in sequence which mean that motor2 not going to be executes until motor 1 achieved it desired angle.
Another alternative is to create one motor with one pid. so I will have ten pid func.fyi I used interrupt to read the potentiometer.thus that mean i need ten interrupt. executes according to priority. Any helps/ideas/advice will be helpful |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Mon Nov 07, 2011 2:03 pm |
|
|
How about using 10 really small PICs? The PIC12F5XX types cost less than US$1 each in a 8 pin DIP package. One clock could drive them all, and you should be able to do your PID totally in software if that is all the PIC has to do. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Tue Nov 08, 2011 6:17 am |
|
|
is it easier to do that by having each pic for each motor + pot. fyi my system also will have imu (accelerometer and gyro), compass and maybe servo. so do you suggest that I have one pic (act as master) for main program and 10 other small pic (slave) for motors.
I don't have any idea how master slave works.how they comm each other. do you have any material that can i read about about it |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Tue Nov 08, 2011 7:06 am |
|
|
SherpaDoug is right, just think of RC servo systems. Each servo receives info from the 'master', then acts accordingly. Simple, easy to implement.
You can easily do the same with either RS232,RS485,I2C, or your own communications protocol.Just start with one servo, add another, test, add another, test,....until all ten are installed.
One of the MAJOR benefits of this approach is if one servo'subsystem' fails the master PIC won't be destroyed ! Also, spare servo 'subsystems' are cheap and all would be interchangable.
The 'master' PIC can be anything even an 16F84 depending on how fancy the system is. |
|
|
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Tue Nov 08, 2011 9:03 am |
|
|
oo ok. What about the hw configuration? For example I want to use pic16f877a one for master and another as a slave. Does it mean that the slave have the same conf as master which has its own crystal frequency, pull up resistor?
I already have one interrupt (timer 0) for pid calc. if i put this programme in slave. for ex if i use i2c, I notice that it need to call the interrupt #int_ssp to comm with the master. if i plan to use i2c, does it effect the interrupt for my pid (the interrupt in pid is use to read potentiometer and while doing the calculation, i disable the timer0 interrupt) |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Tue Nov 08, 2011 4:12 pm |
|
|
First, you need to decide on some overall details.
Overall system performance. Speed that the PID control loops need to operate at. Is this going to be a CNC machine or 'robot'.
Servos ? PWM, linear, ?? Since you say 'pots', can we assume a limited(270* or less) rotation of the servos?
Physical size of the system. How far away will the servos be from the controller. That will decide communication strategy.
Power requirement of the servos. Is this a battery device or tethered to the AC wall socket. |
|
|
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Wed Nov 09, 2011 3:57 am |
|
|
thanks for the replies. let me answer ur questions
temtronic wrote: | First, you need to decide on some overall details.
Overall system performance. Speed that the PID control loops need to operate at.. |
I need the motor to move to the desired angle in 1/8 seconds. Currently the interrupt in my pid which reading the pot is execute every 3.3 ms.
temtronic wrote: | Is this going to be a CNC machine or 'robot'.
Servos ? PWM, linear, ?? Since you say 'pots', can we assume a limited(270* or less) rotation of the servos? |
this is a robot. the motors will be place in series (ex a tail/snake). I use the pid to calculate the pwm to varies the speed of each motor but excutes in the same time period. yes, the rotation of the gear motors are plus minus 20 degrees.
temtronic wrote: | Physical size of the system. How far away will the servos be from the controller. That will decide communication strategy. Power requirement of the servos. Is this a battery device or tethered to the AC wall socket. |
it is a robot and the motors are in series so the end of the tail (last motor) will be approx 40cm from the controller.about the power req, i use 12v battery for the motor |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Wed Nov 09, 2011 6:17 am |
|
|
Ah, much better 'picture' of the overall project. It's similar to a 'snake' I designed about 10 years ago based on an IEEE article.I hacked common RCservos to get the pot position voltage and fed to a 16F877.It was the cheapest way to get the snake working.
Today, I'd use the servos but have an 8 pin PIC control each servo.It would 'listen' for the master command signal, send the servo pot info, then adjust the 'servo control pulse(1.0-2.0ms)' as dictated by the master.
You could easily use RS485 as the communications bus.It has the speed,noise immunity and simple code to implement.Each 'segment' would consist of the servo,PIC and MAX488 plus a few caps and Rs for filtering.The 'fun' is in the master code to program the 'snake' or 'tail'. Depending on how many segments you have, getting the 'end of the tail' to a predefined point is a lot of math(several DOF) but simple 'S' movements are fairly easy. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Wed Nov 09, 2011 6:45 am |
|
|
Have to agree wholeheartedly with using RS485. Also, since the basic needs are really simple, you can be 'sneaky', with a protocol that is easy to implement. Something (say), like using values under 127, for 'motor number', and values over this for 'position'. Each unit then just looks for it's 'motor number' value, and when this is seen, reads the next byte, subtracts 128, and moves to the position this defines. At (say) 100Kbps (a nice round figure, that is easily achieved by most standard clocks), it then takes just 1/5000th second to send a position, and 1/500th second to update them all.
Best Wishes |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Nov 09, 2011 10:53 am |
|
|
This sounds like a cool project! If this is for hobby or school you might be able to use a open collector parallel serial bus instead of real RS485 for this short distance.
Either connect all the transmit PIC pins in parallel with a common pull-up resistor and set the UARTS to open collector mode (I don't have my CCS reference with me now). Or have the PIC UART TX pins each drive an external transistor. It will be simpler than putting a real RS484 driver/reciever chip on each motor unit.
With the right software protocol you could have stackable self contained interchangable segments, each with its own motor and processor. You could make the snake longer by removing the tail segment, adding any number of new segments and replacing the tail. On initialization the head segment measures how many segments there are till it finds the tail and adjusts the motion scheme to suit. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Wed Nov 09, 2011 11:11 am |
|
|
Thanks. This robot is for my research. Currently I try to understand the difference between rs485 and rs232. I try to see how can I interface multi pic + max488. With rs485, it needs the termination resistor. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Wed Nov 09, 2011 4:06 pm |
|
|
RS232 - Single source, single destination. Quite good noise immunity because of voltages used, and receive levels selected. Limited maximum speed.
RS488 - Possibly you mean IEEE-488?
RS423 - lower voltage, but similar to RS232 - supports higher data rates, and requires a terminating resistance once data rates rise - supports multiple destination devices (10).
RS485/RS422 - Similar low voltage differential busses. Again requires termination (over 250Kbps, and depending on bus length), supporting higher data rates up to 10Mb.
General comments:
Differential busses, with twisted pair wiring, are _much_ more likely to be reliable with motors around. Even over the short distances involved, you _will_ have problems with single ended busses like RS232/RS423, and motors nearby.....
Once data rates go up, you need to match the bus impedance with a terminating resistor. It's all down to slew rates, and ringing at the ends of the wire. RS232/423, or even RS485, _will_operate happily without termination, but only up to perhaps 250kbps, and with limited slew rates. Go faster, and termination becomes essential. Seriously though, it only involves choosing a cable with a known impedance, and a couple of resistors. Not exactly hard.....
Best Wishes |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Nov 09, 2011 6:14 pm |
|
|
Ttelmah wrote: |
Once data rates go up, you need to match the bus impedance with a terminating resistor. It's all down to slew rates, and ringing at the ends of the wire. RS232/423, or even RS485, _will_operate happily without termination, but only up to perhaps 250kbps, and with limited slew rates. Go faster, and termination becomes essential. Seriously though, it only involves choosing a cable with a known impedance, and a couple of resistors. Not exactly hard..... |
Unless this robotic snake is going to be outrunning a real live snake I doubt the data speeds will have to exceed 9600 baud. RS485 on a twisted pair with terminating resistors in the head and tail sections will certainly work.
RS485 allows one node at a time to transmit to all nodes on the twisted pair line, including itself. You have to establish the protocol so only one node speaks at a time. Usually one node is Master and the others are Slaves who only speak when spoken to. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Thu Nov 10, 2011 6:24 am |
|
|
SherpaDoug wrote: | How about using 10 really small PICs? The PIC12F5XX types cost less than US$1 each in a 8 pin DIP package. One clock could drive them all, and you should be able to do your PID totally in software if that is all the PIC has to do. |
i looked at pic12f5xx, and try to find that has pwm and able to do rs485 but couldn't find one. as i need 10 of it, better to have small pic. the closest i get are 18 pin (PIC16F87/8828) and 28 pin (PIC16F882/883/886). earlier i run my pid using pic16f877a with 20MHz |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Nov 10, 2011 10:19 am |
|
|
Are these motors the hobby servo type that take a 1 to 2ms pulse width to set position? If they are you don't really need PWM hardware. A PIC12F1840 has a UART, 7k of flash 256 RAM, and clocks at 32MHz, all in a 8 pin DIP for $1.50 at Digi-Key.
At 32MHz your PID should really fly, with plenty of CPU cycles left to use one of the timers to drive your servo. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|
|
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
|