Quote:
Originally Posted by Monochron
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...
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
}