View Full Version : Speed controlling a relay..?!?!?one/????
Monochron
16-02-2007, 19:44
Okay. We want to slow down the speed with which a spike relay drives a motor. We have tried programming in delays in the proccessing, and creating loops that would only let the relay activate after they had cycled for a while. We are trying to make it pulse on and off instead of constantly open or closed.
The problem with that is that the method that tells the relay to active makes it so that there will be a delay after we press the button so it takes a minute for the motor to go, but doesn't pulse the relay.
Has anyone successfully programed something that would pulse a relay in this fasion?
ps. We don't want to reduce the voltage to the motor because we want to retain power.
Okay. We want to slow down the speed with which a spike relay drives a motor. We have tried programming in delays in the proccessing, and creating loops that would only let the relay activate after they had cycled for a while. We are trying to make it pulse on and off instead of constantly open or closed.
The problem with that is that the method that tells the relay to active makes it so that there will be a delay after we press the button so it takes a minute for the motor to go, but doesn't pulse the relay.
Has anyone successfully programed something that would pulse a relay in this fasion?
ps. We don't want to reduce the voltage to the motor because we want to retain power.
Your post is a little confusing, but it sounds like you want to turn on a relay output immediately, then control the amount of time that it is on, and then enforce a minimum 'off' time.
How about something like this in your default_user() code...
#define TIMER_ON_VALUE 10; // 26.3ms * 10 = 263ms
#define TIMER_OFF_VALUE 38; // 26.3ms * 38 = 1 second
unsigned int TimerOn = 0;
unsigned int TimerOff = 0;
if (TimerOn) { // if on timer is running
if (!(--TimerOn)) { // decrement it, and if it just hit zero then...
relay1_fwd = 0; // turn off the output
TimerOff = TIMER_OFF_VALUE; //... and start the off delay timer
}
}
if (TimerOff) { // if off delay timer is running
--TimerOff; // decrement it
}
// if user triggers motor on and neither timer is running
if (p1_sw_trig && (!(TimerOff)) && (!(TimerOn))) {
relay1_fwd = 1; // turn on the relay output
TimerOn = TIMER_ON_VALUE; // ... and start the 'on' timer
}
Matt Krass
16-02-2007, 20:53
If I read that correctly, it sounds like you're trying to make the Spike emulate a Victor with the pulsed power output. Why not just use a Victor? Pulsing the Spikes that rapidly is probably bad for them as well.
Kevin Sevcik
17-02-2007, 00:20
Concur with Matt. All you're doing here is making a very poor imitation of a speed controller. The speed controllers do exactly what you're trying to do, only faster, better, and more reliably. If you're trying to slow the motor down without losing power, you might just try mechanically gearing it down more. With your method, the motor will just sag and be backdriven during the off periods so you'll still be losing "power" just the same as with the speed controllers.
Ben Englert
17-02-2007, 03:03
Spikes are mechanical - that is, the current is controlled by moving parts. (Victors also are, internally, but they're tuned for high speed switching) You can probably wear one out pretty quickly by clicking it on and off too fast.
Spikes are mechanical - that is, the current is controlled by moving parts. (Victors also are, internally, but they're tuned for high speed switching) You can probably wear one out pretty quickly by clicking it on and off too fast.
The specifications can be found here (http://www.ifirobotics.com/spike.shtml), and as long as the pulsing falls within the specifications, there is nothing inherently wrong with pulsing the relay on and off.
Since no expectations as to duration and repetition rate were provided, I chose somewhat reasonable values to use in my example. If a small motor were connected, the relay would probably survive at least couple days of competition. If a large motor were connected, then it would probably be good to have a box of spare relays on hand.
Monochron
17-02-2007, 16:58
Thanks. I know that a victor would be better (and yes, that is what I want the result to emulate) however, we can't really do that at this stage. Our board is very compact and we don't have as much time as we would like. We really desire a programming solution.
If anyone has a solution to make a spike emulate a victor, though, that would be extremely helpful.
kitscuzz
17-02-2007, 17:01
Max Switching Rate 20 operations per second no load, 6 operation per minute for rated life at rated load.
Sure, it can switch 20 times a second, but only if you have NOTHING CONNECTED AND NO POWER.
At best you can turn it on and off 6 times per minute if you plan on attaching a motor to it. The spikes really just can't do speed controlling.
Shinigami2057
17-02-2007, 17:42
Yeah, you are really much better off just using a Victor - they're not all that bigger than the spikes, you can probably squeeze them in somewhere.
Kevin Sevcik
17-02-2007, 20:07
Sure, it can switch 20 times a second, but only if you have NOTHING CONNECTED AND NO POWER.
At best you can turn it on and off 6 times per minute if you plan on attaching a motor to it. The spikes really just can't do speed controlling.
I have to disagree. 6 times per minute? 10 seconds between switches? That is patently untrue. I can walk over to the robot and toggle a switch a few times if you'd like proof.
MasterZahn
17-02-2007, 20:49
Spike relays are meant to give a on signal, reverse signal, and a neutral signal. As someone said earlier, you should use a speed controler if variation is what you want.
I had this idea, but my team shot it down, I later learned that a relay is for full forward or full back or not at all, and speed controlers are used for motors. I hoped this helped.
Blaise
paulcd2000
17-02-2007, 21:36
yeah, i see why you might want to use a spike. But frankly, unless you've used every PWM port, your team will basically need to deal. I'm not trying to be rude, but why even risk (i'm not sure of the electrical component, so i wont take a side) unnecessary damage to a SPIKE when a VICTOR is designed for exactly this purpose? They're not that much larger, and it sounds like this is exactly what you want.
EricVanWyk
17-02-2007, 21:43
Spikes are mechanical - that is, the current is controlled by moving parts. (Victors also are, internally, but they're tuned for high speed switching) You can probably wear one out pretty quickly by clicking it on and off too fast.
Untrue. The only moving parts on a victor are the fan. They switch using MOSFETs (transistors).
Spikes do use mechanical parts. They do not like being switched quickly. However, nothing says you can't do so provided you are willing to live with the consequences. It is very possible that you will burn your Spike out.
Modify this code to fit it into your program.
spike_pwm_timer++;
if(spike_pwm_timer>=spike_pwm_max_value)
spike_pwm_timer=0;
spike=spike_pwm_timer<spike_pwm_ontime;
This will pulsewidth modulate your spike's output with a frequency of 40Hz/spike_pwm_max_value, with a duty cycle of spike_pwm_ontime/spike_pwm_max_value.
I did this one year for the last 8 rounds of nationals. It worked, sort of.
I think my values were
spike_pwm_max_value 32
spike_pwm_ontime 10
but your mileage may vary.
Again, you do run the risk of breaking things, so don't blame me for lighting your Spikes on fire.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.