<root>
<document schema='101' license='1,JohnCrow,HRKH69' title='Log Light Sensor' description='PORT A0 = ADC0 Light Sensor
PORT B = LCD Display

Connect Header Pin18 (AREF) to 3.3 V
Sensor VCC = 5V

Underange
Raw = 97

Overrange
Raw = 971

Lux Range = 3 To 55000

1 Lux = 0.09290 FC
1 FC = 10.76391 Lux' target='AVR.ATMEGA.ATMEGA324P' >
	<config data='!0,ff!8,ff!10,ff%0,3f%6,1%7,1' clkspd='20000000' 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='1' head='' body='' />
	<debug />
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='39499e91-f50a-40ab-83e6-db6c47bf1c15' 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='adc4' type='f32' description='' isconst='0' isinit='0' usrinit='0.0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='adc3' type='f32' description='' isconst='0' isinit='0' usrinit='0.0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='adc2' type='f32' description='' isconst='0' isinit='0' usrinit='0.0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='adc1' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='adc' type='u16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='lux_s' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='20' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='lux' type='f32' description='' isconst='0' isinit='0' usrinit='0.0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='fc_s' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='20' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='fc' type='f32' description='' isconst='0' isinit='0' usrinit='0.0' setinit='' />
				</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='Main' description='' >
						<command class_type='call' title='Setup LCD' component='lcd_4x20' macro='Start' />
						<command class_type='call' title='' component='lcd_4x20' macro='Clear' />
						<command class_type='comment' title='' comment='Set to 2 decimal places
Doesn&apos;t simulate' textarea='12,0,12,0' />
						<command class_type='native' title='C Code' ccode='#ifdef FCV_PRECISION
#undef FCV_PRECISION
#endif
#define FCV_PRECISION 2
' language='C' />
						<command class_type='call' title='Call Component Macro' component='lcd_4x20' macro='Clear' />
						<command class_type='call' title='Call Component Macro' component='lcd_4x20' macro='Cursor' >
							<argument exp='1' />
							<argument exp='0' />
						</command>
						<command class_type='call' title='Call Component Macro' component='lcd_4x20' macro='PrintString' >
							<argument exp='&quot;Simple Light Meter&quot;' />
						</command>
						<command class_type='loop' title='Loop' type='0' exp='1' >
							<flowline >
								<command class_type='comment' title='' comment='ADC Needs 3.3V Ref Voltage
Connect to 3.3V to PIN18 on AVR Programmer Header' textarea='12,0,12,0' />
								<command class_type='call' title='Read LogLight Sensor' component='pot_trim_finger1' macro='GetInt' >
									<return exp='adc' />
								</command>
								<command class_type='calculation' title='Calculation' >
									<exp exp='adc2 = int2float (adc)' />
									<exp exp='adc3 = fmul (adc2,5)' />
									<exp exp='adc4 = fdiv (adc3,1024)' />
									<exp exp='lux = pow (10,adc4)' />
									<exp exp='lux_s = FloatToString$ (lux)' />
									<exp exp='' />
									<exp exp='// Convert Lux To Foot Candles' />
									<exp exp='fc = fmul (lux,0.09290)' />
									<exp exp='fc_s = FloatToString$ (fc)' />
									<exp exp='' />
									<exp exp='// Convert Foot Candles To Lux' />
									<exp exp='// Not Four Candles :)' />
									<exp exp='// 10.76391' />
									<exp exp='' />
								</command>
								<command class_type='comment' title='' comment='Raw ADC value is not shown on display in this version' textarea='12,0,12,0' />
								<command class_type='call' title='Display Light Level In Lux' component='lcd_4x20' macro='Cursor' >
									<argument exp='0' />
									<argument exp='2' />
								</command>
								<command class_type='call' title='' component='lcd_4x20' macro='PrintString' >
									<argument exp='lux_s' />
								</command>
								<command class_type='call' title='' component='lcd_4x20' macro='Cursor' >
									<argument exp='7' />
									<argument exp='2' />
								</command>
								<command class_type='call' title='' component='lcd_4x20' macro='PrintString' >
									<argument exp='&quot; Lux&quot;' />
								</command>
								<command class_type='call' title='Display Light In Footcandles' component='lcd_4x20' macro='Cursor' >
									<argument exp='0' />
									<argument exp='3' />
								</command>
								<command class_type='call' title='' component='lcd_4x20' macro='PrintString' >
									<argument exp='fc_s' />
								</command>
								<command class_type='call' title='' component='lcd_4x20' macro='Cursor' >
									<argument exp='7' />
									<argument exp='3' />
								</command>
								<command class_type='call' title='' component='lcd_4x20' macro='PrintString' >
									<argument exp='&quot; FC&quot;' />
								</command>
								<command class_type='delay' title='Delay' exp='50' type='1' />
								<command class_type='call' title='Clear Lux Line' component='lcd_4x20' macro='ClearLine' >
									<argument exp='2' />
								</command>
								<command class_type='call' title='Clear FC Line' component='lcd_4x20' macro='ClearLine' >
									<argument exp='3' />
								</command>
								<command class_type='comment' title='' comment='Sensor will display over 98 000 Lux
But max specification is 55 000 Lux' textarea='12,0,12,0' />
								<command class_type='decision' title='Calculate if reading is overange (55000 Lux)' exp='adc &gt; 971' swap='0' >
									<flowline >
										<command class_type='call' title='Display Over Range' component='lcd_4x20' macro='Cursor' >
											<argument exp='5' />
											<argument exp='1' />
										</command>
										<command class_type='call' title='' component='lcd_4x20' macro='PrintString' >
											<argument exp='&quot;Over Range&quot;' />
										</command>
										<command class_type='delay' title='Delay' exp='50' type='1' />
										<command class_type='call' title='' component='lcd_4x20' macro='ClearLine' >
											<argument exp='1' />
										</command>
									</flowline>
									<flowline >
										<command class_type='decision' title='Calculate if reading is underange (3 Lux)' exp='adc &lt; 97' swap='0' >
											<flowline >
												<command class_type='call' title='Display Under Range' component='lcd_4x20' macro='Cursor' >
													<argument exp='5' />
													<argument exp='2' />
												</command>
												<command class_type='call' title='Call Component Macro' component='lcd_4x20' macro='PrintString' >
													<argument exp='&quot;Under Range&quot;' />
												</command>
												<command class_type='delay' title='Delay' exp='50' type='1' />
												<command class_type='call' title='' component='lcd_4x20' macro='ClearLine' >
													<argument exp='1' />
												</command>
											</flowline>
											<flowline />
										</command>
									</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='-64' y='-56' z='10.1015' xsz='50' ysz='50' zsz='67.3434' 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='330' />
					<value target='vrefop' data='001' />
					<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='a2b40602-5421-4e2f-ba82-96db1be51d69' vmin='296' vmaj='16' codename='lcd_4x20' x='-13.5537' y='12' z='7.87879' xsz='2.20386' ysz='2.20386' zsz='2.20386' 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='Pin_Data_0' data='$PORTD.0' />
					<value target='Pin_Data_1' data='$PORTD.1' />
					<value target='Pin_Data_2' data='$PORTD.2' />
					<value target='Pin_Data_3' data='$PORTD.3' />
					<value target='Pin_RS' data='$PORTD.4' />
					<value target='Pin_E' data='$PORTD.5' />
				</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='-6' ye='-5' ze='300' xt='-6' yt='-5' 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---------------------wAAAAAUAAAAaAMAAHYCAAA' zoom='75' scrollx='0' scrolly='1410' flags='0' />
	</layout>
</document>
</root>
