Relay switching time
- Problem: relay can switch while FET is on, arcing
- Violating relay specs
- Solution: before switching relay, turn off FET (easy)
- Stops opening arc, but does not prevent closing arc
- Just wait while relay is switching? 40mS = 40,000 instructions
TMR0 overflow routine
- TMR0 is counter for PWM
- Also sets flag when overflows every 256*64uS = 16.4mS
- Main loop checks status of this flag, calls subroutine when flag set
- We don't watch for TMR0=0 -- the hardware does.
- First thing in TMR0 overflow routine is reset TMR0-overflow flag!
- In main routine, when we want to change relay, we set a counter to 4
- In main routine, if that counter is non-zero, we turn FET off (regardless of value of TMR0 vs. speed)
- In TMR0 overflow routine, if counter is non-zero, decrement it.
- Result: after we set counter to 4, 4*16.4mS = 65.5mS must pass before FET can energize
- Works if bouncing back and forth -- counter continually set to 4
Now that we have it...
- 16mS is pretty fast in human terms
- TMR0 overflow routine is also a handy place to put other stuff
that needs to be executed periodically
- See if radio receiver is alive (stop motors if radio dies)
- Show if joystick is centered
This page works best with Lynx.
mail me
or go home.