To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 8045
8044  |  8046
Subject: 
Robot Program for Rover so far...
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Sun, 10 Sep 2000 20:51:25 GMT
Viewed: 
1026 times
  
Hi everyone.

Well I decided to go with a Quad Hall Effect encoder.  I mounted
4 very small magnets on my 1" plastic drive gears and used the
Hall Effect switch  that Fred recommended.  Here's the code I have
and the results!

For a 180 degree turn I get 24 ticks
              90                                12
              45                                  6
              22.5                               3

For the lego gears this is ok, possibly later when the gears on the Mars
Rover
get updated with some metal gears I will have an optical encoder. For
now I
am getting pretty good results with the hall effect encoder


Has anyone tried to have multiple devices on the SPI bus?
RTC, Polaroid Sonar,  Compass ????



int irccmd = 0;
int oldirccmd ;
void main ()
{
alloff ();
sony_init(1);

start_process(getircommand());
while (irccmd != 23)
{ if (irccmd == 26 && oldirccmd != irccmd) {
                go_fwd();
                                   }
else if (irccmd == 24 && oldirccmd != irccmd) {
        go_bwd();
}

else if (irccmd == 31 && oldirccmd != irccmd){
go_right ();
}

else if  (irccmd == 30 && oldirccmd != irccmd) {               int
irccmd = 0;
int oldirccmd ;
void main ()
{
alloff ();
sony_init(1);

start_process(getircommand());
while (irccmd != 23)
{ if (irccmd == 26 && oldirccmd != irccmd) {
                go_fwd();
                                   }
else if (irccmd == 24 && oldirccmd != irccmd) {
        go_bwd();
}

else if (irccmd == 31 && oldirccmd != irccmd){
go_right ();
}

else if  (irccmd == 30 && oldirccmd != irccmd) {
go_left ();
}
else if (irccmd == 63) {
stop ();
}
if (irccmd == 1 && oldirccmd != irccmd) {
go_beep ();
}
}
printf ("End Test \n");
}


void getircommand()
{
                int irc;
                while(1)
        {
                irc = ir_data(0);
                if(irc)
                {                                  go_left ();
}
else if (irccmd == 63) {
stop ();
}
if (irccmd == 1 && oldirccmd != irccmd) {
go_beep ();
}
}
printf ("End Test \n");
}


void getircommand()
{
                int irc;
                while(1)
        {
                irc = ir_data(0);
                if(irc)
                {
                       if(irc >= 128)
                                irc -= 127;
       irccmd = irc;

                }
                else
                        defer();
        }
}



void go_fwd()
{
  oldirccmd = irccmd;
encoder2_counts=0;
printf ("fwd \n");
motor (1,25);
motor (2,25);
fd (1);
fd (2);
                return;
}


void go_bwd () {
  oldirccmd = irccmd;
  encoder2_counts=0;
        printf ("bwd \n");
motor (1,-25);
motor (2,-25);
bk (1);
                bk (2);
                return;
}

void go_right () {
  oldirccmd = irccmd;
  encoder2_counts=0;
                printf ("right \n");
        motor (1,25);
                return;
}


void go_bwd () {
  oldirccmd = irccmd;
  encoder2_counts=0;
        printf ("bwd \n");
motor (1,-25);
motor (2,-25);
bk (1);
                bk (2);
                return;
}

void go_right () {
  oldirccmd = irccmd;
  encoder2_counts=0;
                printf ("right \n");
        motor (1,25);
                motor (2,-25);
                  fd (1);
                bk (2);
                return;
}

void go_left () {
  oldirccmd = irccmd;
encoder2_counts=0;
                printf ("left \n");
        motor (2,25);
        motor (1,-25);
                fd (2);
                bk (1);
                return;
}
     void stop ()
{
  oldirccmd = 100000;
                printf ("stop \n");
           printf ("%d encoder ticks \n", encoder2_counts);
        alloff();
        sleep (1.5);
                return;
}

void  go_beep ()

{
  oldirccmd = irccmd;
                printf ("beep \n");
        beep();
                return;
}



1 Message 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