|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Non-variable Victor Control
Simple question for you all:
How can we program the RC to operate the Victor's with a toggle switch? In other words, we want the speed controller to be on (255) when the switch is on, or off (127) when it's not. Simple in concept, but our brain trust hasn't been able to make it work in practice. Your help, as always, is appreciated. |
|
#2
|
|||||
|
|||||
|
Assume you're using PWM7.
if button_pressed then toggleOn PWM7 = 127 goto endToggle toggleOn: PWM7 = 254 endToggle Make sure that you actually pass the PWM value through to the SerOut command (look at the sample for what to send). Also, make sure to limit the value to 254 and not 255. 255 is not a valid output value. The above is mostly in psuedocode but you should be able to figure the rest out. Matt |
|
#3
|
|||||
|
|||||
|
Try this:
Declare nice_motor as a variable byte Then state that: nice_motor = 127 + (127*button1) - (127*button2) And of course, serout nice_motor to the desired PWM pin What will happen: If button 1 is pressed, the motor will go full forward, if button 0 is pressed, it'll go full reverse, and if you press them both (who would do that? ), nothing happens. |
|
#4
|
||||
|
||||
|
Yay!
In case you can't tell, I'm on the same team as Micheal. I'm the main programmer, and I have to say, THANK YOU!!!! Now, we can do something that we think is pretty cool, and we can use cool toggle switches too
. If you guys are going to the L.I, N.Y.C., or nationals, you'll see why we need the toggle switch controlled pwms. Other than that, if I say anything else, my team members will kill me. So, once again, thanks a whole lot, and good luck to all! |
|
#5
|
||||
|
||||
|
?
Well, I understood the nice little if statement one (by matt), but the second one makes no sense to me. Sorry if I sound mean, but this is my first year doing PBASIC, and I want to keep it simple. We tried the first solution, and it worked. When we tried to make it work before, we set it to switch the pwm to 255, where as it can only go to 254 (thanks matt). So, end result, problem fixed, controllers of team #810 happy.
![]() |
|
#6
|
|||
|
|||
|
would the following make it so you didnt have to edit the serout?
(assume victor is connected to the port for p4_wheel)
if fswitch = 1 goto move p4_wheel = 127 goto nomove move: p4_wheel = 256 nomove: also would this work better/worse if there was/wasn't a joystick plugged into port 4? |
|
#7
|
||||
|
||||
|
Well, I made it work using Matt's solution, mostly because that's the simplest (to me at least), because this is the first year I've ever used PBASIC before. I'm surprising myself with how well I already know it (I'm currently the team 810 PBASIC Guru, so t speak), but I still want to keep the program simple.
Another reason why it's easy to keep simple, the motors only have to go foward and off, they don't need to be reversed. This might give a clue to some of you what we're doing, but I'm not telling . If you want to see the secret, you'll have to wait until the L.I. regional. Once again, thanks for all the help. This is one of the best forums I've ever been to, I get a response so fast. ![]() |
|
#8
|
|||||
|
|||||
|
Re: would the following make it so you didnt have to edit the serout?
Quote:
Matt |
|
#9
|
||||
|
||||
|
Don't worry, I'm not using 256. Someone told me it resets the RC, so I've stayed away from it always. 255 I thought was full power, although I guess I'm wrong. Oh well, learn from your mistakes.
|
|
#10
|
|||
|
|||
|
Quote:
Not like it matters anyway. 218 (?) to 254 is all full power, if I remember. And 0 - 36 (?) is all full power. I'm not too sure about the exact values and its something that Dr. Joe would know. |
|
#11
|
||||
|
||||
|
Really? I did not know that. I thought a number of 256 would reset the uP. Hmm, maybe that's why our relays flipped out when we flipped the switch. Oh well, no damage done (I hope). Thanks for all the help, cause now our little sercret works.
![]() |
|
#12
|
|||
|
|||
|
Re: Re: would the following make it so you didnt have to edit the serout?
Quote:
|
|
#13
|
|||||
|
|||||
|
Quote:
nice_motor = 127 + (button * 127) ![]() |
|
#14
|
||||||
|
||||||
|
You guys bring tears to my eyes! ;-)
Wow! That was great!
The question was posted at 3:00 and by 11:00 we are all a lot smarter. This is why I love these forums. Well done, FIRST online folks. Keep up the good work. Joe J. |
|
#15
|
||||
|
||||
|
Yes, I have to agree with Joe. I've pretty much self-taught myself PBASIC over the past two or three weeks. Yeah, it's a bit late to be learning it, but someone else who was supposed to do the programming dropped out. But me and my friend looked through the default code, learned literally every line of that (took about an hour or two), and after that went on to alter the code to our needs. So far, it hasn't been that hard, the math is kind of annoying though. But the coolest thing is that whenever I have a problem, I can just come here and I have an answer right away. Yay for online forums! Now I just wish my team's forums were as active...
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| variable? | manodrum | Programming | 11 | 01-04-2003 17:20 |
| Coupling the Chiaphua & a variable Drill output | Jeff Sharpe | Motors | 9 | 13-01-2003 20:21 |
| Variable Amperage in DC Circuit. How? | Jordan A. | Electrical | 4 | 01-11-2002 20:26 |
| Dashboard programs and the char variable | Ian W. | Programming | 13 | 26-06-2002 02:07 |
| what teams have a variable transmissions? | Greg Perkins | Technical Discussion | 4 | 06-03-2002 06:10 |