{\rtf1\mac\ansicpg10000\cocoartf100 {\fonttbl\f0\fswiss\fcharset77 Helvetica;} {\colortbl;\red255\green255\blue255;} \paperw11900\paperh16840\margl1440\margr1440\vieww14480\viewh15500\viewkind0 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \f0\fs24 \cf0 '\{$stamp BS2\}\ \ '13/1/2002 - version 1: Provide 5 basic controls via serial port Rec, Play, Ffwd, 'Rwnd, Stop.\ '2/2/2002 - Version 2: Replace CMOS logic cct with Stamp as controller\ '21/3/2002 - Version2.0.1: Changed some of the names of routines to reflect the fact that this code\ 'is now for a full cassette deck controller, not just a serial remote control.\ \ '*********Declare Variables***************\ \ command var byte\ \ '**********Main Code**********************\ \ DIRS=%0000001111111111 'Set required ports (P9 - P0) as OUTPUTS\ \ 'Record is P0 (LSB)\ 'Play is P1\ 'Rewind is P2\ 'Fastforward is P3\ 'Motor on/off is P4\ 'Record LED is P5\ 'Play LED is P6\ 'Rewind LED is P7\ 'FastForward LED is P8\ 'Stop - from the Front Panel Controls or IR Remote is simply Reset on the BS2. \ 'A Stop command from the serial port will send all ports low\ \ CheckSerial: 'This routine listens to serial port for a command from PC\ SERIN 16, 396, 200, CheckButtons,[command]\ if not command = 82 then serincheckforplay '82 = R\ gosub activaterecord\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 serincheckforplay:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 if not command = 112 then serincheckforrewind '112 = p\ gosub activateplay\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 serincheckforrewind:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 if not command = 114 then serincheckforfastforward '114 = r\ gosub activaterewind\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 serincheckforfastforward:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 if not command = 102 then serincheckforstop '102 = f\ gosub activatefastforward\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 serincheckforstop:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 if not command = 115 then checkserial '115 = s\ gosub activateforstop\ goto CheckSerial\ \ checkbuttons:\ 'Record Pressed? Port 15\ Rec:\ if not IN15 = 0 then Playdeck\ gosub activaterecord\ 'Play Pressed? Port 14\ Playdeck:\ if not IN14 = 0 then FF\ gosub activateplay\ 'FF Pressed? Port 13\ FF:\ if not IN13 = 0 then Rew\ gosub activatefastforward\ 'REW Pressed? Port 12\ Rew:\ if not IN12 = 0 then Autostop\ gosub activaterewind\ Autostop:\ gosub checkautostop\ goto CheckSerial\ \ checkautostop:\ 'Pulses from counter stopped? Port 10\ 'Connected to Port 10 is a capacitor to GND and asscociated components\ 'When the pulses stop, the capacitor will discharge and Port 10 will go low.\ 'if not IN10 = 0 then backtocheckbuttons\ 'gosub checkforstop\ 'backtocheckbuttons:\ return\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 activaterecord:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 'RECORD pressed?\ OUTS = %0000000000110011 'Set ports hi or low\ return\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 activateplay:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 'PLAY pressed?\ OUTS = %0000000001010010\ return\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 activaterewind:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 'REWIND pressed?\ OUTS = %0000001010010100\ return\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 activatefastforward:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 'FASTFORWARD pressed?\ OUTS = %0000000100011000\ return\ \ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 activatestop:\ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural \cf0 'STOP pressed?\ OUTS = 0\ return}