|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Controlling
How would I arrange the programming so that one controller controls the robots movement.
We have the right side motors connected through with ONE wire and the same with the left. So: pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127); pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127); How would I edit this since both the right side and the left side only use one port. pwm01 pwm02 We are using the second stick for the launcher, I am not quite sure how to set that up (two weeks experience with programming). We need it so that when the top button is pressed, the motor starts. (I think that would be aux) pwm 04 Then when the stick is pressed forward it moves the other motor forward and when moved backwards it goes backwards. pwm 05 |
|
#2
|
|||
|
|||
|
Re: Controlling
I am really bad at describing.
|
|
#3
|
|||
|
|||
|
Re: Controlling
Quote:
pwm01 = Limit_Mix(2000 + p1_y + p1_x - 127); pwm02 = Limit_Mix(2000 + p1_y - p1_x + 127); For your pwm04 motor: remember pwm ports need a value from 0 to 254, 0 is full reverse, 254 is full forward, and 127 is neutral. The aux1 input is boolean, meaning it has a value of 1 or 0. Actually in C it is an unsigned char that can be evaluated as a boolean. So assuming your second joy is connected to port 2 of your OI: if (p2_aux1) { pwm04 = 254; // full forward } else { pwm04 = 127; //stop } For your pwm05 motor: Now you have to realize that moving the joy stick around returns a value of 0 to 254. When the joys are calibrated correctly, the center position should return p2_x = 127 and p2_y = 127: // This makes your pwm05 speed proportional to joy position with a // deadband that alleviates accidental actuation (147 - 107 sets // pwm05 to 127; if (p2_y > 147 || p2_y < 107) { pwm05 = p2_y; } else { pwm05 = 127; } Alternatively if you just want to turn the motor on full blast: if (p2_y > 147) { pwm05 = 254; } else if (p2_y < 107) { pwm05 = 0; } else { pwm05 = 127; } Notice all the examples have a way to stop the motor. Generally you want to send all your motors a 127 when the controls are released. This is especially important for the drive motors so that if the driver releases the controls for some reason (knocked senseless by a poof ball!) the robot will stop in a stable configuration. Good luck! |
|
#4
|
|||
|
|||
|
Re: Controlling
I put this code in
pwm01 = Limit_Mix(2000 + p1_y + p1_x - 127); pwm02 = Limit_Mix(2000 + p1_y - p1_x + 127); and got this error H:\Project\Project\user_routines.c:139:Error: syntax error |
|
#5
|
||||
|
||||
|
Re: Controlling
I dont see anything wrong with those two lines of code
I think the error message is telling you there is a syntax error on line 139 of your code? check your code and see what is on line 139 |
|
#6
|
|||
|
|||
|
Re: Controlling
hmmm, my friend decided that it would be nice to insert a random period in the file.
|
|
#7
|
|||
|
|||
|
Re: Controlling
Where would I insert the code for the 04 and 05 code lines?
|
|
#8
|
||||
|
||||
|
Re: Controlling
right after the other lines you added/edited.
also search your code for those pwms to make sure they dont get set to 127 right before the serial output. If there are more than one pwm0x = nnn assignments in your code, the last one is the one that takes effect. |
|
#9
|
|||
|
|||
|
Re: Controlling
Okay, I put it all in, and built it, this error came up.
H:\Project\Project\user_routines.c:230:Error [1105] symbol 'p2_aux1' has not been defined |
|
#10
|
||||
|
||||
|
Re: Controlling
look at the default code and see what the exact variable name is. I dont know off the top of my head, it should be something like p2_sw_aux1 ?
|
|
#11
|
|||
|
|||
|
Re: Controlling
Well, I was just informed that that code will not be needed, Thx for the help
Cheers! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Controlling visibility of cells in Excel | sanddrag | IT / Communications | 5 | 05-01-2006 02:45 |
| Problem controlling a servo | Entropia | Programming | 2 | 18-06-2005 18:36 |
| controlling just x or y axis of a double articulated arm | Leav | Programming | 8 | 06-02-2005 14:50 |
| Legality of controlling 2 cylinders with 1 solenoid | mtangolics | Pneumatics | 4 | 19-02-2004 21:29 |
| Controlling Arm travel - Limit Switch or Mechanical Stop? | archiver | 2001 | 8 | 23-06-2002 23:55 |