Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Controlling motor speed (http://www.chiefdelphi.com/forums/showthread.php?t=53643)

WGRAY 07-02-2007 13:59

Controlling motor speed
 
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.:confused:

Mike Betts 07-02-2007 14:09

Re: Controlling motor speed
 
Quote:

Originally Posted by WGRAY (Post 573679)
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.:confused:

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

Kingofl337 07-02-2007 22:25

Re: Controlling motor speed
 
You should use the online window to determine the speed you want your arm to move at and then using a formula like Mike posted make that your maximum.

WGRAY 07-02-2007 23:01

Re: Controlling motor speed
 
I understand the formula however I do not have anything in my c window that resembles his format "pwm01 = (unsigned char) ((((int) p1_y - 127) / 4) + 127); otherwise I would replace my code with his. What steps in easycpro would I use to generate code in that format?http://www.chiefdelphi.com/forums/im...es/redface.gif
:o

Kingofl337 08-02-2007 07:04

Re: Controlling motor speed
 
Here is the easiest way to do this in easyC.

Code:

      int Arm_Joystick;
      unsigned char Arm_Output;

      while ( 1 )
      {
            Arm_Joystick = GetOIAInput ( 2 , 2 ) ; // Analog OI Input Block
            Arm_Output = ((( Arm_Joystick - 127 ) / 4) + 127 ) ; // User Code Block
            SetPWM ( 4 , Arm_Output ) ; // PWM Control Block
      }

Here is a more advanced way to do this in easyC Pro

Code:

while (1)
  {
        SetPWM ( 5 , ((( GetOIAInput(2,2) - 127) / 4) +127 ) ) ;
  }

Oh, and when you put a smiley in your post all you have to do is click on the smile you want once and the forum software
automagicly loads the image. :D

WGRAY 08-02-2007 11:01

Re: Controlling motor speed
 
Thanks
With a little tweaking your more advanced code worked perfectly!

Kingofl337 08-02-2007 13:54

Re: Controlling motor speed
 
Variables are overrated :p

Drake Hunter 11-02-2009 18:23

Re: Controlling motor speed
 
Can anyone help me in labview?

dboisvert 12-02-2009 21:29

Re: Controlling motor speed
 
This isnt the proper area to ask a labview question. I would suggest going under Programming > Labview

Drake Hunter 16-02-2009 22:50

Re: Controlling motor speed
 
Quote:

Originally Posted by dboisvert (Post 819612)
This isnt the proper area to ask a labview question. I would suggest going under Programming > Labview

no kidding....but i needed help so i figured i would ask


All times are GMT -5. The time now is 10:58.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi