Email
 Microcontroller and PC projects Forum Index : Microcontroller and PC projects         Section -- Select Forum -- Off grid living and renewables   - Windmills   - Solar   - EV's Electronics and Microcontrollers   - Electronics   - Microcontroller and PC projects   - PCB Manufacturing Miscellaneous   - Other Stuff   - Site News   - Off topic archive. Classifieds   - Price Watch   - Wanted   - For Sale Guest Book   - Guest Book
 Topic: Is there a HS comparator in the MM?
Author
 Message << Prev Topic | Next Topic >>
Grogster
Guru

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 5722
 Posted: 13 May 2018 at 2:41pm | IP Logged
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 October 2012
Location: Australia
Online Status: Offline
Posts: 464
 Posted: 13 May 2018 at 9:10pm | IP Logged
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  endifend function

panky

__________________
DonTSM1,Duinomite,CGCMM1,CGCMM2,2xDimitech,3xWWuMites,MicksMuP,Grogster1A,4xPeterMuM+,Zonker DIP-600,3xCGuKits,CGuBoard2,SnadPic100,SCBP64 & Exp100,PMMZ144,PMMZ100 .. and loving it![:D

matherp
Guru

Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2046
 Posted: 13 May 2018 at 10:13pm | IP Logged
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
Guru

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 5722
 Posted: 14 May 2018 at 9:50am | IP Logged
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!

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register