Go to Post Because you know what they say, the new year doesn't begin until Dean, Dave, and Woodie drop the big one. - Jay Trzaskos [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 18-02-2005, 08:29
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Joystick Button programming

Hi guys,
I have run into a sort of stupid problem. I can't get the buttons on the joystick to work.
Code:
 if (p1_sw_top ==1)
 {
 pwm01=200;
 }
Even something simple like that wont work. I tried this also:
Code:
 //Somewhere in the top of the file
 int output =0;
 
 //Down in the file
 output = p1_sw_top;
 if (output = 1)
 {
 pwm01=200;
 }
Any help/advice?
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #2   Spotlight this post!  
Unread 18-02-2005, 08:46
jdhawg's Avatar
jdhawg jdhawg is offline
Programmer/Mentor/Parent. Pick One
AKA: Jack D Higgs
FRC #0364 (Team Fusion)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Gulfport, MS
Posts: 49
jdhawg will become famous soon enough
Re: Joystick Button programming

Is it compiling correctly? Before you start yelling, let me explain..... We were programming along over the weekend when things started going crazy on our robot. It took about 30 minutes before I realized that I was getting a compile error, but it was still building the .hex file for me to download even though it should abort. Double check for any error messages when you do your 'Make All' just in case.

Other than that, desk check your code and make sure you are actually getting to the the lines you are trying to run. Trust me, I've added the greatest routines ever written to some of my software over the years, only to have them not execute because I put them in the wrong place in my code. It's quite embarrassing when your boss is expecting to see a simulated missile attack show up on the screen and nothing happens!
__________________
"Opportunity is missed by most people because it is dressed in overalls and looks like work." - Thomas A. Edison

"In the professional world, spelling mistakes, grammatical shortcuts, leet-speek, and misused verbiage are not interpreted as signs of cute, efficient communications. They are indicators of illiteracy, inefficiency, unprofessional behavior, and sloppy work habits." - Dave Lavery
  #3   Spotlight this post!  
Unread 18-02-2005, 09:08
cbolin's Avatar
cbolin cbolin is offline
Programming & Electrical
FRC #0342 (Burning Magnetos)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Charleston, SC
Posts: 72
cbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to beholdcbolin is a splendid one to behold
Re: Joystick Button programming

Hi,
Here is a couple of things to consider.

1. Try a different joystick to verify that is okay.
2. Modify the code to do something like this...

Code:
if (p1_sw_top == 1)
  pwm01 = 254;
else
  pwm01 = 0;
3. jdhawg is right on. If the program is not actually building correctly (you don't see the error messages) and you load, the IFI loader will download the last .hex file that was created....leading you to believe that your new code simply is not working. This has happened to us before.

4. Try a different port to verify port 1 does not have a problem.

Let us know what you have learned.
Regards,
ChuckB
__________________
Team 342 Programming & Control Systems
Good luck and have fun!
  #4   Spotlight this post!  
Unread 18-02-2005, 09:33
Bharat Nain's Avatar
Bharat Nain Bharat Nain is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: New York
Posts: 2,000
Bharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond reputeBharat Nain has a reputation beyond repute
Send a message via AIM to Bharat Nain Send a message via MSN to Bharat Nain
Re: Joystick Button programming

I have tried different ports, buttons, joysticks.. it still doesnt work. I do agree I did not check to see if it builds correctly, but how do I tell? Here is the last output summary when I was building:

Code:
 Clean: Deleting intermediary and output files.
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\main.o".
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\user_SerialDrv.o".
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\user_routines.o".
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\user_routines_fast.o".
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\ifi_utilities.o".
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\ifi_startup.o".
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\user_camera.o".
 Clean: Deleted file "FrcCode.cof".
 Clean: Deleted file "FrcCode.cod".
 Clean: Deleted file "FrcCode.hex".
 Clean: Deleted file "FrcCode.lst".
 Clean: Deleted file "C:\2005 Programming\frcV24\frc\FrcCode.mcs".
 Clean: Done.
 Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8520 "main.c" -fo="main.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_USE_CMU_CAMERA -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
 Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8520 "user_SerialDrv.c" -fo="user_SerialDrv.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_USE_CMU_CAMERA -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
 Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8520 "user_routines.c" -fo="user_routines.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_USE_CMU_CAMERA -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
 Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8520 "user_routines_fast.c" -fo="user_routines_fast.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_USE_CMU_CAMERA -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
 Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8520 "ifi_utilities.c" -fo="ifi_utilities.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_USE_CMU_CAMERA -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
 Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8520 "ifi_startup.c" -fo="ifi_startup.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_USE_CMU_CAMERA -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
 Executing: "C:\mcc18\bin\mcc18.exe" -p=18F8520 "user_camera.c" -fo="user_camera.o" /i"C:\mcc18\h" -D_FRC_BOARD -D_USE_CMU_CAMERA -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- -nw=2066
 Executing: "C:\mcc18\bin\mplink.exe" /l"C:\mcc18\lib" "18f8520user.lkr" "C:\2005 Programming\frcV24\frc\main.o" "C:\2005 Programming\frcV24\frc\user_SerialDrv.o" "C:\2005 Programming\frcV24\frc\user_routines.o" "C:\2005 Programming\frcV24\frc\user_routines_fast.o" "C:\2005 Programming\frcV24\frc\ifi_utilities.o" "C:\2005 Programming\frcV24\frc\ifi_startup.o" "C:\2005 Programming\frcV24\frc\user_camera.o" "C:\2005 Programming\frcV24\frc\FRC_library.lib" /o"FrcCode.cof"
 MPLINK 3.90, Linker
 Copyright (c) 2004 Microchip Technology Inc.
 Errors	: 0
 
 MP2COD 3.90, COFF to COD File Converter
 Copyright (c) 2004 Microchip Technology Inc.
 Errors	: 0
 
 MP2HEX 3.90, COFF to HEX File Converter
 Copyright (c) 2004 Microchip Technology Inc.
 Errors	: 0
 
 Loaded C:\2005 Programming\frcV24\frc\FrcCode.cof
 BUILD SUCCEEDED: Fri Feb 18 09:28:05 2005
Does that look right? The only custom code I have on there is the brakes, nothing else.

Thanks for all the help you guys are offering,
-Bharat
__________________
-= Bharat Nain =-

Whatever you do, you need courage. Whatever course you decide upon, there is always someone to tell you that you are wrong. There are always difficulties arising that tempt you to believe your critics are right. To map out a course of action and follow it to an end requires some of the same courage that a soldier needs. Peace has its victories, but it takes brave men and women to win them. - Ralph Waldo Emerson
  #5   Spotlight this post!  
Unread 18-02-2005, 11:27
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Joystick Button programming

Code:
 if (p1_sw_top ==1)
 {
 pwm01=200;
 }
That should work. Make sure nothing else is controlling pwm01 later, and that your motor is actually connected to a Victor on pwm01. If the Victor's light is flashing, there's a problem with the pwm cable. You can plug a servo directly onto the pwm pins to make sure the signal is getting out of the RC. Also, use the Dashboard program to make sure the top joystick button is being recognized by the OI.
Code:
 //Somewhere in the top of the file
 int output =0;
 
 //Down in the file
 output = p1_sw_top;
 if (output = 1)
 {
 pwm01=200;
 }
This will not work the way you intend, because you used a single equals sign in your if statement. That sets output to 1 every time, pwm01 will always be set to 200.
  #6   Spotlight this post!  
Unread 18-02-2005, 11:48
Thadanator's Avatar
Thadanator Thadanator is offline
Program/Electric/Driver/Website/etc
AKA: Walking Disaster
#1188 (Oaktown Crewz)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Royal Oak, MI
Posts: 11
Thadanator is an unknown quantity at this point
Send a message via AIM to Thadanator
Re: Joystick Button programming

have you tried doing this?
Code:
 if (p1_sw_top ==1)
 {
 pwm01=200;
 }
pwm01=200;
what i mean is, RIGHT after the button code, you make it go foward anyway.
this way, if there's anything that would change pwm01's values, you will know, because the robot will still not move. if it does move, well then move on to another solution.
__________________

1188 - Oaktown Crewz
Programmer, electrician, website, driver, and of course builder.
¤ It aint no thang but a chicken wang ¤
</Stupidness>
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
Programming motors with joystick buttons TMHStitans Programming 5 21-03-2005 21:07
Joystick Button Deference cibressus53 Electrical 3 01-11-2004 09:38
single joystick programming Bill Bonsky OCCRA 2 04-10-2003 09:47
Programming the second joystick in PBASIC archiver 2001 2 24-06-2002 00:25
Arm Rotation (1 Button Programming!!) Joelster Technical Discussion 1 14-02-2002 13:15


All times are GMT -5. The time now is 02:39.

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