| Posted: 11:10am 13 May 2018 |
Copy link to clipboard |
 Print this post |
|
G,
Don't know if there is a high speed comparitor but the following function takes about 230 uSec on a MZ running at 252MHz. Enter with 2 analogue in pins as a and b You could optionally add a third variable which determines the hysteresis - in the example below I have set it at +/- 10 so with the 12 bit ADC in the MZ, this would be roughly 0.5%
function CompAB(a,b) if pin(a)+10 > pin(b)-10 then CompAB = 1 els eif pin(a)+10 < pin(b)-10 then CompAB = -1 else CompAB = 0 endif end function
panky ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |