©2005 GE Fanuc Automation, Inc. All Rights Reserved PACSystems Training Programmer’s Toolkit.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Introducing JavaScript
C Language.
Creating a Dialog-Based Comet Windows Program Brian Levantine.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
COSC 120 Computer Programming
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Exploring Office Grauer and Barber 1 Creating More Powerful Applications: Introduction to VBA(Wk9)
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
WaveMaker Visual AJAX Studio 4.0 Training Troubleshooting.
Module 1: Introduction to C# Module 2: Variables and Data Types
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training course describes how to configure the the C/C++ compiler options.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Using Visual Basic 6.0 to Create Web-Based Database Applications
Object Oriented Programming in C++ Dr. Hammadi Nait-Charif Media School Bournemouth University
chap13 Chapter 13 Programming in the Large.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 27 - Phone Book Application Introducing Multimedia.
Chapter 6: User-Defined Functions
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Our Environment We will exercise on Microsoft Visual C++ v.6 We will exercise on Microsoft Visual C++ v.6 because that is what we have in the univ. because.
Active-HDL Interfaces Debugging C Code Course 10.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Fundamental Programming: Fundamental Programming Introduction to C++
Introduction to Programming with RAPTOR
Module 6: Debugging a Windows CE Image.  Overview Debug Zones IDE Debug Setup IDE Debug Commands Platform Builder Integrated Kernel Debugger Other Debugging.
CECS 121 Test 1. Functions allow you to group program statements under one name C and C++ are case-sensitive so main(), MAIN(), and Main() are all different.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Programmable Logic Training Course HDL Editor
Writing a Run Time DLL The application loads the DLL using LoadLibrary() or LoadLibraryEx(). The standard search sequence is used by the operating system.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 3 – Inventory Application: Introducing Variables,
1 CSC2100B Data Structure Tutorial 1 Online Judge and C.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Functions Math library functions Function definition Function invocation Argument passing Scope of an variable Programming 1 DCT 1033.
A.Abhari CPS1251 Topic 2: C Overview C Language Elements Variable Declaration and Data Types Statement Execution C Program Layout Formatting Output Interactive.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
Overview of Compilation Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 2.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
A variable is a name for a value stored in memory.
User-Written Functions
Chapter 7: User-Defined Functions II
A bit of C programming Lecture 3 Uli Raich.
Key Ideas from day 1 slides
Microsoft Access Illustrated
Computer Science 210 Computer Organization
Exploring Microsoft Excel
Homework Applied for cs240? (If not, keep at it!) 8/10 Done with HW1?
Our Environment We will exercise on Microsoft Visual C++ v.6
Presentation transcript:

©2005 GE Fanuc Automation, Inc. All Rights Reserved PACSystems Training Programmer’s Toolkit

©2005 GE Fanuc Automation, Inc. All Rights Reserved  New 32 bit C-Programmer's Toolkit Overview  Series C-Toolkit vs. PACSystem RX7i C-Toolkit  Steps for Developing a C application for the RX7i  Steps for migrating an existing Series C-Toolkit application into PAC RX7i  Active Sessions  Demos  ‘Hands on’

©2005 GE Fanuc Automation, Inc. All Rights Reserved New 32 bit C-Programmer's Toolkit Overview New C-Toolkit supports:  C Blocks (Does not support C Programs)  C global, static and local/automatic variables  Retentive and non-retentive variables  Subset of Standard C Library functions  PLC Interface functions and macros which: - Access user memory - Carry out miscellaneous PLC functions such as service requests - Read/Write memory from some modules on the bus - Access and generate PLC faults

©2005 GE Fanuc Automation, Inc. All Rights Reserved Series C-Toolkit vs. PACSystem RX7i C-Toolkit Series functionality with the following changes...  PACSystem C-Toolkit uses 32 bit C code generation vs. 16 bit  C Blocks can be as large as all of 'user space' (10 MB) vs. 64K  Uses GNU C compiler vs. Microsoft Compiler  PLC Read/Write memory functions required instead of macros for writing to Discrete memory if overrides and transitions are to be respected  Set of non-standard C library routines (Microsoft specific) are not supported for this release  Changes to interface on some PLC C functions (ex. Bus read/write functions instead of VME read/write functions)

©2005 GE Fanuc Automation, Inc. All Rights Reserved Series C-Toolkit vs. PACSystem RX7i C-Toolkit Series functionality with the following changes... (cont.)  Serial Read/Write functions instead of printf function  Miscellaneous (retentive/non-retentive syntax, GefMain() start location, int type is 32 bit vs. 16 bit etc. )  C Standalone programs are not supported in this release.  C Debugger on PLC is not provided on RX7i 1 st release  Cygwin C Debugger available for PC debugging

©2005 GE Fanuc Automation, Inc. All Rights Reserved Steps for Developing a C application for the RX7i  Install C-Toolkit 2. Develop C Code for C Block 3. Compile C Code 4. Import C Block into Logic Developer PLC 5. Call C Block from LD Logic 6. Store and Execute C Block on the PLC

©2005 GE Fanuc Automation, Inc. All Rights Reserved Process Diagram

©2005 GE Fanuc Automation, Inc. All Rights Reserved Step 1 : Install the C-Toolkit

©2005 GE Fanuc Automation, Inc. All Rights Reserved Step 2 : Develop C Code for C Block 1. The user develops a C Block using an editor of choice (CodeWright, Microsoft Visual Studio, NotePad etc.). 2. In order to use the Target Library functions and macros, the user must use the following line at top of the C file: #include 3. In order to use the C Run-Time Library functions, the user must include one of more of the following files as appropriate at the top of the C file: #include /* Input/Output */ #include /* Math */ #include /* Math, Data Conversion, Search */ #include /* String Manipulation, Internationalization */ #include /* Time */ #include /* Character Classification and Conversion */ #include /* non-standard C functions provided for compatibility with the Only a small subset of functions are supported in Release 1 */

©2005 GE Fanuc Automation, Inc. All Rights Reserved 4. After including the appropriate header files, the user writes their C block using library calls as needed to implement the desired functionality. The user’s C Block file or set of C Block files must have one and only one function titled “GefMain” to act as the entry point. A short example is shown below: /* myCFile.c */ #include int status; int status2 = 1; char failMessage[] = “Failure in myCFile”; int failCount = 0; int GefMain(int *x1, int *y1) { if (*x1 != 0) { RW(10) = *x1; /*write x1 to %R10 as word */ return GEF_EXECUTION_OK; } else { status = GEF_EXECUTION_ERROR; status2 = failCount; failCount++; return status; } Step 2 : Develop C Code for C Block(cont.)

©2005 GE Fanuc Automation, Inc. All Rights Reserved Step 3 : Compile C Code After developing a C Block as described in the previous step, the C Block must be compiled to create a relocatable object file that can be loaded into the PLC. Open a DOS box either directly or by double clicking on the PACSystems(tm) C Toolkit icon on their desktop and then navigates to the project directory containing the C block file. For a C file called “myCFile” the user runs the compiler by typing in: compileCPACRX7i myCFile If there are errors or warnings, they are noted on the screen. The file is placed in a subdirectory under the user’s project directory called “plc” so that it is clear which file is intended for download to the PLC.

©2005 GE Fanuc Automation, Inc. All Rights Reserved Step 4 : Import C Block into Logic Developer PLC 1)Right click on the Program Blocks element under Logic. 2)Select Add C Block 3)Navigate to the location of the *.gefElf file and select the file 4)Access properties of the C Block to set up the correct number of input/output parameters. 5)Use a Call instruction in the ladder 6)Provide the name of the C Block to the Call instruction. 7)Provide reference memory locations for each of the inputs and outputs of the C Block.

©2005 GE Fanuc Automation, Inc. All Rights Reserved The input parameters to the main block (x1 and y1) are derived from the input/output parameters in the ladder program that calls the C Block. Input parameters are always passed as pointers. An example is shown below: For this example, x1 points to the memory location of %R1 and y1 points to the memory location of %R2. The least significant bit of the main function return value determines the output of the myCBlk CALL function block. Step 5 : Call C Block in LD Code

©2005 GE Fanuc Automation, Inc. All Rights Reserved Step 6 : Store and Execute C Block on the PLC Using the programmer to Run the C Block: 1) Go online with the PLC. 2) Store the program to the PLC 3) Put the PLC in Run mode 4) Enable the Call to the C Block

©2005 GE Fanuc Automation, Inc. All Rights Reserved Step 7 : Debugging C Blocks Two Options… On PLC  Use serial port write functions to output messages and data values at strategic points in the C Block.  Reserve reference memory locations as indicators of C Block operation On PC  Create C Test driver code that calls the C Block. For example: int main(int argc, char *argv[]) { initCBlock(); /* creates ref memory and initializes pointers to that memory*/ GefMain(&RB(8,0), &Ib(1000), &Mb(500)); /* calling main passing pointers to %R8, %I1000 and %M500 and passing a constant parameter */ return 0; }

©2005 GE Fanuc Automation, Inc. All Rights Reserved  Add code to the PLC C stub functions to simulate the desired PLC behavior.  Compile C Block for the PC using the following command: compileCDebugPACRX7i myCProgram  Run the Cygwin debugger using the following command: debugPACRX7i pc\myCProgram.exe This will bring up a Windows based debugger that allows setting break points, single step, view and change memory, etc.  The application can also be run at the DOS prompt with the following command: runPACRX7i pc\myCProgram.exe Debugging in this case would require the use of printf to indicate program flow and state. Step 7 : Debugging C Blocks On PC (cont.)

©2005 GE Fanuc Automation, Inc. All Rights Reserved Steps for migrating an existing Series C-Toolkit application into PAC RX7i 1) Change main() to GefMain(). 2) Analyze Discrete macros IB, QB, etc for cases where they write to user memory. Change these to their corresponding write function such as WritePlcByte(). If the macro reads from user memory, change the macro so that the second letter is lower case (for example IB() to Ib()) or use the appropriate read function (for ex. ReadPlcByte). 3) Analyze the use of pointers that could write to discrete user memory. For these cases, write to discrete user memory using the function PlcMemCopy.

©2005 GE Fanuc Automation, Inc. All Rights Reserved Steps for migrating an existing Series C-Toolkit application into PAC RX7i (cont.) 4)Convert any PLC C functions that have changed between the and RX7i (a table will be provided with user documentation) 5)Modify code that uses non-Standard C library functions to use Standard C library functions if possible or write code to do the same function. 6)Analyze code for cases where the application assumed uninitialized non- static variables were being set to 0 on a stop to run transition and add code to initialize these variables.

©2005 GE Fanuc Automation, Inc. All Rights Reserved Demo #include "copyright.h" /****************************************************************************** `ModuleName fahr_to_Celsius.c *******************************************************************************/ /* `IncludeFiles */ #include #include "PACRX7iPlc.h" /* Constants / #defines */ /* Structures and typedefs */ /* Declarations for Global variables */ /* Routines */ int GefMain (T_REAL32 *fahrenheitTemp, /* Input Param 1 */ T_REAL32 *celsiusTemp) /* Output Param 1 */ { /* C Block retrieves the Fahrenheit temperature to convert from */ /* the incoming parameter, and stores the calculated Celsius */ /* temperature in the output parameter. */ *celsiusTemp = (5.0/9.0) * (*fahrenheitTemp ); return GEF_EXECUTION_OK; }

©2005 GE Fanuc Automation, Inc. All Rights Reserved Demo compileCPACrx7i f_2_c

©2005 GE Fanuc Automation, Inc. All Rights Reserved #include "copyright.h" /****************************************************************************** `ModuleName ctkCBlockTest.c ` This file uses all C Run Time and Target Library functions supported ` by the C Toolkit to test that all the supported functions can ` be compiled. *******************************************************************************/ /* `IncludeFiles */ #include #include #include "PACRX7iPlc.h" /* Constants / #defines */ #define COOLANT_TEMP_HIGH_WARNING #define COOLEAN_TEMP_ERROR_CODE 1 /* Structures and typedefs */ /* Declarations for Global variables */ T_BOOLEAN coolantFaultLogged = FALSE; char coolantFaultString[] = "Coolant Temp too high."; /* Routines */ int GefMain (T_REAL32 *fahrenheitTemp, /* Input Param 1 */ T_REAL32 *coolantTemp, /* Input Param 2 */ T_REAL32 *celsiusTemp) /* Output Param 1 */ { Exercise

©2005 GE Fanuc Automation, Inc. All Rights Reserved T_WORD errorCode; T_INT32 funcCallResult; /* C Block retrieves the Fahrenheit temperature to convert from */ /* the incoming parameter, and stores the calculated Celsius */ /* temperature in the output parameter. */ *celsiusTemp = (5.0/9.0) * (*fahrenheitTemp ); /* Use some Macros to write to reference memory. */ RW(55) = 6943; AIW(1) = 2278; AQW(5) = 2278; /* Log a user specified application fault in the PLC fault table. */ if (*coolantTemp >= COOLANT_TEMP_HIGH_WARNING) { *coolantTemp = 0.0; if (!coolantFaultLogged) { errorCode = COOLEAN_TEMP_ERROR_CODE; funcCallResult = PLCC_gen_alarm (errorCode, coolantFaultString); coolantFaultLogged = TRUE; } return GEF_EXECUTION_OK; } Exercise