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 / 7767
7766  |  7768
Subject: 
Servo function (new?)
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Sun, 23 Apr 2000 15:03:39 GMT
Reply-To: 
john@coastalgeology.orgSPAMCAKE
Viewed: 
837 times
  
Hello all, here's a servo function that I worked up. It's really very
simple, but I figured that someone else might want to use/hack it up.

My problem was that I wanted to be able to set the servo
(non-continuous) at *any* point in its travel easily. I decided to do
it by percentage. This was because doing it by degrees meant that I'd
have to calculate the total number of degrees that the servo had in
the first place (since they're not exactly 180). I guess I'll still
have to do that if I need a more precise function, but I don't right
now.

-------------cut here-------------------

/* minimum and maximum travel values for my servos. I use conservative
numbers because some can use 4600, but some squeal like hell at that
value. You'll obviously want to change these. */

int servo_0          = 500;
int servo_100        = 4000;

/* my micro servos have different values */

int mc_servo_0       = 950;
int mc_servo_100     = 4400;

/* THe argument "servo" is for the model, I actually use 3-4 different
ones, all with different values. If you only have one, take this an
dthe if statement out. */

int set_servo (int servo, int value) {
  float p,point;
  int range,min,max;

  /* Find out which kind of servo it is using model number */

  if (servo == 3101) {          /* Futaba 3101 is a micro servo */
    min = mc_servo_0;
    max = mc_servo_100;
  } else if (servo == 3003) {   /* Futaba 3003 is a regular servo */
    min = servo_0;
    max = servo_100;
  }

  /* Get total range of travel  */

  range = max-min;

  /* Calculate value as a percentage */

  p = ((float) value) / 100.;

  /* Find point of travel that is x percent of total. If you don't add
  the minimum value, 100% will be equal to range, not max. 0% will be
  way out of range on the low end.*/

  point = p * ((float) range) + ((float) min);
  return ((int) point);
}
-------------cut-------------------

like I said, it's simple, but it might stop somone from reinventing
the wheel, so to speak.

-J
--
Jonathan Pennington | A computer without Windows
john@coastalgeology.org | is like a dog without bricks
http://www.coastalgeology.org | tied to its head.



Message is in Reply To:
  New Servo Routines?
 
Because I have an expansion board, I cannot use my hacked up servo motors together with unaltered motors. In order to stop the hacked servos, I have to call init_expbd_servos(0) which dis-allows use of the other ones. Does anyone have any asm code (...) (24 years ago, 20-Apr-00, to lugnet.robotics.handyboard)

3 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