Pages: [1]   Go Down
Author Topic: Wheel Encoders for complet newbies  (Read 1554 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I’ve hesitated posting here for some time because I really am a complete newbie but desperation now forces.

I wanted a project to get my sons attention and use the computer for something other than gaming.

I’ve bought an arduino based robot  (http://www.robotshop.com/eu/dfrobotshop-rover-tracked-robot-basic-kit-15.html), and we very quickly reached its limits because both turning and distance are governed by time.

It was suggested that we should add wheel encoders and so I’ve bought these http://www.arobose.com/shop/capteurs-robot/19-2-encodeurs-roue-pour-robots-dfrobot-3pa-et-4wd-rovers.html

The problem is that I cannot find any very simple guide to programme them, we just want to make the robot go forward a given distance, turn a certain number of degrees etc.

Any help or advice would be much appreciated.

Thankyou in advance.
Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You just break things into their parts.

The wheel encoder gives you a way to know how much the wheel has turned. Sort out simply getting a report of that information.

Once you know how to tell how far the wheel has turned, you then build your program to make the vehicle do what you want...

Start wheel turning (turn motor on)
Watch turning of wheel
When it has turned as far as you need it to, turn motor off.

hth
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for breaking things down somewhat tkbyd,
I realise that I am going to have to take very small steps in order to bring this project to fruition.
I'll let you know when I complete step 1.  smiley-wink
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 221
Posts: 13853
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

read this leaflet, page 6 shows a nice picture - http://products.cui.com/CUI_AMT103-V_Product_Training_Presentations.pdf?fileID=6203
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

San Diego, California
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Using a treaded base you won't get a lot of accuracy in turns even with an encoder (though the encoder won't hurt if it's there). The agility in turns for a tank-type robot depends on the surface it's going over. The rubber treads used on this kit -- and many like it -- is very compliant, meaning it literally sticks to hard surfaces. That means it may skate unpredictably if the tread simply skips over the surface in turns.

Over carpet and other slippery surfaces the treads won't skate, but the amount of turn is very hard to determine.

You can still play and experiment using the kit you have, but the turns will seldom be as accurate as what you may be looking for. Instead of worrying about odometry, maybe apply a different type of project. A line or wall follower doesn't need encoders, for example.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thks for the info robtillaart, I think that I have bitten off a little more than I can chew  smiley-sweat

You are probably right Gordon a line or wall following robot probably would of been more sensible but I'm not good at sensible smiley-cry

I'm not good at quitting either, so I'm going to try and continue as far as I can (probably not very far), whilst starting another project in paralelle.

This is the code I have so far:

// Wheel encoder/LED/Motor
#define LED 13 //pin for LED
#define ECOD 7 //pin for encoder pulse
int transistorPin = 11; // sends current to transistor/motor

int val = 0; // store state of encoder

void setup(){
 
  pinMode(LED, OUTPUT); //led is output
   pinMode(transistorPin, OUTPUT); // motor is output
    pinMode(ECOD, INPUT); //encoder is input
}

void loop()
{
  val = digitalRead(ECOD); //read value of encoder and store it
  if (val == HIGH)
  {
    digitalWrite(LED, HIGH); // turn led on during pulse
      digitalWrite(transistorPin, HIGH); //turn Motor on during pulse
} else {
    digitalWrite(LED, LOW); // turn led off when pulse stops
      digitalWrite(transistorPin, LOW); // turn motor off when pulse stops
  }
}


So at the moment when I turn the encoder it turns the motor and Led on and off (at least if I move it very slowely).

Now I need to get it to count the pulses and turn off after a predifined number?

I did a nice little schematic to show the wiring but with no web space I don't seem to be able to post it smiley-cry If anyone where interested I'll e-mail it.

Thanks again for your interest.




Logged

Pages: [1]   Go Up
Jump to: