![]() |
Control Problems
We have our bot set up for one-joystick drive, with the two-motor transmissions hooked up to PWMs 13-16. here's the set-up:
(right side) PWM 13 = PWM 14 = Limit_Mix(2000 + p1_y + p1_x - 127) (left side) PWM 15 = PWM 16 = Limit_Mix(2000 _ p1_y + p1_x + 127) The wheels go forwards and backwards correctly, but turns like a boat (turns left when you push the joystick right; turns right when you push the joystick left). Any idea why this isn't working?? |
Re: Control Problems
Quote:
2000 - p1_y |
Re: Control Problems
It sounds like the left and right sides are swapped.
|
Re: Control Problems
Quote:
Quote:
Code:
PWM 13 = PWM 14 = Limit_Mix(-(2000 + p1_y + p1_x - 127)); |
Re: Control Problems
Quote:
|
Re: Control Problems
Quote:
You went to far in modifying the code. If this original doesn't work: Code:
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);Code:
pwm13 = pwm14 = Limit_Mix(2000 + p1_y - p1_x + 127); |
Re: Control Problems
Before I left the shop today I copied down the X and Y values given when I moved the joystick in all directions, and I was going to do the math on it tomorrow to see what was going wrong (or something, I'm not really sure what I was looking for). For some reason I think I messed with pairs of terms, instead of individual terms, which probably explains the problem. Though, when I originally switched the signs of the whole Limit_Mix operation, I did leave the 2000 positive, but changed everything else, and got the same result, or something similar.
Thanks for the suggestion, I always overlook the 'simple' solutions. I'll try that tomorrow and see if it works. |
Re: Control Problems
Quote:
|
Re: Control Problems
Quote:
|
Re: Control Problems
Just say "no" to PWMs 13-16. (Are you using open-loop driving?)
|
Re: Control Problems
Quote:
See the Motors and the High Port Numbers post, but to summarize it in the words of M. McLeod: Quote:
Robinson |
Re: Control Problems
Quote:
|
Re: Control Problems
If anything is moving in the wrong direction, you could just subtract the Limit_Mix result from 254. (To reverse direction)
for the right motor I use (254-(Limit_Mix(2000 + p1_y + p1_x - 127))); for the left motor I use (Limit_Mix(2000 + p1_y - p1_x + 127)); I've used this setup for all of my team's robots. |
Re: Control Problems
Quote:
if he inverted the PWMs to the motors then forward would go backward. |
Re: Control Problems
Quote:
Quote:
|
Re: Control Problems
IN RESPONSE TO:
"When I encounter problems like this where I'm not sure if my logic or formulas are working I create some test cases on paper with real numbers and see what happens. When I do the math on the original code it appears to me that the steering is reversed - based on the comments! But I don't have a working robot in front of me to verify." Hi my name is Holly, I am a mentor for team 1228, (the team with this problem) and I have taken your advice and plugged these numbers into the formula, and it seems like the formula creates the backward turning that we are experiencing... If I put in a value for full power to the right (x axis=255) and neutral on fwd/rev (y axis=127). THe values that the program returns are (right motors=full power=255) BUT...that would make the robot go into a LEFT spin (correct)? Because the right wheels are in full forward motion? |
Re: Control Problems
Quote:
If the wiring is done such that the motors spin the opposite way from what we want with the Joystick centered left to right, we change the motor wiring. Keeping 254 meaning forward on both sides just makes more sense when debugging. In looking through this thread it appears to me that in inverted's posts there are signs wrong on the p1_x term. One of the choices presented by Keith Watson in his second post should be the correct solution. It matches what we've done for years. |
Re: Control Problems
It sounds like your y-axis is correct (forward is forward, back is back), but your x-axis, which controls the turn, needs to be reversed.
Prior to the mixing equation you can use p1_x = 254 - p1_x to reverse the direction of your turn. e.g., Code:
p1_x = 254 - p1_x; |
Re: Control Problems
Quote:
One more quick question. We have a motor on the bot that we don't need on all the time, just to save battery power. I wired a toggle switch so that when it's turned on, it shows up as the trigger button of a joystick being held on. Is there any way I can set a PWM to be equal to the y-axis of a joystick, ONLY when the switch is on, and then neutral when it's off? Here's the idea I had: Code:
int my_y; |
Re: Control Problems
Quote:
|
Re: Control Problems
Quote:
To figure out why though, go through the debug process of checking front to back how things are used. Check the joystick direction as Mark indicated. When we calibrated our joysticks x was not backward. Check if the pwm outputs used in the code for left are really wired to the left motors. Etc. |
Re: Control Problems
I'd also move the pwm assignment to after the if statement. Otherwise, there will be an additional cycle delay in your response, since the pwm will reflect the old value from the if statement.
The my_y value could be defined as an unsigned character (8 bits) instead of int. It's not essential, but it is good practice to match variable types. Code:
unsigned char my_y; |
Re: Control Problems
Quote:
|
Re: Control Problems
This shoudl fix your problem:
pwm13 = pwm14 = Limit_Mix(2000 - p1_y - p1_x + 381); pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127); I had the same problem, and figured out the answer by simply setting up a table with actual and desired values using the dashboard viewer. I have tried this on our robot and it works. Le t me know if it doesn't work out for you. |
Re: Control Problems
I'd also have to recommend moving to different PWMs if there is anyway possible, those are flaky, since they're generated in software rather than hardware, any code lag disrupts them, quite unreliable.
|
| All times are GMT -5. The time now is 03:20. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi