Thank you Steve,
I am aware of multiple ways around the barn. I just didn't know if there was a direct path through the barn... a command that allows you to set execution on the positive or negative going edge of a pulse. I couldn't find such a funciton in PBP but thought I might have overlooked it so I posed the question.
I am satisfied with my solution and it only added a couple lines of code. Easy enough.
The project I am working on uses a slave microcontroller to control pulses to a heater (through an alternistor). The zero-cross detector senses when the AC wave form crosses zero and outputs a pulse to the slave. The slave then outputs a pulse to the triac after a variable pause. But the zero-pulse came about 200us before actual zero and ended 200us after zero. If I acted on the beginning of the pulse, then I could never output a pulse at actual zero without fear of missing the next zero-cross. The following snippet should solve that problem.
If it seems like I'm fussy about my controlling current right down to zero, it's because I'm trying to control many amps of current through three inches of nichrome ribbon (approx 1 ohm of resistance) and maintaining a set temperature. I'm trying to do it without a stepdown transformer. Don't know if I'll get there but I just have to try. :-) Can you say "welding transformer"? :-)
I am receiving 400us pulses every 8ms. The trailing edge of the pulse is in the positive going direction. Portb is constantly updated with the required power (in one byte). The following waits for the pulse, then waits for the positive going transition to execute.
wait_for_pulse:
if portc.2 = 1 then goto wait_for_pulse
wait_for_positive_edge:
if portc.2 = 0 then goto wait_for_positive_edge
pauseus 8276 - portb * 8
pulsout portc.4,45 'fire alternistor
goto wait_for_pulse
end
Thank you Steve for getting back to me!
Ross
Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!
I like that! :-)
Bookmarks