|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
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.
![]() |
|
#2
|
||||
|
||||
|
Re: Controlling motor speed
Quote:
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 |
|
#3
|
||||
|
||||
|
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.
|
|
#4
|
|||
|
|||
|
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
![]() |
|
#5
|
||||
|
||||
|
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
}
Code:
while (1)
{
SetPWM ( 5 , ((( GetOIAInput(2,2) - 127) / 4) +127 ) ) ;
}
automagicly loads the image. ![]() Last edited by Kingofl337 : 08-02-2007 at 07:08. |
|
#6
|
|||
|
|||
|
Re: Controlling motor speed
Thanks
With a little tweaking your more advanced code worked perfectly! |
|
#7
|
||||
|
||||
|
Re: Controlling motor speed
Variables are overrated
![]() |
|
#8
|
||||
|
||||
|
Re: Controlling motor speed
Can anyone help me in labview?
|
|
#9
|
|||
|
|||
|
Re: Controlling motor speed
This isnt the proper area to ask a labview question. I would suggest going under Programming > Labview
|
|
#10
|
||||
|
||||
|
Re: Controlling motor speed
no kidding....but i needed help so i figured i would ask
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Motor speed | HellBoy | Programming | 2 | 05-02-2007 10:41 |
| Multi-Speed motor Questions | Burg | Robotics Education and Curriculum | 2 | 23-12-2004 15:54 |
| Multi Speed Dual Motor Gearbox | tenfour | General Forum | 14 | 08-09-2003 13:09 |
| Drill Motor Speed Difference | Mark Jones | Motors | 2 | 14-02-2003 15:23 |
| Drill motor true speed? | archiver | 2001 | 0 | 23-06-2002 23:58 |