<root>
<document scada='0' schema='102' license='1,Jorg Guldner,1C4UVZ' title='' description='' fcversion='524801' target='PIC.12F.12F617' >
	<config data='!0,3f94%0,4%3,0%4,1%5,0%6,0%7,1%8,3%a,3' clkspd='8000000' simspd='1' usewdt='1' constif='0' Use3V3='0' />
	<plugins >
		<dll_models enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug />
	<traces />
	<ghost >
		<FK2 >
			<data name='FK2D0' port='4294967295' pin='4294967295' />
			<data name='FK2D1' port='4294967295' pin='4294967295' />
			<data name='FK2D2' port='4294967295' pin='4294967295' />
			<data name='FK2D3' port='4294967295' pin='4294967295' />
			<data name='FK2D4' port='4294967295' pin='4294967295' />
			<data name='FK2D5' port='4294967295' pin='4294967295' />
			<data name='FK2D6' port='4294967295' pin='4294967295' />
			<data name='FK2D7' port='4294967295' pin='4294967295' />
			<data name='FK2D8' port='4294967295' pin='4294967295' />
			<data name='FK2D9' port='4294967295' pin='4294967295' />
			<data name='FK2D10' port='4294967295' pin='4294967295' />
			<data name='FK2D11' port='4294967295' pin='4294967295' />
			<data name='FK2D12' port='4294967295' pin='4294967295' />
			<data name='FK2D13' port='4294967295' pin='4294967295' />
			<data name='FK2D14' port='4294967295' pin='4294967295' />
			<data name='FK2D15' port='4294967295' pin='4294967295' />
			<data name='FK2A0' port='4294967295' pin='4294967295' />
			<data name='FK2A1' port='4294967295' pin='4294967295' />
			<data name='FK2A2' port='4294967295' pin='4294967295' />
			<data name='FK2A3' port='4294967295' pin='4294967295' />
			<data name='FK2A4' port='4294967295' pin='4294967295' />
			<data name='FK2A5' port='4294967295' pin='4294967295' />
		</FK2>
		<ICD >
			<data name='AnalogPrescaleValue' value='19' />
			<data name='DigitalSampleRate' value='100000' />
			<data name='BreakpointCount' value='8' />
			<data name='CallStackDepthCount' value='8' />
			<data name='ClockPort' value='0' />
			<data name='ClockPin' value='1' />
			<data name='DataPort' value='0' />
			<data name='DataPin' value='0' />
			<data name='UseDefaultPins' value='1' />
			<data name='WrapEnabled' value='1' />
			<data name='CommsDelayOverridden' value='0' />
			<data name='CommsDelay' value='21' />
			<data name='CalculatedCommsDelay' value='21' />
			<data name='AnalogEB2PrescaleValue' value='2' />
			<data name='DigitalEB2SampleRate' value='100000' />
		</ICD>
		<pins >
			<digital A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
			<analog A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
		</pins>
	</ghost>
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='0' scadaCompatible='0' embeddedCompatible='1' iconpath='' />
		<component class_type='root' codename='panel' x='0' y='0' z='0' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties />
			<values />
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='comparator_flag_bit' type='b1' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='int_trm0_00' description='cpu: 12f617
int oscillator 8mhz
timer interrupt at 512us' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='native' title='test comparator flag' textarea='36,0,511,300' ccode='FCV_COMPARATOR_FLAG_BIT = test_bit(PIR1, CMIF);' cmdcolor='16760832' cmdcolor_sec='16760832' language='C' />
						<command class_type='decision' title='flag gesetzt' textarea='36,0,511,300' cmdcolor='16734039' cmdcolor_sec='16734039' exp='comparator_flag_bit = 1' swap='0' >
							<flowline >
								<command class_type='native' title='clear  flag' textarea='36,0,511,300' ccode='clear_bit (PIR1, CMIF);' cmdcolor='16760832' cmdcolor_sec='16760832' language='C' />
								<command class_type='output' title='led 1' textarea='36,0,511,300' cmdcolor='8453975' cmdcolor_sec='8453975' mode='1' port='1048576' mask='16' exp='1' />
							</flowline>
							<flowline >
								<command class_type='output' title='led 0' textarea='36,0,511,300' cmdcolor='8453975' cmdcolor_sec='8453975' mode='1' port='1048576' mask='16' exp='0' />
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='native' title='setup comparator' textarea='36,0,511,300' ccode='// pin6 = extern analog voltage
// interne reference
// set bit1 to an input
TRISIO = 0b00000010;
ANSEL = 0b00000010; // not in version 6
 

// comparator setup
CMCON0 = 0b10000100;
/*
10000000 = CMON --&gt; Comparator Enable bit
                    1 = Comparator is enabled
                    0 = Comparator is disabled
01000000 = COUT --&gt; Comparator Output bit
                 If C1POL = 1 (inverted polarity):
                    COUT  = 0 when CMVIN+ &gt; CMVINCOUT
                          = 1 when CMVIN+ &lt; CMVINIf
                    C1POL = 0 (non-inverted polarity):
                    COUT  = 1 when CMVIN+ &gt; CMVINCOUT
                          = 0 when CMVIN+ &lt; CMVIN
00100000 = CMOE --&gt; Comparator Output Enable bit
                    1 = COUT is present on the COUT pin(1)
                    0 = COUT is internal only
00010000 = CMPOL --&gt; Comparator Output Polarity Select bit
                     1 = COUT logic is inverted
                     0 = COUT logic is not inverted
00001000 = Unimplemented --&gt; Read as ‘0’
00000100 = CMR --&gt; Comparator Reference Select bit (non-inverting input)
                   1 = CMVIN+ connects to CMVREF output
                   0 = CMVIN+ connects to CIN+ pin
00000010 = Unimplemented --&gt; Read as ‘0’
00000001 = CMCH --&gt; Comparator C1 Channel Select bit
                    0 = CMVIN- pin of the Comparator connects to CIN0-
                    1 = CMVIN- pin of the Comparator connects to CIN1-

note: Comparator output requires the following three conditions --&gt; 
      CMOE = 1, CMON = 1 and corresponding port TRIS bit = 0.
*/



//  VOLTAGE REFERENCE CONTROL REGISTER --&gt; Low range = 5/24*3300mv = ##### 687mv #####
VRCON = 0b10100101;
/*
bit 7 CMVREN: Comparator Voltage Reference Enable bit(1, 2)
              1 = CVREF circuit powered on and routed to CVREF input of the Comparator
              0 = 0.6 Volt constant reference routed to CVREF input of the Comparator
bit 6 Unimplemented: Read as ‘0’
bit 5 VRR: CVREF Range Selection bit
           1 = Low range
           0 = High range
bit 4 FVREN: 0.6V Reference Enable bit(2)
             1 = Enabled
             0 = Disabled
bit 3-0 VR&lt;3:0&gt;: Comparator Voltage Reference CVREF Value Selection bits (0  VR&lt;3:0&gt;  15)
                 When VRR = 1: CVREF = (VR&lt;3:0&gt;/24) * VDD
                 When VRR = 0: CVREF = VDD/4 + (VR&lt;3:0&gt;/32) * VDD
Note 1: When CMVREN is low, the CVREF circuit is powered down and does not contribute
        to IDD current.
Note 2: When CMVREN is low and the FVREN bit is low, the CVREF signal should provide
        Vss to the comparator.
*/' cmdcolor='16760832' cmdcolor_sec='16760832' language='C' />
						<command class_type='interrupt' title='Interrupt' textarea='36,0,511,300' cmdcolor='49344' cmdcolor_sec='49344' enable='1' name='TMR0' call='int_trm0_00' >
							<settings timer='1' prescale='4' postscale='-1' rollover='-1' bitcount='-1' trigger='3' maskhi='-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAA' masklo='-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAD-AAAA-wAAAP8AAAA' >
								<option value='1' />
								<option value='0' />
								<option value='2' />
								<option value='-1' />
								<option value='-1' />
								<option value='-1' />
								<option value='-1' />
								<option value='-1' />
							</settings>
						</command>
						<command class_type='loop' title='Schleife' textarea='36,0,511,300' cmdcolor='16734039' cmdcolor_sec='16734039' type='0' exp='1' >
							<flowline />
						</command>
					</flowline>
				</macro>
			</macros>
		</component>
	</components>
	<scadaresourcelookup />
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' >
		<background rgb='7292207' img='' style='0' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel2d>
	<panel3d shadows='0' lighting='2' brightness='0' perspective='1' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='0' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey0 xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey1 xe='-3.67394e-14' ye='0' ze='-300' xt='0' yt='0' zt='0' xquat='0' yquat='1' zquat='0' wquat='6.12323e-17' />
		<camerakey2 xe='0' ye='-300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.707107' yquat='0' zquat='0' wquat='0.707107' />
		<camerakey3 xe='-3.67394e-14' ye='300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-4.32978e-17' yquat='0.707107' zquat='0.707107' wquat='4.32978e-17' />
		<camerakey4 xe='-300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='0.5' zquat='0.5' wquat='0.5' />
		<camerakey5 xe='300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='-0.5' zquat='-0.5' wquat='0.5' />
		<camerakey6 xe='-173.205' ye='-173.205' ze='173.205' xt='0' yt='0' zt='0' xquat='-0.424708' yquat='0.17592' zquat='0.339851' wquat='0.820473' />
	</panel3d>
	<layout >
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAAPQcAAH4DAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='int_trm0_00' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAAPQcAAH4DAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
