<root>
<document scada='0' schema='103' license='1,79829088,14T0PE' title='' description='' fcversion='655617' target='ARD.ATMEGA.Arduino Uno R3 PDIP' >
	<config data='' clkspd='16000000' simspd='0' usewdt='0' constif='0' commport='5' Use3V3='0' />
	<plugins >
		<dll_models enabled='1' />
	</plugins>
	<supplement use='1' head='    #define MICROSTEPS 16                       // 8 or 16

    #define MOTOR12_64KHZ _BV(CS20)             // no prescale
    #define MOTOR12_8KHZ _BV(CS21)              // divide by 8
    #define MOTOR12_2KHZ _BV(CS21) | _BV(CS20)  // divide by 32
    #define MOTOR12_1KHZ _BV(CS22)              // divide by 64

    #define MOTOR34_64KHZ _BV(CS00)             // no prescale
    #define MOTOR34_8KHZ _BV(CS01)              // divide by 8
    #define MOTOR34_1KHZ _BV(CS01) | _BV(CS00)  // divide by 64
    
    #define DC_MOTOR_PWM_RATE   MOTOR34_8KHZ    // PWM rate for DC motors
    #define STEPPER1_PWM_RATE   MOTOR12_64KHZ   // PWM rate for stepper 1
    #define STEPPER2_PWM_RATE   MOTOR34_64KHZ   // PWM rate for stepper 2
    
    // Bit positions in the 74HCT595 shift register output
#define MOTOR1_A 2
#define MOTOR1_B 3
#define MOTOR2_A 1
#define MOTOR2_B 4
#define MOTOR4_A 0
#define MOTOR4_B 6
#define MOTOR3_A 5
#define MOTOR3_B 7

// Constants that the user passes in to the motor calls
#define FORWARD 1
#define BACKWARD 2
#define BRAKE 3
#define RELEASE 4

// Constants that the user passes in to the stepper calls
#define SINGLE 1
#define DOUBLE 2
#define INTERLEAVE 3
#define MICROSTEP 4

/*
#define LATCH 4
#define LATCH_DDR DDRB
#define LATCH_PORT PORTB

#define CLK_PORT PORTD
#define CLK_DDR DDRD
#define CLK 4

#define ENABLE_PORT PORTD
#define ENABLE_DDR DDRD
#define ENABLE 7

#define SER 0
#define SER_DDR DDRB
#define SER_PORT PORTB
*/

// Arduino pin names for interface to 74HCT595 latch
#define MOTORLATCH 12
#define MOTORCLK 4
#define MOTORENABLE 7
#define MOTORDATA 8' body='' />
	<debug >
		<watch expr='OneStep.num' />
		<watch expr='OneStep.dir' />
		<watch expr='OneStep.style' />
		<watch expr='OneStep.i' />
		<watch expr='OneStep.index' />
		<watch expr='OneStep.ocra' />
		<watch expr='latch_state' />
		<watch expr='currentStep' />
		<watch expr='OneStep.cs' />
		<watch expr='OneStep.ocrb' />
	</debug>
	<traces />
	<ghost >
		<FK2 >
			<data name='FK2D0' port='4294967295' pin='4294967295' />
			<data name='FK2D1' port='4294967295' pin='4294967295' />
			<data name='FK2D2' port='4294967295' pin='4294967295' />
			<data name='FK2D3' port='4294967295' pin='4294967295' />
			<data name='FK2D4' port='4294967295' pin='4294967295' />
			<data name='FK2D5' port='4294967295' pin='4294967295' />
			<data name='FK2D6' port='4294967295' pin='4294967295' />
			<data name='FK2D7' port='4294967295' pin='4294967295' />
			<data name='FK2D8' port='4294967295' pin='4294967295' />
			<data name='FK2D9' port='4294967295' pin='4294967295' />
			<data name='FK2D10' port='4294967295' pin='4294967295' />
			<data name='FK2D11' port='4294967295' pin='4294967295' />
			<data name='FK2D12' port='4294967295' pin='4294967295' />
			<data name='FK2D13' port='4294967295' pin='4294967295' />
			<data name='FK2D14' port='4294967295' pin='4294967295' />
			<data name='FK2D15' port='4294967295' pin='4294967295' />
			<data name='FK2A0' port='4294967295' pin='4294967295' />
			<data name='FK2A1' port='4294967295' pin='4294967295' />
			<data name='FK2A2' port='4294967295' pin='4294967295' />
			<data name='FK2A3' port='4294967295' pin='4294967295' />
			<data name='FK2A4' port='4294967295' pin='4294967295' />
			<data name='FK2A5' port='4294967295' pin='4294967295' />
		</FK2>
		<ICD >
			<data name='AnalogPrescaleValue' value='19' />
			<data name='DigitalSampleRate' value='100000' />
			<data name='BreakpointCount' value='8' />
			<data name='CallStackDepthCount' value='8' />
			<data name='ClockPort' value='3' />
			<data name='ClockPin' value='1' />
			<data name='DataPort' value='3' />
			<data name='DataPin' value='0' />
			<data name='UseDefaultPins' value='1' />
			<data name='WrapEnabled' value='1' />
			<data name='CommsDelayOverridden' value='0' />
			<data name='CommsDelay' value='11' />
			<data name='CalculatedCommsDelay' value='11' />
			<data name='AnalogEB2PrescaleValue' value='2' />
			<data name='DigitalEB2SampleRate' value='100000' />
		</ICD>
		<pins >
			<digital A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
			<analog A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
		</pins>
	</ghost>
	<components >
		<settings autoimg='0' center='1' unitscale='0' fixedscale='0' fixedx='25' fixedy='25' fixedz='25' headcode='0' />
		<definition guid='8b1826e6-40d7-4592-9a7e-1a582264a1d9' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='HW-130' description='HW-130 L293D motor driver board component.

Handle 2 stepper or 4 DC motors or solenoids using this component (and 2 servos using standard FC components)' category='Development' category2='' category3='' bIs2dOnly='0' bIs3dOnly='0' catenable='1' author='Martin Fisher' manuname='' manucode='' sysinfo='0' keywords='L293D|Stepper|Motor|Solenoid|Servo' dynamic='1' scadaCompatible='0' embeddedCompatible='1' showmacros='1' iconpath='' />
		<component class_type='root' codename='HW' panelId='-1' 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' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' comp2dType='0' >
			<resources />
			<properties >
				<property name='motorLatch' target='motorLatch' typeid='5' hidden='0' locked='0' info='' />
				<property name='motorEnable' target='motorEnable' typeid='5' hidden='0' locked='0' info='' />
				<property name='motorClk' target='motorClk' typeid='5' hidden='0' locked='0' info='' />
				<property name='motorData' target='motorData' typeid='5' hidden='0' locked='0' info='' />
				<property name='Motors' hidden='0' />
				<property name='HBridge Enable 1 ' target='h1' typeid='5' hidden='0' locked='0' info='' />
				<property name='HBridge Enable 2' target='h2' typeid='5' hidden='0' locked='0' info='' />
				<property name='HBridge Enable 3' target='h3' typeid='5' hidden='0' locked='0' info='' />
				<property name='HBridge Enable 4' target='h4' typeid='5' hidden='0' locked='0' info='' />
				<property name='Pulse Width' folder='Servo_Controller1::property_1' hidden='0' >
					<property name='Minimum (us)' target='Servo_Controller1::min_pulse_width' typeid='21' hidden='0' locked='0' info='Shortest pulse width that will be used.' />
					<property name='Maximum (us)' target='Servo_Controller1::max_pulse_width' typeid='21' hidden='0' locked='0' info='Longest pulse width used for the PWM signals.' />
					<property name='CCP_Lo' target='Servo_Controller1::CCPLo' typeid='21' hidden='1' locked='0' info='' />
					<property name='CCP_Hi' target='Servo_Controller1::CCPHi' typeid='21' hidden='1' locked='0' info='' />
					<property name='Servo_Clock_Count_25us' target='Servo_Controller1::Servo_Clock_Count_25' typeid='21' hidden='1' locked='0' info='' />
					<property name='Servo_Clock_Count_1280' target='Servo_Controller1::Servo_Clock_Count_1280' typeid='21' hidden='1' locked='0' info='' />
					<property name='Servo_Clock_Count_2500' target='Servo_Controller1::Servo_Clock_Count_2500' typeid='21' hidden='1' locked='0' info='' />
					<property name='Period Multiplier' target='Servo_Controller1::Servo_Period_Multiplier' typeid='21' hidden='0' locked='1' info='Number of instructions for 1 / 256th of the positional accuracy.
This sets the default movement speed to maintain legacy move speeds.
Also sets the multiplication factor to convert from a byte 0-255 to a clocked position value.' />
					<property name='Int Range' target='Servo_Controller1::IntRange' typeid='10' hidden='1' locked='1' info='Acceptable range for Int values calculated with the current project target device and clock speed' />
					<property name='Divider' target='Servo_Controller1::Divider' typeid='7' hidden='1' locked='0' info='' />
					<property name='RoundUp' target='Servo_Controller1::RoundUp' typeid='7' hidden='1' locked='0' info='' />
					<property name='IntScaler' target='Servo_Controller1::IntScaler' typeid='15' hidden='1' locked='0' info='Int Scaler - Conversion from 0-65535 INT to Servo Period Clock Count' />
					<property name='MaxPeriod' target='Servo_Controller1::MaxPeriod' typeid='21' hidden='1' locked='0' info='' />
				</property>
			</properties>
			<values >
				<value target='motorLatch' data='$D12' />
				<value target='motorEnable' data='$D7' />
				<value target='motorClk' data='$D4' />
				<value target='motorData' data='$D8' />
				<value target='h1' data='$D11' />
				<value target='h2' data='$D3' />
				<value target='h3' data='$D5' />
				<value target='h4' data='$D6' />
				<value target='Servo_Controller1::min_pulse_width' data='1000' />
				<value target='Servo_Controller1::max_pulse_width' data='2000' />
				<value target='Servo_Controller1::CCPLo' data='64' />
				<value target='Servo_Controller1::CCPHi' data='125' />
				<value target='Servo_Controller1::Servo_Clock_Count_25' data='400' />
				<value target='Servo_Controller1::Servo_Clock_Count_1280' data='16016' />
				<value target='Servo_Controller1::Servo_Clock_Count_2500' data='32064' />
				<value target='Servo_Controller1::Servo_Period_Multiplier' data='62' />
				<value target='Servo_Controller1::IntRange' data='0 - 15871' />
				<value target='Servo_Controller1::Divider' data='0' />
				<value target='Servo_Controller1::RoundUp' data='1' />
				<value target='Servo_Controller1::IntScaler' data='0.244877' />
				<value target='Servo_Controller1::MaxPeriod' data='15810' />
			</values>
			<events />
			<apis >
				<api name='MotorSetSpeed' alt='MotorSetSpeed' type='1' proto='1' />
				<api name='SolenoidsPulse' alt='SolenoidsPulse' type='1' proto='1' />
				<api name='MotorEnable' alt='MotorEnable' type='1' proto='1' />
				<api name='StepperEnable' alt='StepperEnable' type='1' proto='1' />
				<api name='SolenoidPulse' alt='SolenoidPulse' type='1' proto='1' />
				<api name='StepperRelease' alt='StepperRelease' type='1' proto='1' />
				<api name='StepperSpeed' alt='StepperSpeed' type='1' proto='1' />
				<api name='StepperStep' alt='StepperStep' type='1' proto='1' />
				<api name='MotorRun' alt='MotorRun' type='1' proto='1' />
				<api name='Initialise' alt='Initialise' type='1' proto='1' />
				<api name='SolenoidEnable' alt='SolenoidEnable' type='1' proto='1' />
			</apis>
			<variables >
				<variable public='0' >
					<def class_type='variable' name='latch_state' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='STEP_LATCH' type='u8' description='Latch values for 8 phases of 2 steppers' isconst='1' isHidden='0' isinit='1' usrinit='&quot; 4,6,2,10,8,24,16,20,1,33,32,96,64,192,128,129 &quot;' setinit='{4,6,2,10,8,24,16,20,1,33,32,96,64,192,128,129}' >
						<array size='16' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='stepCounter' type='u32' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' >
						<array size='2' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='currentStep' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='2' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='false' type='b1' description='' isconst='1' isHidden='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='MOTOR_BITS' type='u8' description='Bit positions of the &apos;motor&apos; in shift register' isconst='1' isHidden='0' isinit='1' usrinit='&quot; 2, 3, 1, 4, 0, 6, 5, 7 &quot;' setinit='{2, 3, 1, 4, 0, 6, 5, 7}' >
						<array size='8' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='uSPerStep' type='u32' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' >
						<array size='2' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='revsteps' type='u16' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' >
						<array size='2' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='STEP_CURVE' type='u8' description='' isconst='1' isHidden='0' isinit='1' usrinit='&quot; 0, 25, 50, 74, 98, 120, 141, 162, 180, 197, 212, 225, 236, 244, 250, 253, 255 &quot;' setinit='{0, 25, 50, 74, 98, 120, 141, 162, 180, 197, 212, 225, 236, 244, 250, 253, 255}' >
						<array size='17' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='STEPS' type='u8' description='Number of steps for single, double, interleave and micro' isconst='1' isHidden='0' isinit='1' usrinit='&quot; 16, 8, 8, 1 &quot;' setinit='{16, 8, 8, 1}' >
						<array size='4' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='STEP_CLEAR' type='u8' description='Clear motor pins for both steppers' isconst='1' isHidden='0' isinit='1' usrinit='&quot; 0b11110, 0b11100001 &quot;' setinit='{0b11110, 0b11100001}' >
						<array size='2' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='true' type='b1' description='' isconst='1' isHidden='0' isinit='1' usrinit='1' setinit='1' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='LatchTX' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<local name='mask' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='i' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='motorLatch = 0' />
							<exp exp='motorData = 0' />
							<exp exp='.mask = 0b10000000' />
						</command>
						<command class_type='loop' title='Loop' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' type='2' forvar='.i' exp='8' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='motorClk = 0' />
									<exp exp='motorData = ((latch_state &amp; .mask) != 0)' />
									<exp exp='motorClk = 1' />
									<exp exp='.mask = .mask &gt;&gt; 1' />
								</command>
							</flowline>
						</command>
						<command class_type='calculation' title='Latch the data' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='motorLatch = 1' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MotorSetSpeed' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='motor' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='speed' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetPWM' >
							<argument exp='.motor' />
							<argument exp='.speed' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='InitPWM' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='pwm' type='u8' description='Channel (1 ..4)' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='freq' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='switch' title='Switch' textarea='36,25,36,25' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.pwm' >
							<case >
								<flowline />
							</case>
							<case exp='1' >
								<flowline >
									<command class_type='native' title='Code' ccode='TCCR2A |= _BV(COM2A1) | _BV(WGM20) | _BV(WGM21); // fast PWM, turn on oc2a
TCCR2B = FCL_FREQ &amp; 0x7;
OCR2A = 0;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
							<case exp='2' >
								<flowline >
									<command class_type='native' title='Code' ccode='    // use PWM from timer2B (pin 3)
    TCCR2A |= _BV(COM2B1) | _BV(WGM20) | _BV(WGM21); // fast PWM, turn on oc2b
    TCCR2B = FCL_FREQ &amp; 0x7;
    OCR2B = 0;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
							<case exp='3' >
								<flowline >
									<command class_type='native' title='Code' ccode='    // use PWM from timer0A / PD6 (pin 6)
    TCCR0A |= _BV(COM0A1) | _BV(WGM00) | _BV(WGM01); // fast PWM, turn on OC0A
    TCCR0B = FCL_FREQ &amp; 0x7;
    OCR0A = 0;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
							<case exp='4' >
								<flowline >
									<command class_type='native' title='Code' ccode='    TCCR0A |= _BV(COM0B1) | _BV(WGM00) | _BV(WGM01); // fast PWM, turn on oc0a
    TCCR0B = FCL_FREQ &amp; 0x7;
    OCR0B = 0;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='SolenoidsPulse' description='Activate multiple solenoids for a pulse simultaneously
Use 0b1111 where bit 0 is solenoid  1 and bit 3 is solenoid 4' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='solenoids' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='pulse' type='u16' description='Length of pulse in ms' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='i' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='mask' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='1' setinit='1' />
						<local name='old_latch' type='u8' description='Save latch state' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.old_latch = latch_state' />
						</command>
						<command class_type='loop' title='Loop' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' type='2' forvar='.i' exp='4' >
							<flowline >
								<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.solenoids &amp; .mask' swap='0' >
									<flowline >
										<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatchEnable' >
											<argument exp='.i + 1' />
											<argument exp='1' />
										</command>
									</flowline>
									<flowline />
								</command>
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='.mask = .mask &lt;&lt; 1' />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
						<command class_type='delay' title='Delay' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.pulse' type='1' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='latch_state = .old_latch' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
					</flowline>
				</macro>
				<macro >
					<flowline name='MotorEnable' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='motor' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='a' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='b' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='pos' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.pos = (.motor - 1) &amp; 0b11' />
							<exp exp='.a = MOTOR_BITS[.pos * 2]' />
							<exp exp='.b = MOTOR_BITS[.pos * 2 + 1]' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
							<argument exp='.a' />
							<argument exp='false' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
							<argument exp='.b' />
							<argument exp='false' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='InitPWM' >
							<argument exp='.motor' />
							<argument exp='2' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='StepperEnable' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='num' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='steps' type='u16' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='i' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='index' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='comment' title='' comment='Black, green, blue, red' textarea='12,0,12,0' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.index = .num - 1' />
							<exp exp='revsteps[.index] = .steps' />
							<exp exp='currentStep[.index] = 0' />
						</command>
						<command class_type='loop' title='Set all 4 motor bits to 0' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' type='2' forvar='.i' exp='4' >
							<flowline >
								<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
									<argument exp='MOTOR_BITS[.index * 4 + .i]' />
									<argument exp='false' />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
						<command class_type='decision' title='Enable both H brdiges for motor' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.num == 1' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='h1 = 1' />
									<exp exp='h2 = 1' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='h3 = 1' />
									<exp exp='h4 = 1' />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='InitPWM' >
							<argument exp='.index * 2 + 1' />
							<argument exp='1' />
						</command>
						<command class_type='call' title='`' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='InitPWM' >
							<argument exp='.index * 2 + 2' />
							<argument exp='1' />
						</command>
						<command class_type='call' title='n ' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetPWM' >
							<argument exp='.index * 2 + 1' />
							<argument exp='255' />
						</command>
						<command class_type='call' title='n ' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetPWM' >
							<argument exp='.index * 2 + 2' />
							<argument exp='255' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='SolenoidPulse' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='solenoid' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='pulse' type='u16' description='Length of &apos;on&apos; in ms' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorRun' >
							<argument exp='.solenoid' />
							<argument exp='1' />
						</command>
						<command class_type='delay' title='Delay' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.pulse' type='1' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorRun' >
							<argument exp='.solenoid' />
							<argument exp='3' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='SetLatch' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='bit' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='state' type='b1' description='Set to true for on, false for off' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.state' swap='0' >
							<flowline >
								<command class_type='calculation' title='Set bit to 1' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='latch_state = latch_state | (1 &lt;&lt; .bit)' />
								</command>
							</flowline>
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='latch_state = latch_state &amp; ( ~(1 &lt;&lt; .bit))' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='StepperRelease' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='num' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='index' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='i' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.index = .num - 1' />
						</command>
						<command class_type='loop' title='Set all 4 motor bits to 0' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' type='2' forvar='.i' exp='4' >
							<flowline >
								<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
									<argument exp='MOTOR_BITS[.index * 4 + .i]' />
									<argument exp='false' />
								</command>
							</flowline>
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
					</flowline>
				</macro>
				<macro >
					<flowline name='StepperSpeed' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='num' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='rpm' type='u16' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='div' type='u32' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='index' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.index = .num - 1' />
							<exp exp='uSPerStep[.index] = 60000000' />
							<exp exp='.div = revsteps[.index] * .rpm' />
							<exp exp='uSPerStep[.index] = 60000000 / .div' />
							<exp exp='stepCounter[.index] = 0' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='StepperStep' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='num' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='steps' type='u16' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='dir' type='s16' description='-1 = reverse, 1 = forward' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='style' type='u8' description='0 = single, 1 = double, 2 = interleave, 3 = microstep' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='uS' type='u32' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='r' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='0' setinit='0' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.uS = uSPerStep[.num - 1]' />
						</command>
						<command class_type='switch' title='Switch' textarea='36,25,36,25' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.style' >
							<case >
								<flowline />
							</case>
							<case exp='2' >
								<flowline >
									<command class_type='calculation' title='Interleave' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
										<exp exp='.uS = .us / 2' />
									</command>
								</flowline>
							</case>
							<case exp='3' >
								<flowline >
									<command class_type='calculation' title='Microstep' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
										<exp exp='.uS = .us / 16' />
									</command>
								</flowline>
							</case>
						</command>
						<command class_type='loop' title='Loop' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' type='0' exp='.steps' >
							<flowline >
								<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='StepperOneStep' >
									<return exp='.r' />
									<argument exp='.num' />
									<argument exp='.dir' />
									<argument exp='.style' />
								</command>
								<command class_type='delay' title='Delay' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.uS / 1000' type='1' />
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='.steps = .steps - 1' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='SetLatchEnable' description='Set motor to forward (cmd = 1), reverse (cmd = 2) or Release (cmd = 3)' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='motor' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='cmd' type='u8' description='1 = forward 2 = reverse, 3 = release' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='a' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='b' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.motor = (.motor - 1) &amp; 0b11' />
							<exp exp='.a = MOTOR_BITS[.motor * 2]' />
							<exp exp='.b = MOTOR_BITS[.motor * 2 + 1]' />
						</command>
						<command class_type='switch' title='Switch' textarea='36,25,36,25' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.cmd' >
							<case >
								<flowline />
							</case>
							<case exp='1' >
								<flowline >
									<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
										<argument exp='.a' />
										<argument exp='1' />
									</command>
									<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
										<argument exp='.b' />
										<argument exp='0' />
									</command>
								</flowline>
							</case>
							<case exp='2' >
								<flowline >
									<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
										<argument exp='.b' />
										<argument exp='1' />
									</command>
									<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
										<argument exp='.a' />
										<argument exp='0' />
									</command>
								</flowline>
							</case>
							<case exp='3' >
								<flowline >
									<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
										<argument exp='.a' />
										<argument exp='0' />
									</command>
									<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatch' >
										<argument exp='.b' />
										<argument exp='0' />
									</command>
								</flowline>
							</case>
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
					</flowline>
				</macro>
				<macro >
					<flowline name='SetPWM' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='pwm' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='speed' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='switch' title='Switch' textarea='36,25,36,25' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.pwm' >
							<case >
								<flowline />
							</case>
							<case exp='1' >
								<flowline >
									<command class_type='native' title='Code' ccode='OCR2A = FCL_SPEED;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
							<case exp='2' >
								<flowline >
									<command class_type='native' title='Code' ccode='    // use PWM from timer2A on PB3 (Arduino pin #11)
    OCR2B = FCL_SPEED;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
							<case exp='3' >
								<flowline >
									<command class_type='native' title='Code' ccode='    // use PWM from timer0A on PB3 (Arduino pin #6)
    OCR0A = FCL_SPEED;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
							<case exp='4' >
								<flowline >
									<command class_type='native' title='Code' ccode='    // use PWM from timer0A on PB3 (Arduino pin #6)
    OCR0B = FCL_SPEED;' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' language='C' />
								</flowline>
							</case>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<local name='on' type='b1' description='' isconst='0' isHidden='0' isinit='1' usrinit='1' setinit='true' />
						<local name='mstate' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='0' setinit='0' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='Initialise' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorEnable' >
							<argument exp='1' />
						</command>
						<command class_type='call' title='Set Speed' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorSetSpeed' >
							<argument exp='1' />
							<argument exp='255' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SolenoidEnable' >
							<argument exp='2' />
						</command>
						<command class_type='call' title='User Macro' disable='1' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='StepperEnable' >
							<argument exp='1' />
							<argument exp='200' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='StepperEnable' >
							<argument exp='2' />
							<argument exp='200' />
						</command>
						<command class_type='call' title='User Macro' disable='1' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='StepperSpeed' >
							<argument exp='1' />
							<argument exp='60' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='StepperSpeed' >
							<argument exp='2' />
							<argument exp='100' />
						</command>
						<command class_type='call' title='User Macro' disable='1' ccode='  // User Macro
  FCM_Run(1, 1);' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorRun' >
							<argument exp='1' />
							<argument exp='1' />
						</command>
						<command class_type='loop' title='Loop' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' type='0' exp='1' >
							<flowline >
								<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorRun' >
									<argument exp='1' />
									<argument exp='.mstate + 1' />
								</command>
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='.mstate = (.mstate + 1) % 3' />
								</command>
								<command class_type='call' title='User Macro' disable='1' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SolenoidsPulse' >
									<argument exp='0b11' />
									<argument exp='50' />
								</command>
								<command class_type='call' title='User Macro' disable='1' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SolenoidPulse' >
									<argument exp='1' />
									<argument exp='200' />
								</command>
								<command class_type='call' title='User Macro' textarea='36,-10,36,-10' disable='1' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SolenoidPulse' >
									<argument exp='2' />
									<argument exp='200' />
								</command>
								<command class_type='call' title='User Macro' disable='1' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SolenoidPulse' >
									<argument exp='3' />
									<argument exp='100' />
								</command>
								<command class_type='call' title='User Macro' disable='1' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='StepperStep' >
									<argument exp='1' />
									<argument exp='100' />
									<argument exp='1' />
									<argument exp='1' />
								</command>
								<command class_type='delay' title='Delay' disable='1' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='2' type='2' />
								<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='StepperStep' >
									<argument exp='2' />
									<argument exp='400' />
									<argument exp='1' />
									<argument exp='1' />
								</command>
								<command class_type='delay' title='Delay' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='200' type='1' />
							</flowline>
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='MotorRun' description='Set motor to forward (cmd = 1), reverse (cmd = 2) or Release (cmd = 3)' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='motor' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='cmd' type='u8' description='1 = forward 2 = reverse, 3 = release' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='a' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='b' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetLatchEnable' >
							<argument exp='.motor' />
							<argument exp='.cmd' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Initialise' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<command class_type='output' title='SET PWM Pins as outputs' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' mode='1' port='1048577' mask='8' exp='0' usechipref='0' />
						<command class_type='output' title='Output' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' mode='1' port='1048579' mask='64' exp='0' usechipref='0' />
						<command class_type='output' title='Output' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' mode='1' port='1048579' mask='8' exp='0' usechipref='0' />
						<command class_type='output' title='Output' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' mode='1' port='1048579' mask='32' exp='0' usechipref='0' />
						<command class_type='calculation' title='Set control pins to output and 0' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='motorLatch = 0' />
							<exp exp='motorEnable = 0' />
							<exp exp='motorData = 0' />
							<exp exp='motorClk = 0' />
							<exp exp='latch_state = 0' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='motorEnable = 0' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='StepperOneStep' description='' statediag='0' >
						<return name='Return' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='num' type='u8' description='Motor number' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='dir' type='s16' description='1 = forward, -1 = reverse' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<param name='style' type='u8' description='0 = single, 1 = double, 2 = interleave, 3 = microstep' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='index' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='ocra' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='255' setinit='255' />
						<local name='ocrb' type='u8' description='' isconst='0' isHidden='0' isinit='1' usrinit='255' setinit='255' />
						<local name='i' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='step' type='u16' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<local name='cs' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.index = .num - 1' />
						</command>
						<command class_type='calculation' title='Calculation' break='1' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='currentStep[.index] = currentStep[.index] + (STEPS[.style] * .dir)' />
						</command>
						<command class_type='decision' title='If microstepping' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.style == 3' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='.cs = (currentStep[.index] + 64) % 64' />
									<exp exp='currentStep[.index] = .cs' />
								</command>
								<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='(.cs &gt;= 0) &amp;&amp; (.cs &lt; 16)' swap='0' >
									<flowline >
										<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
											<exp exp='.ocra = STEP_CURVE[16 - .cs]' />
											<exp exp='.ocrb = STEP_CURVE[.cs]' />
										</command>
									</flowline>
									<flowline >
										<command class_type='decision' title='' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='(.cs &gt;= 16) &amp;&amp; (.cs &lt; 32)' swap='0' >
											<flowline >
												<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
													<exp exp='.ocra = STEP_CURVE[.cs - 16]' />
													<exp exp='.ocrb = STEP_CURVE[32 - .cs]' />
												</command>
											</flowline>
											<flowline >
												<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='(.cs &gt;= 32) &amp;&amp; (.cs &lt; 48)' swap='0' >
													<flowline >
														<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
															<exp exp='.ocra = STEP_CURVE[48 - .cs]' />
															<exp exp='.ocrb = STEP_CURVE[.cs - 32]' />
														</command>
													</flowline>
													<flowline >
														<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='(.cs &gt;= 48) &amp;&amp; (.cs &lt; 64)' swap='0' >
															<flowline >
																<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
																	<exp exp='.ocra = STEP_CURVE[.cs - 48]' />
																	<exp exp='.ocrb = STEP_CURVE[64 - .cs]' />
																</command>
															</flowline>
															<flowline />
														</command>
													</flowline>
												</command>
											</flowline>
										</command>
									</flowline>
								</command>
							</flowline>
							<flowline />
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.cs = (currentStep[.index] + 64) % 64' />
							<exp exp='currentStep[.index] = .cs' />
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='latch_state = latch_state &amp;  ~STEP_CLEAR[.index]' />
						</command>
						<command class_type='decision' title='Decision' cmdcolor='4767473' cmdcolor_sec='11337727' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='.style == 3' swap='0' >
							<flowline >
								<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
									<exp exp='.cs = (((.cs &gt;&gt; 4) &lt;&lt; 1) + 1) &lt;&lt; 3' />
								</command>
							</flowline>
							<flowline />
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='latch_state = latch_state | STEP_LATCH[.index * 8 + (.cs &gt;&gt; 3)]' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetPWM' >
							<argument exp='(.index * 2) + 1' />
							<argument exp='.ocra' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='SetPWM' >
							<argument exp='.index * 2  + 2' />
							<argument exp='.ocrb' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='LatchTX' />
						<command class_type='delay' title='Delay' disable='1' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' exp='1' type='1' />
						<command class_type='calculation' title='Calculation' cmdcolor='4206456' cmdcolor_sec='10785756' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' >
							<exp exp='.Return = currentStep[.index]' />
						</command>
					</flowline>
				</macro>
				<macro >
					<flowline name='SolenoidEnable' description='' statediag='0' >
						<return name='Return' type='v0' description='' isconst='0' isHidden='0' isinit='0' usrinit='' setinit='' />
						<param name='motor' type='u8' description='' isconst='0' isHidden='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorEnable' >
							<argument exp='.motor' />
						</command>
						<command class_type='call' title='User Macro' cmdcolor='4487093' cmdcolor_sec='11066367' cmdcolor_txt='16777215' cmdgradient='4' cmdopacity='0.64' macro='MotorSetSpeed' >
							<argument exp='.motor' />
							<argument exp='255' />
						</command>
					</flowline>
				</macro>
			</macros>
		</component>
	</components>
	<scadaresourcelookup />
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' >
		<background rgb='7292207' img='' style='0' />
		<camera xe='0' ye='0' ze='969.145' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<viewport dx='336' dy='1491' zoom='41.9504' fix_topleft='0' />
		<page x='1000' y='1000' show='0' rgb='7360576' />
		<winpos ID='7005' RectRecentFloat='709,289,1359,739' RectRecentDocked='0,0,336,1524' RecentFrameAlignment='16384' RecentRowIndex='0' IsFloating='0' MRUWidth='32767' PinState='0' IsMaximized='0' IsVisible='0' />
	</panel2d>
	<panel3d shadows='0' lighting='2' brightness='0' perspective='1' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='0' />
		<camera xe='0' ye='0' ze='781.66' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey0 xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey1 xe='-3.67394e-14' ye='0' ze='-300' xt='0' yt='0' zt='0' xquat='0' yquat='1' zquat='0' wquat='6.12323e-17' />
		<camerakey2 xe='0' ye='-300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.707107' yquat='0' zquat='0' wquat='0.707107' />
		<camerakey3 xe='-3.67394e-14' ye='300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-4.32978e-17' yquat='0.707107' zquat='0.707107' wquat='4.32978e-17' />
		<camerakey4 xe='-300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='0.5' zquat='0.5' wquat='0.5' />
		<camerakey5 xe='300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='-0.5' zquat='-0.5' wquat='0.5' />
		<camerakey6 xe='-173.205' ye='-173.205' ze='173.205' xt='0' yt='0' zt='0' xquat='-0.424708' yquat='0.17592' zquat='0.339851' wquat='0.820473' />
		<winpos ID='7004' RectRecentFloat='585,182,1045,752' RectRecentDocked='0,0,336,1530' RecentFrameAlignment='16384' RecentRowIndex='0' IsFloating='0' MRUWidth='32767' PinState='0' IsMaximized='0' IsVisible='0' />
	</panel3d>
	<panels2d count='1' >
		<panel2d_0 id='0' name='2D Panel' >
			<winpos ID='1171' RectRecentFloat='1964,736,2614,1186' RectRecentDocked='963,220,1553,964' RecentFrameAlignment='16384' RecentRowIndex='0' IsFloating='0' MRUWidth='32767' PinState='0' IsMaximized='0' IsVisible='0' />
			<background fill='288230376151053813' showgrid='1' gridstyle='1' gridsize='10' gridbrush='71776119075691740' snaptogrid='1' />
		</panel2d_0>
	</panels2d>
	<layout >
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='129' scrollx='0' scrolly='342' flags='0' />
		<view type='0' name='Initialise' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='LatchTX' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='InitPWM' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='SetPWM' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MotorEnable' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MotorRun' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='128' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='MotorSetSpeed' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='SetLatch' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='StepperEnable' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='128' scrollx='0' scrolly='504' flags='0' />
		<view type='0' name='StepperRelease' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='StepperOneStep' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='134' scrollx='0' scrolly='963' flags='0' />
		<view type='0' name='StepperSpeed' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='StepperStep' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='140' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='SolenoidPulse' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='105' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='SolenoidsPulse' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='68' flags='0' />
		<view type='0' name='SetLatchEnable' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='100' scrollx='0' scrolly='0' flags='0' />
		<view type='0' name='SolenoidEnable' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAiAAAA2AYAADADAAA' zoom='5' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
