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 support@ccsinfo.com

4 rpm measurement and 4 pwm control

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



Joined: 25 Feb 2008
Posts: 5

View user's profile Send private message

4 rpm measurement and 4 pwm control
PostPosted: Sun Aug 31, 2008 10:30 am     Reply with quote

Hello, I'm going to make a sumo robot for a competition, and I want to connect my 4 motors directly to the wheels without gearhead. I need to measure the rpm in each motor to control independently their pwm, because even the motors are of the same model and brand they can have small diferences on speed.

but I need some help because I don't know it all this work can be made by only one PIC or DsPic(especially for the timers), for example the DsPic 30f4012 or maybe using 4 Pics?? Shocked
Ttelmah
Guest







PostPosted: Sun Aug 31, 2008 10:36 am     Reply with quote

Hint. We are not telepathic.
What are the motors?. stepper?. DC motors?.
How are they actually driven?.

Best Wishes
chelitog555



Joined: 25 Feb 2008
Posts: 5

View user's profile Send private message

PostPosted: Sun Aug 31, 2008 12:54 pm     Reply with quote

Sorry, there are 4 mabushi dc motors, I want to use drivers like l298
RLScott



Joined: 10 Jul 2007
Posts: 459

View user's profile Send private message

PostPosted: Mon Sep 01, 2008 7:11 am     Reply with quote

If the motor has an attached quadrature encoder, then that can be used to measure the RPM. If not, then you are faced with the less accurate means of estimating RPM by means of the back EMF generated by the motor. So which is it?
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
chelitog555



Joined: 25 Feb 2008
Posts: 5

View user's profile Send private message

PostPosted: Mon Sep 01, 2008 5:44 pm     Reply with quote

or maybe I can use any LM331, AD650, VFC32, XR4151 to make a frequency to voltage converter and use one on each motor??
SherpaDoug



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

View user's profile Send private message

PostPosted: Mon Sep 01, 2008 7:19 pm     Reply with quote

I would tend to use a PIC for each motor. Have a master processor that commands four virtual motors. Each virtual motor is a slave PIC controlling its own real motor.
With only one motor to worry about the slave code should be easy to write, and then just duplicate. PICs cost less than the time it takes to write more complex code.
Plus there is inherent fault tolerance. If one motor gets damaged, the others won't be affected.
_________________
The search for better is endless. Instead simply find very good and get the job done.
RLScott



Joined: 10 Jul 2007
Posts: 459

View user's profile Send private message

PostPosted: Tue Sep 02, 2008 5:22 am     Reply with quote

chelitog555 wrote:
or maybe I can use any LM331, AD650, VFC32, XR4151 to make a frequency to voltage converter and use one on each motor??

A frequency to voltage converter is fine if you have a frequency. If all you have is a DC motor, then there is no frequency being generated by the motor that says how fast it is going. Again, what hardware do you have on these motors to sense RPM?
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
chelitog555



Joined: 25 Feb 2008
Posts: 5

View user's profile Send private message

PostPosted: Tue Sep 02, 2008 10:43 pm     Reply with quote

the hardware is an optocoupler using an encoder on each motor
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Sep 02, 2008 11:17 pm     Reply with quote

I guess, you mean a single channel photointerrupter, not a two channel quadrature encoder? In this case e. g. a 30f4011, that has 4 ICx pins and sufficient PWM outputs could be used to control four motors. The said 4012 unfortunately is missing just the ICx pins.
Ttelmah
Guest







PostPosted: Wed Sep 03, 2008 2:23 am     Reply with quote

There would also appear to be a very large problem with the timing involved. If this is an interrupter, giving just one pulse per rev, at 4RPM, you are only going to see one pulse every 15 seconds. A frequency to voltage converter, itself adds a time delay to detecting any speed change. Even with multiple teeth on the interrupter, the data the processor receives is going to be so far 'out of touch', that the code is going to be very hard to generate, without massive overshooting, or very slow responses...
Better to measure _time_ between the interrupter pulses. If you measure how long the gap is, using the clock of the processor, you have a measure that reflects the speed during the last interrupter gap, and which is therefore much more recent. Look at the example code for tacho applications.
I agree with Sherpa Dog's comment. It really is going to be easier to use a relatively 'basic' PIC for each motor. Or going just a little more upmarket, something like the PIC18F1220, which gives the ECCP, which is ideal for controlling a motor through the L298.
I would worry that the motor is going to have enough torque without reduction. Sit down and do some estimates of how much torque you need (there are formulae on the web for this), and then look at the motor data sheets. You may be suprised at how large the motors have to be, for direct drive. Generally, smaller motors, spinning faster, with a reduction gearbox, will be able to deliver much better performance, than direct drive units. Typical 'short cut' motor assemblies, are the units in modern cheap rechargeable electric drills. These have reduction gearboxes built in, and the basic units, are often cheaper than you can buy the motors for!...

Best Wishes
chelitog555



Joined: 25 Feb 2008
Posts: 5

View user's profile Send private message

PostPosted: Sat Sep 06, 2008 4:08 pm     Reply with quote

Thanks so much, well I think my motors have torque enough, there are four mabushi fs-578va power window motors, and now I can sense the speed of each motor using only one timer, but when I try to use the dspic 30f4012 to drive the 4 motors I found that this dspic have only 3 pwm generators, what can I do now? I need to use 2 Pic?
thanks
Code:
#include "primero.h"
#include <lcd.c>

int8 a0,a1,a2,a3,b=0,c0,c1,c2,c3,count0,count1,count2,count3,contador;
int8 rpm0,rpm1,rpm2,rpm3;
// variables rpm are not really the rpm measurement

#INT_TIMER0
void interr()
{
a0=input(PIN_B0);
a1=input(PIN_B1);
a2=input(PIN_B2);
a3=input(PIN_B3);
if(b==1){
output_high(PIN_C0);}
if(b==0){
output_low(PIN_C0);}

if(a0!=c0){
count0++;}

if(a1!=c1){
count1++;}

if(a2!=c2){
count2++;}

if(a3!=c3){
count3++;}
contador++;

if(contador==10){
rpm0=count0; rpm1=count1;  rpm2=count2; rpm3=count3;
count0=0; count1=0; count2=0; count3=0; contador=0;}

c0=a0; c1=a1; c2=a2; c3=a3;

}

// regresa un 1 si hay flanco
int8 detectar_flanco(int8 actual,int8 anterior)
{
if(actual==anterior){
return(0);}
else{
return(1);}
}


void main()
{

   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   setup_oscillator(False);

   enable_interrupts(GLOBAL);
   enable_interrupts(INT_TIMER0);
   set_timer0(0);
   
   
   set_tris_b(0b00001111);
   set_tris_c(0b11111110);
   // TODO: USER CODE!!
   lcd_init();
   do
   {
   printf(LCD_PUTC,"\f %u %u %u %u",rpm0,rpm1,rpm2,rpm3);
   b=!b;
   delay_ms(100);
   }while(true);

}
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