<root>
<document schema='101' license='1,Martin Whitlock,GCYPWG' title='' description='' target='PIC.16F.16F1937' >
	<config data='!0,fe4!10,1633%0,4%3,0%5,1%6,1%7,1%8,1%9,3%b,1%c,0%d,0%10,3%14,3%18,0%19,1%1a,1%1c,1%1d,0' clkspd='16000000' simspd='1' usewdt='0' constif='0' />
	<plugins >
		<dll_dbg_icd enabled='0' >
			<data name='debug' value='1' />
			<data name='userpins' value='0' />
			<data name='speed' value='0' />
			<data name='usev9' value='0' />
			<data name='breaks' value='8' />
			<data name='stacks' value='8' />
			<data name='clkport' value='1' />
			<data name='clkbit' value='6' />
			<data name='dataport' value='1' />
			<data name='databit' value='7' />
			<data name='monitor' value='1' />
			<data name='ictloop' value='0' />
			<data name='ictrate' value='20000' />
			<data name='ictmask' value='0' />
		</dll_dbg_icd>
		<dll_models enabled='1' />
		<dll_upgrader enabled='1' />
		<dll_webhelp enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug >
		<watch expr='ReadAn0' />
		<watch expr='Sensitivity' />
	</debug>
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='f3ebc951-7870-48fd-96bf-b41d8e175acc' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='0' 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' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties />
			<values />
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='T1PreviousValue' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='SensorDetected' type='b1' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='false' type='b1' description='' isconst='1' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='CapSenChannel' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Sensitivity' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='ReadAn0' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='DisableChChange' type='b1' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Timer1OscVal' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='true' type='b1' description='' isconst='1' isinit='1' usrinit='1' setinit='1' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='Timer1_int' description='' />
				</macro>
				<macro >
					<flowline name='Timer0Int' description='' >
						<command class_type='calculation' title='Calculation' >
							<exp exp='T1PreviousValue = Timer1OscVal' />
						</command>
						<command class_type='native' title='C Code' ccode='FCV_TIMER1OSCVAL = tmr1l+(tmr1h &lt;&lt; 8); //Retreve 16bit timer1 osc value' language='C' />
						<command class_type='decision' title='Decision' exp='Timer1OscVal &lt; 100' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' >
									<exp exp='Timer1OscVal = T1PreviousValue' />
									<exp exp='DisableChChange = 1' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' >
									<exp exp='' />
									<exp exp='DisableChChange = 0' />
								</command>
							</flowline>
						</command>
						<command class_type='native' title='C Code' ccode='tmr1h=0;//reset timer1 high byte
tmr1l=0;//reset timer1 low byte' language='C' />
						<command class_type='decision' title='Decision' exp='Timer1OscVal &lt; Sensitivity //Triger is about1660' swap='0' >
							<flowline >
								<command class_type='comment' title='' comment='To increase sensitivity, increase Timer1OscVal' textarea='12,0,12,0' />
								<command class_type='calculation' title='Calculation' >
									<exp exp='SensorDetected = 1' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' >
									<exp exp='SensorDetected = 0' />
								</command>
							</flowline>
						</command>
						<command class_type='switch' title='Switch' textarea='36,25,36,25' exp='CapSenChannel' >
							<case >
								<flowline />
							</case>
							<case exp='0' >
								<flowline >
									<command class_type='output' title='Output' mode='1' port='1048578' mask='1' exp='SensorDetected' />
								</flowline>
							</case>
							<case exp='1' >
								<flowline >
									<command class_type='output' title='Output' mode='1' port='1048578' mask='2' exp='SensorDetected' />
								</flowline>
							</case>
							<case exp='2' >
								<flowline >
									<command class_type='output' title='Output' mode='1' port='1048578' mask='4' exp='SensorDetected' />
								</flowline>
							</case>
							<case exp='3' >
								<flowline >
									<command class_type='output' title='Output' mode='1' port='1048578' mask='8' exp='SensorDetected' />
								</flowline>
							</case>
							<case exp='4' >
								<flowline >
									<command class_type='output' title='Output' mode='1' port='1048578' mask='16' exp='SensorDetected' />
								</flowline>
							</case>
						</command>
						<command class_type='decision' title='Decision' exp='DisableChChange' swap='0' >
							<flowline >
								<command class_type='comment' title='' comment='Since read value of timer, now change channel.' textarea='12,0,12,0' />
								<command class_type='calculation' title='Calculation' >
									<exp exp='CapSenChannel = CapSenChannel + 1' />
								</command>
								<command class_type='decision' title='Decision' exp='CapSenChannel &gt; 4' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' >
											<exp exp='CapSenChannel = 0' />
										</command>
									</flowline>
									<flowline />
								</command>
								<command class_type='decision' title='Decision' exp='CapSenChannel = 4' swap='0' >
									<flowline >
										<command class_type='native' title='C Code' ccode='cpscon1 = 5; //enable cap sense channel 5 = RA5. Eblock misses out RA4.' language='C' />
									</flowline>
									<flowline >
										<command class_type='native' title='C Code' ccode='cpscon1 = FCV_CAPSENCHANNEL; //enable cap sense channel 1 at a time 0 = ch0, 1=ch1 etc.' language='C' />
									</flowline>
								</command>
							</flowline>
							<flowline />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<command class_type='comment' title='' comment='Cap Touch Eblock EB088 connect to port B (RB0 to RB5 missing out RB4)
LED Eblock EB004 connect to Port C
' textarea='12,0,12,0' />
						<command class_type='comment' title='' comment='Set inputs for cap sense channels 0 to 4' textarea='36,43,36,43' />
						<command class_type='native' title='C Code' ccode='osccon=0x78; //set int osc to 16MHz' language='C' />
						<command class_type='input' title='Input' mode='2' port='1048577' mask='31' exp='CapSenChannel' />
						<command class_type='calculation' title='Calculation' >
							<exp exp='CapSenChannel = 0' />
						</command>
						<command class_type='interrupt' title='Interrupt' enable='1' name='TMR1' call='Timer0Int' >
							<settings timer='1' prescale='1' postscale='-1' rollover='-1' bitcount='-1' trigger='3' maskhi='--------------------------------------------------------------------------------------------------------------------------------------------------------------------------8' masklo='--------------------------------------------------------------------------------------------------------------------------------------------------------------------------8' >
								<option value='2' />
								<option value='0' />
								<option value='-1' />
								<option value='-1' />
							</settings>
						</command>
						<command class_type='native' title='C Code' ccode='t1con=0b11000101; //Timer1 select source to cap sens osc
t1gcon=0b11100001; //Set up Timer1 gate control
cpscon0=0b10001100; //enable cap sense module &amp; set osc forhigh range' language='C' />
						<command class_type='interrupt' title='Interrupt' enable='1' name='TMR0' call='Timer0Int' >
							<settings timer='1' prescale='128' postscale='-1' rollover='-1' bitcount='-1' trigger='3' maskhi='--------------------------------------------------------------------------------------------------------------------------------------------------------------------------8' masklo='--------------------------------------------------------------------------------------------------------------------------------------------------------------------------8' >
								<option value='1' />
								<option value='0' />
								<option value='7' />
								<option value='-1' />
							</settings>
						</command>
						<command class_type='loop' title='Loop' type='0' exp='1' >
							<flowline >
								<command class_type='call' title='Call Component Macro' component='pot_color_cap1' macro='GetInt' >
									<return exp='ReadAn0' />
								</command>
								<command class_type='calculation' title='Calculation' >
									<exp exp='Sensitivity = ReadAn0 * 8 / 4 + 600' />
								</command>
								<command class_type='delay' title='Delay' exp='300' type='1' />
							</flowline>
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='14683ea8-5a08-4b3a-be2d-3dea3e17e720' vmin='552' vmaj='16' codename='pot_color_cap1' x='0' y='0' z='9' xsz='25.1419' ysz='25.1419' zsz='18.45' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='1' >
				<resources />
				<properties />
				<values >
					<value target='angle_start' data='225.000000' />
					<value target='angle_sweep' data='270.000000' />
					<value target='cap_color' data='192' />
					<value target='point_color' data='16777215' />
					<value target='channel' data='0' />
					<value target='vrefvol' data='500' />
					<value target='vrefop' data='000' />
					<value target='convspd' data='003' />
					<value target='actime' data='40' />
					<value target='bits' data='10' />
					<value target='bitmul' data='0.004883' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='text' codename='label1' x='0' y='-16' z='0' xsz='8' ysz='8' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='Color' data='192' />
					<value target='Background' data='-1' />
					<value target='Font' data='Arial' />
					<value target='Text' data='Sensitivity' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='9737364' 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='0' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='25' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel3d>
	<layout >
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA-wUAAI0CAAA' zoom='75' scrollx='0' scrolly='60' flags='0' />
		<view type='0' name='Timer0Int' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA-wUAAI0CAAA' zoom='75' scrollx='0' scrolly='192' flags='0' />
		<view type='0' name='Timer1_int' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAA-wUAAI0CAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
