SPiiPlus Training Class

Slides:



Advertisements
Similar presentations
SPiiPlus Training Class
Advertisements

SPiiPlus Training Class
Chapter 3 Basic Input/Output
SPiiPlus Training Class
© 2013 SPiiPlus Training Class Homing. © 2013 Homing Homing is a very important aspect for almost any motion system. With a wide variety of mechanical.
© 2013 SPiiPlus Training Class Multi-Axis Motion 1.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Microprocessor and Microcontroller
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
CS0004: Introduction to Programming Repetition – Do Loops.
Input/Output Management and Disk Scheduling
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
1 - buttons Click “Step Forward” to execute one line of the program. Click “Reset” to start over. “Play,” “Stop,” and “Step Back” are disabled in this.
System Calls 1.
Weston Schreiber & Joshua Gabrielse Robotics Summer Training Programming #1: EasyC Basics.
MICROPROCESSOR INPUT/OUTPUT
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Date: File:PRO1_12E.1 SIMATIC S7 Siemens AG All rights reserved. Information and Training Center Knowledge for Automation Troubleshooting.
Chapter 10 Advanced Programming, PLC Interfacing, and Troubleshooting
CPS120: Introduction to Computer Science Lecture 14 Functions.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Embedded Programming and Robotics Lesson 11 Arduino Interrupts 1.
Calling Procedures C calling conventions. Outline Procedures Procedure call mechanism Passing parameters Local variable storage C-Style procedures Recursion.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Anti-Sway Function Anti-Sway Block Confidential Property of Schneider Electric Schneider Electric.
1 Computer System Overview Chapter 1. 2 Operating System Exploits the hardware resources of one or more processors Provides a set of services to system.
SPiiPlus Training Class
SPiiPlus Training Class
Chapter 4: Control Structures I (Selection)
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
VAB™ for INFINITY Tutorial
User-Written Functions
Programming and File Management Part 2
BRX Technical Training
Topics Introduction to Repetition Structures
UNIT – Microcontroller.
RL78 POC and LVD © 2010 Renesas Electronics Corporation. All rights reserved.
Computer Architecture
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 5: Loops and Files.
Scripts & Functions Scripts and functions are contained in .m-files
Interrupt.
Stack Data Structure, Reverse Polish Notation, Homework 7
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Conditinoal Constructs Review
Arrays, For loop While loop Do while loop
More Selections BIS1523 – Lecture 9.
Unit 2 Programming.
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Program Control Instructions.
Conditinoal Constructs Review
Exception Handling Oo28.
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
BRX Technical Training
Lecture 9: TI MSP430 Interrupts & Low Power Modes
Faculty of Computer Science & Information System
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Control Structures Part 1
Programmable Logic Controllers (PLCs)
Microsoft Visual Basic 2005 BASICS
Functions continued.
Chapter 2: Input, Processing, and Output
Computer Organization and Assembly Language
CMSC 202 Exceptions 2nd Lecture.
Switch Case Structures
Presentation transcript:

SPiiPlus Training Class Autoroutines, Subroutines and Function Calls

Structured Applications Every programmer has his/her own way of structuring their application. While there is no wrong way of creating this structure in ACSPL+, there are consequences that must be considered. The important programming structures in ACSPL+ are: Subroutines / Function calls Autoroutines / Interrupts

Subroutines / Function Calls Subroutines calls are supported in ACSPL+ using the CALL…RET commands. Function calls are not explicitly supported, but can be created by using subroutines and local variables. Using subroutines / function calls can be very helpful for organizing a program. Labels provide high level description of routine Routines are easily reused Routines can be removed from application by simply commenting out the CALL command

Subroutines / Function Calls Subroutines / function calls have certain limitations that should be considered when using them. CALL always takes 1 controller cycle to execute (regardless if in a BLOCK…END statement) RET can return in the same controller cycle A buffer program can only call a subroutine that exists in the same buffer program Parameters cannot be directly passed into / out of a subroutine (must explicitly define variables)

Subroutines / Function Calls Basic Example: A linear axis has 3 different modes of operation: normal mode, homing mode, and scanning mode. Normal Mode Maximum velocity, acceleration, and jerk parameters are used Homing Mode For safety, lower velocity, acceleration, jerk and current limits (XCURI, XCURV) are used Scanning Mode Low velocity is used Subroutines can be used to switch between the different modes.

Subroutines / Function Calls GLOBAL INT mode; mode = 0 GLOBAL INT X; X = 0 STOP Switch_Modes: IF ( mode = 0 ) ! Normal mode CALL Normal_Mode ELSEIF ( mode = 1 ) ! Homing mode CALL Homing_Mode ELSEIF ( mode = 2 ) ! Scanning mode CALL Scanning_Mode END Normal_Mode: VEL(X) = 1000 ACC(X) = 10000 DEC(X) = 10000 JERK(X) = 100000 XCURI(X) = 50 XCURV(X) = 100 RET Homing_Mode: VEL(X) = 10 ACC(X) = 1000 DEC(X) = 1000 JERK(X) = 10000 XCURI(X) = 25 XCURV(X) = 25 Scanning_Mode: VEL(X) = 1

Subroutines / Function Calls Basic Example: An application requires an axis to scan between two points (P0 and P1) at a constant velocity. In order to make sure the axis is at a constant velocity, the move needs to include a ramp up and ramp down displacement. A routine is used that is passed the two positions, velocity, acceleration, deceleration, and calculates the ramp up and ramp down displacements.

Subroutines / Function Calls ! Global variables STOP GLOBAL REAL P0, P1 Calc_Displacement: ! Local Variables ! Assume 2nd order calculation REAL flVel REAL flAcc ! Calculate Ramp Up REAL flDec t = flVel / flAcc REAL flRampUp, flRampDown flRampUp = 0.5 * flAcc * pow(t, 2) REAL t ! Calculate Ramp Down ! Set function inputs t = flVel / flDec flVel = VEL(0) flRampDown = 0.5 * flAcc * pow(t, 2) flAcc = ACC(0) RET flDec = DEC(0) CALL Calc_Displacement DISP "Ramp up displacement = %f", flRampUp DISP "Ramp down displacement = %f", flRampDown

Autoroutines / Interrupts Autoroutines / Interrupts are supported in ACSPL+ using the ON…RET commands. Autoroutines are very useful when trying to write a routine that will automatically trigger when some condition becomes true. Examples include: Fault Handling Interlocks PLC algorithms Logging

Autoroutines / Interrupts Autoroutines can reside in any program buffer, but have a unique way in which they work. Autoroutines are never directly executed (you do not CALL an autoroutine) Autoroutines trigger based on a conditional expression. If edge-triggered (expression goes from false to true), the autoroutine body will be executed An autoroutine is ready to trigger as soon as the buffer is compiled Multiple autoroutines can reside in a single buffer Autoroutines share local variables with the program buffer in which it resides

Autoroutines / Interrupts Autoroutines / interrupts have certain limitations that should be considered when using them. If an autoroutine is triggered and the program buffer it resides in is executing, the buffer will pause until the autoroutine finishes If an autoroutine is executing in a buffer, and another autoroutine in the same buffer is triggered, it must wait for the first to complete If an autoroutine is executed, it will not execute again until it is edge triggered (condition goes false and then true again)

Autoroutines / Interrupts When working with autoroutines, it is sometimes necessary to disable or remove them. To disable all autoroutines in a program buffer, you set PFLAGS().#NOAUTO (bit 0). To re-enable them, you clear PFLAGS().#NOAUTO To remove an autoroutine, you need to re-compile the buffer with the code removed or commented out.

Autoroutines / Interrupts Basic Example: A conveyor system has two sensors used to detect when a product is present. If either of the sensors are on, a single output is used to inform an upstream PLC.

Autoroutines / Interrupts STOP ! Rising edge trigger ON ( (IN(0).0 = 1) | (IN(0).1 = 1) ); BLOCK OUT(0).0 = 1 END; RET ! Falling edge trigger ON ^( (IN(0).0 = 1) | (IN(0).1 = 1) ); BLOCK OUT(0).0 = 0

ACSPL+ Programming Example: 1 When error-mapping is used on the controller with the CONNECT function, the HALT command should be used for the limit switches instead of the KILL command. Write custom autoroutines for the left and right limit switches on axis 1 to HALT the axis whenever the autoroutine is triggered, and to only allow motion out of the limit.

ACSPL+ Programming Example: 2 An operator terminal has two push-buttons used for diagnostic purposes. Whenever the user pushes the first button (IN(0).0), the current state and motion parameters of axis 1 (FPOS(1), MST(1), VEL(1), ACC(1), DEC(1) and JERK(1)) are logged in an array. Whenever the user pushes the second button (IN(0).1), the array is saved to flash memory. Write custom autoroutines to handle these requirements.

ACSPL+ Programming Example: 3 A system has a safety interrupt (IN(0).0) such that whenever it is on, axis 1 cannot be commanded to move. Write a custom autoroutine to handle this requirement.