BRX Technical Training Interrupts Interrupts BX 10 6
BRX Technical Training Interrupts
Interrupts � BX 10 ◦ ◦ ◦ 6 discrete IN (all high-speed) 4 discrete OUT (2 high-speed) No analog IN No analog OUT No Ethernet port ◦ ◦ ◦ 6 discrete IN (all high-speed) 4 discrete OUT (2 high-speed) 1 analog IN 1 analog OUT Ethernet port � BX 10 E
Interrupts � BX 18 ◦ ◦ ◦ 10 discrete IN (all high-speed) 8 discrete OUT (4 high-speed) No analog IN No analog OUT No Ethernet port ◦ ◦ ◦ 10 discrete IN (all high-speed) 8 discrete OUT (4 high-speed) 1 analog IN 1 analog OUT Ethernet port � BX 18 E
Interrupts � BX 36 ◦ ◦ ◦ 20 discrete IN (10 high-speed) 16 discrete OUT (8 high-speed) No analog IN No analog OUT No Ethernet port ◦ ◦ ◦ 20 discrete IN (10 high-speed) 16 discrete OUT (8 high-speed) 4 analog IN 2 analog OUT Ethernet port � BX 36 E
Interrupts (Why? ) � � � Inputs are normally read at top of scan Outputs are normally written to at bottom of scan If input changes during scan, it is not seen by logic until the next scan Read Inputs Interrupts allow an input to be seen during scan Interrupts allow an output to be changed during scan 3 types of triggers for generating interrupts: Code Blocks ◦ Most of the time this is OK because scan times are so fast for industrial world � � � ◦ Events (up to 4) ◦ Timers (up to 4) ◦ Match registers (up to 4) � � Each interrupt calls an ISR Only on-board inputs can be used ◦ Doesn’t have to be high-speed inputs Write Outputs
Interrupts (Input Events) � Uses onboard input(s) to trigger interrupt � Input Event: ◦ Expansion I/O cannot be used LEVELS (all must be true): - If X 13 is LOW � Levels - AND X 14 is HIGH � High - AND X 15 is HIGH � Low - AND X 19 is HIGH � None or up to 19 …THEN… � Levels are AND’d (i. e. all have to be true) Read as: ◦ Event My. ISR gets invoked if X 13 is � Edges (!X 13) and X 14 is high AND � Rising low If all LEVELS are true then… is high(any andis. X 19 is high � Falling X 15 EDGES true) either a rising is � Either - and If then there’s a rising edge on X 0 seenthere’s on X 0 a(p. X 0), a falling � 1 or up -to 20 OR fallingoredge on X 1 (n. X 1) or either � Edges are -OR’d (i. e. any one will OR there’s any edge on X 2 trigger interrupt) edge on X 2 (n. X 2 | p. X 2) … THEN… ◦ Name of ISR that is. Call called My. ISR ◦ Prequalifiers
Interrupts (Timer) � Uses hardware 1µsec timer � Timer Mode ◦ Recurrent ◦ One Shot � Timer Duration � Name of ISR that is called ◦ 1 to 2, 147, 483, 647 µsec (35 min, 47. 483647 sec)
Interrupts (Timer Example) � � Test example to compare between 4 ways of doing a 1 -second timer that toggles an output Each method will utilize Tickus() function in MATH to calculate the ON time of the toggle ◦ TMR Instruction to toggle Y 0 � D 1 = current measured time in µsec � D 2 = current difference from 1 second � D 3 = maximum difference from 1 second ◦ ENTASK instruction to toggle Y 1 � D 5 = current measured time in µsec � D 6 = current difference from 1 second � D 7 = maximum difference from 1 second ◦ t$1 Second to toggle Y 2 � D 9 = current measured time in µsec � D 10 = current difference from 1 second � D 11 = maximum difference from 1 second ◦ Interrupt Timer to toggle Y 3 � D 13 = current measured time in µsec � D 14 = current difference from 1 second � D 15 = maximum difference from 1 second
Interrupts (Timer Example) � 1 -sec TMR Instruction = $Main T 0 resets itself PONOFF toggles Y 0 every 1 second When Y 0 comes ON store TICKus() in D 0 When Y 0 goes OFF store difference between TICKus() in D 0 into D 1 Store the maximum difference into D 3 Calculate the difference from 1 second (1, 000 µsec), store in D 2
Interrupts (Timer Example) � ENTASK (enables Toggle_Y 1)
Interrupts (Timer Example) � Toggle_Y 1 Task
Interrupts (Timer Example) � $t 1 Second
Interrupts (Timer Example) � Configuration Recurrent Timer with a duration of 1 second (1, 000 µsec) that executes Toggle_Y 3 ISR
Interrupts (Timer Example) � ISR Toggle_Y 3
Interrupts (Timer Example) � Typical Accuracy TMR varies by 583µsec User Task varies by 579µsec $t 1 Second varies by 578µsec Timed Interrupt varies only 2µsec!
Interrupts (Timer Example) D 14 gray line’s standard deviation is negligible
Interrupts (Match Registers) � Monitors high-speed I/O register values ◦ Ctr/Tmr Accumulator (1, 2, 3) ◦ Pulse Output Position (1, 2, 3) � Comparison ◦ =, !=, >, >=, <, <= ◦ …to an integer value (signed double-word) � Name of ISR that is called
Interrupts (Match Registers Example) � Will compare the ability of ladder logic comparative contact VS Match Register interrupt, to see a specific (=; equal to) value in a high-speed position count ◦ ◦ ◦ Axis 1 = virtual axis D 0 = random new position (0 to 1, 500, 000) 1, 000 = position in which to toggle output Y 6 = output for Match Register Interrupt to toggle Y 7 = output for ladder logic comparative contact to toggle
Interrupts (Match Registers Example) � Configuration
Interrupts (Match Registers Example) � $Main Ladder comparative Configures Axis 1 as a virtual axis Calculate a random new position Move to the new position which might cross position 1, 000
Interrupts (Match Registers Example) � ISR = My. Match Toggles Y 6 immediately
Interrupts (Match Registers Example) � Typical Results ◦ Ladder logic Y 7 never toggles Match Register Interrupt always happens when current position exactly equals 1, 000 Ladder logic compare never happens Position 1, 000 in Green
Interrupts (Instructions) � INTSUSPEND “Suspend Interrupts” ◦ Edge triggered – suspend interrupts when input leg goes from OFF to ON ◦ Power flow enabled – suspend interrupts while the input leg is ON � INTRESUME “Resume Interrupts” ◦ Clear any Pending interrupts �If multiple interrupts occur during suspension, they “want” to run after resumption & will run in priority order; this selection makes sure they don’t run at all ◦ Edge triggered ◦ Power flow enabled Code Blocks No Interrupts
Interrupts (Instructions) � INTCONFIG “Configure Interrupt” ◦ Allows interrupts to be configured just like the System Configuration dialog ◦ 3 tabs for configuring (Input Event, Timer, Match Register) ◦ Edge triggered or Power flow enabled ◦ Can use <Load from System Config> button to pull data in from what is already configured there ◦ Can use variables in the instruction whereas variables cannot be used in the System Configuration
Interrupts (INTCONFIG Example) � Will generate a pulse with a 3 -second period but with a variable duty cycle: ◦ D 0 = Duty Cycle in percent ◦ D 1 = ON time of pulse ◦ D 2 = OFF time of pulse
Interrupts (INTCONFIG Example) & the ISR (My. Pulse) � D 0 = Duty. Cycle (in percent) � Configuration Based on Duty Cycle (D 0) ON & OFF times are calculated When Y 6 is OFF reconfigure Timer interrupt for ON time When Y 6 is ON reconfigure Timer interrupt for OFF time Timer Interrupt configuration just kicks things off 2 seconds Toggle Y 6 immediately (2, 000 µsec) after Program-to-Run transition
Interrupts (INTCONFIG Example) � Results � D 0 = Duty. Cycle 10% Duty Cycle (D 0) 3 -second period ON time = 0. 3 sec OFF time = 2. 7 sec
- Slides: 27