BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 9:12 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Calculation for QPPS,positioning,speed,acceleration
PostPosted: Sat Feb 04, 2012 12:45 am 
Offline
New User

Joined: Thu Feb 02, 2012 4:03 am
Posts: 2
Hi,
I having problem using packet serial..How calculate the QPPS,speed,acceleration and distance?

I have made some simple program using command 42- buffered motor M2 with speed and distance using PIC16F877a microcontroller with hitech C compiler..

Code:
/*
Control RoboCLaw using packet serial.
By: Khairul
*/

#include<htc.h>
#include "PS2controller_code.h"

void uart_send(unsigned long data);

main(){

//setup USART
   BRGH  = 1;         //baud rate low speed option
   SPBRG = 0x40;      //set boud rate to 19200bps for 20Mhz crystal spbrg64
   TX9  = 0;         //8-bit transmission
   TXEN = 1;         //enable transmission
   CREN = 1;         //enable receive
   SYNC = 0;         //asynchronous
   SPEN = 1;         //enable serial port


/*
This line will move motor M2 according to speed,direction and distance
*/
            __delay_ms(2500); ///delay 2.5 second
            uart_send(128);
            uart_send(42); //command 42
            uart_send(0);
            uart_send(6);
            uart_send(26);
            uart_send(128);
            uart_send(0);
            uart_send(0);
            uart_send(7);
            uart_send(208);
            uart_send(0);
            uart_send(545&0x7f);
            __delay_ms(2300);   

/*
This line will stop motor M2
*/
            uart_send(128);
            uart_send(42);//command 42
            uart_send(0);
            uart_send(0);
            uart_send(0);
            uart_send(0);
            uart_send(0);
            uart_send(0);
            uart_send(0);
            uart_send(0);
            uart_send(0);
            uart_send(170&0x7f);
            __delay_ms(2300);   
     
}

void uart_send(unsigned long data)
{   
   while(TXIF==0);            //only send the new data after
      TXREG=data;
}



The problem are:

Motor not stop when command to stop motor is send.Bythe way, the encoder resolution is 200ppr and is attached to the main shaft of the motor(attached after gearbox).
=========================================================================
Problem 1:
from my calculation the encoder resolution i should get is:

200ppr x 4 = 800ppr =====> correct me if i'm wrong
==========================================================================================
Problem 2:
to calculate the Qspeed, i used:
lets say i want the motor speed to 20rpm,so

20rpm x 800ppr = 16000 pulse / min ======> correct me if i'm wrong..is this 16000 value must be put to Qspeed??
==========================================================================================
Problem 3:
For acceleration, i dont know how to calculate so i just put 12,000 as said in the manual.
==========================================================================================
Problem 4:
My wheel diameter is 15cm and is attached directly to 200ppr encoder.

To find distance, i use this formula:

distance to go= (distance to go / wheel diameter) * 800

let say i want the motor rotates 1 rotation only..so,
circumference of wheel = Pi * wheel diameter
= 3.142* 15cm
= 47.13cm ~ 47cm
so, the value of distanceM2 should be is:

( 47cm / 47cm ) * 800 = 800 ========> is this value must be put in distanceM2? correct me if im wrong..
===============================================================================================

Problem 5:
Lastly, when o key in all the data, the motor does not move according to distance, speed and acceleration..PLease refer the attached source code above..

Finally, i really hope that somebody experts in this forum could lend me a hand:)) i really appreciate if can give any suggestions because almost 5 days i focused on this problem to solve.

By the way, if someone know how to set the PID, please kindly share it with us:))


Top
 Profile  
 
 Post subject: Re: Calculation for QPPS,positioning,speed,acceleration
PostPosted: Mon Feb 06, 2012 8:07 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
1. Don't start with distance commands(eg 42). Start with testing your encoders by reading backl the encoder values and manually moving the encoders. Then move up to the Speed comamnds(no accel or distance, just speed) and make sure that your motors are running correct(eg the speed is correct and they can change direction correctly). Then you can move on to accel/speed commands or distance speed commands and know your encoders are properly setup.

2. The QPPS should be calculated empirically if possible. Write a simple program to run a motor at full power(eg using command 0 or 1) and then read back the speed several times after the motor has gotten up to speed. This is your QPPS value(eg the max encoder speed the motor can produce). You should do this with a fully charged battery. I usually set my QPPS a little bit higher than this value as well.

3. Id confirm that one rotation is 800 encoder counts by manually rotating the wheel 360 degrees and checking the encoder position change. But assuming your encoder count for 1 rotation is correct then yes, 16000 = 20rpm.

4. If your wheel counts 800 per rotation then distance / circumference * 800 = distance in encoder counts. Personally I'd go distance * 800 / circumference if I was coding it so I don't underflow or have to use floating point math.

5. Thats why I say at the begining you need to start with speed only commands. Until that is working correctly none of the other encoder commands will work. You need to make sure your encoder wire are not backwards relative to the direction the motor wants to turn. If they are you will get bad results. You need to make sure the encoders are being properly read, if they aren't you will get bad results.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO