670 likes | 1.39k Views
SPiiPlus Training Class. Programming Environment. How to Program in ACSPL+?. ACSPL+ programs are written in simple ASCII text Can be opened and edited in any text editor Stored in *. prg or *. spi files (Note: *. spi files have checksum)
E N D
SPiiPlus Training Class Programming Environment
How to Program in ACSPL+? ACSPL+ programs are written in simple ASCII text • Can be opened and edited in any text editor • Stored in *.prg or *.spi files (Note: *.spi files have checksum) ACSPL+ programs are compiled directly on the controller or simulator • Controller compilation requires communications libraries or SPiiPlus MMI Application Studio • Simulator compilation requires SPiiPlus MMI Application Studio
SPiiPlus MMI Application Studio • Basic tool used for interacting with controllers or simulator • Free download • Contains many useful components • Communication terminal • Adjuster wizard (for motor setup) • Program manager • Many others • Program manager is the default tool used for programming ACSPL+
How to use Program Manager • To use program manager, first connect to simulator or controller • Find the workspace window • If you can’t find, click the view drop-down menu and select workspace window • If empty, right-click on workspace and add controller • If controller exists, right-click on controller and select properties
How to use Program Manager – Connect to Simulator • Switch to Simulator communication tab • Click Connect
How to use Program Manager – Connect to Controller via Serial • Switch to Serial communication tab • Select computer COM port connected to controller • Select Auto baud rate • Click Connect
How to use Program Manager – Connect to Controller via Ethernet • Switch to Ethernet communication tab • Specify IP address of controller • Use controller port 701 • Select ‘Network’ network type • Click Connect
How to use Program Manager – Add Program Manager • If the program manager is not in the workspace you need to add it • Right-click on controller • Select Add Component –> Application Development –> Program Manager
Program Manager Features Program manager includes many of the basic program writing and debugging tools • Save / Load programs to / from file • Save program to flash • Compile program • Run program • Step through program • Pause program • Add / remove breakpoints
Program Manager Features Save ACSPL+ program to flash Clear ACSPL+ program buffer Copy ACSPL+ program buffer Set ACSPL+ program buffer parameters Save ACSPL+ program to file on PC Set number of ACSPL+ program buffers to display Load ACSPL+ program from file on PC
Program Manager Features Run selected buffer(s) Pause selected buffer(s) Step through selected buffer(s) Stop selected buffer(s) Stop all buffers Remove all breakpoints from selected buffer(s) Compile selected buffer(s) Trigger scope on selected buffer(s) start Buffer Number Clear / erase selected buffer(s) Select buffer ACSPL+ program buffer status Open buffer Lines in ACSPL+ program buffer
Program Manager Features – Open a Buffer Different ways to open a buffer • Click on open file icon next to buffer • Double-click on buffer status field • Right-click on buffer status field and select Open Buffer
Program Manager Features – Write code in a buffer Writing code is as simple as writing in any programming editor • Line numbers are shown on left side • Copy / Paste / Cut ctrl+c / ctrl+v / ctrl+x • Undo / Redo ctrl+z / ctrl+shift+z • Find ctrl+f • Replace Icon only • Breakpoints ctrl+b • Tab indentation
Program Manager Features – Write code in a buffer Many options shown through right-click anywhere in program editor
Program Manager Features – Compile a Buffer Once you are done writing your buffer, the next step is to compile. • Before you compile, all code resides on your computer • Compiling will download the code to the controller’s working memory and have the controller try to compile the code Many ways to compile • Right-click in program editor and select compile • Ctrl+F5 • Compile icon in program editor • Select buffer in program manager and click on compile icon • Right-click on buffer status field in program manager and select compile • Run buffer! (forces compile before running)
Program Manager Features – Compile a Buffer Select buffer with check box and left-click on Compile icon Right-click and select Compile Left-click on Compile icon Place focus on buffer and hit ctrl+F5
Program Manager Features – Close a Buffer When you are done editing and compiling a buffer, you can close it to free up the working environment. Many ways to close • Click X on buffer window • Click on the open buffer icon in program manager • Right-click on buffer in workspace and select close • Note: closing the buffer keeps it within the workspace for quick access, removing it will close it and also remove it from the workspace
Program Manager Features – Close a Buffer Left-click on X icon Right-click on buffer in workspace and select close Left-click on file open icon in program manager
Program Manager Features – Run a Buffer When you are finally ready to run the buffer, there are many ways to do so: • F5 key • Click on Run icon in buffer • Right-click in buffer and select run • Right-click on buffer status in program manager and select run • Select buffer in program manager and hit run icon • Open communication terminal and type “START (buffer number), (start line)” Or “#$X”, with $ being the buffer number
Program Manager Features – Run a Buffer Left-click Run icon Right-click on buffer and select Run Focus on buffer and hit F5 Type start commands into communication terminal Select buffer in program manager and click Run icon Right-click on buffer status in program manager and select run
Program Manager Features – Stop a Buffer If a buffer is running and you want to stop it, there are many ways to do so: • Shift+F5 • Click on Stop icon in buffer • Right click in buffer and select stop • Right-click on buffer status in program manager and select stop • Select buffer in program manager and hit stop icon • Click Stop All Buffers icon – will stop all buffers • Open communication terminal and type “STOP (buffer number)” Or “STOPALL” – will stop all buffers • Click Estop button - will stop all buffers and disable all motors
Program Manager Features – Stop a Buffer Click to stop all buffers and disable all motors Left-click Stop icon Right-click on buffer and select Stop Focus on buffer and hit Shift+ F5 Left-click Stop All Buffers icon Select buffer in program manager and click Stop icon Type stop commands into communication terminal Right-click on buffer status in program manager and select stop
Program Manager Features – Save Buffer to Flash After writing, compiling, and running your code it only resides in the controller’s working memory • Will be lost if controller restarts or loses power • No local storage held on computer A few ways to save to flash for non-volatile storage: • Click on Save To Flash icon in program manager • Right-click on controller in workspace and select Save to Flash
Program Manager Features – Save Buffer to Flash Right-click on controller in workspace and select Save to Flash Click Save to Flash icon in program manager
Program Manager Features – Save Buffer to Flash When saving to flash there are different options • ACSPL+ Program Buffers • System and Axis Configuration Parameters • SP Programs • User Arrays For now, only need to save the ACSPL+ Program Buffers
Program Manager Features – Save Buffer to Flash Select buffers to save Left-click Save
Program Manager Features – Save Buffer to File It is also good practice tosave the programs to your computer for local storage. Two ways: • Program Manager -> Save To File • Saves ACSPL+ programs as *.prg file • Application Wizard -> Save Application from Controller • Saves ACSPL+ programs as *.spi file • Can also include the System and Axis Configuration Parameters, SP Programs, and User Arrays
Program Manager Features – Save Buffer to File – Program Manager Browse for file location on computer to save to Left-click Save to File icon Left-click Save
Program Manager Features – Save Buffer to File – Application Wizard To use application wizard, it needs to be added to workspace • Right click on controller in workspace • Add component -> Application Development -> Application Wizard
Program Manager Features – Save Buffer to File – Application Wizard Select Save Application from Controller Click Next
Program Manager Features – Save Buffer to File – Application Wizard Select buffers to save Left-click Save
Program Manager Features – Save Buffer to File – Application Wizard Browse for file location on computer to save to Select buffers to save Left-click Next
Program Manager Features – Load Buffer from File When you have a program buffer (or multiple buffers) saved to file and need to load it, there are multiple ways to do so • *.prg file • Loaded using program manager • *.spi file • Loaded using application wizard • Other • Loaded by copying ASCII text into program buffer
Program Manager Features – Load Buffer from File – Program Manager Browse for file location For every buffer in file, select buffer to load to Left-click Load from File icon
Program Manager Features – Load Buffer from File – Application Wizard Select Load Application from Controller Click Next
Program Manager Features – Load Buffer from File – Application Wizard Browse for file on computer to load from Select buffers to load Left-click Next
Program Manager Features – Load Buffer from File – Other Open in your favorite text editor Copy text from favorite editor and paste into program buffer
Program Manager Features – Clear Code from a Buffer When code already exists in a buffer, it can be cleared in a few ways: • Click on clear buffer icon in program manager • Right-click on buffer status in program manager and select Clear Buffer • Select all text in program buffer, delete, and re-compile empty buffer • Reset controller / Factory Defaults – will clear all user files (buffers, configuration parameters, user arrays, custom SP programs) and should only be done if application is backed up on PC.
Program Manager Features – Clear Code from a Buffer Select all text in buffer, delete, and re-compile Right-click on controller in workspace and select Factory Defaults Click Clear Buffer(s) and select buffer Select buffer and click Clear Selected Buffer
ACSPL+ Program Debugging Once a program is written and needs to be tested, there are multiple tools that can be used for program debugging. • Breakpoints and Program Stepping • Communication Terminal • Scope
ACSPL+ Program Debugging – Breakpoints and Program Stepping Breakpoints and program stepping allow a program to be executed and paused in pre-defined ways. • Breakpoints will pause program execution at line where the breakpoint occurs. • User can either continue program execution, or step through the program • Program stepping will only execute one controller cycles worth of commands every step
ACSPL+ Program Debugging – Breakpoints and Program Stepping Run / Continue execution Add / Remove breakpoints Step program Breakpoints
ACSPL+ Program Debugging – Using Communication Terminal The communication terminal is a powerful tool used for debugging. • Display messages sent from the program buffer • ACSPL+ command DISP sends messages to be displayed (similar to C printf command) • “Show Messages” must be selected in terminal • Query global and local variables • ?Variable • Set global variables • Variable = 1 • Start / Stop / Pause / Resume program buffers
ACSPL+ Program Debugging – Using Communication Terminal DISP command similar to C print Set variables with “=“ Query variables with “?” Show Messages must be selected to show DISP messages
ACSPL+ Program Debugging – Using Scope The scope can be used to plot any firmware or user-defined ACSPL+ variable • Scope has 3 different display methods • Variable vs. Time • Variable vs. Variable (X-Y) • Variable vs. Frequency (FFT) • Scope has 3 different triggering modes • Single: Trigger once based on a pre-defined trigger • Normal: Trigger based on pre-defined triggering criteria • Auto: Trigger continuously • Can display up to 8 variables simultaneously • Can sample ACSPL+ variables at rates up to controller cycle rate (1 or 2 kHz) • Can sample 2 SP variables at rates up to Servo Processor rate (20 kHz)
ACSPL+ Program Debugging – Using Scope Total Acquisition Time Sample Time Triggering Mode Display Method Channel Variables Variable Scale
ACSPL+ Program Debugging – Using Scope Trigger Scope (Scope in single mode)