<root>
<document schema='101' license='1,Martin Whitlock,GCYPWG' title='' description='' target='PIC.16F.16F1937' >
	<config data='!0,fe4!10,1eff%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 />
	<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' 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='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='Rs232Temp' type='s16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</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='PreviousReadAn0' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Timer1Value' type='s16' description='' isconst='0' isinit='0' usrinit='0' setinit='' >
						<array size='5' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Rs232StringTemp' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='5' />
					</def>
				</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='Timer0Tick' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='SensorTriggered' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='5' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Current_Channel' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='Update' type='b1' 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='native' title='C Code' textarea='36,0,1146,0' ccode='FCV_TIMER1VALUE[FCV_CAPSENCHANNEL] = tmr1l+(tmr1h &lt;&lt; 8); //Retreve 16bit timer1 osc value' language='C' />
						<command class_type='native' title='C Code' textarea='36,0,511,300' ccode='tmr1h=0;//reset timer1 high byte
tmr1l=0;//reset timer1 low byte
' language='C' />
						<command class_type='decision' title='Decision' textarea='36,0,511,300' exp='Timer0Tick &lt; 30' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
									<exp exp='Timer0Tick = Timer0Tick + 1' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
									<exp exp='Timer0Tick = 0' />
									<exp exp='Update = 1 //update about every 500ms' />
								</command>
							</flowline>
						</command>
						<command class_type='decision' title='Decision' textarea='99,-10,99,-10' exp='(Timer1Value[CapSenChannel] &gt; 5)' swap='0' >
							<flowline >
								<command class_type='decision' title='Decision' exp='(Timer1Value[CapSenChannel] &lt; Sensitivity)' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
											<exp exp='SensorTriggered[CapSenChannel] = 1' />
										</command>
									</flowline>
									<flowline >
										<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
											<exp exp='SensorTriggered[CapSenChannel] = 0' />
										</command>
									</flowline>
								</command>
								<command class_type='switch' title='Switch' textarea='36,25,511,325' exp='CapSenChannel' >
									<case >
										<flowline />
									</case>
									<case exp='0' >
										<flowline >
											<command class_type='output' title='Output' textarea='36,0,511,300' mode='1' port='1048578' mask='1' exp='SensorTriggered[CapSenChannel]' />
										</flowline>
									</case>
									<case exp='1' >
										<flowline >
											<command class_type='output' title='Output' textarea='36,0,511,300' mode='1' port='1048578' mask='2' exp='SensorTriggered[CapSenChannel]' />
										</flowline>
									</case>
									<case exp='2' >
										<flowline >
											<command class_type='output' title='Output' textarea='36,0,511,300' mode='1' port='1048578' mask='4' exp='SensorTriggered[CapSenChannel]' />
										</flowline>
									</case>
									<case exp='3' >
										<flowline >
											<command class_type='output' title='Output' textarea='36,0,511,300' mode='1' port='1048578' mask='8' exp='SensorTriggered[CapSenChannel]' />
										</flowline>
									</case>
									<case exp='4' >
										<flowline >
											<command class_type='output' title='Output' textarea='36,0,511,300' mode='1' port='1048578' mask='16' exp='SensorTriggered[CapSenChannel]' />
										</flowline>
									</case>
								</command>
								<command class_type='calculation' title='Calculation' >
									<exp exp='CapSenChannel = CapSenChannel + 1' />
								</command>
								<command class_type='decision' title='Decision' textarea='36,0,511,300' exp='CapSenChannel &gt; 4' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
											<exp exp='CapSenChannel = 0' />
										</command>
									</flowline>
									<flowline />
								</command>
								<command class_type='decision' title='Decision' textarea='36,0,511,300' exp='CapSenChannel = 4' swap='0' >
									<flowline >
										<command class_type='native' title='C Code' textarea='36,0,511,300' ccode='cpscon1 = 5; //enable cap sense channel 5 = RA5. Eblock misses out RA4.' language='C' />
									</flowline>
									<flowline >
										<command class_type='native' title='C Code' textarea='36,0,661,0' ccode='cpscon1 = FCV_CAPSENCHANNEL; //enable cap sense channel 1 at a time 0 = ch0, 1=ch1 etc.' language='C' />
									</flowline>
								</command>
								<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
									<exp exp='Update = 1' />
								</command>
							</flowline>
							<flowline />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='DisplayUART_Data' description='' >
						<command class_type='calculation' title='Calculation' >
							<exp exp='Rs232StringTemp = ToString$ (Rs232Temp)' />
						</command>
						<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
							<argument exp='&quot; &quot;' />
						</command>
						<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
							<argument exp='Rs232StringTemp' />
						</command>
						<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
							<argument exp='&quot; &quot;' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<command class_type='call' title='Call Component Macro' component='RS232' macro='Initialise' />
						<command class_type='native' title='C Code' ccode='osccon=0x78; //set int osc to 16MHz' language='C' />
						<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='49,96,49,96' />
						<command class_type='comment' title='' comment='Set inputs for cap sense channels 0 to 4' textarea='12,0,12,0' />
						<command class_type='input' title='Input' textarea='36,0,511,300' mode='2' port='1048577' mask='31' exp='CapSenChannel' />
						<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
							<exp exp='CapSenChannel = 0' />
						</command>
						<command class_type='interrupt' title='Interrupt' textarea='36,0,511,300' enable='1' name='TMR1' call='Timer1_Int' >
							<settings timer='1' prescale='1' 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='-1' />
								<option value='-1' />
							</settings>
						</command>
						<command class_type='native' title='C Code' textarea='36,0,511,300' 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' textarea='36,0,511,300' enable='1' name='TMR0' call='Timer0Int' >
							<settings timer='1' prescale='256' 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='8' />
								<option value='-1' />
							</settings>
						</command>
						<command class_type='loop' title='Loop' textarea='36,0,511,300' type='0' exp='1' >
							<flowline >
								<command class_type='decision' title='Decision' textarea='36,0,511,300' exp='(Update = 1) &amp;&amp; (Timer1Value[Current_Channel] &gt; 5)' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' >
											<exp exp='PreviousReadAn0 = ReadAn0' />
										</command>
										<command class_type='decision' title='Decision' textarea='36,0,511,300' exp='Current_Channel &gt; 4' swap='0' >
											<flowline >
												<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
													<exp exp='Current_Channel = 0' />
												</command>
											</flowline>
											<flowline />
										</command>
										<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='pot_trim_finger1' macro='GetInt' >
											<return exp='ReadAn0' />
										</command>
										<command class_type='decision' title='Decision' exp='PreviousReadAn0 &gt; ReadAn0' swap='0' >
											<flowline >
												<command class_type='decision' title='Decision' textarea='36,0,511,300' exp='(PreviousReadAn0 - ReadAn0) &gt; 2' swap='0' >
													<flowline />
													<flowline >
														<command class_type='comment' title='' comment='If ADC has changed by less than 3, then ignore' textarea='12,0,487,300' />
														<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
															<exp exp='ReadAn0 = PreviousReadAn0' />
														</command>
													</flowline>
												</command>
											</flowline>
											<flowline >
												<command class_type='decision' title='Decision' exp='(ReadAn0 - PreviousReadAn0) &gt; 2' swap='0' >
													<flowline />
													<flowline >
														<command class_type='comment' title='' comment='If ADC has changed by less than 3, then ignore' textarea='12,0,12,0' />
														<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
															<exp exp='ReadAn0 = PreviousReadAn0' />
														</command>
													</flowline>
												</command>
											</flowline>
										</command>
										<command class_type='calculation' title='Calculation' >
											<exp exp='Sensitivity = ReadAn0 * 5 + 50' />
										</command>
										<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
											<argument exp='&quot;Ch&quot;' />
										</command>
										<command class_type='calculation' title='Calculation' >
											<exp exp='Rs232Temp = Current_Channel' />
										</command>
										<command class_type='call' title='Call Macro' textarea='36,0,511,300' macro='DisplayUART_Data' />
										<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
											<argument exp='&quot; Val&quot;' />
										</command>
										<command class_type='calculation' title='Calculation' >
											<exp exp='Rs232Temp = Timer1Value[Current_Channel]' />
										</command>
										<command class_type='call' title='Call Macro' textarea='36,0,511,300' macro='DisplayUART_Data' />
										<command class_type='calculation' title='Calculation' >
											<exp exp='Rs232Temp = Sensitivity' />
										</command>
										<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
											<argument exp='&quot;Sens&quot;' />
										</command>
										<command class_type='call' title='Call Macro' textarea='36,0,511,300' macro='DisplayUART_Data' />
										<command class_type='call' title='Call Component Macro' component='RS232' macro='SendString' >
											<argument exp='&quot;Triggered?&quot;' />
										</command>
										<command class_type='decision' title='Decision' textarea='36,0,511,300' exp='SensorTriggered[Current_Channel]' swap='0' >
											<flowline >
												<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
													<argument exp='&quot; Yes&quot;' />
												</command>
											</flowline>
											<flowline >
												<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendString' >
													<argument exp='&quot; No&quot;' />
												</command>
											</flowline>
										</command>
										<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendChar' >
											<argument exp='13' />
										</command>
										<command class_type='call' title='Call Component Macro' textarea='36,0,511,300' component='RS232' macro='SendChar' >
											<argument exp='10' />
										</command>
										<command class_type='calculation' title='Calculation' textarea='36,0,511,300' >
											<exp exp='Update = 0' />
											<exp exp='Current_Channel = Current_Channel + 1' />
										</command>
									</flowline>
									<flowline />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='8462ac99-ca8f-429b-953a-36dbe58ada72' vmin='808' vmaj='16' codename='pot_trim_finger1' x='-96' y='32' z='2.4' xsz='11.8794' ysz='11.8794' zsz='16' 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='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='ref' guid='c73616d1-7ad0-45d9-aada-69ccfa4c5efc' vmin='296' vmaj='16' codename='RS232' x='-32' y='32' z='0.755' xsz='60' ysz='26' zsz='1.51' 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='CHANNEL' data='000' />
					<value target='BAUD_LIST' data='002' />
					<value target='BAUD' data='9600' />
					<value target='DBITS' data='008' />
					<value target='RETURN' data='000' />
					<value target='ToutVal' data='255' />
					<value target='FLOWEN' data='000' />
					<value target='ECHO' data='000' />
					<value target='TX' data='$PORTB.7' />
					<value target='RX' data='$PORTD.7' />
					<value target='CTS' data='$PORTB.1' />
					<value target='RTS' data='$PORTB.2' />
					<value target='TXRemap' data='' />
					<value target='RXRemap' data='' />
					<value target='label' data='RS232' />
					<value target='ConsoleColumns' data='64' />
					<value target='DataSource' data='001' />
					<value target='com_port' data='003' />
					<value target='Injector' data='000' />
					<value target='InjectorHandle' data='' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='text' codename='label1' x='-96' 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---------------------wAAAAAUAAAADQMAAFUCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='DisplayUART_Data' mode='0' placement='LAAAAAAAAAABAAAA---------------------wAAAAAUAAAADQMAAFUCAAA' zoom='75' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
