![]() |
One Joystick Drive
Hey. My team is interested in one joystick drive. We have the code loaded into our robot, but it needs some tweaking. For example, when we turn right, we want the left motor to go slower than the right motor. How would we add this into our program? Any help is greatly appreciated.
|
Re: One Joystick Drive
The IFI default code does the axis mixing for you with this section of code in user_routines.c depending on how your motors are hooked up (both forward or one forward, the other reverse).
Code:
/*---------- 1 Joystick Drive ---------------------------------------------- |
Re: One Joystick Drive
We are using our IFI Controller for an underwater robotics competition. We want to use one joystick drive for many reasons. I loaded the code in at our meeting today and it seemed to work fine. We haven't tested it in the pool yet. One of the students on the team were saying something about how our left motor seems to move faster than our right motor. What I think I need to know is how to make our motors adjust to this, (For example: When we turn left, the right motor spins a bit faster than the left motor, and when we turn right, the left motor spins a bit faster than the right motor, which I may have worded incorrectly in the original post). Do you guys have any idea about what I could do with the code to help? BTW, I am new to programming.
Thanks a lot |
Re: One Joystick Drive
Yeah, sorry about that, I worded the example wrong in the original post.
|
Re: One Joystick Drive
Quote:
|
Re: One Joystick Drive
Quote:
Code:
#define LEFT_MOTOR_CORRECTION 42; // example value at full pwm (254)You’ll have to discover through measurement or trial & error what pwm value (e.g., 220 instead of 254) for the left motor matches the max pwm value on the right motor at full speed. Also, be aware that reverse on your machine might require a completely different offset value, i.e., the right motor might be faster than the left motor in reverse. So measure in both directions and correct for them separately. If that’s the case then something like the following might help: Code:
#define LEFT_MOTOR_CORRECTION 42; // Correction value at full forward pwm (254) |
Re: One Joystick Drive
Quote:
|
Re: One Joystick Drive
Quote:
|
Re: One Joystick Drive
Im not positive about that. I'll let you guys know more on Thursday when I get a chance to test it in the pool with new code you guys helped with.
Also, the first code the Mark posted, when I put it in MPLab, it won't compile. I think I may be doing something wrong considering that I am new to programming, but when I take it out, it compiles fine. Any ideas? |
Re: One Joystick Drive
Quote:
What "baseline" code are you starting with? The IFI 2005 v2.2 default code (http://www.ifirobotics.com/docs/frc-...2-2005v2.2.zip) or something else, such as your team's 2005 modified code? The code in my first post was quoted verbatim from the v2.2 default code and wouldn't have to be added. The default code already does what you want. The MPLAB problem you're encountering can be caused by lots of simple mistakes, especially if you've never used it before. It might be misplaced code, or if you aren't starting with the default code then the function Limit_Mix might be missing. Whenever you get an error you want to ask the forum about, post (copy and paste) the actual error message. That usually tells us all we need to know to solve the problem. As an aside, you'll need to be sure the correct motor pwms are being used. If you are starting with your team's customized 2005 code then post a zip of the user_routines.c file, so we can see what's been modified and how. Then we'll be able to describe the easiest may to add the one joystick lines if they aren't already there. |
Re: One Joystick Drive
I attached my userroutines.c file
|
Re: One Joystick Drive
A couple of simple issues.
the new code is at lines 204-205 and 239-255. What you wrote originally will actually work, but would be confusing to anyone reading the code, because it does all the joystick work in Default_Routine() then overrides it all in Process_Data_From_Master_uP(). Anyone else have comments to add? |
Re: One Joystick Drive
We have cameras attached to our robot, so we can't actually see our robot, but we can see from certain perspectives.
Thank you guys so much for helping me with this. |
Re: One Joystick Drive
We'd like to see photos and hear about your progress, so don't forget about us here on the ChiefDelphi forums.
Good Luck! |
Re: One Joystick Drive
We have an online album of pictures. I'll check with our coach to make sure that I can give the link out.
|
Re: One Joystick Drive
http://photobucket.com/albums/v660/lhsrobotics/
http://photobucket.com/albums/y205/lhsrobotics1/ Those are the two links to our photo albums. |
Re: One Joystick Drive
I assume you are going to the MATE championship in Houston.
If so be sure to look for us. We also use the FRIST controller equipment on our ROV except we put the robot controller and the battery on the ROV. It allows us to use a small diameter tether which really helps the maneuverability. Looking forward to meeting y'all Allan |
Re: One Joystick Drive
Yeah. We are going to the MATE competition in Houston. Our team saw some pictures of your team's robot (not sure what year), but it was in one of your past tech reports. It looked excellent.
|
Re: One Joystick Drive
We finally got a chance to test our robot in the pool. The robot worked fine going forwards, and turning. However, when we pull our joystick backwards, the robot goes forward, and when we push the joystick forward, our robot goes backwards. Is there a way you guys can help me fix that? Also, our robot does not goes very fast when it is moving backwards, but moves at a good speed when it goes forwards. Is there a way to make it so that when we go backwards, it goes the same speed as it goes when going forwards?
Thanks |
Re: One Joystick Drive
Quote:
1. transpose the wires from the motor speed controller that go to the motor by switching the M+ and M- wires. (I think this is the best solution) OR 2. in the code, add pwm01 = 255 - pwm01; pwm02 = 255 - pwm02; // put after any other assignments to pwm01. (I used PWM01 Ind 02, but of course, use the pwm## that the motors use As for the different speeds, there can be three solutions: 1. calibrate the motor speed controllers 2. in the code,use a lookup table or a function so that the p1_y goes from 0 - 255 3, It may be the motors, They just may go faster in one direction or its the water flowing more efficiently in one direction that the other. Not much you could do about that. Fix the direction problem first and test in the water. Maybe the speed problem will go away or not be so noticeable. Let me know what happens Allan |
Re: One Joystick Drive
1 Attachment(s)
Thanks a lot. We gonna test our robot again in the pool tomorrow. I'll try changing the cords. Also, do you think that someone could add the part Allan suggested into our user routines.c file (I uploaded it). I would really appreciate it because I am new to programming. I'm going to add everyone who helped to our acknowledgements section of our teams tech report.
Thanks a lot |
| All times are GMT -5. The time now is 04:11. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi