View Single Post
  #2   Spotlight this post!  
Unread 07-02-2007, 14:09
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Controlling motor speed

Quote:
Originally Posted by WGRAY View Post
I would like to control the speed of motors so that my arm motors spin slowly, ie when I use my joystick to control my arm and push it full throttle, it would return a quarter throttle response. If you could step by step instruct in easycpro, I am a newbie rookie.
I can't help you with easyC but can explain the basics...

A PWM is defined to be:

255 - Full Forward
127 - Stop
0 - Full Reverse

Let's assume that your PWM is #1 and you are using the Y axis of the Joystick installed into Port 1 to control it. Your C code would look like this:

pwm01 = (unsigned char) ((((int) p1_y - 127) / 4) + 127);

(int) and (unsigned char) are compiler directives called a cast. (int) tells the compiler to transform the unsigned char, p1_y, to a signed integer. (unsigned char) transforms it back.

Note that there are many ways to skin a cat, all of which are intensely undesirable to the cat...

Regards,

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...