|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: A New Programmer
Looking at your code, I would recommend that you replace some of your absolute numbers with Calibration
values for future ease of Use. That way,you can change one Calibration value at the top of your program and it changes all the values in your program saving you valuable editing time and the possibility of an editing bo-bo. For Example, if Fwd is > 127 for pwm outputs, try something Like Fwd_Low = 150 ; Fwd_Med = 170 ;Fwd_High = 190 , Similiarly, if Rwd is < 127 how about Rev_Low = 104, Rev_Med = 84, and Rev_High = 64. Last edited by marccenter : 20-01-2008 at 20:12. Reason: Improve response |
|
#2
|
||||
|
||||
|
Re: A New Programmer
Thanks for all the help guys. You've all been great. I'll be testing those things ASAP. Now, there are some other things I need help with, also. Our robot's claw is run by pneumatics. On our arm control, I need to program two buttons on the joystick (Or one to do both functions) to open and close the claw. How would I go about porgramming the buttons?
|
|
#3
|
||||
|
||||
|
Re: A New Programmer
Quote:
|
|
#4
|
|||
|
|||
|
Re: A New Programmer
under ///*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/ or at the top of any .c file
to make it easier you should define your speeds so that you can update all of your speed values without changing every single one. you can define your speeds once and call them multiple times Code:
#define stop 127 #define forward 200 #define reverse 50 Code:
pwm01 = 200; pwm02 = 50; Code:
pwm01 = forward; pwm02 = reverse; |
|
#5
|
||||
|
||||
|
Re: A New Programmer
Okay. It's beginning to make sense now. I'll give it a shot.
|
|
#6
|
||||
|
||||
|
Re: A New Programmer
Okay. Once I get the basics done, I will need help programming the IR board functions, and programming the pneumatics for our claw to the arm joystick. I'll let you know when we get to that stage, but please, feel free to explain ahead of time. It'll help our team get a better understanding so there's no head-scratching later.
|
|
#7
|
|||
|
|||
|
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 |
|
#8
|
||||
|
||||
|
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. |
|
#9
|
|||
|
|||
|
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. |
|
#10
|
|||||
|
|||||
|
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;
:
|
|
#11
|
||||
|
||||
|
Re: A New Programmer
Quote:
|
|
#12
|
||||
|
||||
|
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?
|
|
#13
|
|||
|
|||
|
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? |
|
#14
|
|||
|
|||
|
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. |
![]() |
| 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 |