Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:15 11 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Is there a HS comparator in the MM?

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9751
Posted: 04:41am 13 May 2018
Copy link to clipboard 
Print this post

As per title, is there a HS comparator or a way of doing same within MM?

This is related to my other thread about model railway DCC ideas, and along with another page that posted a circuit for easily multiplexing UART serial across a low-voltage power line. She uses a HS comparator inside another PIC chip, but I don't seem to recall that the MM has that ability, unless I am missing something obvious - which I probably am.....

Failing that, I will use an external HS comparator such as the TS3011. But if the MM can do it, then that saves another three bucks for the external HS comparator is all.
Smoke makes things work. When the smoke gets out, it stops!
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1116
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!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10570
Posted: 12:13pm 13 May 2018
Copy link to clipboard 
Print this post

  Quote  As per title, is there a HS comparator or a way of doing same within MM?


Yes - see datasheet. However, using it would be tricky even in a CFunction as you can't get access to the interrupt
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9751
Posted: 11:50pm 13 May 2018
Copy link to clipboard 
Print this post

Lovely, thanks chums. External HS comparator it is, if I elect to go down that path.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025