What I'm not seeing is a way to connect the 0-500 A/D reading to the 165uS rollover of the timer.
Setting one of the timers so that at max Z, it will rollover at 165uS, I can adjust that timer with the Z to slow it down and get the "gain", ie: increase the time it takes to rollover
Reading the A/D, I can tell whether it is above 528 or below 500 and set direction.
Each of the 4 possible 0-500 values signify the number of those rollovers that generate pulses out.
Does this snippet look plausible?
Code:
IntCnt var word
ADval var word[3]
Holdoff var word[3]
'**** Interrupt ****************
IntCnt = IntCnt + 1
ADval[n]*12 = Holdoff[n]
if IntCnt = Holdoff[n] then Pulse
else NoPulse
endif
Pulse:
Pin[n] low ' drive a step pulse active
IntCnt = 0 ' clear count of interrupts
pauseus 2 ' delay to meet minimum time for drive
Pin[n] high ' return the pulse to inactive
return '
NoPulse:
return ' go back without sending a pulse
Bo
Bookmarks