|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Relays and IR Board
Quote:
The pneumatic cylinders are piped by solenoids (electronic valves,) which are controlled by a spike (relay.) Relays don't use the analog 0-254 scale. They are essentially digital outputs that can be either forward, off, or reverse. You map the relays the same way that you map speed controllers. Code:
relay1_fwd = p1_sw_trig; IFI has a list of the joystick inputs here. pdf warning As far as the IR, you need to read the digital input (1 or 0) and pass it through a conditional (if, else, switch) to execute a command. Code:
if (rc_dig_in01 == 1) {
pwm01 = pwm02 = 200;
}
else {
pwm01 = pwm02 = 127;
}
the reference docs to wire and train the IR board are here. pdf warning |
|
#17
|
||||
|
||||
|
Re: A New Programmer
Okay. Next question: Is it possible to program the joystick trigger to, when squeezed the first time, open the claw, and when pressed a second time, closes the claw?
Also, where do these code lines fit in at? Last edited by Spartan151 : 22-01-2008 at 19:45. |
|
#18
|
|||
|
|||
|
Re: A New Programmer
Quote:
I'm pretty sure you would have to write a toggle function, but I'm not exactly sure how it should work. |
|
#19
|
|||||
|
|||||
|
Re: A New Programmer
Examples of toggle functions are common on the Chief Delphi forums. Here's another:
Code:
:
:
static char prev_trig = 0;
static char toggle = 0;
:
if (p1_trig && !prev_trig)
{
toggle = !toggle;
}
prev_trig = p1_trig;
:
|
|
#20
|
|||
|
|||
|
Re: A New Programmer
Hi,
You can try this, but I don't make any guarantee. Toggle_gripper(current state) { int temp_state; If ((p3_sw_trig==TRUE)&&( current _state== CLOSED) temp_state=current_state; else if (p3_sw_trig==TRUE) temp_state=OPEN; else if ((p3_sw_trig==FALSE)&&(current_state==OPEN)) temp_state=current_state; else if ((p3_sw_trig==FALSE) temp_state=CLOSED; } return (temp_state); In you Default _Routine, simply call the function: pwm_state=Toggle_Gripper(current_pwm); if (current_pwm<>pwm_state) pwm=pwm_state; I'm writing this off the cuff, you will need to correct the syntax and apply your own values for the pwm assignments, but it looks plausable. Good luck. |
|
#21
|
||||
|
||||
|
Re: A New Programmer
Quote:
|
|
#22
|
||||
|
||||
|
Re: A New Programmer
Okay. Here's another problem. I have the code written, but I keep getting a syntax error every time I try to build. How exactly do I run MPLAB? Also, where do those codes involving the toggling and pneumatics fit in?
|
|
#23
|
|||
|
|||
|
Re: A New Programmer
A syntax error means that typed something in your code wrong, forgot a semicolon, mistyped a variable, etc.
in MPLAB where it says syntax error Code:
user_routines_fast.c:27:Error: syntax error Can you compile the default code? |
|
#24
|
||||
|
||||
|
Re: A New Programmer
Another general comment on your original bit of code...besides defining variables to use in place of direct values. You will want to include some sort of "deadband" into almost all of your drive code to account for the dynamic trim of the joysticks, prevent twitching/jerking, et cetera.
As somebody posted previously (sorry, I don't remember the name!), true neutral usually ends up at a value higher or lower than 127 (132 is quite common). To compensate for this fluctuation, we include a deadband of 6 in either direction, so "neutral" is really a range around 127. Good luck! ![]() |
|
#25
|
||||
|
||||
|
Re: A New Programmer
Haven't ied compliling the default code yet. I'll give it a shot. But as to the toggling.....I'm stumped as everyone on the team is. Yeah...we're gonna need a lot of help.
|
|
#26
|
||||
|
||||
|
Re: A New Programmer
This programming issue is putting us behind schedule, sadly. I just can't figure out where certain lines go. However, there may be a solution to it tomorrow, if we can get hold of Team 462. Got a lot more work to do. I'll be getting about 3 hours of sleep tonight, but our team doesn't back down from a challenge.
Last edited by Spartan151 : 23-01-2008 at 22:29. |
|
#27
|
|||
|
|||
|
Re: A New Programmer
Quote:
Joey |
|
#28
|
||||
|
||||
|
Re: A New Programmer
Okay. I had someone walk me through the autonomous programming, and now I need to know how to put the OI in disabled mode so I can test the autonomous code WITHOUT SHUTTING DOWN THE PWM OUTPUTS. How would I go about doing that?
|
|
#29
|
|||||
|
|||||
|
Re: A New Programmer
Quote:
I think what you want to know is how to put it in autonomous mode and have it actually provide outputs. For that, you need to connect to the competition port and close a switch between the proper pins. See the Competition Port Pinout Guide (it's on the OI section of the IFI Robotics web site). |
|
#30
|
||||
|
||||
|
Re: A New Programmer
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| NEW PROGRAMMER!!!!! NEED HELP!!!! | delphi demon | Programming | 5 | 19-04-2007 13:22 |
| pic: Team 1249's new programmer | roborat | Extra Discussion | 4 | 23-06-2006 22:02 |
| Senior Programmer: advice on training new recruits | Jeff_Rice | Programming | 9 | 04-01-2005 16:59 |
| Help for New Programmer | Mike375 | Programming | 3 | 27-09-2001 09:04 |