<root>
<document scada='0' schema='102' license='1,viktor_aust,WE9E5E' title='' description='' fcversion='524544' target='ARD.ATMEGA.Arduino Nano 328' >
	<config data='' clkspd='16000000' simspd='1' usewdt='0' constif='0' />
	<plugins >
		<dll_models enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug />
	<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' />
		</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='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='cd556bff-3751-4299-b46a-37215483672d' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='0' scadaCompatible='0' embeddedCompatible='1' 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' scadavisible='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='value' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='phase' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='val_B2' type='u16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='val_B1' type='u16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='dtB' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='dtA' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='num' type='s16' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='pulse' type='u8' description='' isconst='0' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='true' type='b1' description='' isconst='1' isinit='1' usrinit='1' setinit='1' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='Timer1' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='comment' title='' comment='The captured 16-bit count value can be read into a Flowcode variable &apos;captval&apos; with the following C code line:


FCV_CAPTVAL = ICR1;

** captval must be declared as an integer variable **
' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
						<command class_type='native' title='C Code' disable='1' ccode='FCV_VALUE = ICR1;' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
						<command class_type='comment' title='' comment='ISR(TIMER1_OVF_vect){
    static int num;
    static int  ph;    
    static int dtA=0;
    static int dtB=5;' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
						<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='num &gt;= 100' swap='0' >
							<flowline >
								<command class_type='delay' title='Delay' cmdcolor='12632064' cmdcolor_sec='16769676' exp='50' type='0' />
								<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
									<exp exp='num = 0' />
								</command>
								<command class_type='comment' title='' comment='

dutyCycle is a value from 0 to 255, and pin is one of the PWM pins (3, 5, 6, 9, 10, or 11).
' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
								<command class_type='comment' title='' comment='Nano pin 11 = B3
Nano pin 12 = B4' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
								<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='phase == 1' swap='0' >
									<flowline >
										<command class_type='output' title='Output' cmdcolor='16762795' cmdcolor_sec='13879979' mode='1' port='1048577' mask='8' exp='0' />
										<command class_type='output' title='Output' cmdcolor='16762795' cmdcolor_sec='13879979' mode='1' port='1048577' mask='16' exp='1' />
									</flowline>
									<flowline >
										<command class_type='output' title='Output' cmdcolor='16762795' cmdcolor_sec='13879979' mode='1' port='1048577' mask='8' exp='1' />
										<command class_type='output' title='Output' cmdcolor='16762795' cmdcolor_sec='13879979' mode='1' port='1048577' mask='16' exp='0' />
									</flowline>
								</command>
							</flowline>
							<flowline />
						</command>
						<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='num &gt;= 99' swap='0' >
							<flowline >
								<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='phase == 0' swap='0' >
									<flowline >
										<command class_type='native' title='C Code' ccode='TCCR1A = 0b10110000;' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='dtA = 0' />
											<exp exp='dtB = 5' />
										</command>
										<command class_type='comment' title='' comment='pins OC1A and OC1B- pin 9 or 10
or pin9=B1
pin10=B2' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
										<command class_type='native' title='C Code' disable='1' ccode='OCR1A = int(lookUp1[num]*0.7)+dtA;' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='lut1' macro='GetInt' >
											<return exp='val_B1' />
											<argument exp='num' />
										</command>
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='val_B1 = (val_B1 * 0.7) + dtA' />
										</command>
										<command class_type='output' title='Output' cmdcolor='16762795' cmdcolor_sec='13879979' mode='1' port='1048577' mask='2' exp='val_B1' />
										<command class_type='native' title='C Code' disable='1' ccode='OCR1B = int(lookUp1[num]*0.7)+dtB;' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='lut1' macro='GetInt' >
											<return exp='val_B2' />
											<argument exp='num' />
										</command>
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='val_B2 = (val_B2 * 0.7) + dtA' />
										</command>
									</flowline>
									<flowline >
										<command class_type='comment' title='' comment='TCCR1A/B
-8-bit registers and 
have no CPU access restrictions' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
										<command class_type='native' title='C Code' ccode='TCCR1A = 0b11100000; 
// OC1B as SPWM out' cmdcolor='7687168' cmdcolor_sec='8152576' language='C' />
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='dtA = 5' />
											<exp exp='dtB = 0' />
										</command>
									</flowline>
								</command>
								<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
									<exp exp='phase = ~phase' />
								</command>
							</flowline>
							<flowline />
						</command>
						<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
							<exp exp='num = num + 1' />
						</command>
						<command class_type='comment' title='' comment='


    if (num&gt;=99){
      if(ph==0){             // OC1A as SPWM out
        TCCR1A = 0b10110000; // clear OC1A, set OC1B on compare match 
        dtA=0;               // no dead time
        dtB=5;              // adding dead time to OC1B
      }else {
        TCCR1A = 0b11100000; // OC1B as SPWM out
        dtA=5;              
        dtB=0;
      }
     ph ^=1;
    }  
    OCR1A = int(lookUp1[num]*0.7)+dtA;  // SPWM width update   
    OCR1B = int(lookUp1[num]*0.7)+dtB;  // note: 0.7 used to reduce inveter output voltage  
 
    num++; 
    if (num&gt;=100){                      // toggle left bridge (50Hz) 
      delayMicroseconds(50);            
      if(ph==1){
        digitalWrite(12,LOW);        
        digitalWrite(11,HIGH);
      }else {
        digitalWrite(11,LOW);      
        digitalWrite(12,HIGH);
      }
      num=0;  
    }   ' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='comment' title='' comment='Init
----------------------
TCCR1A = 0b10110000;  
TCCR1B = 0b00010001;
TIMSK1 = 0b00000001;
ICR1   = 800;      /* Counter TOP value (at 16MHz XTAL, SPWM carrier freq. 10kHz, 200 samples/cycle).*/
sei();             /* Enable global interrupts.*/
DDRB = 0b00011110; /* Pin 9, 10, 11, 12 as outputs.*/' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
						<command class_type='comment' title='' comment='Disable code:
------------
TIMSK &amp;= ~(1 &lt;&lt; TICIE1); // disable input capture interrupts

' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
						<command class_type='comment' title='' comment='Handler code:
-------------------
ISR(TIMER1_CAPT_vect) // input capture vector
{
FCM_%n(); // Call Flowcode Macro
}

The captured 16-bit count value can be read into a Flowcode variable &apos;captval&apos; with the following C code line:


FCV_CAPTVAL = ICR1;

** captval must be declared as an integer variable **
' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
						<command class_type='comment' title='' comment='Timer Interrupt Mask Register (TIMSK1' textarea='12,0,12,0' cmdcolor='10944511' cmdcolor_sec='11465458' />
						<command class_type='interrupt' title='Interrupt' cmdcolor='17151' cmdcolor_sec='355583' enable='1' name='' call='Timer1' >
							<custom name='Timer1' handler='ISR (TIMER1_CAPT_vect)
{
FCM_%n();
}
' enable='TCCR1B = 0X45;
TIMSK1 &amp;=(1&lt;&lt;ICIE1);
' disable='' />
						</command>
						<command class_type='call' title='Call Component Macro' disable='1' cmdcolor='1879295' cmdcolor_sec='5751039' component='lcd_4x20' macro='Start' />
						<command class_type='call' title='Call Component Macro' disable='1' cmdcolor='1879295' cmdcolor_sec='5751039' component='lcd_4x20' macro='Cursor' >
							<argument exp='0' />
							<argument exp='0' />
						</command>
						<command class_type='loop' title='Loop' cmdcolor='12615680' cmdcolor_sec='15376912' type='0' exp='1' >
							<flowline >
								<command class_type='delay' title='Delay' disable='1' cmdcolor='12632064' cmdcolor_sec='16769676' exp='100' type='1' />
								<command class_type='call' title='Call Component Macro' disable='1' cmdcolor='1879295' cmdcolor_sec='5751039' component='lcd_4x20' macro='PrintNumber' >
									<argument exp='pulse' />
								</command>
								<command class_type='call' title='Call Component Macro' disable='1' cmdcolor='1879295' cmdcolor_sec='5751039' component='lcd_4x20' macro='Cursor' >
									<argument exp='0' />
									<argument exp='1' />
								</command>
								<command class_type='call' title='Call Component Macro' disable='1' cmdcolor='1879295' cmdcolor_sec='5751039' component='lcd_4x20' macro='PrintNumber' >
									<argument exp='value' />
								</command>
							</flowline>
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='a2b40602-5421-4e2f-ba82-96db1be51d69' vmin='1' vmaj='1' codename='lcd_4x20' x='0' y='0' z='3.575' 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='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='Pin_Data_0' data='$PORTD.2' />
					<value target='Pin_Data_1' data='$PORTD.3' />
					<value target='Pin_Data_2' data='$PORTD.4' />
					<value target='Pin_Data_3' data='$PORTD.5' />
					<value target='Pin_RS' data='$PORTD.6' />
					<value target='Pin_E' data='$PORTD.7' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='dfb4d07a-3d70-45d5-83ef-07e3c95d86ab' vmin='6' vmaj='1' codename='lut1' x='-30' y='50' z='0' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='StorageType' data='001' />
					<value target='Sign' data='000' />
					<value target='intfixed' data='0,  25, 50, 75, 100,125,150,175,199,223,247,271,294,318,341,363,385,407,429,450,
470,490,510,529,548,566,583,600,616,632,647,662,675,689,701,713,724,734,744,753,
761,768,775,781,786,790,794,796,798,800,800,800,798,796,794,790,786,781,775,768,
761,753,744,734,724,713,701,689,675,662,647,632,616,600,583,566,548,529,510,490,
470,450,429,407,385,363,341,318,294,271,247,223,199,175,150,125,100,75, 50, 25' />
					<value target='floatfixed' data='' />
					<value target='fixedexp' data='0' />
					<value target='EmbedIntoC' data='1' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<scadaresourcelookup />
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='9737364' img='' style='0' />
		<camera xe='-20.4299' ye='-11.0265' ze='151.641' xt='-20.4299' yt='-11.0265' 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' />
		<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' />
	</panel3d>
	<layout >
		<view type='0' name='Timer1' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAABwQAAN4CAAA' zoom='80' scrollx='123' scrolly='776' flags='0' />
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAABwQAAN4CAAA' zoom='75' scrollx='0' scrolly='112' flags='0' />
	</layout>
</document>
</root>
