To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1712
1711  |  1713
Subject: 
Re: Motor Speed Control
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Tue, 30 Nov 2004 14:16:57 GMT
Viewed: 
5275 times
  
In lugnet.robotics.rcx.nqc, Iain Hendry wrote:
Hi,

I'm trying to do a basic test setup to code a compact speed control module
for the 9V gearmotor.  I've mounted an encoder (rotation sensor) directly to
the gearmotor shaft.


Has anyone done something at all similar to this?  I'm aiming at geting
smooth, slow motor speed.

    Iain

I'm doing somthing similair at the moment. My robot runs along a track and needs
to be controlled so it doesn't go too fast. I've successfully written some code
which limits the top speed, you may be able to modify it or just incorparate
ideas from it.

This got my robot moving but calculating speed is not that easy.


I could really do with a way of calculating speed really quickly. I thought of
timing the gap between changes on the rotation sensor. The problem with that is,
that the slower the robot the longer the ticks, which is the reverse of what I
want.

I thougt I could divide a second by my value and then multiply a single rotation
step by the same amount - to work out how far the sensor would turn in a second
- but without floating point I don't know if this would work.


I also need a system that can bring my robot to a gentle stop in exactly the
right position. The speed and weight of the robot are variable, so I need a
system to take that into account. How can I generate a smooth decelaration curve
to control my feedback loop?

I was thinking if my robot was above the curve it could brake and if below add
power otherwise float.


One solution I might try is to accelarate my robot to top speed then float to a
halt, recording the length of each rotation tick (in the datalog). I could then
compare against this to bring my robot to a halt. Would this work?

Steve


Here is my speed control program

#define TRUE 1
#define FALSE 0

int Aforward=1;
int speed;
int maxspeed=0;

task main()
{

start speedcontrol;

SetSensor(SENSOR_1, SENSOR_ROTATION); ClearSensor(SENSOR_1);

SetDirection(OUT_A, OUT_FWD);
SetOutput(OUT_A, OUT_ON);
Wait(150);
Float(OUT_A);
start speedlimiter;
    start repeater;
    }


  task speedcontrol()
        {
        int safetyspeed;
        while(TRUE){
        int oldvar=SENSOR_1;
        Wait(1);
        if(Aforward)
           {safetyspeed=SENSOR_1-oldvar;}
        else
           {safetyspeed=oldvar-SENSOR_1;}
        speed=safetyspeed;
        if(speed > maxspeed){maxspeed=speed;}
        SetUserDisplay(speed,0);
        }
        }

    task speedlimiter()//if motor doesn't reach top speed before this task
starts their could be probs
         {
         while(TRUE){
         if(speed > maxspeed/6)
            {
            Float(OUT_A);
            Wait(1);
            SetOutput(OUT_A, OUT_ON);

            }        }
         }

task repeater()
{
while(true){
SetDirection(OUT_A, OUT_FWD);
SetOutput(OUT_A, OUT_ON);
Aforward = 1;
Wait(200);
SetDirection(OUT_A, OUT_REV);
SetOutput(OUT_A, OUT_ON);
Aforward = 0;
Wait(200);}
}



Message is in Reply To:
  Motor Speed Control
 
Hi, I'm trying to do a basic test setup to code a compact speed control module for the 9V gearmotor. I've mounted an encoder (rotation sensor) directly to the gearmotor shaft. In my code, I'd like to set a variable (speedDesired) and have the motor (...) (20 years ago, 30-Nov-04, to lugnet.robotics.rcx.nqc)

10 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR