|
Page 1 of 1
|
[ 12 posts ] |
|
| Author |
Message |
|
christianik1407
Rookie
Joined: Thu Oct 06, 2011 6:37 pm Posts: 9
|
 Tetrix power limiter?
I'm in robotics club at my school and I have been designated as the lead programmer, as I had had some experience with C++ before. My club sponsor has said I can write any kind of program, but I can only run the motors at 50% capacity or less. This hasn't been difficult so far, as I have just entered 50 as the highest percentage I have used, but now I have graduated into joystick control and have no idea how to limit the motors to 50%. The code is below, any criticism is helpful, THANKS!!  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop, reversed) #pragma config(Servo, srvo_S1_C2_1, servo1, tServoStandard) #pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone) #pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone) #pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone) #pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone) #pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() { int threshold = 20; // Threshold is the area that the motor won't activate until the value is greater // than the threshold. This is so we don't have to edit the threshold
while(true) // keeps loop going forever { getJoystickSettings(joystick); if(abs(joystick.joy1_y2) > threshold) // If the right analog stick's Y-axis readings are either above or below the threshold: { motor[motorD] = joystick.joy1_y2; // Motor D is assigned a power level equal to the right analog stick's Y-axis reading. } else // Else if the readings are within the threshold: { motor[motorD] = 0; // Motor D is stopped with a power level of 0. }
if(abs(joystick.joy1_y1) > threshold) // If the left analog stick's Y-axis readings are either above or below the threshold: { motor[motorE] = joystick.joy1_y1; // Motor E is assigned a power level equal to the left analog stick's Y-axis reading. } else // Else if the readings are within the threshold: { motor[motorE] = 0; // Motor E is stopped with a power level of 0. }
// BUTTONS TO CONTOL SERVO ARM // button 5 makes servo goes up, 6 goes down.
if(joy1Btn(5)) // If Button 5 is pressed: { servo[servo1] = 245; // Raise Servo 1 to position 200. }
if(joy1Btn(6)) // If Button 6 is pressed: { servo[servo1] = 10; // Lower Servo 1 to position 20. } } } |  |  |  |  |
|
| Thu Oct 06, 2011 6:48 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Tetrix power limiter?
The following macros will help you. You can use the macros like this:
|
| Thu Oct 06, 2011 7:07 pm |
|
 |
|
mattallen37
Expert
Joined: Thu Sep 29, 2011 11:09 pm Posts: 146 Location: Michigan USA
|
 Re: Tetrix power limiter?
Why ever such a limitation?
_________________ Matt
|
| Thu Oct 06, 2011 8:41 pm |
|
 |
|
christianik1407
Rookie
Joined: Thu Oct 06, 2011 6:37 pm Posts: 9
|
 Re: Tetrix power limiter?
To avoid blowing up motors, one of my peers blew up two last year 
|
| Thu Oct 06, 2011 9:37 pm |
|
 |
|
christianik1407
Rookie
Joined: Thu Oct 06, 2011 6:37 pm Posts: 9
|
 Re: Tetrix power limiter?
Thanks, it seems to be PERFECT! I haven't been able to download it to the brick yet but THANKS!
|
| Thu Oct 06, 2011 10:01 pm |
|
 |
|
mattallen37
Expert
Joined: Thu Sep 29, 2011 11:09 pm Posts: 146 Location: Michigan USA
|
 Re: Tetrix power limiter?
Sounds more like a mechanical limit than it does electrical. You shouldn't have to worry about them burning out at 100% PWM, unless mechanically you are restricting them too much.
_________________ Matt
|
| Thu Oct 06, 2011 10:41 pm |
|
 |
|
christianik1407
Rookie
Joined: Thu Oct 06, 2011 6:37 pm Posts: 9
|
 Re: Tetrix power limiter?
Any idea why the code would only allow me to engage the left motor while the right motor is in reverse or vise versa? This isn't a huge problem, but it would be more convienient if I could turn of a lesser degree.
|
| Fri Oct 07, 2011 4:34 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Tetrix power limiter?
Depending on how you wired your motor, you may need to play with the "reversed" check box in the "Motor and Sensor setup menu" to get the motor direction you want. The "Motor and Sensor setup" will automatically generate an updated pragma section such as the one below.
|
| Fri Oct 07, 2011 4:40 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Tetrix power limiter?
Wait, I think I misunderstood your question. Can you clarify your question? Are you saying you have problem turning the right amount?
|
| Fri Oct 07, 2011 4:45 pm |
|
 |
|
christianik1407
Rookie
Joined: Thu Oct 06, 2011 6:37 pm Posts: 9
|
 Re: Tetrix power limiter?
Sorry, in order for me to have the left motor go backwards, the right motor must be going forwards. I can go forward with both motors or back with both, but they are unusable one at a time.
|
| Fri Oct 07, 2011 6:53 pm |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: Tetrix power limiter?
Are you saying you were trying to turn by moving the one stick up (one motor going forward) and the other stick down (the other motor going backward) but one of the motors was not turning? Or both motors were not turning? What do you mean by "they are unusable one at a time"? Can you post your current code so I can see what you mean?
|
| Fri Oct 07, 2011 7:01 pm |
|
 |
|
magicode
Moderator
Joined: Tue Sep 14, 2010 9:19 pm Posts: 495
|
 Re: Tetrix power limiter?
By running your motors at a lower power, you might actually be increasing the chance of them burning out. Motors burn out when there is power being sent through them, but they are not physically able to turn. This has to do with how current works in a motor. Basically, counter-current is not being generated if the motor is not spinning, and the amperage of the power draw gets too high because there is no counter-current to reduce it. The wires are not meant to handle so much current, and the insulation melts, and there is often a short. Google burned out motors for more information. If you mechanically gear the motors to go slower, then you will get more torque, and possibly prevent your motors from burning out. But you cannot really do anything with programming, except maybe making sure that you don't switch direction at full speed.
_________________ sudo rm -rf /
|
| Fri Oct 07, 2011 9:15 pm |
|
|
|
Page 1 of 1
|
[ 12 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 8 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|