Go to Post Let’s not scare the newbies away, let’s welcome them and help them. - Arefin Bari [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-02-2007, 18:04
kbregler kbregler is offline
Registered User
FRC #1791
 
Join Date: Feb 2007
Location: Clayton, NJ
Posts: 7
kbregler is an unknown quantity at this point
PWM Problem with Default Code

This is our fist year modifying the code and I am having a problem. If I take the code that is marked as default for 2007, compile, and download, I am having a problem with PWM1. It seems that the X and Y axis are swapped.

When using 2 joysticks, the x axis activated the red and green output LED's on the OI but the motor drive and the PWM levels on the Dashboard program are correct. This wasn't a big deal until I wanted to try 1 joystick mode. Again it seems as if they are swapped, if I push foward or backward the motors go in the opposite direction like its trying to turn, if I push left or right they both go in the same direction.

I thought maybe we had something hooked up wrong so I reloaded the .bin file I pulled off before modifying anything. I am not too familiar with how the PWM's are generated in the library files, but the code in the user section all seems to be correct.

Thanks,

Kevin
  #2   Spotlight this post!  
Unread 02-02-2007, 18:51
teh_pwnerer795 teh_pwnerer795 is offline
Registered User
AKA: !!Mitch!!
FRC #1392
Team Role: Programmer
 
Join Date: Nov 2006
Rookie Year: 2006
Location: Ajax, Canada
Posts: 142
teh_pwnerer795 is just really niceteh_pwnerer795 is just really niceteh_pwnerer795 is just really niceteh_pwnerer795 is just really nice
Send a message via MSN to teh_pwnerer795 Send a message via Yahoo to teh_pwnerer795
Re: PWM Problem with Default Code

Quote:
Originally Posted by kbregler View Post
if I push foward or backward the motors go in the opposite direction like its trying to turn, if I push left or right they both go in the same direction.
have u tried another controller? is it the one FIRST gave u guys, cuz the ones u get are always crappy. Maybe u have a bad joystick
__________________
Great Art is Created; Master Pieces are Stolen

[n00b]Teh_Foxdonut teh_pwnerer795 - CounterStrike:Source
  #3   Spotlight this post!  
Unread 02-02-2007, 18:56
teh_pwnerer795 teh_pwnerer795 is offline
Registered User
AKA: !!Mitch!!
FRC #1392
Team Role: Programmer
 
Join Date: Nov 2006
Rookie Year: 2006
Location: Ajax, Canada
Posts: 142
teh_pwnerer795 is just really niceteh_pwnerer795 is just really niceteh_pwnerer795 is just really niceteh_pwnerer795 is just really nice
Send a message via MSN to teh_pwnerer795 Send a message via Yahoo to teh_pwnerer795
Re: PWM Problem with Default Code

OH!!! i think i noe ur problem!! ... wat pwms do u have ur motors set in?? Left should be pwm13 & pwm14 while RIGHT should be pwm15 & pwm16........Now its either that! or u have ur motors set opposite on the victors..... what i recommend doing.. is hooking 1 motor up at a time on pwm01, and pressing forward on the joystick 1.... if it goes forwards ... *High Five* .... do the same for the other motor... if it goes backwards... swap the + and - terminals of the wires from the motor on the victor......

i hope i did not confuse u in anyway
__________________
Great Art is Created; Master Pieces are Stolen

[n00b]Teh_Foxdonut teh_pwnerer795 - CounterStrike:Source

Last edited by teh_pwnerer795 : 02-02-2007 at 18:58.
  #4   Spotlight this post!  
Unread 02-02-2007, 20:22
ballasingh09 ballasingh09 is offline
Registered User
AKA: Amrit
None #0234
Team Role: Mechanical
 
Join Date: Feb 2006
Location: Indianapolis
Posts: 2
ballasingh09 is an unknown quantity at this point
Re: PWM Problem with Default Code

We had this problem earlier and what we had to do was switch the output wires of one of the drive victors. Once we did this, our drive worked properly.
  #5   Spotlight this post!  
Unread 02-02-2007, 21:05
Aaron_H Aaron_H is offline
Registered User
FRC #1033
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Virginia
Posts: 9
Aaron_H is on a distinguished road
Re: PWM Problem with Default Code

Please try to respond in a somewhat more grammatically conscience way. It is critical to speak clearly in order to achieve effective communication. If you really don't know that "know" is not spelled "noe", okay. At the very least then, start with the capitalization of "I," then work your way to spelling. I'm not trying to be mean, I just want you all to have good communication skills when you come into the professional world.
  #6   Spotlight this post!  
Unread 02-02-2007, 22:55
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,082
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: PWM Problem with Default Code

If the motors go in reverse, you may want to switch the + and - motor leads on the speed controller.

If that doesn't fix it, check the speed controller calibration.
  #7   Spotlight this post!  
Unread 03-02-2007, 02:24
kbregler kbregler is offline
Registered User
FRC #1791
 
Join Date: Feb 2007
Location: Clayton, NJ
Posts: 7
kbregler is an unknown quantity at this point
Re: PWM Problem with Default Code

Guys, thanks for the responses.

It is the controller that first gave us.

If I leave the code in that came on it from the factory the lights for PWM1 work correctly, red and green at neutral, green full forward, red full reverse. One joystice mode useing PWM 13 or 14 and 15 or 16 work correctly as well.

If I compile the code labeled as FrcCode_2007_8722 or last years code, PWM1 operates correctly, but the lights now map to the X axis, all the way left gives me green and all the way right gives me red. I wasnt worried about this, I actually corrected this with code, but when we tried using 1 joystick with PWM 13 and 15 we saw the same issue as the lights, all the way left seemed to be all the way forward and all the way right seemed to be all the way reverse.

I know the higher PWMs are calculated differently, do the light functions and the higher PWM's use a similar function call?

just to reiterate, PWM1 operates correctly, regardless of the lights, and the dashboard is correct. 1 joystick mode even shows incorrectly in the dashboard program.

Thanks again,

Kevin
  #8   Spotlight this post!  
Unread 03-02-2007, 07:07
kbregler kbregler is offline
Registered User
FRC #1791
 
Join Date: Feb 2007
Location: Clayton, NJ
Posts: 7
kbregler is an unknown quantity at this point
Re: PWM Problem with Default Code

I didnt answer all the questions, sorry, it was 2AM.

Since the unit operates perfectly fine with code that shipped on the controller I dont think any of the items are bad. We have 4 joysticks we used with no luck, the Motor controllers operate as needed with the code that shipped on it so they are connected correctly and calibrated.

Even the PWM LEDs are mapped wrong so it shows that its something internal, and they are correct with the code that shipped on the controller.

I have even tried downloading the default.hex file they give you with the default code and it does the same thing.
  #9   Spotlight this post!  
Unread 03-02-2007, 07:54
65_Xero_Huskie's Avatar
65_Xero_Huskie 65_Xero_Huskie is offline
One T
AKA: Mat
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Michigan
Posts: 697
65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute
Re: PWM Problem with Default Code

Quote:
Originally Posted by ballasingh09 View Post
We had this problem earlier and what we had to do was switch the output wires of one of the drive victors. Once we did this, our drive worked properly.
Same here, you should check all of your connections just to make sure. WE spent about 30 minutes trying to figure out why we couldnt turn left or right...maybe the PWM cables should be in the right spot..
__________________
Min-Max to the Max!
  #10   Spotlight this post!  
Unread 03-02-2007, 08:12
kbregler kbregler is offline
Registered User
FRC #1791
 
Join Date: Feb 2007
Location: Clayton, NJ
Posts: 7
kbregler is an unknown quantity at this point
Re: PWM Problem with Default Code

The cables are all correct, we have the robot driving fine with the code that shipped on the the RC. Its only when I download a different .hex file where things change, even the one that came with the code, default.hex.

It has to be something internal because the lights on the OI for PWM1 are mapped to the x axis and not the y axis like they should be.

Also, when I open dashboard, the code that shipped on the robot is fine, any new code i can watch the values for PWM13 and PWM15 and as I push the joystick forward they both should climb to 255 and they do not, one goes to 255 and the other goes to 0. If i push right both climb to 255 and if I push left they both climb to 0. This indicates that in the program somewhere the x and y axis are getting swapped. This completely rules out any wiring or calibration issues.
  #11   Spotlight this post!  
Unread 03-02-2007, 08:15
65_Xero_Huskie's Avatar
65_Xero_Huskie 65_Xero_Huskie is offline
One T
AKA: Mat
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Michigan
Posts: 697
65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute65_Xero_Huskie has a reputation beyond repute
Re: PWM Problem with Default Code

Some of your code is messed up then, you should double check some of your code to see what is wrong. If you posted the drive part of your code maybe(im sure) someone on here can help you.
__________________
Min-Max to the Max!
  #12   Spotlight this post!  
Unread 03-02-2007, 09:23
kbregler kbregler is offline
Registered User
FRC #1791
 
Join Date: Feb 2007
Location: Clayton, NJ
Posts: 7
kbregler is an unknown quantity at this point
Re: PWM Problem with Default Code

Its completely unmodified code, I have taken both the hex file they send as well as recompile the unmodified code and I get the same error. If this is supposed to be the default code what am I missing?

I am not very familiar with the code, where is the drive code located? I was searching for what calculates the PWM values but I could not find it. I found a spot that said it was in a library file but I couldnt find that file.

Thanks,

Kevin
  #13   Spotlight this post!  
Unread 03-02-2007, 09:56
N7UJJ N7UJJ is offline
Teacher
AKA: Allan Cameron
FRC #5465 (BinaryBots)
Team Role: Teacher
 
Join Date: Jan 2004
Rookie Year: 2002
Location: Phoenix, AZ
Posts: 253
N7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond reputeN7UJJ has a reputation beyond repute
Re: PWM Problem with Default Code

Here is the section of source code that is found in file user_routines.c that maps the joystick inputs to the PWMs




/*---------- Analog Inputs (Joysticks) to PWM Outputs-----------------------
*--------------------------------------------------------------------------
* This maps the joystick axes to specific PWM outputs.
*/
pwm01 = p1_y;
pwm02 = p2_y;
pwm03 = p3_y;
pwm04 = p4_y;
pwm05 = p1_x;
pwm06 = p2_x;
pwm07 = p3_x;
pwm08 = p4_x;
pwm09 = p1_wheel;
pwm10 = p2_wheel;
pwm11 = p3_wheel;
pwm12 = p4_wheel;

/*---------- 1 Joystick Drive ----------------------------------------------
*--------------------------------------------------------------------------
* This code mixes the Y and X axis on Port 1 to allow one joystick drive.
* Joystick forward = Robot forward
* Joystick backward = Robot backward
* Joystick right = Robot rotates right
* Joystick left = Robot rotates left
* Connect the right drive motors to PWM13 and/or PWM14 on the RC.
* Connect the left drive motors to PWM15 and/or PWM16 on the RC.
*/
p1_x = 255 - p1_y;
p1_y = 255 - pwm05;

pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);





Note that if you are using two joystick drive, that pwm01 and pwm02 should be connected to the motor speed controler, but if you want to use 1 joystick drive, the motor speed controlers should be contected to pwm13 and the other to pwm15. You would not have to modify the code one bit.

However, if you want to modify the code to change the way the joysticks control the pwms, then the above section of the source code is the place to do it.

Last edited by N7UJJ : 03-02-2007 at 09:57. Reason: spelling errors
  #14   Spotlight this post!  
Unread 03-02-2007, 10:15
kbregler kbregler is offline
Registered User
FRC #1791
 
Join Date: Feb 2007
Location: Clayton, NJ
Posts: 7
kbregler is an unknown quantity at this point
Re: PWM Problem with Default Code

That is exactly where I have been looking and see nothing wrong. I did not modify anything whatsoever, everything there is the default.

There is a new beta relase of the firmware, maybe that will fix my problem, I will be able to try it this afternoon.

Like I said, if I download the .bin file I pulled from the RC when we recieved it, it works fine. This updates both the RC and OI, if I dowload just the .hex file, it only changes the RC. There may be an incompatibility issue, just strange that no one else is seeing it.
  #15   Spotlight this post!  
Unread 03-02-2007, 10:51
Manoel's Avatar
Manoel Manoel is offline
Registered User
FRC #0383 (Brazilian Machine)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Porto Alegre, RS, Brazil
Posts: 608
Manoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond repute
Send a message via ICQ to Manoel Send a message via MSN to Manoel
Re: PWM Problem with Default Code

kbregler,

Try deleting those two lines from the default code and see if it works:

p1_x = 255 - p1_y;
p1_y = 255 - pwm05;

I have no idea why IFI chose to include them this year, but they make no sense to me and have caused some teams we mentor problems, too.

Let us know if you need further help.
__________________
Manoel Flores da Cunha
Mentor
Brazilian Machine
Team # 383
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Kevin's 2007 default code bruss6 Programming 8 19-01-2007 15:42
problems using gyro/adc code with camera default code tanstaafl Programming 7 22-01-2006 23:09
Default code problem capenga Programming 8 01-02-2005 08:09
problem with the default code MarkVH Programming 7 28-01-2005 00:04
Problem with FRC Default code AsimC Programming 2 11-01-2004 19:22


All times are GMT -5. The time now is 03:55.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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