<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://shawnreeves.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Photo-gate_timer_with_a_PICAXE_20M2</id>
	<title>Photo-gate timer with a PICAXE 20M2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://shawnreeves.net//wiki/index.php?action=history&amp;feed=atom&amp;title=Photo-gate_timer_with_a_PICAXE_20M2"/>
	<link rel="alternate" type="text/html" href="https://shawnreeves.net//wiki/index.php?title=Photo-gate_timer_with_a_PICAXE_20M2&amp;action=history"/>
	<updated>2026-08-02T15:36:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://shawnreeves.net//wiki/index.php?title=Photo-gate_timer_with_a_PICAXE_20M2&amp;diff=2931&amp;oldid=prev</id>
		<title>Shawn: /* Program listing */</title>
		<link rel="alternate" type="text/html" href="https://shawnreeves.net//wiki/index.php?title=Photo-gate_timer_with_a_PICAXE_20M2&amp;diff=2931&amp;oldid=prev"/>
		<updated>2025-03-31T02:25:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Program listing&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:25, 30 March 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See [[Photo-gate timer]] for a full discussion.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See [[Photo-gate timer]] for a full discussion.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;syntaxhighlight lang=&quot;BASIC&quot; line copy&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;2014 Shawn Reeves&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;2014 Shawn Reeves&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;Hardware notes:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;Hardware notes:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l133&quot;&gt;Line 133:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 134:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  return&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  return&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Electronics]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Electronics]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Shawn</name></author>
	</entry>
	<entry>
		<id>https://shawnreeves.net//wiki/index.php?title=Photo-gate_timer_with_a_PICAXE_20M2&amp;diff=2594&amp;oldid=prev</id>
		<title>Shawn: link to parent page</title>
		<link rel="alternate" type="text/html" href="https://shawnreeves.net//wiki/index.php?title=Photo-gate_timer_with_a_PICAXE_20M2&amp;diff=2594&amp;oldid=prev"/>
		<updated>2014-03-15T02:20:28Z</updated>

		<summary type="html">&lt;p&gt;link to parent page&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:20, 14 March 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Program listing===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Program listing===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This program can be compiled for a PICAXE 20M2, paired with a Newhaven 3V i2c LCD display. It will watch for high signals on five input pins, starting with C.5, and display times between C.5 tripping and the rest of the gates.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This program can be compiled for a PICAXE 20M2, paired with a Newhaven 3V i2c LCD display. It will watch for high signals on five input pins, starting with C.5, and display times between C.5 tripping and the rest of the gates.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;See [[Photo-gate timer]] for a full discussion.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;2014 Shawn Reeves&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;2014 Shawn Reeves&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;Hardware notes:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  ;Hardware notes:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Shawn</name></author>
	</entry>
	<entry>
		<id>https://shawnreeves.net//wiki/index.php?title=Photo-gate_timer_with_a_PICAXE_20M2&amp;diff=2593&amp;oldid=prev</id>
		<title>Shawn: Created page with &quot;===Program listing=== This program can be compiled for a PICAXE 20M2, paired with a Newhaven 3V i2c LCD display. It will watch for high signals on five input pins, starting wi...&quot;</title>
		<link rel="alternate" type="text/html" href="https://shawnreeves.net//wiki/index.php?title=Photo-gate_timer_with_a_PICAXE_20M2&amp;diff=2593&amp;oldid=prev"/>
		<updated>2014-03-15T02:19:54Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;===Program listing=== This program can be compiled for a PICAXE 20M2, paired with a Newhaven 3V i2c LCD display. It will watch for high signals on five input pins, starting wi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===Program listing===&lt;br /&gt;
This program can be compiled for a PICAXE 20M2, paired with a Newhaven 3V i2c LCD display. It will watch for high signals on five input pins, starting with C.5, and display times between C.5 tripping and the rest of the gates.&lt;br /&gt;
 ;2014 Shawn Reeves&lt;br /&gt;
 ;Hardware notes:&lt;br /&gt;
 ;only C.1 to C.5 may be used as interrupts on the 20M2 or 20X2 parts&lt;br /&gt;
 ;Only 20X2 and greater parts offer a dedicated hardware timer. To use 20M2, we use software counting&lt;br /&gt;
 ;Tested with a 20M2 to 20ms precision, but may drift with temperature, ICs, VCC.&lt;br /&gt;
 ;For more precise timing, leave the PICAXE environment for a crystal-timed µC with hardware timer.&lt;br /&gt;
 ;Attach a photo-gate to pins 5, 6 (and optionally 7, 8, then 9) of the PICAXE 20M2&lt;br /&gt;
 ;Tie unused photo-gate pins to ground or spurious signals will trip floating pins.&lt;br /&gt;
 ;Gates should provide TTL output &lt;br /&gt;
 ;LCD display contrast depends on voltage of power supplied.&lt;br /&gt;
 ; Here it is adjusted to be readable from 3.3V to to 2.9V. Lower voltage will make lighter characters.&lt;br /&gt;
 &lt;br /&gt;
 #picaxe 20M2	;declare type so compiler works correctly.&lt;br /&gt;
 symbol count1 = w1	;track the time at second gate (pin 6)&lt;br /&gt;
 symbol count2 = w2	;track the time at third gate&lt;br /&gt;
 symbol count3 = w3	;track the time at fourth gate&lt;br /&gt;
 symbol count4 = w4	;track the time at fifth gate&lt;br /&gt;
 symbol counter = w5	;track the time since first gate was crossed (pin 5)&lt;br /&gt;
 symbol loopWord = w6&lt;br /&gt;
 symbol ones = b14&lt;br /&gt;
 symbol tens = b15&lt;br /&gt;
 symbol hundreds = b16&lt;br /&gt;
 symbol thousands = b17&lt;br /&gt;
 symbol tenThousands = b18&lt;br /&gt;
 &lt;br /&gt;
 symbol interruptPin = b1 	;Track which gate we expect to close next&lt;br /&gt;
 symbol LCDAddress = 124	;0x7C&lt;br /&gt;
 symbol controlByte = 0&lt;br /&gt;
 symbol functionSetDisplay = 0x38&lt;br /&gt;
 symbol clearDisplay = 1&lt;br /&gt;
 symbol homeDisplay = 2&lt;br /&gt;
 symbol updatePeriod = 100	;How often to refresh display, in centiseconds. The larger, the more precise the timing&lt;br /&gt;
 &lt;br /&gt;
 init:&lt;br /&gt;
 pause 1000	;give a second for inputs to settle&lt;br /&gt;
 ;setfreq will affect all future timing instructions, including pause, pauseus, and hi2csetup&lt;br /&gt;
 setfreq m32&lt;br /&gt;
 ;HI2CSETUP I2CMASTER, slaveaddress, i2cfast | i2cslow | i2cfast_8 | i2cslow_8 | i2cfast_16 | etc, i2cbyte | i2cword&lt;br /&gt;
 HI2CSETUP I2CMASTER, LCDAddress, i2cfast_32, i2cbyte&lt;br /&gt;
 initLCD:&lt;br /&gt;
 hi2cout 0,($38);%00111000; FUNCTION SET 8 bit, 2 line, not double-height, 0, instruction set zero&lt;br /&gt;
 pause 2&lt;br /&gt;
 hi2cout 0,($39);%00111001; FUNCTION SET 8 bit, 2 line, not double-height, 0, instruction set one&lt;br /&gt;
 pause 2&lt;br /&gt;
 hi2cout 0,($14);%00010100; OSC set 1/5 bias, frequency last three bits&lt;br /&gt;
 hi2cout 0,(%01111111);%01111000; Contrast set, four least significant contrast bits&lt;br /&gt;
 hi2cout 0,(%01011101);%01011110; Power/ICON set, Icon on, booster on, two most significant contrast bits&lt;br /&gt;
 hi2cout 0,($6D);%01101101; FOLLOWER CONTROL, follower on, last three bits follower amp ratio&lt;br /&gt;
 hi2cout 0,($38);BACK TO INSTRUCTION SET ZERO&lt;br /&gt;
 hi2cout 0,($0C);%00001100; DISPLAY ON, display on, cursor off, cursor position off&lt;br /&gt;
 hi2cout 0,($01)		; Clear display&lt;br /&gt;
 hi2cout 0,($06);%00000110;	ENTRY MODE, increment cursor, don&amp;#039;t shift display&lt;br /&gt;
 pause 3&lt;br /&gt;
 &lt;br /&gt;
 restarting:&lt;br /&gt;
 hi2cout 0, ($80)	;set data address to beginning of line 1&lt;br /&gt;
 hi2cout $40, (&amp;quot;waiting for 1st gate&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 counter = 0&lt;br /&gt;
 count1 = 0&lt;br /&gt;
 count2 = 0&lt;br /&gt;
 count3 = 0&lt;br /&gt;
 count4 = 0&lt;br /&gt;
 interruptPin = 32	;%00100000	;Start at C.5&lt;br /&gt;
 ;set interrupt on inputs along port C, starting with C.5, C.4, ... for each photogate&lt;br /&gt;
 setint interruptPin,interruptPin	;Interrupt only on current expected pin&lt;br /&gt;
 &lt;br /&gt;
 main:&lt;br /&gt;
 ;Breaking 10µs pause into 1µs pauses, since interrupt causes program to go to next line&lt;br /&gt;
 ;;no matter how far pause was in execution.&lt;br /&gt;
 ;the timing overhead for each iteration of the following loop is about 40µs&lt;br /&gt;
 for loopWord = 2 to updatePeriod&lt;br /&gt;
 	pauseus 7700	;in units of 10µs (divided by frequency scale, 8), so this will count every 10 ms, our least significant digit&lt;br /&gt;
 	inc counter&lt;br /&gt;
 next loopWord&lt;br /&gt;
 pauseus 6000	;adjust down from 10ms to account for display routine below. since setfreq is 32, 8000 is 10ms.&lt;br /&gt;
 inc counter&lt;br /&gt;
 #ifdef calibrateTime&lt;br /&gt;
 	;the following conversion and display take about 2.5ms&lt;br /&gt;
 	BINTOASCII counter, tenThousands, thousands, hundreds, tens, ones	;display counter to calibrate timing&lt;br /&gt;
 	hi2cout 0, ($C8)	;set data address to middle of line 2&lt;br /&gt;
 	hi2cout $40, (tenThousands, thousands, hundreds, %00101110, tens, ones)&lt;br /&gt;
 #else&lt;br /&gt;
 	pauseus 1500;estimate of amount of overhead the above time display would take.&lt;br /&gt;
 #endif&lt;br /&gt;
 &lt;br /&gt;
 goto main&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 interrupt:&lt;br /&gt;
 if interruptPin = 32 then	;first gate was tripped, so start counting&lt;br /&gt;
 	counter = 0&lt;br /&gt;
 	count1 = 0&lt;br /&gt;
 	count2 = 0&lt;br /&gt;
 	count3 = 0&lt;br /&gt;
 	count4 = 0&lt;br /&gt;
 	interruptPin = 16&lt;br /&gt;
 	setint interruptPin,interruptPin	;Interrupt only on current expected pin&lt;br /&gt;
 	hi2cout 0, ($80)	;set data address to beginning of line 1&lt;br /&gt;
 	hi2cout $40, (&amp;quot;1st gate tripped&amp;quot;)&lt;br /&gt;
 else if interruptPin = 16 then	;next gate was tripped, get time&lt;br /&gt;
 	count1 = counter&lt;br /&gt;
 	interruptPin = 8&lt;br /&gt;
 	setint interruptPin,interruptPin	;Interrupt only on current expected pin&lt;br /&gt;
 	hi2cout 0, ($80)	;set data address to beginning of line 1&lt;br /&gt;
 	BINTOASCII count1, tenThousands, thousands, hundreds, tens, ones&lt;br /&gt;
 	hi2cout $40, (tenThousands, thousands, hundreds, %00101110, tens, ones,32,32,32,32,32,32,32,32,32,32);clear 1st line&lt;br /&gt;
 else if interruptPin = 8 then&lt;br /&gt;
 	count2 = counter&lt;br /&gt;
 	interruptPin = 4&lt;br /&gt;
 	setint interruptPin,interruptPin	;Interrupt only on current expected pin&lt;br /&gt;
 	hi2cout 0, ($88)	;set data address to middle of line 1&lt;br /&gt;
 	BINTOASCII count2, tenThousands, thousands, hundreds, tens, ones&lt;br /&gt;
 	hi2cout $40, (tenThousands, thousands, hundreds, %00101110, tens, ones,32,32)&lt;br /&gt;
 else if interruptPin = 4 then&lt;br /&gt;
 	count3 = counter&lt;br /&gt;
 	interruptPin = 2&lt;br /&gt;
 	setint interruptPin,interruptPin	;Interrupt only on current expected pin&lt;br /&gt;
 	hi2cout 0, ($C0)	;set data address to beginning of line 2&lt;br /&gt;
 	BINTOASCII count3, tenThousands, thousands, hundreds, tens, ones&lt;br /&gt;
 	hi2cout $40, (tenThousands, thousands, hundreds, %00101110, tens, ones)&lt;br /&gt;
 else if interruptPin = 2 then&lt;br /&gt;
 	count4 = counter&lt;br /&gt;
 	interruptPin = 32	;allow hitting the original to reset&lt;br /&gt;
 	hi2cout 0, ($C8)	;set data address to middle of line 2&lt;br /&gt;
 	BINTOASCII count4, tenThousands, thousands, hundreds, tens, ones&lt;br /&gt;
 	hi2cout $40, (tenThousands, thousands, hundreds, %00101110, tens, ones)&lt;br /&gt;
 endif&lt;br /&gt;
 &lt;br /&gt;
 return&lt;br /&gt;
&lt;br /&gt;
[[Category:Electronics]]&lt;/div&gt;</summary>
		<author><name>Shawn</name></author>
	</entry>
</feed>