Home

Internet TRiLOGI - Department of Electrical and Computer Engineering

image

Contents

1. 100 000 pulse s2 28 2x20 To return a string that represents the decimal value of the numeric argument n If the second format is used then this function will return a string of d number of characters AS STRS 1234 BS STRS 1234 7 AS will contain the string 1234 BS will contain the string 001234 STRCMP A4S B Purpose Perform a comparison between its two string expressions A and BS IF AS and BS are equals STRCMP will return a O if AS is of lower order in ASCII table order than BS the function will return a negative value Otherwise it returns a positive value Examples IF STRCMP AS BS 0 THEN STEPMOVE 1 1000 1 ENDIF Comments IF AS and BS are the same then turn on the stepper motor 1 STRLWR A3 11 32 Purpose To return a string which is an all lowercase copy of AS Examples BS cs Comments The second example shows how to convert a string to all lower case STRLWRS AS Z STRLWRS C STRUPR3 A Purpose To return a string which is an all uppercase copy of AS Examples B STRUPRS A C STRUPR C Comments The second example shows how to convert a string to upper case TESTBIT v n Purpose To return the logic state of bit n of the variable v The function returns 1 if the bit is 1 otherwise it returns O n is an integer of value between 0 and 15 v may be any integer variable however if v is a 32 bit integer T
2. Where xx depends on reading of A D 1 which is returned by function ADC 1 Full scale A D is 4096 A D range 0 to 4096 Temperature O to 50 C C1lk 1 0 setLCD 1 1 Temp Check Display at at Column 1 Linel Custom Function 1 setLCD 2 1 Sitting Rm STR ADC 1 50 4096 2 CHR 223 C Comments Every one second the special bit Clk 1 0s closes and activates Function 1 Within the Custom Function 1 ADC 1 reads the A D converter 1 and converts it into degrees The integer value is then converted into a two digit string using the STR function and concatenated to the rest of the text string for display using the SETLCD command Simulation of the display string to built in LCD is supported on TRiLOGI Version 6 x When in Simulation mode press lt V gt key to view the Special Variables and the messages will appear in an LCD Simulation window 2 Setting Timer Counter Set Values S V Using LCD Display If you have an LCD display then you can use two push buttons inputs to change the Set Values SV of any selected timers or Counters with visual feedback Al 5 Assignment e Press push button Increase increment the SV of timer 1 by 0 5s The upper limit for timer 1 SV is 10s SV lt 100 e Press push button Decrease decrement the SV of timer 1 by 0 5s e Press test button turns ON output 1 for a duration given by timer 1 and then turns it OFF Increase F
3. When this statement is executed the PLC will not properly resoond to any host link commands sent to it except the command PWXXxx Xx which must contains the same string xxxx xx not more than 19 characters as defined in the SETPASSWORD command All other commands will receive a PWER response indicating a password error state Once the correct password has been accepted the PLC will work as normal and respond to all host link Commands Execution of PW host link command without any string will put the password lock back in force to prevent unauthorized access SETPASSWORD I love TRiLOGI When using TRILOGI the software will automatically prompt you to enter the password string if it encounters a PLC which has been password locked Note that the password is case sensitive Password locked PLC cannot be accessed by older version of TRILOGI This feature is mainly used to protect an unattended PLC which is linked to an auto answer modem Without password protection anybody can dial in with a TLServer or TL41 exe and have full control of the PLC which may be a serious security problem Within the PLC software you may also use a timer fo periodically re arm the PLC with this command for maximum protection You can also use different passwords for different time of the day or a set of rotating passwords to provide greater security SETPROTOCOL ch mode Purpose A TIOOM series PLC automatically s
4. When entering an integer constant using the hexadecimal prefix amp H it is important to note the sign of the intended value and extend the signs to most significant bit of the 32 bit expression E g to represent a decimal number 1234 the hexadecimal representation must be amp HFFFFFB2E and not amp HFB2E Assuming that a 16 bit variable DM 1 contains the number 1234 and a comparison statement is made to check if the number is 1234 The 32 bit hexadecimal representation of constant 1234 is amp HFFFFFB2E If you enter the constant as 16 bit representation amp HFB2E as follow IF DM 1 lt gt SHFB2E CALL 5 TBASIC translates the number amp HFB2E into a 32 bit decimal number 64302 which when compared to the number 1234 contained in DM 1 will yield a False result which is an error The following are the correct representation Q IF DM 1 lt gt 1234 CALL 5 ENDIF b IF DM 1 lt gt amp HFFFFFB2E CALL 5 ENDIF 2 Integer Variables Variables are memory locations used for storing data for later use All Integer variables used in TBASIC are GLOBAL variables this means that all these variables are shared and accessible from every custom function NEW With Trilogi version 6 2 and above you can now attach comments to any variable name of any length to make program easier to read See section 5 Integer Variable Comments below for more details Specific examples with each variable type ar
5. lt gt lt gt js the NOT EQUAL operator These operators only work for integef use the STRCMP fucntion see STRI NOTEQUAL 2 3 4 5 6 7 8 9 A B c ID E F Select either item D CusFn Custom Function or E dCusF Diff Up Custom Func to create a CusFn You will be required to enter the selected custom function number from 1 to 256 Note that CusFn created using RE dCusF Diff Up Custom Func is a Differentiated Up instruction This means that the function will be executed only once every time when its execution condition goes from OFF to ON this is also Known as one shot action Nothing will happen when its execution condition goes from ON to OFF 9 8 On the other hand using D CusFn Custom Function means that the CusFn will be executed every scan as long as its execution condition is ON This is often not desirable and the coil created using this menu item will be highlighted in RED color to serve as an alarm to programmer You will probably find that you will use the differentiated form dCusF far more frequently Periodic Execution of a Custom Function There are many situations when you need the PLC to periodically monitor an event or perform an operation For example to monitor the temperature reading from a probe or to check the real time clock for the scheduled time and to continuously display changing variables on the LCD display It is not efficie
6. 11 12 After entering label names for Inputs 1 to 4 move to the Output table by pressing the right cursor key or by clicking on the right arrow button Enter all the output and relay label names in their respective I O tables We will discuss the Timer table in the next step Important Notes a You can shift the Items in the I O table up or down or insert a new label between two adjacent pre defined labels Simply press the lt Ins gt key or Right Click the mouse button to pop up the Shift I O menu which allows you to shift the selected I O However please note that if you shift the I O down the last entry in the I O table e g Input 256 will be lost b In Trilogi 6 2 and up shifting of Custom Function Label names will now shift the function content along with the label name In previous versions of Trilogi shifting of the I O label would not shift the function content therefore making it untenable to use I O label shift to reorganize custom functions Warnings are provided if such an action were to result in overwriting of an existing Custom function c TRILOGI Version 6 2 and up allows I O label names of up to 16 characters However if you wish to keep compatibility with Version 5 x to 6 1x you should use no more than 10 characters to define the I O names Timer table has an extra column Set Value located to the right of the Label Name column Label Name Set Value EEE Duration 100
7. 4 Force READMODBUS amp READMB2 to use function 04 to communicate with Modbus slaves 3 default Force READMODBUS amp READMB2 to use function 03 to communicate with Modbus slaves This command works on firmware r49 amp above k Allow the PLC to change its own ID to k 0 to 255 This command works on firmware r49 amp above O default Interrupt CusFn not run during I O refresh 1 allow Interrupt CusFn to run during I O refresh shorter interrupt latency STATUS n Purpose Return the status of various system operations Returned value STATUS 1 0 Normal power on reset 1 Reset by Watch Dog Timer WDT STATUS 2 0 READMODBUS or WRITEMODBUS failure 1 READMODBUS or WRITEMODBUS successful STATUS 8 PLC s ID address stored in EEPROM for host communication Examples IF STATUS 2 MODBUS READ WRITE OK ENDIF STEPCOUNT ch 11 28 Purpose While the stepper motor controller is sending out pulses this function can be used to monitor the number of stepper pulses sent to the Stepper Motor Channel ch since the execution of the last STEPMOVE command Hence this function returns the relative number of step moves This function can also be used to measure the physical size of a part if we use the stepper motor to drive a sensor and use the STEPSTOP Command and the interrupt input to halt the stepper motor when the edges are detected The physical size is then co
8. In that case you can only access the PLC using the TL6 application program 4 4 Chapter 5 Ladder Logic Programming Tutorial I Your Assignment Creating Your First Ladder Logic Program In this tutorial we would like to create a simple program as shown below EE i TRILOGI Version 6 20 C TRILOGI TL 6 usr samplesWemo PC6 Sour E BR File Edit Controller Simulate Circuit Help Stop Run il i2 RLY Duration Int Manual Seq1 ri j AYseq Cik 0 5s Manya Outi l OUT outs cue Out2 OUT Out OUT Out3 OUT Out OUT Out4 OUT Outs OUT Seq1 4 EventCount fa UE Simply follow the steps below to create your first ladder logic circuit 1 Open pull down File menu and select New 5 1 You should now be in the Browse mode of the logic editor The vertical line on the left end of the screen is the power line The cursor is at the position where you can key in your very first ladder logic Before we commence the circuit creation let us define the I Os to be used in this program The following I Os are required 1 0 Labels Inputs Start Stop Manual Step Outputs Out Out2 Outs Relays gt Run Timers Duration Sequencer Seq Open up the I O label editing Window by pressing lt F2 gt Although you can also click on Edit menu and select the item I O Table to achieve the same we strongly recommend learning the hot key F2 as it is often mu
9. Tha TI CAninr will alaca tha fia aftar it rnnniine than Ann af service tag lt gt from the PLC and it will in turn send a lt OK gt string to the PLC to acknowledge that the WRITE request has been completed successfully It is up to your PLC program to check for the lt OK gt tag to determine if the service it requested have been completed successfully 2 Append data E g To append the time of an event to a file name to file testAppend ixt execute the following statements in a custom function when the event take place Format lt APPEND PRINT 1 lt APPEND testAppend ixt gt _ Append data request filename gt PRINT 1 Event Time TIME 1 sTIME 2 TIME 3 ee oar PRINT 1 A A ae a eyes PRINT 1 lt gt End of Service request e f the file does not exist a new file will be created Otherwise the PLC s real time clock data in the format nh mmiss and the value of A will be appended at the end of the file testAppend txt every time the above statements are executed The TLServer will close the file after it receives the end of service tag lt gt from the PLC and it will in turn send a lt OK gt tag to the PLC to acknowledge that the APPEND request has been successfully completed It is uo to your PLC program to check for the lt OK gt tag to determine if it the service it requested have been completed successfully E g To send data to an email addres
10. section 12 8 for more detail or if the battery is not installed The special bit is called RTC Er and can be obtained from the special Bits I O Table The RIC Err contact can be used to activate an alarm of some kind 8 8 Ill Special Functions During ladder circuit editing when you click on the or icon to create a special function coil a special function menu will pop up as shown below 1 Select a Function DNCtr Decrement Rev Counter RSCtr Reset Counter UpCctr Increment Rev Counter AVseq Advance Sequencer RSseq Reset Sequencer StepN Set Sequencer to Step N Latch Latching Relay Output Clear Clear Latched Relay an oe WN Fe ILock Interlock Begin ILof Interlock End ADIFU Differentiate Up ADIFD Differentiate Down CusFn Custom Function dCusF Diff Up Custom Funcs MaRST Master Reset 8 9 A B c D E E Reversible Counter Functions DNctr Upctr and RSctr The DNetr UPctr and RSctr functions work together to implement reversible Counter functions on any of the 128 counters supported by TRILOGI The ordinary down counter created by clicking on the nicon essentially decrements the counter value by 1 from the Set Value SV and will stop when its count becomes zero Unlike the ordinary down counter a reversible counter is a circular counter that changes the counter present value PV between O and
11. 3 What Happens when a Client is behind a firewall but the TLServer has direct link to the Internet If the client PC is located within a corporate Intranet and protected by a firewall then there are very limited means for the client to access the Internet outside of the firewall Note that NOT all PCs within the LAN have access to the Internet Whether a PC has access to the Internet or not is decided by your company s System Administrator Even if a particular client PC does have access to the Internet because you are able to use a browser to visit Google it doesn t mean that the PC has a direct connection to the Internet What may actually happen is that the network administrator could have setup a Proxy Server that will intercept your client PC s request to link to the Internet The proxy server is the one that actually has a direct link to the Internet It acts on behalf of the client within the Intranet to process HTTP connection to the Internet and passes the response data to back to the client So how does the proxy server determine whether a network packet is meant for the Internet and not meant for another workstation within the Intranet It determines it by examining the port number that the packet attempts to connect to If a connection is made to the well known HTTP port which is 80 it will be handled by the proxy server If you use a port number such as 9080 default TLServer port address it may think that the connection i
12. Enter the name Seq at the label column for Counter 1 Press lt Enter gt and the text entry field will be opened at the Set Value column For now let s enter a preset value of 4 for Seql We have now completed defining the I Os timers and counters Press the lt ESC gt key to close the counter or other tables Note that not all labels need to be defined before programming You may create the label names any time during circuit creation by pressing the lt F2 gt hotkey We are ready to create Circuit 1 as shown below Start Stop Run RLY Run Duration IMi With the circuit pointer red color triangle at Circuit 1 press the lt Spacebar gt to enter the Ladder Edit mode You can also enter the circuit edit mode by double clicking at Circuit 1 i TRiLOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help Circati A HHJH H dd m d eng Geni Ft 4 EEN vo Table Open CusFn 5 4 19 20 Once you enter the Ladder Edit mode a row of ladder element icons appear along the top of the main TRILOGI window just below the pull down menu The following is a description of each item A yellow color highlight bar which you can move to select an element in the ladder circuit will appear lt 1 gt Left click to insert a normally open series contact lt 2 gt Right click to insert a normally closed series contact lt 3 gt Left click to insert a N O paralle
13. e g A 5000 DM 99 5678 OUTPUT 2 amp HO1AB BS Welcome to TBASIC The variable will take up the new value as soon as it is entered and if the execution condition for any CusFn is ON the simulator will process the newly entered data immediately and produce the new outcomes This gives you greater flexibility in controlling the simulation process Decimal and Hexadecimal Representation All the numeric data shown in the Special Variables window are by default displayed in decimal notation You can display the number in hexadecimal format by clicking on the Hex button or by pressing the lt H gt key Press the lt D gt key if you wish to switch back to the decimal format This feature is very useful for programmers who are familiar with 9 14 hexadecimal representation of a binary number The Hex button will become the Dec button when you enter the Hex display mode V On Line Monitoring of TBASIC Variables If you execute the On Line Monitoring Control command from the Controller pull down menu TRILOGI Version 6 will continuously query the PLC for the values of all their internal variables These variables values will be updated in real time in the View Special Variables window You may also alter the value of any variables in the PLC using the Edit Variable window by clicking on the Edit button at the View xxx Variables window This ability of TRILOGI to provide instant and full visibility of
14. you have made to a circuit without going through all the undo steps Undo _ lt Ctrl Z gt Undo the last changes made to a ladder circuit TRILOGI automatically stores the last 10 edited steps so you could execute undo several times to restore the circuit back to its original shape Cut Circuit lt Ctrl X gt You can remove a number of circuits from the current ladder program and store them temporarily in the clipboard for pasting into another part of this ladder program or into another file altogether In other words it lets you move a block of circuits from one part of the ladder program to another part or into another file Once you execute the Cut Circuit command a prompt box as shown below will appear You have to specify the range of the circuits you wish to cut and press the Yes button to remove them from the ladder program Cut Ladder Circuits to Clipboard Please note that you can t UNDO a Cut Circuit operation Copy Circuit Ctrl C You can copy a block of circuits from the current ladder program and store them into the clipboard for pasting into another part of this ladder program or into another ladder program file altogether The range 7 9 dialog box similar to Cut Circuit will appear for you to enter the range of circuit to Copy Paste Circuit lt Ctrl V gt When you execute this command the block of ladder circuit that you Cut or Copy into the clipboard will be pasted just before the curre
15. 15 0 15 0 15 0 INPUT 3 INPUT 2 INPUT 1 OUTPUT 3 OUTPUT 2 OUTPUT 1 seteenees RELAY 3 RELAY 2 RELAY 1 TIMERBIT 3 TIMERBIT 2 TIMERBIT 1 CTRBIT 3 CTRBIT 2 CTRBIT 1 Timers and Counters Present Values The present values PV of the 128 timers and 256 counters in the PLC can be accessed directly as system variables timerPV 1 to timerPV 128 for timers present value ctrPV 1 to ctrPV 256 for counters present value DATE and TIME Variables The PLC s Real Time Clock RTC derived date and time can be accessed via variables DATE 1 to DATE 4 and TIME 1 to TIME 3 respectively as shown in the following table Date Time YEAR DATE 1 HOUR TIME 1 MONTH DATE 2 MINUTES TIME 2 DAY DATE 3 SECOND TIME 3 Day of Weal DATE 4 DATE 1 may contain four digits e g 1998 2003 etc DATE 4 1 for Monday 2 for Tuesday 7 for Sunday High Speed Counters The M series and F series PLCs support High Soeed Counters HSC that can be used to capture high frequency incoming pulses from positional feedback encoder These high speed counters are accessible by CusFn using the variables HSCPV 1 to HSCPV 8 All HSCPV n are 32 bit integer variables Note that TRILOGI does not simulate high speed counter operations Integer operators Operators perform mathematical or logical operations on data TBASIC supports the following integer operators i Assignment Operator An integer variable A to Z DM an
16. 4096 188 Convert to Cx1d IF S T gt 15 SETIO OUT1 Cold Air conditioning ON ELSE CLRIO OUT1 if T is hotter by 1 5 C ENDIF IF S T lt 15 SETBIT OUTPUT 1 1 lt Heater ON ELSE CLRBIT OUTPUT 1 1 if T is colder by 1 5 C ENDIF Comments Since TRILOGI Version 6 x does not support floating point computation in order to handle decimal value 1 5 C in this application we use a unit integer to represent 0 1 quantity All temperature readings are x10 times Hence 16 0 C is represented by 160 10 0 C is represented by 100 This method known as fixed point computation is quite commonly used in industrial control program Al 10 7 Closed Loop PID Control of Heating Process A D 5 E g Implementing Closed loop Digital Control with PID computation function PID Controller A D 1 PID Controller Transfer Function K G s Kp Kps 1 Proportional Band 1 Kp Proportional Gain K Integral Gain Integral Time Constant Assignment Read desired set point temperature fom a potentiometer connected to A D 5 S with temperature range between 50 C 200 C Measure the process temperature from a thermocouple signal conditioner attached to A D 1 T Compute the Error S T Apply Proportional Integral Derivative P I D algorithm to compute output X Apply output X to Digital to Analog converter D A 1 to control a variable position valve that feed fuel to
17. 6 1 gf Uninstall Internet TRILOGI 6 1 fa Internet TRILOGI 6 an InterVideo WinDVD gt FPA iTunes gt 2 You can also open My Computer and open the folder C TRILOGI TIL6 3 a then double click on the file TL62 jar to start TRILOGI application If JRE has been properly installed the TL62 jar file will be recognized by Windows to represent executable Java program and it will run immediately Note In the same folder you will also find the file TLServer3 1 jar which is the actual jar file for TLServer The third alternative is to run the program from DOS command line First run the MS DOS prompt also called Command Prompt in Windows XP and then navigate to the directory C TRILOGI IL6 At the directory enter the following command line C TRiLOGI TL6 gt java jar TL62 jar or C TRiLOGI TL6 gt java Duser language zh jar TL62 jar The TL6 BAT batch file located at the c TRiLOGI TL6 folder contains the first form so you can double click TL6 bat to start the program too This method of starting TRILOGI application has an advantage in that it opens the Java Console window which can be useful because system errors and exceptions are normally reported via the Java Console This can give clues to the reason of failure You can also start TLServer by running the tlserver bat file 4 1 NOTE The main window window size is memorized in the config tl file The second form forces the program t
18. Flag Norm ON You can make use of this flag if you need to keep something permanently ON regardless of any input conditions This is because with the exception of Interlock Off function ILoff a coil or a special function is not allowed to connect directly to the power line the vertical line on the left end of the ladder diagram If you need to permanently enable a coil consider using the Normally ON bit from the Special Bits menu as follow Light OUT 4 First Scan Pulse 1st Scan This special bit will only be turned ON in the very first scan time of the ladder program After that it will be permanently turned OFF This is useful if you need to initialize certain conditions at the beginning When the program is transferred to the PLC this bit will only be ON when the PLC is first powered up or after it has been reset 5 Real Time Clock Error RTC Err M Series PLC This bit is turned ON if the M series PLC does not have battery backed MX RTC option and the clock has been reset due to power failure or watchdog timer reset This gives warning to applications that require a correct real world time such as scheduled ON OFF operation that the clock data is incorrect hence enabling corrective action to be taken F Series PLC Since the F Series PLCs do not use the MX RTC and instead have an on board batter backed RTC the RTC Error event occurs if the RTC is corrupted or damaged see the F Series User Manual 8 7
19. Interlock ILock The Interlock ILock and Interlock Off ILoff functions work together to control an entire section of ladder circuits If the execution condition of a ILock function is ON the program will be executed as normal If the execution condition of ILock is OFF the program elements between the ILock and ILoff will behave as follow All output coils are turned OFF All timers are reset to inactive All counters retain their present values Latched relays by Latch function are not affected ADIFU and dDIFD functions are not executed All other functions are not executed OQA00Q An Interlock section is equivalent to a master control relay controlling a number of sub branches as follow Master _ Lock Master LSI z CR1 p Ta 10min TIM Interlock Section overhe Using Interlock Functions Equivalent Circuit Note that ILoff is the only function that does not need to be energized by other program elements When you use one or more ILock functions there must be at least one ILoff function before the 8 12 6 7 end of the program Otherwise the compiler will warn you for the missing ILoff The logic simulator always clears the Interlock at the end of the scan if you omit the ILoff function You can program a second or third level Interlock within an Interlock section using a few ILock functions However you only need to program one ILoff function for th
20. Internet TRILOGI Home Page Mozilla Firefox File Edit View Go Bookmarks Tools Help TRiPLC Q Banks Kalla DigitalRS Client Portal Others Internet TRILOGI Version 6 0 Copyright c 2001 2005 Triangle Research International Inc Menu Item Description Run the Internet TRILOGI directly off your browser No Local 5 The browser will now issue a HTTP request to the TLServer Since no filename has been specified the default file in the web server root directory index html is loaded This HTML file is written in Javascript to provide some other options To start the TRILOGI as an applet select the appropriate option and the TL Applet jar file will be loaded from the TLServer into your browser for execution Note The TLServer s root directory is not the same as the PC s root directory In TLServer the root directory is actually at C TRiLOGI TL6 public This is the directory where the index html ANd TL6Applet jar file are stored and these files are served to the web browser when you enter the TLServer s IP Address as mentioned above Visitors have no access to the 4 3 PC s file directory above the server s root directory so the content of your other PC files will not be at risk of being exposed to visitors to TLServer Disabling TRILOGI Applet If you want to prevent visitors to TLServer from loading TRILOGI Applet at all just remove the TL6Applet jar file from the directory C TRiLOGI TL6 public
21. J 100 to 1 STEP 10 DM I DM J NEXT NEXT FOR NEXT loops may be nested i e a FOR NEXT loop may be placed within the context of another FOR NEXT loop When loops are nested each loop must have a unique variable name as ifs counter The NEXT statement for the inside loop must appear before that for the outside loop Each Loop must have a separate NEXT statement to mark the end of the loop WHILE ENDWHILE GetTimerSV n Purpose Return the Set Value S V of the Counter n or Timer n n should be between 1 and the maximum number of timers and counters in your PLC Note See Also Although the present values P V of timers and counters n can be accessed directly as variables TimerPV n amp CirPV n the Set Values however can only be obtained by these two functions SetCtrSV SetTimerSV GETHIGH16 v Purpose Examples See Also GOTO n Purpose Examples Comments HEX 7 HEX n d Purpose Examples Comments See Also This function returns the upper 16 bit of a 32 bit integer variable v This can be used to break the value of a 32 bit integer data or variable into two 16 bit values so that they can be saved to the EEPROM or to the DM n DM 1 GetHIGH16 A save_EEP GetHIGH16 amp H12345678 10 SETHIGH16 To branch unconditionally out of the normal program sequence to a specified line with label n within the present Custom Function The destination line mu
22. Loading Local File Look In C usr J Administrator J samples File Name Files of Type TRILOGI Version 6 Files Cancel You should open the samples folder and select any files with PC6 extension for viewing Loading Local File Look In C samples v a oi FileService_Modem C XServer R Call pc6 C ADC pc6 clock zh PC6 Analog Timer PC6 Clock PC6 Bi Blank pc6 Bi ClockPulses pc6 File Name Files of Type TRILOGI Version 6 Files Cancel There are also sub folders within the samples folder where sample programs that relate to a particular topic or device are stored such as those relates to using the MD HMI We strongly encourage you to open these example programs to see how these programs are structured Most of these programs can be run in the simulator except those that involve communication with other devices or high speed counters Display Alphanumeric Messages on built in LCD Display M series PLC such as the TIOOMD 1616 supports built in LCD display port that allows low cost connection to industry standard LCD display module Al 4 For such PLC programming of the LCD display is via the SETLCD statement supported by TBASIC language Assignment Every 1 second display a message as follow Temp Check Sitting Rm xx C
23. Networking Issues A2 1 Appendix 3 PLC to Modem Communication Setup 1 Modem Connection A3 2 Communication Speed A3 2 3 Software and Programming A3 3 Chapter 1 Internet TRILOGI 6 x Installation Guide Introduction to the TRILOGI Program TRILOGI is a trademark name used by Triangle Research International to describe its family of Ladder and Ladder BASIC program editor compiler simulator and program up loader software The original TRILOGI program was written to run under the Microsoft MS DOS operating system and today it is still available for programming TRi s range of PLCs such as the E10 the H series the M series and the F series PLCs In fact we have included all the DOS version of TRILOGI software in the root directory of your CD ROM free of charge within the zip file DOS TRILOGI V4 13 zip The Internet TRILOGI 5 x and 6 x client server suites are written to run under all currently available 32 bit Microsoft Windows operating systems as Windows 98 Me NT 2000 XP and Vista Vista 64 bit is compatible with TRILOGI 6 14 and up Internet TRILOGI is written in 100 pure Java hence in theory it could someday be ported to other O S platforms such as Apple OSX or Linux However at the moment only the following PC Windows O S have been tested Windows 98 ME NT 2000 XP and Vista The SetupIL 6 exe file can only run under the PC based Windows O S The main improvement in the new Internet TRILOGI versi
24. ONCE when the contact Seq1 4 goes from OFF to ON 5 10 The Cust Func table will Popup and you should click on the first custom function area on the table Since we have not previously defined a name for this custom function TRILOGI will prompt you to define a name for the chosen function Please enter EventCount in the text field as follow Define Label Name Cust Func 2 EventCount Note For custom function only it is possible to create a custom function without defining its label name If you leave the text field empty the program will give the custom function a default name Fn_ n where n is the function number which varies between 1 and 256 42 With the cursor still in Ladder Edit mode right click on the newly created dCusF coil and a custom function editor window will open up for you to enter the TBASIC language statements that define what this function is supposed to do when it is run Please enter the following statements K Custom Function 1 EventCount TBR Control 7 xX X 1 Initial value of X 0 s n SEMO 1 1 Cycle Count 4STR X find End AN 1 EventCount x Rename Function Order Sales 1 877 TRI PLCS 1 877 874 7527 lt Select K d Inquiry 8 30am to 5 00pm PST Mon Fri J aia Undo Abort J A toate baeas parea ae 43 In the above custom function we are using a TBASIC command called SETLCD t
25. PLC the strings to be written to EEP must not contain any of the following characters ASCII O 00 ASCII 10 OA and ASCII 13 OD Click on this button to write both the integer and string EEP buffer contents to the PLC s EEPROM TRILOGI will prompt you to confirm the write action and if will also prompt you to login to a TLServer if it is not already connected to one Get INTEGER EEP data from PLC Get STRING EEPdata from PLC You can click on one of these two buttons to read a range of data EEPROM as 16 bit integer or as an ASCII string into their respective EEP Buffer The program will attempt to login to a TLServer if it is not already connected It will check the maximum EEPROM addresses available on the target PLC and then prompt you to enter the range of integer data you wish to read up to the maximum available 7 17 Retrieve Integer EEPROM Data from PLC Get Integer Data The data read from the PLC are stored into the EEP buffer in comma delimited format as described above Integer EEPROM data can also be paenenenenensscssesensssers captured in hexadecimal format if you check the M HexData check box You can edit or append to the captured data in the buffer and then write them back to the data EEPROM area or save as a hard disk file Save Buffer to File You can save both the Integer and String EEP Buffers content to a single text file with the default extension csv The data are stored
26. PLC s via its serial port before the commands here can be successfully executed Note that TLServer can be running on the same computer that TRILOGI is running on using localhost IP 127 0 0 1 or on another computer in the same local area network or anywhere in the world with an Internet connection The experience is identical regardless of where the TLServer and hence the PLC is situated Note In order to maintain compatibility with the Ethernet XServer device which is not Unicode aware the TL6 Application still uses standard ASCII encoding when communicating with the PLCs This is unlike opening or saving TRILOGI program files to the TLServer that would require Unicode network stream as mentioned in the File menu help page As a result the TL6 application can work with TLServer version 3 x as well as older TLServer 1 x and 2 x when it is only for the purpose of programming controlling and monitoring the PLC and not to read write TRILOGI file If there is no existing connection made to the TLServer then execution of any command in this menu will always bring up the password dialog for you to enter the Username Password as well as the IP address port of the TLServer You must be positively authenticated before you are able to login to the TLServer See Log In to TLServer for detailed explanation of the Username Password Dialog box Once you have login to the TLServer see explanation of each function below Select Controller
27. Sensor E g Implementing Closed loop Digital Control with PID computation function E 10000 ADC 2 20 11 13 A PIDcompute 5 E setPWM 4 A 8000 100 Comments The set point value is 10000 units the feedback value is read from ADC channel 2 and then multiplied by 20 to convert scale it to the same unit as the parameter to be controlled PID computation channel 5 assume somewhere in the program a PlDdef for channel 5 has been executed before is then used to compute the desired controller output value using the error signal set point feedback value ADC 2 x 20 The desired output stored in variable A is then added to the offset value 8000 and then scaled down by a factor of 100 before being sent out physically via PWM Channel 4 Important In actual implementation use a clock pulse such as 0 1s 0 5s or 1s etc to periodically activate the PIDcompute function so that digital control in discrete time can be implemented The PID sampling period depends on the time constant of the system For very slow response processes such as the cooking temperature of a large body of water the time constant is very large and even slower than 1 0 seconds clock may be sufficient Do not use unnecessarily short sampling time because it increases computation time and slows down overall performance of the system PiIDdef ch Imt P I D Purpose To set up the parameters for a Proportional Integral and De
28. TLServer If you replace the RS485 driver IC by a 1 8 power type you can link up to 256 PLCs to a single TLServer for programming and monitoring Terminating resistor Host Computer with t1oomp T100Mx T28H Relay RS 485 OF RS485 RS485 RS485 M series PLC Networking Issues The networking method used by the PC running the TLServer as well as how the TRILOGI client software accesses the TLServer will have impact on the configuration of both the TLServer and the TRILOGI client We will consider various scenarios below A2 1 TLServer and TRILOGI Client On Same PC When both TRILOGI client and TLServer runs on the same PC we call this a localhost access and you can use the IP Address 127 0 01 9080 to login to TLServer Localhost access is always available regardless of whether this PC has any network connection to LAN or the Internet Note that If your PC has no network connection then TLServer will report this localhost IP address on its front panel However if the PC is connected to the Internet or a LAN you will see different IP addresses Remember that even if TLServer does not report 127 0 0 1 it is always available for localhost programming You can either run the TRILOGI Application directly or you can open up your web browser and key in the following URL http 127 0 0 1 9080 In the latter case you are running TRILOGI as an applet that is loaded from the TLServer Internet T
29. TLServer will send an lt OK gt tag to the PLC to acknowledge that the EMAIL request has been successfully completed It is up to your PLC program to check for the lt OK gt tag to determine if it the service it requested has been processed This service allows the PLC to request the TLServer fo open a text file and upload its content to the PLC This may be useful for loading some previously saved parameters Upon receiving this command and if the specified filename is successfully opened the TLServer will begin sending all the ASCII characters contained in the text file to the PLC Note that line breaks in a text file are sent to the PLC as CR character only and not as a CR LF pair As such your PLC program can easily use the INPUTS 1 command to read in all the CR terminated text string one string at a time and then interpret or convert the data as necessary After sending out the last byte in the data file to the PLC the TLServer will send a CR terminated acknowledgement string lt OK gt to the PLC to signal that the READ command has been properly completed This service allows the PLC to get the Real Time Clock data of the TLServer i e the PC in which the TLServer runs on The type of data is indicated in the Date n and Time n parameter which correspond to the DATE n and TIME n system variables in TBASIC ie Date 1 year Date 2 month Date 3 day Date 4 DayofWeek 3 17 a Date
30. a 0 which is clearly wrong The timer 1 s Present Value P V register is loaded with this number which will start the timer countdown In the next logic rung the timer coil connected to the latched OUT1 is necessary to prevent the timer from resetting itself But It will not overwrite the PV with its own Set Value SV which will not be used at all in this case This is because the previous ladder program has already started the timer with a value determined by the position of the potentiometer knob Al 7 4 Motion Control of Stepper Motor The M series PLC can generate pulses to feed to stepper motor driver The maximum speed acceleration deceleration and total number of pulses to generate are definable using TBASIC Both absolute positioning commands and relative move commands are supported Assignment e A DEFHOME input define the current location as home position e Press the START input to begin Indexing the stepper motor to position at 1500 2000 4500 and 9000 steps with respect to the HOME position Pause for 1 seconds at each position Return to home at the end of the cycle e Maximum speed 5000 pps Acceleration 100 steps to full soeed DEFHOME Fn_ 10 a O START Fn_ 11 s SO RLY5 Tlsec PA ti Tlsec Fn_ 20 Custom Function 10 STEPHOME 1 Define the HOME position for stepper 1 Custom Function 11 DM 1 1500 DM 2 2000 DM 3 4500 Store index position DM 4 9000 D
31. a pop up window that displays all the parameters of the motion path STEPMOVE 1 5000 10 Send out 5000 pulses on channel 1 and at the end of motion turn ON relay 10 STEPMOVEABS STEPCOUNT STEPCOUNTABS STEPSPEED STEPSTOP STEPHOME 11 30 STEPMOVEABS ch position r Purpose See Also This new command allows you to move the stepper motor ch to an absolute position indicated by the position parameter At the end of the move the relay r will be turned ON Position can be between 2 to 2 i e about 2 x 10 The absolute position is calculated with respect to the last move from the HOME position Ihe HOME position is set when the STEPHOME command is executed The speed and acceleration profile are determined by the STEPSPEED command as in the original command set This command automatically computes the number of pulses and direction required to move the stepper motor to the new position with respect to the current location The current location can be determined at any time by the STEPCOUNTABS function Once STEPMOVEABS command is executed re execution of this command or the STEPMOVE command will have no effect until the entire motion is completed or aborted by the STEPSTOP command STEPCOUNTABS STEPHOME STEPSPEED STEPMOVE STEPSTOP STEPCOUNT STEPSTOP ch Purpose Examples Important See Also To abort a stepper channel ch which is in motion due to exceptional circu
32. be possible to access the TLServer via the public Internet since the firewall will block any attempts to access a PC inside the LAN There are two possible ways to overcome this 1 Consult your System Administrator to configure a Network Address Translator that will assign you a public IP Address that will be mapped to the local workstation that runs the TLServer 2 If yourneed to provide connectivity from the Internet is only temporary e g allowing your contractor to fix a software bug it may be easier to use a Modem and dial up to an ISP when the need arises Once the connection is no longer needed just hang up the modem However before you do this please check with your company s System Administrator to make sure that you are not violating the security policy If that is a problem you may consider using a standalone notebook computer or PC i e not connected to the LAN to make the dial up connection which provides temporary Internet connectivity for the TLServer and hence the PLCs but will not compromise the security of your corporate Intranet Home Networking Type Routers If your workstation shares an Internet connection via a low cost NAT router these are getting very popular nowadays with home networking suppliers such as Linksys NetGear etc your TRILOGI client should not have much problem accessing a remote TLServer since these routers typically do not forbid your workstation from making direct outgoing connection t
33. ch mode SETPWM n x y SETSYSTEM n data STATUS n STEPCOUNT ch STEPCOUNTABS ch STEPHOME ch STEPMOVE ch count r STEPMOVEABS ch position r STEPSTOP ch STEPSPEED ch pps acc STRS n STRS n d STRCMP A BS STRLWRS A 11 10 11 10 11 10 11 11 11 11 11 12 11 12 11 13 11 13 11 14 11 15 11 15 11 16 11 16 11 17 11 18 11 18 11 19 11 19 11 19 11 20 11 20 11 22 11 22 11 22 11 23 11 23 11 23 11 24 11 24 11 25 11 25 11 26 11 27 11 28 11 29 11 29 11 29 11 29 11 31 11 31 11 31 11 32 11 32 11 33 70 STRUPRS A 11 33 71 TESTBIT v 7 11 33 72 TESTIO labelname 11 33 73 TOGGLEIO labelname 11 33 74 VAL x 11 33 75 WHILE ENDWHILE 11 34 76 WRITEMODBUS ch DevicelD address data 11 34 77 WRITEMB2 ch ID addr var count 11 35 Appendix 1 Application Notes amp Programming Examples I Important Notes to Programmers of TRILOGI Version 5 x Al 1 ll TRILOGI Sample programs Al 3 1 Display Alohanumeric Messages on built in LCD Display Al 4 2 Setting Timer Counter Set Values S V Using LCD Display AI1 5 3 Using a Potentiometer As An Analog Timer Al 7 4 Motion Control of Stepper Motor Al 8 5 Activate Events at Scheduled Date and Time Al 9 6 HVAC Heating Ventilation and Air Conditioning Control A1 10 7 Closed Loop PID Control of Heating Process Al 1 Appendix 2 PLC amp PC Hardware Setup and Configuration I PLC to PC Connection A2 ll
34. contact The contents in the table are not meant to be edited at this moment Scroll to the Input table and click onthe label name Start and a normally open contact will be created at Circuit 1 5 5 KS i TRiLOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help Circuit 1 PSE IYR GES 32 6 Frio nig AF Cae gt Me OTable Open CusFn 21 22 23 If you observe the highlight bar carefully you will notice a dark green color square at the right end of the highlight This indicates the insertion location where a series contact will be attached You can change the insertion location to the left or the right of the highlight bar by pressing the lt SHIFT gt key Next create the contact RUN which is parallel to the Start contact by left clicking on the icon The I O table will appear again Scroll to the Relay table and select the RUN relay To insert the normally closed Stop contact in series with the Start and Run contacts you need to move the highlight bar to the junction of the Start and Run contact First click on the Start contact to select it Then click on the gt icon to move the highlight bar to the junction as follow lt i TRILOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help Next right click on the icon It will change into yellow color normally closed contact as shown in the above diagram You are now inserting a normally close
35. device for the correct LRC and the slave address The status of the operation can be checked by the user program by testing the STATUS 2 function which will return a 0 if there is any error or if the slave device is not present READMODBUS STATUS 2 NETCMD ch ID addr var count Applicable only to M firmware r44 or higher Think of this as the multi word version of WRITEMODBUS command ch PLC COMM port number Ito 8 using Modbus ASCII or 11to 18 using Modbus RTU ID Device ID of the MODBUS slave device 1 to 255 addr Zero offset address of the holding register in the MODBUS slave device starting from O 40001 var the starting variable in the master whose data is to be sent out may be a DM or any system variable count number of variables to send max 16 in M PLC WRITEMB2 13 5 101 DM 10 8 The PLC will use MODBUS RTU protocol via its Comm port 3 to write 8 words of qata from DM 11 to DM 17 to the slave MODBUS device with ID 05 and into it s register offset address 101 to 108 in MODBUS term these refer to the 40102 to 40109 holding registers The command automatically checks the response string received from the slave device for the correct slave address CRC16 Like READMODBUS command the status of this operation can be checked by the user program by testing the STATUS 2 function READMB2 WRITEMODBUS STATUS 2 11 35 Appendix 1 Application Notes amp Progr
36. in comma delimited format described above with Integer data being save first then followed by the string data The comma delimited format makes it very easy for a spreadsheet program such as MS Excel to import the data into the spreadsheet for further processing You can also use MS Excel to generate data that are to be written to the EEPROM and then save the file as CSV file which can then be imported by EEPROM Manager using the Load from File into Buffer button EEPROM Manager Applications a Using EEPROM Manager it is now possible to pre load the PLC s data EEPROM either as 16 bit integer or ASCII strings with pre defined content so that they can be used by the PLC program This is very convenient for implementing a lookup table or to define a large number of ASCII text string constants to be used for LCD display or communication without taking up too much program memory b If you use the PLC s data EEPROM for data logging it is now possible to retrieved the saved data from the PLC and write it to the hard disk as a comma delimited text file which can then be imported into a spreadsheet or database program for further actions C Dansa If you ever need to replace a PLC that logs data to its data EEPROM area you now can also use the EEPROM Manager to retrieve all the 7 18 data EEPROM content from one PLC and transfer them to the replacement PLC so that the replacement PLC will work identically to t
37. lt Ctrl Il gt The only editable field is the ID field You have to enter the ID address in hexadecimal notation 00 to FF This command allows you to select another PLC that is connected to the same TLServer usually via RS485 multi drop connection but with a different ID for on line monitoring or program transfer Connect Disconnect to Server Use this command to login to the TLServer only if you have no intention to perform other controller commands You may find that you seldom need to use this command since running the On Line Monitoring or Program Transfer commands will also let you login to the TLServer if you have not yet done so However once you are connected this command changes into Disconnect from Server and this is the only way for you to log out of the currently connected TLServer so that you can use the 7 13 Username Password dialog box to login as a different user or to login to another TLServer of a different IP Address port number 3 On Line Monitoring lt Ctrl M gt See description of On Line Monitoring in Chapter 5 page 5 16 4 Program Transfer to PLC lt Ctrl T gt This command is only available if your login username is assigned the access level of a Programmer If your login is restricted to either a User or Visitor this command is disabled from the Controller s menu It will be enabled again after you disconnect from the server You can use this command to transfer your TRILOGI ladder TBA
38. n gt Time 1 hour Time 2 minute Time 3 second lt gt For full synchronization use the lt READ RTC gt tag which returns the values of the Date 1 Date 2 Date 3 Date 4 Time 1 Time 2 Time 3 in 7 CR terminated ASCII strings where n 1 2 3 4 lt READ Time m gt lt gt Upon receiving this command the TLServer will immediately where m 1 2 3 send the relevant clock calendar data as CR terminated ASCIl string s to the PLC Your PLC program can easily use the INPUTS 1 command to read in the data and convert them into integers using the VAL command Note that unlike the READ file service the TLServer does not send lt OK gt string after performing the READ RTC service 6 Get IP Address This command allows the PLC to query the TLServer s IP address Upon receiving this command the TLServer will send Format the following response string SIR If successful xxx xxx Xxx Xxx NNNN IP address port of Xserver If error occurred ERR description of error This command does not require a lt gt to close the tag 7 Connect to Remote TLServer or XServer using NETCMD Format lt CONNECT IP address port of TLServer or XServer gt username string password string TLServer replies with lt CONNECTED gt if successful or ERR if error encountered host link command 1 TLServer send the host link command to remote TLserver or Xserver a
39. name from the CusFn table which is part of the I O Table Each TRILOGI file can contain a maximum of 256 custom functions Each custom function will be opened in its own window The custom function number and the optional label name will be displayed on the Title of the Custom Function editor window K Custom Function 1 IF_COMPARISON Control Example use of multiple IF THEN ELSE PONGE pi Find Find All Each IF statement must have an ENDIF ELSE is optional A INPUTS 1 VAL A 1 IF_COMPARISON IF A gt O THEN PRINT 3 Value entered A is greater tha Rename Function DMN 1 4 10 x E Select Keyword Order Sales 1 877 TRI PLCS 1 877 874 7527 Undo Abort Inquiry 8 30am to 5 00pm PST Aon Fri gt NOTE This is a new and improved custom function editor For a full description of its features see the TBasic Introduction page and go to the 2 Custom Function Editor section Clear Custom Functions This command allows you to select a range of custom functions whose content you want completely cleared You will be prompted to select the range of custom functions to erase Note that this action is not undo able 7 12 nitin ladan batin iiias Controller Menu All commands in this menu are for communication with the PLCs via the TLServer Hence the TLServer must be actively running and connected to the
40. of ladder circuits were to work simultaneously In line with the typical Ladder Logic programming rules a CusFn may appear only once within the ladder diagram regardless of whether it appears in the normal or differentiated form A compilation warning will occur if a CusFn appears at more than one circuit but you are given the option to override it to give you more flexibility in your programming A CusFn may be CALLed as a subroutine by any other CusFn and there is no restriction placed on the number of repeated CALL of a CusFn by more than one CusFn A CusFn may also modify the logic states of an I O element or the value of internal timers and counters using its powerful TBASIC commands such as SetBit ClrBit The compiler however will not alarm the user that a CusFn may inadvertently alter the logic state of an I O already controlled by some other ladder circuit The programmer must therefore handle this power and flexibility offered by the TBASIC based custom functions with greater care It is important to prevent conflicting output conditions due to an I O being controlled or modified at more than one place within a logic scan The net result is that the logic state of the I O appears to be in different states at different parts of the ladder circuit This could lead to spooky outcomes that may be difficult to trace and debug 9 10 3 Interrupt Service CusFn A CusFn may also serve as an Interrupt Service Routine which
41. of 34 Fl otal E gt RUN Step Manual Manual Next we want to insert the special bit CIk 0 5s ETIT m to the left of the Manual contact Press the lt SHIFT gt key to move the insertion point to the left end of the highlight bar as shown above Then left click on the HE tlcon to create a normally open contact Scroll the I O table to the Special Bits table and select the item 0 5s Clock The parallel branch would have been completed by now 4 Special Bits gt gt Label Name 1 min Clock RTC Error 5 8 34 35 36 Note The Special Bit table comprises some clock pulses and some other special purpose bits These include the eight built in clock pulses in the system with periods ranging from 0 01s to 1 minute Built in clock pulses are useful if you need a time base to create for example a flashing light A contact such as Clk 0 1s will automatically turn itself ON for 0 05s and then OFF for another 0 05s and then ON again resulting in a series of clock pulses of period 0 1 second Next move the highlight bar to the right end junction of the parallel circuits using the cursor keys or the gt icon You can also try to move the highlight cursor to the junction by clicking on the junction itself as follow KS j TRiLOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help onnea RRS RUN Step Manual Clk 0 5s Manual Now click on the icon to insert
42. program The end users DO NOT need to install the TRILOGI or the Java JRE in order to use the TL5 Uploader program so that makes it more flexible for you to distribute self upgrade for the end users The TL5 Uploader program can be installed by first unzipping the InstallTL5Uploader zip file obtained by emailing to support tri plc com and then run the Setup exe program Please note that the TLS Uploader is a copyrighted program and Triangle Research International is the copyright owner of this program However Triangle Research International authorizes the licensed users of the Internet TRILOGI version 6 x software to freely distribute the InstallTL5Uploader zip program to their end users at no charge Note Although TRILOGI version 6 x supports Unicode for its user interface the compiled code produced by TL6 is identical to that of TL5 and therefore the compiled file is still saved in ASCII format To maintain backward compatibility the Write 7 5 Compiled Code to Disk function still produces CO5 file that can be uploaded using the TL5 Uploader program 8 Print You may use all the printing resources supported by your O S to print a selectable range of the ladder diagram the I O Tables or the custom functions When executed the following Print Control Panel will appear Print Control Panel Print Page setup Print Preview Print Ladder Circuits No of Element 10 Ladder Circuits VO Tables C
43. save to or load from local drive KE i TRiLOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help Circuit PAAA nne cuicktays GERM Stop il RLY Duration ri OUT Step Manual Seq1 ri i j4 ___ AVseq Cik 0 5s Wanga The main body of the program window is for disolaying and editing your ladder logic program A ladder logic program is made up of many ladder rungs In TRILOGI we call each ladder rung a circuit with an associated circuit number The currently selected circuit is marked by a litle red triangle pointed to the circuit s intersection with the left vertical line a k a the power rail in ladder logic terminology The circuit number of the selected circuit is displayed on a button located just above the top left corner of the ladder editor window If you happen to click on this button a dialog box will popup that prompts you to enter the circuit number that you wish to go to and the editor will bring you there immediately The five blue buttons 1 2 3 4 5 next to the Circuit button are called Quick Tags the gray button Define QuickTags next to the quick tags is used to create quick tags and beside the gray button is another blue button Last J The usage of all these buttons has been covered in detail in Chapter 6 File Menu The File menu provides commands for the opening saving of TRILOGI files either on the local hard disk or on the TLServer s storage spac
44. the conversion function e g STRS VAL etc A string is limited to 70 characters There should not be more than 20 GOTO labels within the same CusFn Most likely wrong spelling for TBASIC statement or function Every WHILE statement must be ended with a matching ENDWHILE statement Nested WHILE loop must have proper matching ENDWHILE for each WHILE Every IF statement must be ended with a matching ENDIF statement to define the boundaries for the block controlled by the IF statement For multiole IF THEN statement 9 16 FOR without NEXT Expect keyword TO Must be an integer Must be an integer variable only Must be an integer constant only Must be a string Must be a string variable only Must be a string constant only Incomplete Expression String constant missing closing Must be Integer A to Z only each IF must be matched by a corresponding ENDIF Every FOR statement must be ended with a matching NEXT statement to define the boundaries for the block controlled by the FOR statement For nested FOR loops each FOR must be matched by a corresponding NEXT Required by FOR statement String variable or constant not allowed Integer constant not allowed Integer variable not allowed Integer constant or variable not allowed String constant not allowed String variable not allowed Expression not ended properly String constants must be enclosed between a pair of opening and closing
45. the SV When you try to increment the counter past the Set Value it will overflow to become O Likewise if you try to decrement the counter beyond O it will underflow to become the Set Value All three counter functions DNctr UPctr and RSctr can operate on the same counter i e assigned to the same counter label on different circuits Although these circuits may be located anywhere within the ladder program it is recommended that the two or three functions which operate on the same counter be grouped together in the following order DNetr Upctr and RSctr Note that NOT all three functions need to be used to implement the reversible Counter 8 9 Decrement Counter DNctr OH Execution condition of DNctr function OFF 0002 Counter s Present Value PV OH Counter s contact QFE Each time when the execution condition of a DNctr function changes from OFF to ON the present value of the designated counter is changed as follow a If the counters present value PV is inactive load the counter register with the Set Value SV defined in the Counter table minus 1 b If the counters present value PV is already 0 then load the counters PV with the SV defined in the counter table and turn on the counters contact also known as the completion flag c Otherwise decrement the counter PV register by 1 Increment Counter Upctr Execution condition e m ie al etl na lesal E of U
46. the flame Sample and compute every 1 second Full scale A D range is 4096 Range of Set Point A D 5 0 gt 50 C A D 5 4096 200 C Range of Sensor ADC 1 0 gt 0 C ADC 1 4096 300 C Al 11 Def_PID Fn_ 5 C1k1 8s Fn_ 6 list Custom Function 5 P 500 I 58 PIDDEF 1 2048x109 P 1 D Use PID Engine 1 max limit lt 50 of full scale Custom Function 6 ADC 5 200 58 4096 50 Convert to C ADC 1 308 8 4896 PIDcompute 1 S T 18 2048 X can vary 50 setDAC 1 X Write to analog D A output 1 Comments L We use two decimal places to represent the gains Kp K and Kp Each integer unit represents 0 01 Proportional gain Kp 5 is represented by variable P 500 Likewise Integral gains K 0 5 is represented by I 50 and Differential gains 0 means Differential term is not used P I only The integrator limits of 2048 for the PIDDEF statement must be multiplied by 100 to be put on the same scale as the P I and D parameters Note that since TRiLOGI does not support floating point arithmetic the multiplication must be carried out before the division Otherwise if you compute 150 4096 ADC 5 the result of the integer division of 150 4096 0 and the whole expression yields a 0 which is clearly wrong 2 The value returned by PIDcompute function is then divided by 100 to get the real value of controller output PIDcompute ret
47. to insert a N O parallel contact to enclose one or more elements lt 6 gt Right click to insert a N C parallel contact to enclose one or more elements lt gt Insert a normal coil which may be an output relay timer Ae oo T al or counter lt 8 gt Insert a parallel output coil not an entire branch to the Current coil lt 9 gt Insert a special function coil which includes execution of CusFn lt Q gt Insert a parallel special function coil to the Current coil lt gt Invert the element from N O to N C or from N C to N O oa eee lt gt Convert the element to a rising edge triggered contact one shot qi Ha Click to move the highlight bar to the right same effect as pressing the right arrow key This can be used to move cursor to a junction that cannot be selected by mouse click 4 Double click to delete a highlighted element When you click on an icon for example the HEI the icon will change to bright yellow color to show you the element type that you are creating At the same time an I O table should appear on the screen with a light beige color background The I O table acts like a pop up Menu for you to pick any of the pre defined label names for this contact This saves you a lot of typing and at the same time eliminates typo errors that could result in a compilation failure You should soend a few minutes to follow the Chapter 5 Ladder Logic Programming Tutori
48. try to enter the value 123 at ADC 1 the program would first be receiving 1 then 12 and then 123 which was not the intention Viewing TBASIC Variables The values of the internal variables as a result of the simulation run can be viewed by pressing the lt V gt which stand for View key or by clicking on the View button while in the simulation screen A pop up window will appear with the values of all the variables as well as special peripheral devices supported by TBASIC The variables are organized into 4 screens You can move from screen to screen using the left right cursor keys or by clicking on the navigation buttons Integer variables Screen The first screen comprises all 26 32 bit integer variables A Z the system DATE and TIME ADC DAC PWM and the resulting values of setLED and setLCD commands The initial DATE and TIME figures shown during simulation are taken from the PC s internal real time clock values However subsequent values can be affected by the values assigned to the variable DATE n and TIME n The present values of the first 3 high soeed counters HSC1 to HSC3 are also shown on this page Note that ADC data for any particular A D channel n will only be shown if an ADC n function has been executed Otherwise the ADC value shown on screen will not reflect the true Current value of the ADC port ViewVariable Integers KMWaHydD itt ws fs fa Heek Z2006 6 9 4 lines LCD Display 21 34 2
49. turning ON OFF sequentially in a running light pattern Sequencer Seq in the Ctr Seq column begins to count upward from 1 to 3 and then overflows to 0 and repeats continuously For each step of the Sequencer the corresponding Output will be turned ON Our demo program will show a running light pattern starting from Outputs 1 amp 8 then 2 amp 7 3 amp 6 and 4 amp 5 and then back to 1 amp 8 2 amp 7 Now you should verify that the logic works as intended by observing the ladder diagram You should notice thot the Run labels in all circuits are highlighted as shown below FE i TRILOGI Version 6 20 C TRILOGI TL 6 usr samplesDemo PC6 E BX File Edit Controller Simulate Circuit Help circuit PAAA Here cuick Tass GEE if RLY Duration ri IM Step Manual Seq l E AVseq Cik 0 5s mariya OUT OUT The logic states of any I O can be displayed on the ladder diagram directly An Input Output Relay Timer or Counter contact that is turned ON will have its label name highlighted in the ladder diagram This feature helps greatly in debugging and understanding the logical relationship between each I O For example from the above figure we can see clearly that the Self latching circuit for relay Run works as intended when we first turn ON the Start input Run will be energized and its contact which is parallel to Start will hold itself in the ON state even if we subsequently turn OFF the St
50. which should be initialized to 1 when the program is not requesting email service When the TRILOGI program wants to send an email it first stores the sender recipient and subject into the following variables 3 13 AS Sender email address which can be used to identify the source of the email BS Recipient email address this one must be accurate C Subject of the message D First line of Message ES Second line of email message Z The 23rd line of the email message 1 NOT sending any email emEVENT 1 0 to 23 number of lines in the email message body which are contained in D to ZS The maximum number of lines in your email is limited by the number of string variables D to Z 23 in total available in the M series F series PLCs For example if the PLC needs to send email to trilogi yahoo com with a 1 line greeting then the program needs to activate a custom function that contains the following statements AS Demol PLC sender BS trilogi yahoo com recipient C This is an email demonstration subject D The time is STRS TIME 1 STRS TIME 2 How are you doing Message body emEVENT 1 You must also setup the email service period say every 10 second in the Setup Emails screen for this PLC When the TLServer scans the PLC and found that its EmEVENT 1 is set to 1 it will extract the headers and message body from the PLC s s
51. 0 gt Fri Hex Edit Close 9 13 Data Memory Screen The second screen displays in 25 pages the values of the 16 bit DM variables from DM 1 to DM 4000 Each page displays 16 rows x 10 columns 160 DM variables You can scroll up and down the pages by clicking on the PgUp or PgDn buttons or using the corresponding keys on the keyboard String Variable Screen The third screen displays the value of the 26 string variables AS to ZS in 4 pages depending on the length of each string If the execution condition is ON and the Cus Fn is not of the differentiated type then the CusFn will be continuously executed The result of the variable will be continuously updated on the viewing window System Variable Screen System variables such as INPUT n RELAY n and emiNIT n are visible in this screen You may wish to click on the Hex button to view the values in hexadecimal notation as this is more commonly used by programmers to identify the bit patterns in these variables Changing The Contents of Variables While the View Special Variables window is open you may change the contents of the following variables by clicking on the Edit button A Z AS to ZS DM n DATE n TIME n INPUT n OUTPUT n RELAY n TIMERBIT N CTRBIT n TIMERPV n CTRPV n and HSCPV n emiNT n emLINIT n A text entry window will pop up and you will have to enter the values in the form of assignment statements such as
52. 0 a 2 Em After you have entered the label name Duration for Timer 1 a text entry box is opened up at the Set Value location of Timer 1 for you to enter the SV for the timer SV range is between 0 and 9999 Enter the value 1000 at this location 5 s Em 10 11 12 KEN 5b T f For a normal timer with 0 1s time base the value 1000 represents 100 0 seconds which means that the Duration timer will time out after 100 0 seconds If the timer had been configured as High Speed Timer using the TBASIC HSTimer command then the time base would become 0 01s meaning the value 1000 represents only 10 00 seconds 5 3 14 We are now left to define the sequencer Seql The sequencer is an extremely useful device for implementing sequencing logic found in many automated equipment TRILOGI supports 8 sequencers of 32 steps each Each sequencer requires a Step counter to keep track of the current step sequence The first 8 counters in the counter table also double as the step counters for the 8 sequencers These counters must be named Seq to Seqs if they are to be used as sequencers i e Counter 1 to be named as Seql Counter 2 as Seq2 etc However any counter not used as sequencer may assume any other name up to a maximum of 10 characters if they are used as ordinary counters If you are at the Timers table pressing the right cursor key again will bring up the Counters table
53. 1 ff InterVideo WinDVD gt FA Tunes b Note A short cut for TLServer is also created on the Quick Launch toolbar For Windows XP Vista users you may have to right click on the tool bar area along the bottom of the screen and check the show Quick Launch option in order for the quick launch tool bar to appear TLServer Icon Chapter 2 Introduction to Internet TRILOGI Client Server Architecture 1 Internet TRILOGI is a Client Server application suite The entire program is broken into two parts the Server and the Client 2 Server In order to run the complete TRILOGI program including access to the PLC you must start the TLServer first TLserver behaves like a typical web server and it is capable of serving HTML web pages as well as Java Applet to an Internet Browser such as the Microsoft Internet Explorer or Netscape Navigator Firefox TLserver connects to the PLCs via the PC s serial communication port and it is the one responsible for conveying communication messages between the Internet TRILOGI client and the M series F series PLCs Note TLServer is not included with Education version of TRILOGI since there is no real PLC involved For XServer_users You do not need to run the TLServer if you have installed the Ethernet XServer since the XServer provides similar communication access between the client PC and the M series F series PLCs For FServer users You do not need to run the TLServer if you are us
54. 1 Syntax Error TRILOGI employs a sophisticated yet extremely user friendly syntax error tracking system When a syntax error is encountered the compilation will be aborted immediately and the CusFn which contains the error is automatically opened in the text editor The location of the offending word is also highlighted and a pop up message window reports to you the cause of the error You can then immediately fix the error and re compile until all the errors have been corrected Error Message Undefined symbol found Compiler internal error found without matching Integer expected Value is out of range Duplicate line label number Undefined GOTO destination Invalid GOTO label Type mismatch numeric and string types may not mix String is too long Too many line labels Unknown Keyword WHILE without ENDWHILE IF without ENDIF Cause Action Only TBASIC commands and legal variable names are allowed See Chapter 3 Serious trouble please email to the manufacturer support tri plc com to inform US Expect to see either an integer variable or integer constant Check the language reference for allowable range of values for the command Label for GOTO must be unique within the same CusFn Put a matching label at the place where the GOTO statement is supposed to go must be in the range 0 255 In an expression strings and integers may not be mixed unless converted using
55. 256 PLCs connected to it via RS232 or RS485 To setup the server to handle email requests click on the Setup Emails button on the TLServer to open the following dialog box SMTP Mail Server This will be the KTA AENEA same Outgoing Mail Server that SMTP Mail Server Port No you use in your email program 25 M Authentication such as the Eudora or Outlook Auth Username Auth Password Express If in doubt ask your ISP or System Administrator for help This plep Shake EE server must be setup properly before the TLServer can send any email Email Test Port No This is the port that your Outgoing Mail Server will use to send emails The default port number is 25 which is the most common port however some Mail Servers will use a different port and you should check with your ISP or System Administrator if you are not sure 0 OoO p aqa0d0o0o0o0o0o0o0oooooo Authentication Some ISPs will only allow mail to be sent through their Mail Server if it originates from a trusted IP address typically only the Internet IP address that the ISP assigns to you If this is the case then you may need to authenticate your IP address if it is different from the one provided to you If you are sending mail from a location registered to another ISP using your Mail Server If your ISP uses Authentication then you will need to check the Authentication box and provide the correct Auth Username and Auth Password If you are
56. 26 string variables AS BS Z Each string variable may contain from O null string up to a maximum of 70 characters Note For M series PLC with firmware version r45 and above and alll F series PLCs you can access the 26 string variables using an index S 1 to 26 le AS is the same as 1 ZS is the same as 26 Note that 1 to 26 are not additional string variables it just give you a way to index the string variables not possible on previous firmware version Also only TRILOGI version 5 2 and above properly support these variable names Caution Do not try to transfer a program using n variable to a PLC with firmware earlier than r45 as it can cause the PLC operating system to crash A String variable must NOT contain any of the following characters ASCII O 10 and 13 decimal If a String variable contains one of these characters it could cause the online monitoring of the string variable to fail since O is used as string terminator and ASCII 10 and 13 are LF and 10 8 CR character respectively which are characters used for terminating communication command and response strings If you include one of these characters in a string variable they could cause the command response string to terminate prematurely and the program will complain that the PLC is not responding correctly NEW With Trilogi version 6 2 and above you can now attach comments to any variable name of any length to make program easier to
57. 3 7 matches the Call In Password string in order to maintain the connection If the password is incorrect the TLServer will disconnect the remote modem to prevent unauthorized access If the call in password is validated the TLServer will acknowledge it by sending a CR terminated string lt OK gt to the remote PLC via the modem It is the duty of the incoming caller to check the acknowledgement string to ensure that the TLServer does not drop the connection Configure Users Configure Users By definition only the Administrator is 2 Adminstrator Login authorized to add delete users and change password Hence when you Username Administrator Password click on the Configure Users button you are assumed to be the Administrator and you will be asked to enter the Administrators password to Cancel gain entry By default no password has been defined for the Administrator so you should just press lt Enter gt key to gain entry the first time Once you get through the Administrator Login screen a dialog box will popup which allows you to add new users who are allowed access to the TLServer and the PLCs You can also change the password username or the access level of an existing user or delete an existing user A new user defined here will be given his her own exclusive subdirectory to store ladder programs For PCs this directory is located at C TRiLOGI TL6 usr lt username gt where lt usernam
58. EM ch ID addr var count _ Applicable only to M firmware r44 or higher Think of this as the multi word version of READMODBUS command Unlike the READMODBUS command which is a function that returns a single 16 bit word this command is implemented as a statement so that multiple words of data can be stored into the PLC internal memory ch PLC COMM port number 1to 8 using Modbus ASCII or 11to 18 using Modbus RTU ID Device ID of the MODBUS slave device 1 to 255 addr Zero offset address of the holding register in the MODBUS slave device starting from O 40001 11 17 Example Comments Special See Also REFRESH Purpose var the starting variable in the master for storing the returned data may be a DM or any system variable count number of variables to read max 16 in M PLC READMB2 3 5 101 DM 10 8 The PLC will use MODBUS ASCII protocol via its Comm port 3 to query the slave MODBUS device with ID 05 and ask for 8 words of qata starting from register offset address 101 in MODBUS term this refer to the 40102 holding register Once it receives the returned data these 8 words will be stored in the memory locations DM 10 DM 11 DM 17 This command automatically checks the response string received from the slave device for the correct slave address and LRC or CRC16 RTU protocol is used Like READMODBUS command the status of this operation can be checked by the user program
59. ESTBIT will only test the lower significant 16 bits Following digital electronics convention bit O refers to the least significant bit rightmost bit and bit 15 the most significant bit leftmost bit of the 16 bit integer variable Please refer to page 10 4 in Chapter 10 TBASIC Statemenis Functions Operators and Variables for the mapping between O bits and the variables Examples TESTBIT Input 2 3 Comments To test whether input 20 is ON Inout channel 2 bit 3 Input 17 3 20 See Also SETBIT CLRBIT TESTIO abeiname _ Please refer to the definition of CLRIO command TOGGLEIO Jlabelname Please refer to the definition of CLRIO command VAL x Purpose To return a value of a decimal number contained in the argument xS 11 33 Examples Comments B VAL 123 100 B should contain the value 12300 WHILE expression ENDWHILE Purpose Syntax Examples Comments To execute a series of statements in a loop as long as a given condition is true WHILE expression ENDWHILE When WHILE statement is encountered the expression will be evaluated and if the result is true the statements following the expression will be executed until the ENDWHILE statement Thereafter execution branches back to the WHILE statement and the expression is evaluated again The loop statements will be executed repeatedly until the expression becomes false Warning Be careful that the W
60. Email Setup section When TLServer is first started it will Query the operating system for the IP addresses of the computer that it runs on It may take a while to start up if the O S is slow to return the IP address It will then display the obtained IP addresses maximum of two on the TLServer front panel so that the user can quickly determine the IP addresses that they can use to access the PLC The following are some possible IP address scenarios If the computer is not linked to any network or the Internet and does not have any network adapter installed then only the localhost IP address 127 0 0 1 9080 where 9080 is the port number will be displayed Note Regardless of whether your PC is networked or not the local host IP address 127 0 0 1 9080 is always available to the client program running on the same PC where the TLServer is running even though it may not be displayed on the TLServer s front panel TRILOGI and TRi ExcelLink are all Known as client programs So whether your PC is networked or not you can still use TLServer and TRILOGI on a localhost connection In that case the TRILOGI and TLServer work together on the same PC just like a normal Window based programming software We recommend using the localhost IP address 127 0 0 1 9080 if you are running both the client and the server on the same PC If the computer has an always on direct connection to the Internet then the IP adaress will be your Internet IP
61. Explorer 5 or Netscape Navigator 4 5 to invoke the TRILOGI applet There is no need to install the TRILOGI software in the local computer Application Applet Pros Starts up immediately Can read write TRILOGI files to local hard disk or to TLServer e Can access any TLServer on the network Program behavior predictable since the copy of JVM is local No need to install any software or JVM at the client computer Possible to control your PLC via any Cyber Caf Maintenance and Upgrading of software is simple since only one copy of the TL50Applet jar file needs to be changed Centralized storage of program files only at the server This is good for providing PLC program training TRILOGI Application vs Applet Which is Better Cons Require local installation of TRILOGI software at every client computer Require installation of JVM at every client computer May need to specify the proxy server IP address if running behind a firewall Can only read write TRILOGI files to the TLServer but not to the local hard disk Can only access the TLServer from which it was loaded May take a few minutes to load itself the first time if connect via dial up modem Thereafter the browser should cache it for rapid start up Program behavior may vary for different make or different versions of the browser We shall describe how to run the TRILOGI Application and Applet software
62. HILE loop will not be an endless loop as the PLC will appear to freeze up being trapped in an endless loop execution TRILOGI simulator attempts to detect this situation by giving a warning message if a loop is executed for an unduly large number of loops WHILE S 1 IF INPUT 1 amp amp H0002 S 0 ENDWHILE ENDWHILE Execution will only be terminated when input 2 is ON WHILE loops may be nested i e a WHILE loop may be placed within the context of another WHILE loop Each Loop must have a separate ENDWHILE statement to mark the end of the loop WRITEMODBUS ch DevicelD address data Purpose Automatically write the 16 bit data to a MODBUS ASCII device using the MODBUS ASCII protocol The communication baud rate is the default baud rate of that COMM port unless it has been changed by the SETBAUD command ch PLC COMM port number 1 8 DeviceID Device ID of the MODBUS device 1 to 255 11 34 Example address Zero offset address of the holding register in the MODBUS device data the 16 bit data to be written to the MODBUS device WRITEMODBUS 3 8 1000 1234 Comments The data 1234 will be written to the MODBUS device with ID 08 at the See Also WRITEMB2 Purpose Parameters Example Comments See Also holding register offset address 1000 in MODBUS convention this refer to holding register 41001 The command automatically checks the response string received from the slave
63. IGH16 A DM 1 GETHIGH16 SETIO labelname Please refer to the definition of CLRIO command 11 23 SETLCD n offset x Purpose Examples To display the string expression x on Line n on built in alphanumeric Liquid Crystal Display LCD or compatible Vacuum Fluorescent Display VFD x may be formed by concatenation of various strings using the operator eg Temp STRS A 3 CHRS 223 C Integers must be converted to string using the STRS or HEXS function to be accepted by this function Special case if n O the string x will be sent to the LCD s Instruction Register which allows hardware specific LCD configuration such as clear screen set cursor ON OFF etc please refer to LCD s manual for details The parameter offset 1 to 40 allows you to send the string x beginning from the offset position Only the characters position to be occupied by x will be written to the display other characters of the display remain unaffected The PLC may support LCD display modules capable of displaying up to 4 lines x 40 characters per line of alohanumeric characters If the display has fewer lines or fewer characters per line the unavailable lines or characters will be ignored by the PLC Once set the LCD display will latch the set value until the next SETLCD statement on the same line and same offset is executed On the TRILOGI simulator the result of the SETLCD is displayed together with the S
64. IT OUTPUT 1 4 ENDIF IF TIME L1 J 18 CLRBIT OUTPUT 1 4 ENDIF ENDIF ENDIF Comments 1 Tim30s should have a Set Value 300 and it activates Function 1 every 30 seconds It is not necessary to check the clock too often as checking consume CPU execution cycles 2 We used SETIO to control Output 1 but as a demonstration we use SETBIT to control Output 5 which is bit 4 of the variable OUTPUT 1 The statement SETBIT outputLl1 4 turns ON output 5 3 Actually it may not be necessary to check the minute hand since when the RTC turns from 18 59 to 19 00 the output will be turned ON as long as TIME 1 19 Only when TIME 1 7 then output 1 needs to be changed Al 9 6 HVAC Heating Ventilation and Air Conditioning Control Assignment e Read desired temperature setting S from a potentiometer connected to A D 5 e Read current air temperature T from sensor attached to A D 1 T e Turn ON cold air conditioner output 1 with labelname OUTI if T gt Sby more than 1 5 C e Turn ON heater if output 2 if S gt T by more than 1 5 C e Turn OFF both heater and cold air conditioner if T is within 1 5 C of S Parameters Full scale A D is 4096 Range of Set Point A D 5 0 gt 16 0 C AID 5 4096 gt 30 0 C Range of Sensor ADC 1 0 gt 10 0 C ADC 1 4096 gt 50 0 C C1k 1 0 Fn_ 20 PA acu sf Custom Function 20 S ADC 5 308 168 4096 168 Convert to Cx1 T ADC 1 5884 100
65. LADDER BASIC Editor Simulator Web Server Internet TRILOGI Version 6 2 9 IRI Programmer s Triangle Research Reference International Inc Copyright Notice Internet TRILOGI Version 6 x are trademarks and copyrights 2001 2009 of TRIANGLE RESEARCH INTERNATIONAL Inc TRI All rights reserved No parts of this manual may be reproduced transmitted transcribed stored in retrieval system or translated into any human or computer language in any form or by any means without the express written permission of TRIANGLE RESEARCH INTERNATIONAL PTE LTD SINGAPORE Please refer all inquiries to info tri plc com MSDOS and Windows 95 98 NT 2000 and XP are trademarks of Microsoft MODBUS is a trademark of Groupe Schneider All other trademarks belong to their respective owners Disclaimer TRi makes no representations or warranties with respect to the contents hereof In addition information contained herein is subject to change without notice Every precaution has been taken in the preparation of this manual Nevertheless TRi assumes no responsibilities for errors or omissions or any consequential damages resulting from the use of the information contained in this publication Table of Contents Chapter 1 Internet TRILOGI 6 x Installation Guide I Introduction to the TRILOGI Program ll Installing TRILOGI 6 x on Windows 98 Me NT 2000 or XP Chapter 2 Introdu
66. LCD 1 1 Cycle Count STR X Find Find Al x Find in All CusF i NOTE Highlighting of text found in the editor during a user initiated search or during compilation error tracking now works with JRE Java Runtime Environment 1 5 and 1 6 7 Goto lt Ctil G gt Use this command to move towards a specific circuit number The Goto command is particularly useful if your program contains many circuits and it is inconvenient to search for a particular circuit using the mouse or the cursor keys 8 I O Table lt F2 gt Open up the I O Table for defining label names for the PLC s I O For detailed explanation of I O tables please click on the following link I O Definition Table 9 View I O Type on Ladder _ lt F3 gt Toggle between display and no display of the I O type for ladder logic contacts on the screen All ladder logic contact symbols are normally 7 11 identified by their label names However you can also choose to display an optional small literal to indicate the I O types and physical O number which is now linked to the I O labelname e g i input 1 o12 output 12 r25 relay 25 tl timer 1 and c5 counter 5 When TRILOGI first starts the display is enabled but you have the option of turning it off if you find it distracting Edit Custom Function lt F7 gt Opens up the Custom Function Editor window for you to enter the TBASIC program You will be required to select the custom function number or a label
67. M 5 0 N 1 STEPSPEED 1 5000 100 Stepperl Max 5000pps Acc 100 STEPMOVEABS 1 DM EN 5 lt Move to position stored in DM 1 lt at the end turns ON relay 5 Custom Function 20 N N 1 IF N lt 5 STEPMOVEABS 1 DM N 5 Move to next position in DM N ENDIF lt at the end turns ON relay 5 Comments RLY5 is the label for internal relay 5 T1sec is a timer with preset value of 10 At the end of the pulse generation RLY5 will be activated Ladder logic senses RLY5 and executes the T1sec timer to cause a 1 second delay after which custom function 20 is executed which triggers another SYEPMOVEABS command and the process repeats for the other four indexing positions Al 8 5 Activate Events at Scheduled Date and Time All M series PLCs have built in Real Time Clock which keeps track of Date and Time and can be used to activate events at scheduled time Assignment e Every day turn on output 1 label name Outl at 19 00 e Tum OFF output 1 at 7 00 e On Ist Jan 2000 at 12 00 turn ON output 5 e Onthe same day at 18 00 turn OFF output 5 Tim3 s Fn_ 1 _ _ _ _ _ _ _ _ _____ _ dCusf Tim30s Tim3 s TIM Custom Function 1 IF TIME 1 19 AND TIME 2 8 lt Hour hand at 19 SETIO QOUT1 Minute hand at ELSE IF TIMEL1 7 AND TIME 2 8 CLRIO OUT1 ENDIF ENDIF IF DATE L1 2008 AND DATEL2 1 Jan yr 2008 IF DATE 3 1 IF TIME 1 12 SETB
68. RILOGI Home Page Mozilla Firefox File Edit View Go Bookmarks Tools Help a B a A Ca http 127 0 0 1 9080 Y Go e TRI LC 0 Banks Kall8 _ DigitalRS Client Portal Others Internet TRILOGI Version 6 0 Copyright c 2001 2005 Triangle Research International Inc C Menu Item Description Run the Internet TRILOGI directly off your browser No Local 2 TLServer has Direct Connection to the Internet If the PC running the TLServer enjoys a direct connection to the Internet via dial up DSL TI line or cable modem then TLServer will be accessible to any client on the Internet Note that if you connect to the Internet via dial up connection then do remember to connect to the Internet before you run TLServer so that it can report the actual IP address on its front panel If the TRILOGI client software also accesses the Internet via direct connection you will have the least problem However if the TRILOGI client is sitting behind a corporate firewall then the situation is much more complex and it has impact on both the TLServer and the TRILOGI settings as shown in the following table TRiLOGI Client has Direct TRiLOGI runs on a PC protected Internet Connection by Corporate Firewall e TLServer port settings 80 or e TLServer Port Settings 80 any value above 1024 TRILOGI Use HttoProxy e TRILOGI Use HttoProxy true May need to obtain setting is optional proxy server s IP address A2 2
69. RSHIFT MID x n m Purpose Examples Comments This function returns a sub string of m characters from x beginning with the nth character x any string expression variable or constant n any numeric expression producing a result of between 1 to 255 m any numeric expression producing a result of between 0 to 255 AS MIDS Welcome to TBASIC 4 7 AS should contain the string come to 11 1 NETCMDS cA x Purpose This function sends a multi point host link command string specified in the x via serial port ch to another M series or H series PLC It will then wait for a specified amount of time for a response string from the other PLC and this response string is then returned ch This refer to the communication port Please refer to the target PLC for details x contains a valid host link command in multi point format excluding the Frame Check Sequence FCS and the terminator characters and CR NETCMDS function will automatically compute the FCS and append to the end of x and together with the terminator characters will be sent to the other PLC via COMM ch Note 1 If the target PLC does not respond then this function returns an empty string 2 This function checks the FCS of the response string and if the FCS is wrong it indicates an error in the serial reception and it will return an empty string Examples AS NETCMD 3 O5RI00 Comments To read the In
70. SIC program into the PLC You will be prompted to confirm your action to prevent accidentally affecting the target PLC The ladder program must be compiled successfully before the program transfer process can take place The progress of the transfer process will be clearly shown on the program transfer dialog box 5 Open Matching Source File You can use this command to query the connected PLC for the filename of the last TRILOGI program transferred to it and it will attempt to match it to a file stored in the log in user s directory at TLServer If the file is found it will be Opened Otherwise it will report that the file is not found Note that this command only opens the source file based on file name matching It does not verify whether the file has been modified It is the user s responsibility to ensure that the file stored in the server is the same one that has been compiled and transferred to the PLC Note that if you have created a new file i e the file name is Untitled and then attempt to perform on line monitoring this command will be called automatically to try to open a file that matches the PLC The command is also invoked when you select a PLC with a different ID either from the Controller menu or from within the Full Screen Monitoring window Note to Unicode users If you created your file name using Unicode instead of plain ASCII the Unicode filename will not be saved into the F Series M series PLC since the PLC
71. See Also SETBIT CLRBIT CRC16 var count Applicable only to PLC with firmware r44 or higher Purpose This function returns the computed CRC16 for a range of integers starting from variable var with the range indicated in the parameter count CRC16 is a 16 bit version of Cyclic Redundancy Check a popular mathematical formula for checking error in a data stream Examples DM 100 CRC16 DM 5 8 X CRC16 RELAY 2 4 Comments CRC16 for DM 5 DM 6 DM 12 will be assigned to DM 100 CRC16 for RELAY 2 RELAY 3 RELAY 4 RELAY 5 will be assigned to X DELAY n Purpose To provide a time delay of n millisecond to the process Example DELAY 100 Comments Provide a 100 ms 0 18 delay to the current custom function It is important to note that this is a brute force delay method and only to be used with caution When a DELAY function is executed the CPU waits at the statement until the period specified by the delay is over This means that all the remaining ladder programs and other custom functions will stop responding to changing input conditions only system services serial input countdown timers and host link commands etc as well as interrupt driven CusFns will work during the period of delay This may not be desirable if the rest of the process must respond to fast changing inputs For delays longer than 0 1s a much better way is to invoke the regular PLC timer and use the timer contact t
72. T variable expression Examples LET D 11 AS Welcome to TBASIC Comments LET statement is optional i e the equal sign is sufficient when assigning an expression to a variable name The variable type on both sides of the equal side must be the same i e string variable may not be assigned to a numeric expression and vice versa Important a When assigning a 16 bit variable to a 32 bit integer only the lower 16 bits of the 32 bit integer will be assigned Hence the programmer must take special care if the 32 bit number is out of the range of a 16 bit number which is between 32768 to 32767 b If a negative 16 bit number is assigned to 32 bit integer variable then the sign bit will be extended to 32 bits e g DM 1 123 A DM 1 The 16 bit hexadecimal value of 123 is amp HFF85 but A will be assigned the hexadecimal value amp HFFFFFF85 Their decimal representation are however the same LOAD_EEP addr Purpose To return a 16 bit integer value saved in the EEPROM by the SAVE_EEP statement addr EEPROM address in TRILOGI version 5 x Actual PLC may have less EEPROM space Please refer to your PLC s reference manual for the upper limit Examples relay 1 LOAD_EEP 10 A LOAD_EEP 2 See Also SAVE_EEP LOAD_EEP addr Applicable only to PLC with firmware r44 or higher Purpose This function returns a string previously saved into the PLC s internal data EEPROM using
73. The physical I O number is now linked to the labelname All ladder logic contact symbols are normally identified by their label names However you can also display an optional small literal to indicate the I O types and number eg il input 1 0o12 outout 12 r25 relay 25 tl timer 1 and c5 counter 5 6 1 Refresh the display If for some reason the screen is lt F5 gt garbled by an incomplete circuit display you can just press the lt F5 gt key to redraw the screen Open any custom function If the currently selected lt F7 gt circuit contains a custom function then it will be opened for editing Otherwise TRILOGI will ask you to select a custom function from a menu lt F8 gt Compile the TRILOGI program to show the compilation statistics lt F9 gt Run the simulator without resetting any I O lt Ctr1 F9 gt Reset all I Os and then runs the simulator lt Ctrl F8 gt Reset all I Os except inputs and then runs the simulator Use the up down cursor keys to move the marker to other circuits and the Circuit display at the upper Se status line will simultaneously reflect the change If you lt PgDn gt attempt to move beyond the screen the logic editor screen will scroll The lt PgUp gt and lt PgDn gt keys can be used to scroll one page at a time 3 Navigating Circuits in Browse Mode Although most of the time you will probably be navigating the ladd
74. US term this refer fo the 40102 holding register Reading itinto the relapf J channel allows iit level manipulation by ladder logic It can of course also be read into any data memory The command automatically checks the response string received from the slave device for the correct LRC and the slave address The status of the operation can be checked in the user program by executing the STATUS function which will rerum a O if there is any error or if the slave device is not present See Also lt Basic to TBASIC Reference Manual WRITEMODBUS STATUS 2 NETCMD Find All MBREAD v Rename Function Select Keyword v Undo Abot tial banin azian il 7 24 Chapter 8 Ladder Logic Language Reference I Ladder Logic Fundamentals Contacts Coils Timers and Counters 1 Contacts Ladder logic programs mimic the electrical circuit diagrams used for wiring control systems in the electrical industry The basic purpose of an electrical control system is to determine whether a load should be turned ON or turned OFF under what circumstances and when it should happen To understand a ladder program just remember the concept of current flow a load is turned ON when the current can flow to it and is turned OFF when the current could not flow to it The fundamental element of a ladder diagram is a Contact A contact has only two states open or closed An open contact breaks the current fl
75. a file delete a file or create a subdirectory as shown below Open files stored at TLServer Ed Open files stored at TLServer FileService_Modem LI defineXHMILabel PC6 GetIPAddr PC6 TestXserver PC ClockPulses pc CRC16 PC6 Demo Protected pc 7 2 Simply double click on the desired file or select the file you wish to open and click the Open button to open the TRILOGI file from the TLServer Sub directory The MkDir button allows you to create a sub directory on the server to organize your files Subdirectory names always end with a character If you open a subdirectory its contents will be displayed in the file window To return to the parent directory from a sub directory you simply double click on the symbol Save As TLServer 3 Use this command if you wish to save the currently edited TRILOGI file to the TLServer 3 x using a different filename You will be prompted to enter the Username Password and IP address if it is a TL6 application to gain access to TLServer Once authenticated the network file dialog similar to that described in Open TLServer 3 will be Opened for you to enter a file name or select a filename to overwrite Open Local Drive Save Local Drive For TL6 Application not Applet you can open or save a file from to the local hard disk You will be presented with a file dialog to select a file This command however is not available to the TL6 Applet since an applet does not hav
76. a in the user s definable EEPROM address addr for non volatile storage stringdata may be any string constant or string variable addr EEPROM address 1 2 3 Please refer to your PLC s reference manual for the upper limit of EEPROM space Example save_EEPS AS 3 Comments The content of AS will be stored at string space 3 of data EEPROM See Also LOAD_EEP 11 20 Save_EEP Implementation on M PLC Save EEPS and Load EEPS are two new TBASIC commands available only to the newest M PLC with firmware revision r44 and above These commands allow you to save strings into the non volatile data EEPROM area of the PLC The EEPROM space is divided into 40 byte chunks for string storage l e regardless of the length of the string each string storage location will occupy a fixed 40 character length Hence if stringdata parameter is longer 40 characters then only the first 40 characters will be stored in the EEPROM the remaining characters will be discarded The string and integer data actually share the same pool of data EEPROM space However the string spaces are allocated from the top of the data EEPROM space downward while the integer spaces are allocated from the bottom of the data EEPROM space and grow upward This implementation allows say both SAVE_EEP n 1 and SAVE _EEPS x 1 to be executed in the same program without the string and integer data writing over each other space However when the a
77. a special function coil A popup menu will appear for you to select the desired special function Click on the item 4 AVseq Advance Sequencer to insert the Advance Sequencer function AVseq Select a Function DNCtr Decrement Rev Counter RSCtr Reset Counter Upctr Increment Rev Counter AVseq Advance Sequencer RSseq Reset Sequencer StepN Set Sequencer to Step N 7 Latch Latching Relay Output Clear Clear Latched Relay ILock Interlock Begin ILof Interlock End ADIFU Differentiate Up aDIFD Differentiate Down CusFn Custom Function dCusF Diff Up Custom Funcs MaRST Master Reset This function is one that will increment the step counter of Sequencer 1 each time its execution condition goes from OFF to ON Again remember to press the lt Enter gt key to complete Circuit 2 5 9 37 38 39 40 Al Circuits 3 to 6 are similar to one another They make use of the Sequencer fo turn on the Outputs 1 to 8 to create a pattern of running lights when executed The label Seql 1 of the contact in Circuit 3 represents Step 1 of Sequencer 1 Remember that each sequencer can have up to 32 steps Step 0 to 31 with each step individually accessible as a contact A normally open contact Seq1 1 will be closed whenever the step counter of Sequencer 1 reaches number 1 Likewise a normally closed contact Seq5 20 will be opened when the step counter
78. address f the computer is networked to the corporate Intranet or you have connected this computer to a router to share internet connection with a few other computers then the IP address shown is an internal IP address also known as the Intranet IP address The intranet IP address is assigned by either the System Administrator or by the router known as DHCP server You can 3 2 access this computer from other computers on the same LAN but the intranet IP address is not accessible from outside of the LAN To access the TLServer from outside of the LAN You will need to configure your router s internal settings to define the PC that runs the TLServer as a Virtual Server You can then access the TLServer using the router s public IP address and the routers does the job of translating the public IP address to the intranet IP address and route the messages to from the PC that has been defined as the virtual server This process is known as Network Address Translation NAT If you connect a computer in a LAN to the Internet via a dial up connection you will see two IP addresses one is the Intranet address and another is the Internet IP address The Intranet address is only accessible from within the Intranet The Internet IP address will be what you need to use if you are accessing TLServer from the Internet See the PLC Setup amp Configuration section of the installation guide for more detailed explanation of Intra
79. ail will be sent whenever a PLC raises its email flag You should set a short service period say every 10 seconds for urgent email such as alarm condition For non urgent email such as hourly or daily production report you can set a much longer servicing period to reduce the communication loads on the PLCs You can test your email configuration by clicking the E T St button once you have entered all the correct settings Once you click the Email Test button TLServer will initiate the sending of a test email using the Mail Server you specified A new window will pop up as shown below that allows you to enter the recipient email address Test SMTP Settings Recipient Email to receive a test Email from TLServer Once you have typed the recipients email address you can press enter to send a default email can t be changed If it works you will see a message window that says the email has been sent as shown below and you will receive an email with the following content Test Message sent from TLServer 3 12 Test Email has been sent If some settings in the email configuration are not correct or you do not have a working Internet connection you will see an error message as shown below and you should contact your ISP or System Administrator if you are not sure how to resolve the problem Problem Sending Test Email javax mail MessagingException Could not connect to SMTP host 96 49 10 153 port 25 n
80. al on the steps needed to create a ladder program As mentioned previously the ladder editor is intelligent and will only accept an action that can result in the creation of a correct ladder logic circuit Otherwise it will simply beep and ignore the command 6 6 UNDO Circuit Editing If you have wrongly inserted or deleted an element and wish to undo the mistake you can either select Undo from the Edit menu or press lt Ctrl Z gt key to undo the last step The undo buffer stores the last 10 editing steps You can also choose to abort alll the operations on the current circuit by selecting Abort Edit Circuit to abort all changes made to the current circuit 2 Create Ladder Circuit Using The Keyboard Users of existing TRILOGI version 3 x or 4 x who are familiar with creating ladder programs using the keyboard will be delighted to know that they can still create their ladder programs using the keyboard The keyboard actions are described below Left Right Up Down cursor keys The cursor keys are for moving the highlight bar from one element to another in their four respective directions You can only move in a direction that will end up with an element lt ESC gt Press lt ESC gt key to end the circuit editing mode and return to the browse mode of the logic editor All changes to the current circuit will be saved if you wish to abort any changes to the current circuit please select Abort E
81. ality Special comparison operators may be used in the expression of the IF statement Only integer expression may be compared For comparison of strings please refer to the STRCMP AS BS function Examples Comments INCOMM ch Purpose Example Comments Note See Also Eaua o d E Greater than or Equal to gt IF A gt B 5 20 C OR C 20 B B ELSE B B 3 ENDIF A few comparison expressions may be linked with logical AND AND statement or logical OR OR statement operator as shown in the above examples To return a single 8 bit binary data obtained from Comm channel ch ch must be a numeric constant between 1 and 8 The actual target hardware determines the valid port This function returns 1 if there is no data waiting at serial port FOR I 1 to 100 DM I INCOMM 2 IF DM I lt 0O RETURN ENDIF NEXT Usually the PLC buffers the serial data arriving at its COMM port so that the program does not need to continuously check the COMM port for data When the program is ready to process the data it can use the FOR NEXT loop shown in the above example to read in all the data in the COMM buffer until it encounters a 1 which indicates that the buffer is empty INCOMM is now supported on all COMM ports of T100MD1616 and T100MX families of PLCs OUTCOMM INPUTS PRINT INPUT c Purpose To return a string obtained from communication port
82. all the PLC s internal variables greatly facilitates the programmers debugging process The ease of programming offered by the TRILOGI programming environment is really what really sets the M series F series PLCs far ahead of many other PLCs where both programming and debugging are really painstaking tasks This is assuming they have been fully equipped with all the expensive options to match the M series F series built in Capability 1 PAUSE and RESET of Target PLC During On Line Monitoring if the View Special Variables window is Opened you can still reset the PLC s internal data by pressing the lt Ctrl R gt key Pressing the lt P gt key can halt the PLC A halted PLC can subsequently be released from the halted mode by pressing the lt P gt key again 2 Using LCD Display for Debugging You should take advantage of the built in LCD display port of the TIOOMD to display internal data at the location where you want to track their values especially if the value changes rapidly which may not be constantly captured by on line monitoring screen Vi Error Handling Since the CusFn text editor does not restrict the type of text that may be entered into its editor the TRILOGI compiler will have to check the syntax of the users TBASIC program to look out for misspelling missing parameters invalid commands etc Such errors which can be tracked down during compilation process are known as Syntax Errors 9 15
83. amming Examples Important Notes to Programmers of TRILOGI Version 6 x 1 Understanding Ladder Logic Execution Process Like all industrial PLCs the CPU of the M series PLC first checks the logic states of the physical inputs and copies them into memory During the ladder logic scan the actual logic states of the physical Inputs except for interrupt inputs are ignored by the PLC The CPU uses the memory copy of the inputs to execute the ladder program The CPU executes its ladder logic program starting from the top rung of the program to the bottom rung When the CPU reaches a ladder rung that activates a CusFn or dCusF that custom function will be executed The CPU will only continue to scan the rest of the ladder program when the current custom function ends normally Hence the order in which a ladder rung is placed within a ladder program can have an effect on the behavior of the program Output bits which are changed as a result of the program execution will only be updated to the physical outputs at the end of the ladder logic scan One scan time is defined as the time it takes to execute the 3 steps read physical inputs execute program update physical outputs The CPU repeats these 3 steps continuously all the time known as Ladder Logic Scanning Hence it is important to note that the variables INPUT n s and OUTPUT N in TBASIC are not the actual physical I Os of the PLC but only a memory representation of the act
84. and the maximum speed that both modems are able to achieve We usually have no control of what speed they choose to communicate But one thing is for sure which is that the modem to modem speed is always lower than the DTE speed Since the default communication baud rate of the M series PLC s RS232 serial port is 38 400 bps the PLC should send a modem initialization string to the modem on the first scan pulse so that the modem can recognize its default DIE speed i e 38 400 bps in order to talk to the A3 2 PLC E g To reset the modem you just have to send an ASCIl string ATZ to the modem using the following TBASIC command PRINT 1 ATZ If you want your modem to automatically answer to an incoming call e g using TLServer 2 x 3 x modem dialing capability then you should execute the following TBASIC statement PRINT 1 ATSO 1 The above statement will tell the modem to answer on first ring you can also change the number 1 to other numbers E g if ATSO 3 it will answer on the 3 ring of the phone Software and Programming The TLServer 3 0 which is part of the Internet TRILOGI 6 x software suite already includes built in support for dialing a modem Hence if you are using the PLC in passive answer mode only all the PLC needs to do is to send a modem initialization string ATSO 1 using the Ist Scan pulse to put the modem in auto answer mode whenever the PLC is powered up The PLC does not need to issue any more c
85. annel After enabling the channel you may then use the functions PULSEWIDTH ch and PULSEPERIOD ch to obtain the width and period of the input pulses arriving at the pulse measurement input pin You must call PMON once during initialization to enable the pulse measurement hardware Otherwise the two functions will only return O You should avoid repeatedly executing PMON function otherwise the pulse measurement hardware will be reset repeatedly as well and accurate measurement cannot be obtained If you no longer need to measure the pulse width or period for a particular channel which has been PMON before you should disable it using PMOFF to save CPU time because pulse measurement is interrupt driven and consumes CPU time PMON 1 PMOFF 5 PULSEWIDTH PUSEPERIOD PRINT n x y z Statement Purpose Parameters To send a string of ASCII characters formed by its parameter list x y z out of the PLC to other devices via the communication port n n must be an integer constant of between 1 and 8 Integer value in the parameter list y z will be converted into the equivalent ASCII 11 15 Action Examples Comments See Also representation Each parameter must be separated by the semicolon The ASCII string is first formed by the PRINT statement using all the arguments in the argument list and the completed string is then sent out of the serial channel n at one go The PRINT statement automatically s
86. archy The result is then multiplied by 40 because multiplication has a higher priority then 10 6 addition Finally 3 will be added to the result If two operators are of the same hierarchy then compiler will evaluate from left to right e g X 5 4 3 5 4 is first computed and then 3 will be subtracted The following table list the hierarchy of various operator used Hierarchy Symbol Descriptions Highest Parentheses 2 MOD Multiplication Division Add Subtract Negate amp h c Logical AND OR XOR NOT Lowest lt gt gt gt lt lt Relational operators 5 Integer Variable Comments NEW With Trilogi version 6 2 and above you can now attach comments to any variable register name of any length to make program easier to read The compiler will ignore any alphanumeric characters A to z O to 9 and that are attached behind the variable name following an underscore character It is important to understand that by appending these comments to variables no new variables are being created For Example X_Some_Integer corresponds to X An integer variable such as DM 1 can have different comments each time it is referenced in the same program because the compiler ignores the comments anyways Although in most cases it may be best to limit a variable to one comment to avoid potentially overwriting data since no new variables are actually create as mentioned above For Example If an in
87. art input by releasing the button 5 14 The timer coil Duration being connected in parallel to Run relay will also be energized However its contact will only be closed after 100 seconds when its present value counted to 0 To break the latched On Run relay we must energize the Stop inout momentarily to break the oower flow Try it now Let s restart the system by turning ON the Start input momentarily again Next we want to turn ON the Manual input Move the mouse pointer to the Manual input and then press the right mouse button Manual input will be stuck at ON state even after you have released the right mouse button Click on Manual button using the right mouse button again and it will be turned to OFF When Manual input has been turned ON the running lights should stop This is because the normally closed contact of the Manual input in Circuit 2 is now turned OFF and the 0 5s clock pulse could not trigger the AVseq function anymore If you now left click on the Step input the running lights will move one step at a time in response to your mouse click Observe the Seql x contact with respect to the counter value of Seq and the logic of this circuit become very clear instantly Observe that the timer Duration continues to count down every 0 1 second and when it reaches O the Duration output coil label will be highlighted You can use this timer to stop the program by conne
88. be an input output relay timer or counter contact The moment this O bit DialModem is turned on the PLC will begin to execute the sequence of dialing the remote modem waiting for a successful connection and then turning on an I O bit with the label name Connected If the dialing cannot be completed within 30 seconds this custom function will hang up and then re dial The process will be repeated indefinitely until either a successful connection is made or if the DialModem i o has been turned OFF To disconnect from the modem hang up your PLC program just have to turn off the DialModem I O bit and the abovementioned custom function will automatically perform the action of hanging up the modem Note Since the PLC does not have a carrier detect CD connection to the modem therefore if the connection is lost after a successful initial connection the PLC would have no way of knowing it immediately Your program would have to detect this condition e g if it sends a file service command and does not receive a lt OK gt acknowledgement string from the host Once the PLC notes that the connection is lost it can re establish the connection by simply turning off the I O bit with label name Connected say by executing the CLRIO Connected statement As long as the DialModem I O bit is on the custom function will re dial and attempt to make another connection if it notices that the Connected bit has been turned OFF for what
89. ble and before the Inputs table A Special Bits aa G Then click on the SeqN x item to insert a Normally ON sequencer bit You will be prompted to select a seas Ae sequencer from a pop up menu Choose the desired sequencer 1 to 8 and another dialog box will open up for you to enter the specific step number for this sequencer Each step of the sequencer can be programmed as a contact on the ladder diagram as SeqN X where N Sequencers 1 to 8 X Steps 0 31 e g Seq2 4 Step 4 of Sequencer 2 eq5 25 Step 25 of Sequencer 5 Although a sequencer may go beyond Step 31 if you define a larger SV for it only the first 32 steps can be used as contacts to the ladder logic Hence it is necessary to limit the maximum step number to not more than 31 1 Special Sequencer Functions Quite a few of the ladder logic special functions are related to the use of the sequencer These are described below Advance Sequencer AVseq Increment the sequencer s step counter by one until it overflows This function is the identical to and hence interchangeable with the UpCtr function Resetting Sequencer RSseq The sequencer can also be reset to become inactive by the RSseq function at any time Note that a sequencer that is inactive is not the same as sequencer at Step 0 as the former does not activate the SeqN 0 contact To set the sequencer to step O use the StepN function described next Setting Se
90. bort button The Abort button shown below can be used to abort any changes made to the currently opened Custom Function since it was opened and close the custom function editor 9 7 lll Custom Function Execution It is important to understand when and how a TBASIC based Custom Function is executed with respect to the rest of the program There are basically two ways in which a CusFn will be executed 1 Triggered by Ladder Logic Special function coil CusFn A custom function may work the same way as any other special functions in the TRILOGI ladder diagram programming environment When you are in ladder circuit editing mode select the or icon to create a special function output A pop up Select a Function menu will appear EE i TRILOGI Version 6 20 C TRILOGI TL 6 usr samples lf Then Else PC6 EBR File Edit Controller Simulate Circuit Help ras DNCtr Decrement Rew Counter JERSCEr Reset Counter Upctr Increment Rev Counter A seq Advance Sequencer RSseq Reset Sequencer StepN Set Sequencer to Step N Latch Latching Relay Output Clear Clear Latched Relay ILock Interlock Begin ILoff Interlock End ADIFU Differentiate Up ADIFD Differentiate Down CusFn Custom Function dCusF Diff Up Custom Funes MaRST Master Reset TBASIC support the block structure off Each IF mustbe matched by an ENDI Compare Comparison operators are gt
91. by testing the STATUS 2 function This command by default uses MODBUS function 03 to perform the read which means that it is designed to read from holding register addresses 4 xxxx You can force it to change to using function 04 in order to read from addresses 3 xxxx by executing SETSYSTEM 6 4 only for CPU with firmware revision r47 and above READMODBUS WRITEMODBUS WRITEMB2 STATUS 2 SETSYSTEM To Force immediate refresh of the physical inouts and outputs This can be used after executing a SETBIT or CLRBIT command on an output n variable and to force the physical output to change immediately subject to I O refresh time delay Otherwise the physical output will only be updated during the normal refresh cycle which will occur only at the end of every ladder logic scan This is useful for situations that require immediately action such as shutting down a load during an emergency This command is likely to be used mainly by an Interrupt CusFn Note that REFRESH command on M series PLC takes up to 2ms to complete and if used frequently could increase the program scan time significantly REM or Statement Purpose To allow explanatory remarks to be inserted in a program The text after the REM statement until the end of the line will be ignored by 11 18 Examples RESET Purpose RETURN Purpose See Also the compiler An abbreviation for the REM statement is the apostrophe REM Waiting f
92. captured into these two buffer areas The data must be entered in comma delimited format as described below 1 Integer EEP Buffer Format Integer EEPROM data should be entered in the format adaress data and a line break E g to store decimal data 12345 equivalent to 3039 in hex into address 10 enter the following text into the Integer EEP Buffer area 10 12345 or in hexadecimal data format 10 amp H3039 7 16 2 String EEP Buffer Format String EEPROM data should be entered as adaress text string E g to store the string Test Message 10 into string address 5 enter the following text into the String EEP Buffer area 5 Test Message10 8 Rm Temp 25 DFC If you need to store a non printable character or ASCII character which is gt 127 in value into the string EEP buffer you can enter it as an escape sequence which is in the format of XX The backslash character denotes that this is an escape sequence and XX is the hexadecimal value of the character E g character A can be written as 41 and character Z can be written as 5A In the second example above the DF character is ASCII 223 which on an LCD216 or LCD420 will be displayed as a symbol Note 1 Normally when an EEPROM is in erased state all it memory bits contain binary 1 and when you read them from the EEPROM as string they will be returned as FF 2 To prevent disrupting communication with the
93. ch ch must be a numeric constant between 1 and 8 The actual target hardware determines the valid port This function returns an empty string if there is no valid string waiting at serial port in order not to hold up the CPU Example For I 1 to 1000 loop 1000 times AS INPUTS 1 Read from COMM1 IF LEN AS lt gt 0 String is not empty RETURN AS contains data ENDIF NEXT SETLCD 1 1 Nothing received Comments A Carriage Return CR or ASCII code 13 marks the end of a valid input string from the communication port The returned string however will exclude the CR character In TRILOGI simulator the user will be prompted to enter the string in a pop up window See Also INCOMM PRINT OUTCOMM INTRDEF ch fn_num edge Purpose Enable Interrupt Inout channel ch ch channel number 1 8 fn_num Custom Function number to execute when interrupt pin changes according to the defined edge This is the Interrupt Service Routine ISR edge Positive number means rising edge triggered 0 or negative number means falling edge triggered See Also INTROFF INTROFF ch Purpose Disable Interrupt Inout channel ch See Also INTRDEF LEN x Purpose To return the number of characters in x Examples L LEN This is a test string CHR 13 Comments L 22 because blanks and non printing characters are counted LET Purpose To assign the value of an expression to a variable Syntax LE
94. ch more convenient to use Scroll to the Inputs window by using the left right cursor keys or by clicking on the red color left right arrow buttons or simply select it from the choice box between the left right arrow buttons Move the deep blue color highlight bar to Inout 1 position by clicking on it Click again to open up a text field for entering the name for Input 1 Enter the name Start for Inout 1 Press lt Enter gt key to accept the name The text field will be closed and the name Start is now assigned to Input 1 If you made a mistake simply press the spacebar or click on the input location again to edit it Press lt Enter gt key again and the highlight bar will be moved to Input 2 Without using the mouse button simply start typing the name Stop at Inout 2 The text field will be automatically opened up at Inout 2 for entry Press lt Enter gt after typing in the name for Stop input Complete entries of the other two input label names Manual and Step as above Note that TRILOGI Version 6 2 and up allows I O label names of up to 16 characters However if you wish to keep Compatibility with Version 5 x to 6 1x you should use no more than 10 characters to define the I O names Also white soaces between names are not acceptable and will be automatically converted to the underscore character e g If you enter the name F series PLC for an I O it will be accepted as F_ series P 5 2 10
95. croll to the Counter Table Any counter to be used as sequencer can only assume label names Seq to Seqs corresponding to the counter numbers For e g if Sequencer 5 is to be 8 14 used Counter 5 must be defined as Seq5d Next enter the last step number for the program sequence in the Value column of the table Construct a circuit that uses the special function Advance Sequencer AVSeq The first time the execution condition for the AVseq function goes from OFF to ON the designated sequencer will go from inactive to step 1 Subsequent change of the sequencer s execution condition from OFF to ON will advance increment the sequencer by one step This operation is actually identical to the UPctr instruction The upper limit of the step counter is determined by the Set Value SV defined in the Counter table When the SV is reached the next advancement of sequencer will cause it to overflow to step O At this time the sequencers contact will turn ON until the next increment of the sequencer This contact can be used to indicate that a program has completed one cycle and is ready for a new cycle Accessing individual steps of the sequencer is extremely simple when programming with TRILOGI Simply create a contact NC or NO in ladder edit mode When the I O window pops up for you to pick a label scroll to the Special Bits table as follow 1 0 Labels The Special Bits table is located after the Ej Counters ta
96. cting a N C Duration contact to Circuit 1 This is left as an exercise for you Next please left click the button to bring up the View Variable window as shown in the next picture This panel displays the values of all the 32 bit integer variables A to Z some ADC DAC PWM readings and the PLC s real time clock values Also near to the lower right is a simulation of the LCD panel which simulates what will be shown on the LCD display when a SETLCD command is executed Note Only ASCII characters below 127 can be faithfully simulated on LCD ASCII characters above 127 will appear differently on the SIMULATOR from that shown on the actual LCD 5 15 ViewVariable Integers swana nann r ie ea nnn SEE Date 20067675 4 lines LCD Display Time 13 50 31 Cycle Count 90 Day Mon Hex Edt Close 15 In our custom function EventCount we have defined the following statements X X 1 Initial value of X 0 SETLCD 1 1 Cycle Count STRS X The first statement will add 1 to the variable X every time the custom function EvenCount is run and the second statement will show the value of X on the LCD display Since this custom function is called only when the contact Seql 4 goes from OFF to ON X effectively counts the number of complete cycles the sequencer has gone through You can see the value of X changes every complete cycle of the running light and the
97. ction to Internet TRILOGI Client Server Architecture Chapter 3 Using The TLServer Web Server for TRILOGI l Overview ll Serial Port Setup ll Configure Users IV Setup Emails V Files and Email Services Chapter 4 Running The Internet TRILOGI Client I Running The Internet TRILOGI Application Il Running TRILOGI Applet Using Web Browser Chapter 5 Ladder Logic Programming Tutorial l Your Assignment Creating Your First Ladder Logic Program ll Testing Your Ladder Logic Program Using The Simulator ll Transferring Your First Ladder Program To The PLC Chapter 6 TRILOGI Ladder Logic Editor Reference The Browse Mode ll The Circuit Editing Mode Chapter 7 TRILOGI Main Menu Reference I File Menu ll Edit Menu ll Controller Menu lV Simulate Menu V Circuit Menu VI Help Menu Chapter 8 Ladder Logic Language Reference Ladder Logic Fundamentals Contacts Coils Timers and Counters ll Special Bits 2 3 3 3 3 8 3 10 3 15 7 7 9 7 13 7 19 7 20 7 22 8 1 Ill IV Special Functions Using TRILOGI Sequencers Chapter 9 Introduction to TBASIC Custom Functions l Il Ill iV V VI Overview Custom Function Editor Custom Function Execution Simulation amp Examination of TBASIC Variables On Line Monitoring of TBASIC Variables Error Handling Chapter 10 TBASIC Statements Functions Operators l ll Ill IV And Variables What a
98. currently selected circuit The current circuit number will be increased by one while the new circuit will assume the current circuit number You will be placed in the circuit editing mode for immediate circuit creation Move Circuit You can rearrange the order of the circuits by using this command Select the circuit you wish to move and execute the Move Circuit command then select a destination circuit location and press lt Enter gt The selected circuit will be moved to the new location before the destination circuit Note that if you wish to move a block of circuits to a new location you may find it more productive to use the Cut Circuit and Paste Circuit commands in the Edit menu Append Circuit Execute this to add a new circuit to the ladder logic program This new addition will be positioned immediately after the last circuit in the entire program Delete Circuit This command allows you to delete one or more circuits You will be prompted to enter the range of circuits that you wish to delete Please note that you can t UNDO a delete circuit operation 7 21 VI Help Menu All contents in this manual are available for instant reference on the computer where the TRILOGI program is running This includes running the applet version of TRILOGI program on a remote browser because the relevant help files will be retrieved from the TLServer automatically You can call up the help files anytime by pressing
99. d each line should contain no more than 70 characters A comment circuit may be moved around or deleted just like any other ladder circuits If you wish to edit the comment just double click on it or press the lt Spacebar gt to open up the comment editor window You can use the normal text editing keys such as left right up Gown cursor keys and lt Ctrl Left gt lt Ctrl Right gt lt Del gt and lt Backspace gt keys for editing the comment text Testing Your Ladder Logic Program Using The Simulator The stage has been set and the show is ready Having completed the demo program it is time to test if it works as intended using the built in real time programmable controller simulation engine Open the Simulate pull down menu and activate the command Run All I O reset Ctr F9 TRILOGI will immediately compile the ladder program and if no error is detected it will instantly proceed to open up the Programmable Logic Simulator screen as shown below 5 12 Programmable Logic Simulator Eel 1 If you have followed closely all the instructions during the creation of the demo program you should not encounter any compilation error However if you do receive an error message then please check your circuit against the picture shown onpage 5 1 then make all the necessary corrections and try again 2 The simulator screen comprises 5 columns Input Timer Counter Sequencer Relay and Output With the exception
100. d for adding comments copying or delete circuit as well as for re arranging the order of the ladder circuits Please refer to Chapter 7 for descriptions of the actions associated with each item in these menus FE i TRILOGI Version 6 20 C TRILOGINTL 6 usr samplesWemo PC6 Sou E BRK File Edit Controller Simulate Eemi Circuit 1 ae 3 EE Insert Comment Insert Circuit Run RLY Move Circuit Duration Append Circuit Ih Delete Circuit Step Waruar t Seq i i Avseg Manual FE i TRILOGI Version 6 20 C TRiLOGI TL6 usr samplesWemo PC6 Sour E BR Controller Simulate Circuit Help Ci abort Edit Circuit Last Undo Ctrl zZ me Cut Circuit Copy Circuit Ctrl C IM Paste Circuit Ctrl V B Seq Find Ctrl F lisen Goto Ctr1 G I O Table F2 s En View I O Type on Ladder SL OUT Edit Custom FunctionF7 Outs Clear Custom Function 6 4 ll The Circuit Editing Mode TRILOGI comes with a smart editor that allows you to insert or delete a single element within a circuit easily The editor interorets your circuit immediately upon entry and prevents you from creating illegal circuit connections The functions of various keys in the circuit editing mode are detailed below You know that you are in the circuit editing mode when a row of ladder logic icons appears along the upper status line next to the circuit number and a yellow color highlight bar appears which you can move to s
101. d series contact at the location of the highlight bar Pick the Stop label from the Input table to add the series contact 5 6 24 25 26 27 28 29 We will now connect a relay coil Run to the right of the Stop contact Click on the icon to insert the coil Select RUN label from the Relay table Remember that an input can never be used as a coil Fortunately TRILOGI is smart enough not to call up the Inputs table when you are connecting a coil to avoid unintentional errors Notice that the coil symbol RLY indicates that this is a relay coil which is helpful in identifying the function of the coil TRILOGI automatically places the coil at the extreme right end of the screen and completes the connection with an extended wire Right below the relay coil is a parallel timer coil with label name Duration To create this coil click on the icon This allows you to connect a parallel coil to the existing coil The I O table will pop up for selection again Since we want to choose a timer scroll to the Timer table and pick the first timer with the label Duration to complete the circuit Press the lt Enter gt key once to complete Circuit 1 Congratulation You have just successfully created you very own ladder logic circuit It is that simple Now press lt Ctrl S gt keys to save the file to the hard disk We will now create Circuit 2 as shown below oy nr Manual Segi Avseg Clik
102. d system variables etc may be assigned a value using the assignment statement A 1000 X H I J len AS ii Arithmetic Operators Symbol Operation Example y Addition A B C 25 Subtraction Z TIME 3 10 x Multiplication PRINT 1 X Y Division X A 100 8B MOD Modulus Y Y MOD 10 iii Bitwise Logical Operators logical operations is perform bit for bit between two 16 bit integer data Symbol Operation Example amp logical AND IF inout 1 amp amp HO2 logical OR output 1 A amp HO8 A Exclusive OR A RELAY 2 B logical NOT A timerPV 1 iv Relational Operators Used exclusively for decision making expression in statement such as IF exoression THEN and WHILE expression Symbol Operation Example Equal To IF A 100 lt gt Not Equal To WHILE CTR PV O lt gt 0O Greater Than IF B gt C D 10 Less Than IF TIME 3 lt 59 oe eat Than or Equal WHILE X gt 10 a Less Than or Equal To IF DM I lt 5678 AND Relational AND IF A gt B AND C lt D OR Relational OR IF A lt gt 0 OR B 1000 v Functional Operators TBASIC supports a number of built in functions which operate on integer parameters as shown below ABS n ADC n CHR n HEX n STRS n Hierarchy of Operators The hierarchy of operators represents the priority of computation E g X 3 40 5 2 The compiler will generate codes to compute 5 2 first because the parentheses have the higher hier
103. ddresses grow larger up to a certain point the integer and string data space will cross path and overwrite each other s space It is therefore the programmer s responsibility to check that this does not happen Here is how Assume the total EEPROM space for integer data N words 16 bit Total number of data EEPROM space 2N bytes gt Maximum number of string EEPROM space 2N 40 rounded down To determine the upper limit of one type of storage you have to first decide how much space you want to allocate to the other type E g 1 N 1700 and you want use the first 510 location for integer data that means the maximum number of string space available 1700 500 2 40 59 E g 2 N 7700 and you want to store 200 strings The maximum number of integer space available 7700 2 200 40 2 3700 11 2 SETBAUD ch baud_no Purpose Examples SETBIT v n Purpose Examples Comments See Also To set the communication Baud Rate of the PLC s serial channel ch All the M series PLC serial ports are defined as 8 data bit 1 stop bit and no parity and each has been preset to a certain default baud rate which the PLC will assume every time its Powers up The baud rate may or may not be changed depends on the PLC model Please refer to the PLC s Users manual for the baud_no that represent the baud rate of each serial channel and the range of baud_no each of these serial ports may assume Ca
104. dit Circuit from the Edit menu lt Enter gt When you are done with editing the current circuit hit lt Enter gt to proceed to the next circuit lt SHIFT gt If you observe the highlight bar carefully you will notice a dark green color square at the right end of the highlight This indicates the insertion location where a series contact will be attached You can change the insertion location to the left or the right of the highlight bar by pressing the lt SHIFT gt key The position of the cursor has no effect wnen you connect a parallel contact to the highlighted element The left terminal of the element will always be connected to the left side of the parallel branch 6 7 lt 0 gt to lt 9 gt lt gt amp lt E gt keys Pressing the key lt O gt to lt 9 gt and lt gt is equivalent to clicking on the icon shown in the table The equivalent keyboard number is shown as a small numeral at the lower right corner of the icon The lt gt key is the quickest way of converting a normally open contact to a normally closed one and vice versa Pressing the lt E gt key when a contact or coil is selected allows you to edit the label name directly Note that it is the user s responsibility to ensure that the label is valid 6 8 Chapter 7 TRILOGI Main Menu Reference Both TRILOGI application and applet programs have nearly identical look and feel as shown below with the exception that the applet can t
105. e 1 New lt Ctr N gt 7 1 Activate this command when you want to create a new ladder logic program All current ladder circuits and custom functions will be cleared from the screen and the default filename is Untitled poc 2 Save lt Ctr S gt This command saves the whole ladder logic program all I O tables and all the custom functions to the disk The current file will be saved to the same source from which it was opened from i e if a file has been previously opened from the TLServer via the network this command will save the file back to the TLServer Likewise a file opened from the local hard disk will be saved automatically to the local hard disk 3 Open TLServer 3 lt Ctrl O gt This command is for loading a TRILOGI file from the TLServer version 3 x When executed you will be prompted to enter the Username and the Password to gain access to the TLServer The same Username and Password must have already been defined in TLServer for this to work If you are running TRILOGI as a local application instead of as an applet you may be required to enter the IP Address port of TLServer in order to connect to a remote TLServer Note that last entry of IP Address port is saved to the TL6 configuration file and will be loaded when the TL6 application re starts Each user has his her own exclusive directory for storing his her TRILOGI files Once authenticated a network file dialog will be opened for you to select
106. e CusFn execution Thus it will be futile to wait for the INPUT n variable to change inside a CusFn unless you execute the REFRESH statement to refresh the physical I O before you examine the INPUT n variable again 9 9 vi vii Likewise any changes to the OUTPUT n variable using the SETBIT or CLRBIT statement will not be transferred to the physical outputs until the end of the current ladder logic scan Hence do not wait for an event to happen immediately after executing a SETBIT or CLRBIT statement on an OUTPUT n because nothing will happen to the physical output until the Current ladder logic scan is completed If you want to force the output to change immediately you will need to execute the REFRESH statement Consideration must be given to how such an act may affect the other parts of the ladder program since not the entire ladder program has been executed REFRESH may also take a long time to execute e g it takes 2ms to execute a REFRESH statement on a TIOOMD PLC so it can increase the program scan time significantly Like all ladder circuits the relative position of the circuit that triggers the CusFn may affect the way the program works It is important to consider this fact carefully when writing your ladder program and TBASIC CusFns Always remember that the CPU executes the ladder logic and CusFn sequentially even though the equivalent circuits in hard wired relay may seem to suggest that the different rungs
107. e extension from PCS to PC6 via Windows File manager and then attempt to open it from TL6 otherwise TL6 will complain that it is not a valid TRILOGI file b Any Unicode characters used in the program that cannot be represent by 8 bit ASCII code will be lost when the file is saved in PCS format and it is not recoverable So if you use non English I O labels your program will most likely fail to compile when it is saved as a PC5 file since the I O labels will be converted to ASCII and partially truncated Thus it is important to keep the original copy of your PC6 program so that you can work on it to resolve the Unicode conversion issues View Protect Un Protect This feature allows you to prevent others from viewing a pre defined range of ladder logic and custom functions When you select View Protect command you will be asked to enter an unlocking password a range of ladder logic starting from circuit 1 as well as a range of custom functions whose content you wish to prevent others from viewing as follow Password Protection of TRILOGI File Enter range of elements to protect from viewing The moment you click on the View Protect button you can no longer view or print the protected range of ladder circuits and custom functions When you save the view protected program it will be saved in an encrypted format and it cannot be opened using older version of TRILOGI software However you will still be able t
108. e gt is the same as the Username defined here 3 8 e Select Username Double clicking on eae RRene esters an existing username opens up the username password dialog You can now add password to the Administrator if you wish to prevent unauthorized access to the predefined usernames and passwords There is also a pre defined user named samples with no password where many samples TRILOGI files are stored Add New User If you select a username and then press the lt DEL gt key you can delete the user provided its directory is empty You can use Window Explorer or TRILOGI Application to delete the contents of the user s directory first before deleting him her from TLServer Add New User Clicking on this field allows you to add new users to the system You can add as many users as you like subject to memory and hard disk limit Server Port If you click the check box to the left of the Server Port label you can change the default port that the TLServer listens on When the client accesses the TLServer Whatever you define here must be matched by the same port number E g if the port number 8000 then localhost access must be htte 127 0 0 1 8000 However if the port number is defined as 80 default port for HTTP server then you can access the server using just the IP address without the port number http 127 0 0 1 What Port Number Should TLServer Use In most cases you can simply use th
109. e outermost Interlock section i e ILoff need not be a matching pair for an ILock function Differentiate Up and Down dDIFU and dDIFD When the execution condition for ADIFU goes from OFF to ON the designated output or relay will be turned ON for one scan time only After that it will be turned OFF This means that the function generates a single pulse for one scan time in response to the rising edge of its execution condition When its execution condition goes from ON to OFF nothing happens to the output or relay that it controls On the other hand when the execution condition for ADIFD goes from ON to OFF the designated output or relay will be turned ON for one scan time only After that it will be turned OFF This means that the function generates a single pulse for one scan time in response to the trailing edge of its execution condition When its execution condition goes from ON to OFF nothing happens to the output or relay that it controls Execution gy Condition off DIFU function oy output _oFF ae 1 scan time Custom Functions CusFn and dCusF These two functions allow you to connect a user defined custom function CusFn to the ladder logic as if it is a relay coil Custom functions are created using the integrated text editor provided by TRILOGI Version 6 x 8 Master Reset An ON condition to this function clears all mailbox inputs Outputs relays timers and counter bits to OFF resets al
110. e predefined port number 9080 However you may like to read the explanation box below regarding definition of a Port You can see that the default port for most public web servers is port 80 You can define TLServer fo listen at port 80 as well in that case there is no need to specify the port number in the URL However there are reasons why you may or may not want to do that It depends on whether you are installing TLserver on a corporate intranet or on the public Internet and whether the client TRILOGI is to access TLServer within the intranet environment or from the public Internet Please read Appendix 2 PLC amp PC Hardware Setup and Configuration for an explanation of how to use the port number properly 3 9 Ports or addresses within a computer are used to enable communication between programs Port addresses are 16 bit addresses that are usually associated with a particular application protocol An application server such as a Web server or an FIP server listens on a particular port for service requests performs whatever service is requested of it and returns information to the port used by the application program requesting the service Popular Internet application protocols are associated with well known ports The server programs that implement these protocols listen on these ports for service requests The well known ports for some common Internet application protocols are shown below Port Pro
111. e shown below TBASIC supports the following integer variables 26 Integer variables A B C Z which are 32 bit variables Note that the variable name is a single character by default however as mentioned above you can append a comment to the variable EG A temperature A_distance both refer to the same variable A li A large one dimensional 16 bit integer array from DM 1 to DM 4000 where DM stands for Data Memory A DM is addressed by its index enclosed between the two square brackets and J e g DM 3 DM A B 5 where A and B are integer variables A comment can also be appended to DM variables as follows DM 1 Current status of product refers to variable DM 1 iii System variables These are special integer variables that relate to the PLC hardware as follows NOTE All of the following System Variables can have comments appended to them with the same format as described in section 5 Integer Variable Comments Inputs Outputs Relays Timers and Counters Contacts The bit addressable I Os elements are organized into 16 bit integer variables INPUT n OUTPUT n RELAY n TIMERBIT n and CTRBIT n so that they may be easily accessed from within a CusFn These I Os are arranged as shown in the following diagram I O numbers 48 33 32 17 16 1 Bit
112. e that the lt Ctrl F8 gt key also works in the Simulator screen so that at any time you can reset the simulator without affecting the logic states of the inputs Continue Run no reset lt F9 gt Use this command to continue simulating the program since you last closed the simulator All previous data are kept intact and will be used by the simulator to continue execution of the ladder program If you have made changes to the ladder program or custom functions the whole program will be recompiled before running 7 19 Note that first scan pulse 1st Scan will not be activated when this command is executed since this is supposedly a continuation from the previous simulation run This command can be useful if you have discovered a simple bug in your software during simulation you can fix it immediately and test the effect of the change on the simulator instantly without restarting the entire simulation session from the beginning again 4 Compile Only lt F8 amp gt Allow you to compile the TRILOGI file only in order to view the compilation statistics Compilation Success Total Number of circuits Ladder Diagram words 28 Custom Function words 17 Total code Size Checksum 0B3B 5 Reset All I Os lt Ctrl R gt Clears all I Os in the simulation engine without invoking the simulator Since all I Os whose logic states are turned ON in the simulator will also be shown as highlight on the ladder diagram this
113. e the right to access local hard disk resources The default file extension for opening a TRILOGI file is PC6 This signals to the TL6 application that the file is in Unicode format and TL6 will then load it accordingly However TL6 is also able to read files with PC5S extension which are files created by older TL5 applications TL6 assumes that all PCS files are stored in ASCII format and will load it accordingly To display PC5 files in the Open File dialog simply enter the string PC5 in the File Name text field and press lt Enter gt The window will now display only files with PC5 extension You can then navigate to the folder that contains the PC5 files to pick the file you want to open The default file extension for saving a TRILOGI file in TL6 is PC6 This signals to the TL6 application to save the data in Unicode format Unicode is required to store international characters which cannot be properly saved in the ASCII format used by TL5 However you may still save the currently opened TRILOGI file in TL6 to a file with an extension PCS which will then instructs TL6 application to save the file in ASCII format Files saved with PC5 extension may then be opened using older TL5 applications 7 3 Important Notes a Since PC6 files are saved in Unicode while PC5 files are saved in ASCII code format the two files type are NOT interchangeable Therefore you must not simply change a file nam
114. ed Web browser to access the PLC without the need to install a local copy of the TRILOGI application software Note 1 TRILOGI 6 x can only open or save files on TLServer 3 x but not on TLServer 2 x since TRILOGI 6 x requires the Unicode support found only in TLServer 3 0 in order to open save PC files on the TLServer However TRILOGI 6 x can still access and communicate with any PLC connected via the TLServer 2 x or Ethernet Xserver 3 1 2 Since Version 2 0 TLServer also provides File and Email Services to the PLCs That means that a PLC can send a command to the TLServer to open a file and save its data into the PC s hard disk It can also command the TLServer to send out the data as an emai File and Email Services are described in Section V in this chapter The current Email Service works differently from the original email function provided in TLServer 1 0 in that TLServer does not poll the PLC instead it is the PLC that initiates an email request asynchronously This makes it possible for a PLC to dial in via a modem to request the TLServer to help it send out an email without demanding a constant connection the TLServer However the original email function is still supported in Version 2 x and 3 x because it has the advantage of being able to service email requests for multiple PLCs linked via the RS485 network TLServer version 3 15 introduces a change to the Setup Emails area which is explained in the
115. ee Also minimum When STEPMOVE command is first executed the internal relay r will be cleared before the first pulse is sent After the completion of the movement i e when all the pulses have already been sent the relay r will be set ch should be between 1 and 8 Count is a 32 bit integer number which allows you to program the stepper motor to move from 1 to 2 i e 2 147 483 647 steps Count can also be an integer variable A Z However If you use a 16 bit variable such as DM n for count then the range of movement can only be between 1 to 32 767 Speed pps Stepper pulse output speed trajectory If the total number of steps to move is less than 2 times accsteps Desired speed will not be reached Desired speed S i 4 Pp po No of Steps gt ed accsteps Total steps 2xaccsteps accsteps Pulse generation can be interrupted by issuing a STEPSTOP command in another CusFn which may occur say in cases when the hardware hits a limit switth and must stop the motor immediately When a stepper channel is already activated i e mid way through its pulse generation repeat execution of STEPMOVE command on the same channel will be ignored by the PLC Re execution of the STEPMOVE Command on this channel can only take effect after the channel s pulsing operation has been completed by itself or aborted by the STEPSTOP command When in TRILOGI simulation mode execution of the STEPMOVE command will bring up
116. elect an element in the ladder circuit as shown below re i TRiLOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help Girat SR PRE oe on Hen 2 e e A 1 Mouse Actions Left Click When you click on an element using the left mouse button the element is selected and highlighted by the yellow color highlight bar Right Click When you click on an element using the right mouse button you are allowed to directly edit the label name of the element This can be a convenient feature if you need to change one or two characters in the name only However if the element is a custom function dCusFn or CusFn then the custom function editor will be opened for you to edit the function directly Insert Ladder Element You create the ladder circuit element simply by moving the mouse pointer to the icon and pressing either the left or the right mouse button to insert a ladder logic element to the currently highlighted element The following is a description of the functions of each icon A yellow color highlight bar will appear which you can move to select an element in the ladder circuit 6 5 lt 1 gt Left click to insert a normally open series contact lt 2 gt Right click to insert a normally closed series contact lt 3 gt Left click to insert a N O parallel contact to highlighted jp element lt 4 gt Right click to insert a N C parallel contact to highlighted element lt 5 gt Left click
117. elp file would open up in a new window with the syntax for the READMODBUS keyword Now you will be immediately presented with the helo document for READMODBUS command in the lower pane of the custom function editor as illustrated in the following screen shots 7 22 E Custom Function 1 MBREAD Seles Control Find Find All 1 MBREAD v gt Rename Function Order Sales 1 877 TRI PLCS 1 877 874 7527 Select Keyword v Inquiry 8 30am to 5 00pm PST Aon Fri Undo Abort Less JLab Press the lt F1 gt key once after you have selected the keyword of interest and the help file for the selected keyword will be immediately loaded in the lower pane of the custom function editor as follows 7 23 KE Custom Function 1 MBREAD 4 i READMOD Purpose BUS ch DevicelD address Automatically query a MODBUS ASCII device and return the 16 bit register data using the MODBUS ASCII protocol The communication baud rate is the default baud rate of that COMM unless ithas been changed by the SETBAUD command ch PLC COMM port number 1 8 DevicelD device ID of the MODBUS device 1 to 255 address zero offset address of the holding register in the MODBUS device Examples relay 3 READMODBUS 3 5 101 Comments The relay wil contain the 16 int data obtained from the MODBUS device with ID 05 and from register offset address 10 n MODB
118. em manufacturer specifies otherwise The PLC can be operating at a different baud rate from the PC to modem line rate because of the modulation demodulation action of the modem Important The PLC to modem connection must be properly prepared before you can use TLServer to connect to the PLC s modem Please refer to Appendix 3 to read more details about the PLC to Modem Communication Setup Once you have entered a proper phone number click on the Connect button to start dialing the modem make sure that the Auto Answer check box is not checked If the remote modem is busy or does not answer the call you will see the corresponding error messages in the response box Click on the Hang Up button anytime to abort the dialing operation If you click on the Special button a special dialog box will appear as follow 3 6 2 Special Setup e You can change the DIE speed by selecting a new value from the choice 115200 menu e You can specify a special AT command to be sent to the modem during modem initialization Normally you can leave this ts field to its default value which is AT amp KO You can also specify a special Call in Password which is only used if the TLServer puts itself in auto answer mode see description later Any incoming connection made by a remote modem must give the correct password upon connection otherwise the connection will be immediately dropped The Call ln password feature is disabled if t
119. ends a Carriage Return CR ASCIl 13 out of the specified serial port after sending out the last character in the argument list A PRINT statement that ends with a semi colon will not send the CR character If you have a long string to send than you can use to break the whole command into several lines with each line ending with a except the last lines PRINT 2 The value of A B A B PRINT 2 Units IF A 5 and B 100 the string The value of A B 105 Units and a CR character will be sent out via Comm port 2 In TRiLOGI simulation mode the ASCII string will be displayed on a pop up window to simulate PRINT action INPUTS PULSEFREQUENCY c PULSEPERIOD c PULSEWIDTH ci Purpose Example See Also Return in Hz the frequency of the last input pulse Return in microseconds the width or period of the input pulses arriving at channel ch of the pulse measurement pin The pulse measurement channel ch must have been enabled by the PMON statement already If the pulses stop coming in then PULSEFREQUENCY will return a zero while the other two functions will saturate at a certain maximum value for TIOOMD it is equivalent to about 3 28 seconds ch channel 1 8 A PULSEWIDTH 1 PMON PMOFF READMODBUS ch ID addr Purpose Use the MODBUS ASCII or RTU protocol to automatically query a MODBUS ASCII or RTU slave device and obtain the desired 16 bit 11 16 Example Comment
120. enses the type of communication protocols sent to it and responds accordingly You may however fix the protocol type so that it does need to check the protocol type before responding This command also allows he PLC 11 25 to be defined as No Protocol so that it will not automatically resoond to data that it receives which appears like one of the supported protocols This may be important in some applications in which the PLC serial port is used purely to receive incoming data via INCOMM and INPUTS and you do not want it to respond to some data that appears to it as a valid communication protocols This is also useful for implementing user s Own Communication protocol without worrying about conflict with the existing protocols ch 1 2 or 3 COMM port number mode Q Auto sensing default mode 1 Fixed at RTU mode 2 Fixed at EMIT mode 3 Fixed at MODBUS ASCII mode 4 Fixed at OMRON C20H protocol mode 5 Fixed at NATIVE host link command mode 10 No protocol For creating user own Custom protocol IMPORTANT Please note that if you set the protocol to other than the Native mode 5 or Auto mode O0 that serial port will no longer resoond to commands from TRILOGI and you will encounter Communication Errors when you ty to perform any communication using TRILOGI with that serial port You can still use the other unaffected serial port e g COMMS RS485 that support host link commands To regain commu
121. er Circuit diagram using the scroll bar or cursor keys to find the circuit that you are looking for there exist several short cuts to enable you to quickly jump to specific circuit in the program E g If you click on the _ Cireuit 1 you will be prompted by a Goto Circuit dialog box to enter the circuit number to jump to immediately You can also call up the Goto Circuit dialog by pressing lt Ctr G gt key anytime If you have a large ladder program with multiple rungs of circuits then you will find the Quick Tag feature very useful for quickly jumping from one circuit to another The quick tags appear as blue button along the top of the TRILOGI editor windows B EEBB you can define up to five quick tags by clicking on Define GuiekTadS each tag corresponds to a specific circuit By default all 5 tags points to circuit 1 Once you have defined the circuit for a tag then when you click on the quick tag button the editor instantly jumps to the pre defined circuit number When you click on Define Quick Tags the following window will appear 6 2 Quick Tags Definition and Selection Tag No Circuit Description 5 viii Change 1 Pump Start You can select the Tag No either from the choice box or by clicking on the blue tags o 2 Then enter or edit the circuit to associate with the selected tag You can optionally enter edit a description for the tag to helo you recall the purpose of t
122. er logic editor comprises two modes the Browse mode and the Circuit Editing mode I The Browse Mode You are normally in the browse mode when you start up the program The browse mode allows you to manipulate a ladder logic circuit rung as a single entity you can view any circuit make copies of it move it fo another location or delete it entirely Each complete ladder logic circuit is given a circuit number You should see a small red color marker showing you the currently selected circuit The circuit number of the selected circuit is shown on the upper status line as Circuit xxx 1 Mouse Actions Since TRILOGI Version 6 x runs under windowing environment all Usual mouse action applies You can grab the vertical scroll bar to scroll to your desired circuit and click on it to select it Double clicking on a circuit enters the Circuit Editing Mode which will be described later 2 Keyboard Actions The functions of various keys in the browse mode are explained below lt Spacebar gt Allow you t o enter Circuit Editing mode for the currently selected circuit If the selected circuit is a comment circuit the comment editor will be opened automatically lt F1 gt Activate the help function to display on line help lt F2 gt Open the I O Table to create the I O label name Turns ON OFF display of the I O type and the physical lt F3 gt O number for ladder logic contacts on the screen
123. err 4s Manual Follow the steps 20 to 23 to create the following circuit fragment EE i TRiLOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help Circuit 2 zi yA eT Ise 9 e rte Geng gt i iy oe 5 7 30 We want to enclose the two series contacts Step and Manual with a 31 32 33 parallel branch that contains two elements First we will create the branch for the N C Manual contact Click on the element Step to highlight it Then right click on the icon to create a N C parallel circuit that encloses both the Step and the Manual contacts A cross will appear at the left hand end of the Step contact indicating that this is the starting location of the parallel circuit You should now click on the Manual contact to select the ending location for the parallel circuit The yellow highlight bar will be positioned at Manual contact now You will notice that the H Escon has now changed into a yellow color N C contact ith an opposite connection arm You should now click on the Askymbol to close the parallel branch One possible short cut method is to double click at the ending location to close the branch As usual an I O table will be opened for you to select the I O For now select the Manual label from the input table to create the following Circuit es i TRiLOGI Version 6 20 Untitled File Edit Controller Simulate Circuit Help B a eH lol
124. ese are 16 bit unsigned integer variables b emEvent 1 tO emEVENT 16 These are 16 bit unsigned integer variables EMEVENT 1 is also used for email purpose C emLInt 1 to emLInt 16 These are 32 bit unsigned integer variables Note that since EMLINT 1 to EMLINT 16 form an integer array these 32 bit integer variables can be easily addressed by an index such as EMLINT n which is not possible with the 32 bit integer variables A to Z 10 10 ABS x Purpose Examples Comments ADC n Purpose Examples Comments ASC x n Purpose Examples Comments See Also CALL n Purpose Examples See Also Chapter 11 TBASIC Keyword Reference To return the absolute value of the numeric expression x A ABS 2 16 100 A should contain the value 68 To return the value from the Analog To Digital Converter channel n n should be between 1 and 16 A ADC 2 n may be a numeric expression which returns a value between 1 and 16 If it is ouf of range a run time error will be reported and the function will be aborted TRILOGI software is able to support up to 16 channels of 16 bit bipolar ADC which may has a range between 32768 and 32767 The actual number of ADC channels and the resolution will depend on the target PLC On the T100MD and T100MX there are 8 or less ADCs and all the A D are normalized to 12 bit with a range of between 0 and 4096 To return the numeric value t
125. ested exception is java net ConnectException Connection timed out connect Inactive PLC TLServer attempts to communicate with every PLC that has a non zero email service period However if the PLC is inactive e g It has not been turned ON or has been disconnected from the server the communication will fail Since Communication failure takes considerable amount of CPU waiting time and could affect the normal Communication with other active PLCs inactive PLCs are internally marked by the TLServer shown as message in the email setup dialog and will not be checked according to their defined service period to avoid repeated communication failure However TLServer will re scan these inactive PLCs every two minutes to check whether they have come on line If an inactive PLC is found to respond to command it will be unmarked and put back in service for its email request You can also manually force the re scanning of all PLCs by clicking on the Check button once Then scroll to the PLC of interest to check if there is a message Check the PLC communication port wiring if there is an error Writing TRILOGI Programs that Can Send Emails In order to send an email the TRILOGI program needs to use the string variables AS BS C to store the headers and DS to Z to store the messages Not all strings need to be used unused strings are still available for normal program use The special variable emEVENT 1 is used as an email request flag
126. ever reason A8 5 Copyright 2001 2009 Triangle Research International Inc All rights Reserved
127. f the modem marked WALL or Line DBS Male DB25 Male Female DB25 socket MODEM With DB25 socket Modem 2 The modem to be attached to the PLC modem2 must be an external modem with an RS232 connection port Since modem are DCE type device they most likely come with a female type DB25 or A3 1 DB9 socket meant for plugging into the PC s RS232 port Since the PLC s host link port is also a female DBY we need to construct a DB9Y male to DB25 male cable or DB9 male to DB9 male cable to link the PLC to the modem as follow DBS Male DBS Male Female DBS socket To PLC MODEM COMM1 with DBS Female socket Communication Speed When communicating via modems there are two different definitions of communication soeeds that you should be aware of e The DTE Speed or line rate is the serial communication soeed between the modem and the device connected to its RS232 port Most modems can automatically detect the RS232 speed of the device and can assume any speed from 1200 2400 all the way to 115 200 bps The first ASCII character they receive from the device will determine the DIE speed that the modem will use to communicate with the device e The modem to modem communication soeed is what you read on the modem specifications such as 33 6Kops 56Kbps etc When two modems are connected they automatically negotiate for the best soeed to communicate between the two of them based on the quality of the phone connection
128. ft The parameter n indicate the number of channels to be chained starting from i Upward n if only one variable is involved RSHIFT relay 2 3 11 19 Comments The relay channels 2 3 and 4 which represent relays number 17 to 64 are chained together in the following manner RSHIFT Relay 4 Relay 3 Relay 2 Bits are shifted from the upper channel towards the lower channel Bit 0 of Relay 4 will be shifted into Bit 15 of Relay 3 and so on Bit 0 of the lowest channel Relay 2 will be lost See Also LSHIFT SAVE_EEP data addr Purpose To store a 16 bit integer data in the users definable EEPROM address addr for non volatile storage If you attempt to save a 32 bit data only the lower 16 bit will be saved To save the entire 32 bit data save the upper 16 bit using the GETHIGH16 function and the lower 16 bit directly in two separate locations data may be a 16 bit integer constant or variable addr EEPROM address Actual PLC may have less EEPROM space Please refer to your PLC s reference manual for the upper limit Example save_EEP relay 1 100 See Also LOAD_EEP GETHIGH16 SETHIGH16 LOAD_EEP and SAVE_EEP SAVE _EEP strdata addr _ Applicable only to PLC with firmware r44 or higher Purpose To store a string strdat
129. gether to control the lamp A Master switch must be ON and one of the two control switches controlsw1 and controlsw2 must be ON while the other must be OFF in order to turn ON the lamp think of three way switches in your house and you will get the idea We can wire all 3 switches to 3 inputs of the PLC and the lamp to the output of the PLC We can write the following ladder program to perform this task Master controlsvv1 controlswv2 Lamp controls controlSw2 A contact with a across its body is a Normally Closed N C contact What it means is that the ladder program is using the inverse of the logic state of the input to interpret the diagram Hence in the above ladder diagram if Master and controlsW1 are turned ON but controlsW2 is turned OFF the lamp will oe turned ON since the inverse logic state of an OFF state controlsW2 is true Think of an imaginary current flowing through the Master contact then through the controlsW1 and finally through the normally closed controlsw2 contact to turn ON the lamp On the other hand if controlsW1 is OFF but controlsW2 is ON the Lamp is also turned ON because the current could flow via Master and then through the lower parallel branch via N C controlsW1 and the N O controlsWw2 Note As you can see although the switch controlSW1 is connected to only 1 physical input to the PLC but it appears twice in the ladder diagram If you actually try to connect phy
130. hat the Pause light on the PLC being turned ON Now you can actually turn ON the physical outputs or internal relays of the PLC by clicking on any output label using the LEFT mouse button Releasing the LEFT mouse button on the output will turn it OFF You can even latch ON or OFF an output by clicking on the label using the RIGHT mouse button Try it it can be fun Summary We have completed this tutorial and have successfully created a simple ladder BASIC program We have also performed real time simulation to test the program s functionality and have transferred the demo program into the PLC via the TLServer By now you would probably have a good appreciation of TRILOGI s superb Capability and ease of use and are ready to include TRILOGI as an integral part of your programming needs For more Ladder BASIC examples you should click the File menu and select Open Local Drive and then open example program files under the TRILOGI TL6 usr samples folder There are many well commented sample programs in this folder that you can open and run simulation to better understand how the LADDER BASIC programming language works 5 18 Chapter 6 TRiLOGI Ladder Logic Editor Reference TRILOGI s ladder logic editor window lies between the main menu bar along the top of the screen and the helo message line along the bottom of the screen The cursor will appear in the window whenever you are in the logic editor The ladd
131. hat is the ASCII code for the nth character of the string x If x is a null string ASC x n returns value 0 n may start from 1 up to the length of the string B ASC Test String 6 B should contain the value 83 which is ASCII value of S If n is less than 1 or greater than string length ASC x n returns a 0 CHR n To call another Custom Function CusFn n as subroutine When the called function returns execution will continue from the following statement n must be either an integer constant between 1 and 256 or the label name of the Custom Function defined in the Custom Function table IF B gt 5 THEN CALL 8 CALL Addition RETURN ENDIF Addition must be a defined name CHR n Purpose To convert a number n into its corresponding ASCII character n must be a numeric constant O to 255 Examples C This is Message CHR amp H35 Comments CS should contain This is Message 5 since CHRS amp H35 returns the character 5 In TL6 you can also use Escape sequence fo represent non printable ASCII characterr E g OD to represent CR character See Also ASC CLRBIT v n Purpose To clear the Bit n of the integer variable v to O n is an integer constant or variable of value between O and 15 v may be any integer variable or a system variable such as relay n outputfn etc If v is a 32 bit integer CLRBIT will only operate on the lower16 bits Following digital e
132. hat section of ladder circuit with which the tag is associated Then click the Change button to update the circuit and description at the corresponding tag location NEW In Trilogi version 6 2 and later the quick tags you have created will be displayed in the corresponding ladder circuits New programs created will set all the quick tags to a default value of O so that no quick tags are displayed until they have been manually created NEW In Trilogi version 6 2 and later there is a feature that allows you to immediately go the last circuit that was selected This is implemented by clicking on the button that is located beside the quick tag buttons which are described above Whether you move to a new circuit by using the Goto Circuit command or a Quick Tag or just by clicking on a circuit with the mouse the Last button will remember your last circuit position This also allows you to easily switch back and forth between two circuits an unlimited number of times because if you don t select a new circuit after pressing the Last key you will go back to the circuit you came from Note The Quick Tags definitions are saved along with the program body into the PC 6 file This means that the quick tags that you defined for a particular program can be recalled later when you open its PC6 file 6 3 4 Using the Circuit amp Edit Menu The Circuit and Edit menus contain various commands that you may nee
133. he original PLC IV Simulate Menu TRILOGI allows you to perform almost 100 simulation of your PLC s program off line on your PC This is a great tool for testing a program quickly before a machine has been manufactured It is also a wonderful tool for all new PLC programmers to practice their ladder logic programming skill without the need to purchase a PLC test station TRILOGI automatically compiles a ladder program before activating the simulator If an error is found during compilation the error will be highlighted where it occurs and the type of error is clearly reported so that you can make a quick correction 1 Run All I O Reset lt Ctrl F9 gt This should be the option to use when you first begin to test your TRILOGI program When executed all I O bits including inputs are cleared to OFF state all integer data are set to 0 and all string data are set to empty string Then the Programmable Logic Simulator window will open for you to conduct the simulation test of your TRILOGI ladder program Run reset Except i lt Ctrl F8 gt Very offen you may wish to keep the input settings as is when you reset the simulator This situation is quite realistic in the sense that when a PLC is powered on some of its inputs may already be in the ON state e g sensors may detect the end positions of a cylinder rod etc This command allows you to preserve the logic states of all Inputs while resetting all other data Not
134. he corresponding textbox is empty b Auto Answer If you select the Auto Answer checkbox and click on the Connect button the TLServer will setup the modem to automatically answer the incoming call on the first ring There are many uses of this capability Any number of PLCs in the field can periodically dial in to a single TLServer and write or append the values of their internal variables to data files on the PC s hard disk using the PLC File Service Commands This is extremely useful for deploying the M series F series PLC for data acquisition purposes You can format the data using CSV format so that the file can be readily imported into an MS Excel or Lotus 123 spreadsheet The remote PLC can dial in and ask TLServer to send out its data to any email address immediately The remote PLC can dial in and synchronize its real time clock with the TLServer The TLServer can play the role of an ISP where the PLC can dial in and be accessible to the Internet Some PC5 sample programs that enable a PLC to dial in to the TLServer and request for file or email services are provided in the following folder C TRiLOGI TL6 usr samples FileService_Modem To prevent unauthorized access by any incoming call you can specify a Call lIn Password string as described above If the Call ln Password contains any text other than an empty string then the incoming caller upon connection must immediately send a CR terminated string that
135. hile waiting for a response from a slave controller after executing a NETCMDS or a READMODBUS WRITEMODBUS command Default number of wait state 1 e g SETSYSTEM 1 3 Tne PLC will wait 3 x 150ms 450ms for a valid response from the slave controller of retry if NETCMDS or READMODBUS WRITEMODBUS failed to get a valid response from slave controller Default 2 a total of 3 tries e g SETSYSTEM 2 5 The PLC will retry up to 5 times if it failed to communicate with the slave Note longer waiting time when failure occur if you increase the number of retries 3 0 Respond as fast as possible to hostlink or MODBUS commands received from the host computer or another PLC default to allow at least a 0 01s 10ms to elapse before responding to host link commands received from the host computer or another PLC This delay is needed for auto switch type RS485 converter to allow time for the hardware transceiver to switch direction Data This command works on firmware r39 amp above 11 27 0 default simple decoding for both HSC1 amp HSC2 1 enhanced quadrature decoding for HSC 1 2 enhanced quadrature decoding for HSC2 3 enhanced quadrature for HSC1 amp HSC2 This command works on firmware r47 amp above 0 default All DM data cleared to 0 during hard or soft reset k DM 1 to DM k content are not cleared to zero during hard or soft PLC reset This command works on firmware r49 amp above
136. hotkey lt F7 gt to open up the selection table 3 If you have already created a ladder circuit which connects to either a CusFn or dCusF function both appear as menu items within the Special Function pop up menu then you can easily open up that particular CusFn by double clicking the left mouse button while the highlight bar is at the CusFn or dCusFn Alternatively you can open the CusFn by clicking the right mouse button while the highlight bar is at the CusFn or dCusFn Custom Function Editor The custom function editor window allows creation of any number of lines of TBASIC program statements Since this is a standard text editor you should have no problem using the key and mouse controls to edit the text Pressing lt F1 gt at the text editor window opens up a Help screen that will show you the common keys and mouse actions E g To copy a paragraph of text select it using the mouse and the press lt Ctrl C gt Move the text editing cursor to the destination and press lt Ctrl V gt to paste it to the new location 9 1 NEW Trilogi 6 2 and up introduces a brand new custom function editor The custom function editor now has a whole new interface with split panes that provide text editing for writing code just like before on the upper pane and a web browser TBASIC help information on the lower pane When the custom function editor is opened the upper text editor pane will contain the TBASIC program code of
137. igh Soeed Counter ch ch 1 to 8 If you no longer need the high speed counter it should be disabled in order not to waste the CPU s time to service the interrupt generated by the change of state at the HSC input To define PLC Timer 1 to n as High Speed Timers HST A HST counts down every 0 01s instead of every 0 1s for normal timer and their other properties are identical to normal timer Those Timers whose number are above n are not affected and remain ordinary timers ELSE ENDIF To make a decision regarding program flow based on the result returned by an expression IF expression THEN If the result of the expression is non zero logical true the block of program lines between the THEN and the ELSE statements will be executed If the result of the expression is zero false the block between the IF and ELSE will be ignored and the block between the ELSE and ENDIF statements will be executed instead If there is no ELSE statement and if the result of the expression is false the block of program lines between the THEN and the ENDIF statement will be ignored but execution will continue right after the ENDIF statement Nesting of IF statement Statement blocks within the IF THEN ELSE statement may contain other IF THEN ELSE blocks nesting Note that each IF statement must be ended with the ENDIF statement Otherwise an error message IF without ENDIF will be reported during compilation Testing Equ
138. il is de energized before the delay time is up the timer will be reset and its contact will never be closed When a last aborted timer is re energized the delay timing will restart afresh using the SV of the timer and not continue from the last aborted timing operation 5 Counter Coils A counter is also a special kind of relay that has a programmable Set Value SV When a counter coil is energized for the first time after a reset it will load the value of SV 1 into its count register From there on every time the counter coil is energized from OFF to ON the counter decrements its count register value by 1 Note that the coil must go through OFF to ON cycle in order to decrement the counter If the coil remains energized all the time the counter will not decrement Hence counter is suitable for counting the number of cycles an operation has gone through When the count register hits zero all the counters N O contacts will be turned ON These counter contacts will remain ON regardless of whether the counters coil is energized or not To turn OFF these contacts you have to reset the counter using a special counter reset function RSctr 8 5 ll Special Bits TRILOGI contains a number of special purpose Earm bits that are useful for certain applications These include 8 clock pulses ranging from periods of 0 01 second to 1 minute a Normally ON flag and a First Scan Pulse etc 4 Special Bits gt Label Name 1s
139. in Chapter 4 2 2 Chapter 3 Using The TLServer Web Server for TRiLOGI l Overview To Start TLServer either click on its Icon on the Windows Quick Launch bar shown below or click on the Start button and select Internet TRILOGI 6 x then select TLServer Version 3 x and a TLServer panel will appear You can minimize TLServer but it should be actively running in order to service network request from TRILOGI via the Internet or local area network TLServer Icon F DLC WebServer 3 E led TLServer ACts as a gateway to connect Internet TRILOGI Server IP Address1 192 168 1 180 9080 Copyright c Triangle Research Int l Inc 2001 2009 Al Rights Reserved Help Version 3 15 the M series or F series PLC to the corporate LAN or the Internet so that they can be controlled and programmed by a TRILOGI client from anywhere in the world When a client program such as TRILOGI wants to read from or write to a PLC it send a command to the TLServer using the TCP IP protocol transported via the Intranet the Internet or a local host connection The TLServer upon receiving the command will carry out the actual reading or writing to the PLC via the PC s RS232 or RS485 port The data received from the PLC is then relayed back to the client program via TCP IP protocol TLServer is also a Web Server which serves up web pages that contains the TRILOGI Java Applet to enable you to use any Java enabl
140. ing the Fserver since the Fserver provides similar Communication access between the client PC and the F series PLCs 3 Client The TRILOGI program is the one which you use to create your ladder logic TBASIC program and is called the Client program If you are programming the PLC offline then you only need to run the client program without the TLServer The beauty of the client server configuration is that it does not matter whether the server and client are located at the same computer or at 20 000 miles apart and they work exactly the same way The client and the server can communicate via any form of network connection including the Internet This makes it possible for the user to program the PLCs either locally or remotely via the Internet or even wirelessly via mobile Internet Another important advantage of client server architecture is that multiple clients may access the same server simultaneously Hence you can run multiple copies of the TRILOGI clients at different places around the world simultaneously for troubleshooting a single PLC You can also run the TRILOGI client AND the TRi ExcelLink clients simultaneously 4 TRILOGI client software is available in two forms 2 i As a Local Java Application The TRILOGI program as well as the JVM see below must be locally installed in the PC that it runs on ii As a Java Applet The client computer only needs to use a Java enabled Web browser such as the Internet
141. ions This choice box allows you to view another Custom function via a read only popup window without leaving the currently edited custom function This is very convenient when you need to view the content of another custom function while editing one custom function 9 6 Control X C2 call sendNetCmd IF DM 200 _ status 0 Failed to set PLC s ID Probably COM n RETURN ENDIF PRINT 4 lt gt Close Ethernet Connection Select Function to Edit p CALL RdComm4 clear buffer CALL ConnEthernet Connect to UUT via Ethernet L lt lt Laue asda laiii N 4 Use Ethernet Port to transfer program Rename Function IF STRCMP AS lt CONNECTED gt lt gt 0 4 Order Sales 1 877 TRI PLCS 1 877 874 7527 TR Inquiry 8 30am to 5 00pm PST Mon Fri i 6 Undoing Changes In previous versions of Trilogi it was only possible to undo a mistake by using the lt Ctrl z gt shortcut key Trilogi 6 2 allows you to use the lt Cirl z gt shortcut key as well a new Undo button The Undo button shown below can be used to undo the last change to the text in the currently opened Custom Function 7 Exiting the Editor In previous versions of Trilogi it was only possible to exit a function using the lt ESC gt key or by clicking the x button in the top right corner of the editor Trilogi 6 2 allows you to use the same methods as before as well as the option of clicking the new A
142. ions from Input can only be latched once until it is unlatched Input atch The same principles can be applied to internal bits and coils as were previously described for physical input contacts and output coils 8 3 Once you understand this fundamental principle of interpreting a ladder diagram everything should become clearer and simpler Ladder diagram programming can be used to create a rather sophisticated control system However In TRILOGI we augment its power further by allowing a ladder program to activate customized functions created in TBASIC Relay Coils A contact can also be activated by the presence of an electrical current This makes it possible for a control system to control the turing ON or OFF of a large load by using electrical current to activate a switch that can conduct high current The simplest form of this tyoe of contact is a relay In traditional electromagnetic relay a coil of wire is wound around an iron core that turns it into an electromagnet When current passes through the coil the magnet is energized and the force is used to either close a contact that makes it a normally open contact closed only when energized or open it that will be a normally closed contact since it is closed when not energized Ladder Logic programming language borrows some of those terms used to describe the electromagnetic relay for its own use You connect a relay coil fo the right end of the ladder diagra
143. is executed asynchronously from the normal ladder logic execution An interrupt driven CusFn is run when the condition that causes the interrupt occurs The response time to execution is very short compared to the scan time of the ladder program There are several interrupt sources that can trigger a CusFn a Special Interrupt inputs An M series F series PLC contains some special Interrupt inputs which when enabled by the INIRDEF statement will trigger a particular CusFn defined in the INTRDEF statement when the logic level at the interrupt pin changes state either from OFF to ON or from ON to OFF High Speed Counters HSC Reach Target Count An M series F series PLC contains some High Speed Counter inputs which when enabled by the HSCDEF statement will trigger a particular CusFn defined in the HSCDEF statement when the counter reaches a preset target count value This enables the CPU to carry out immediate action such as stopping a motor or performing some computation b 9 11 IV Simulation amp Examination of TBASIC Variables 1 Simulation Run of CusFn TRILOGI fully supports simulation of almost all TRASIC commands After you have completed coding a CusFn test the effect of the function by connecting it to an unused input Run the simulator by pressing lt F9 gt or lt Ctrl F9 gt key Execute the CusFn by turning ON its control input If your CusFn executes a command that affects the logic state of an
144. l contact to the fH highlighted element lt 4 gt Right click to insert a N C parallel contact to the highlighted element JE i lt 5 gt Left click to insert a N O parallel contact to enclose one or more elements lt 6 gt Right click to insert a N C parallel contact to enclose one or more elements TE n lt 7 gt Insert a normal coil which can be an output relay timer i or counter lt 8 gt Insert a parallel output coil not an entire branch to the current coil lt 9 gt Insert a special function coil which includes execution of CusFn Fnilp lt O gt Insert a parallel special function coil to the current coil lt gt Invert the element from N O to N C or from N C to N O lt gt Convert the element to a rising edge triggered contact one shot Click to move the highlight bar to the right same effect as gt pressing the right arrow key This can be used to move cursor to a junction that cannot be selected by mouse click L ag gt Double click to delete a highlighted element Now insert the first element by left clicking on the icon The icon will change to a bright yellow color to show you the element type that you are creating At the same time an I O table should appear on the screen with a light beige color background instead of the normal light blue background The I O table now acts like a pop up menu for you to pick any of the pre defined label names for this
145. l timers counters sequencers to inactive state and clears all latched relay bits All integer variables will be cleared to zeros and all string variables will be assigned to empty string IV Using TRILOGI Sequencers A sequencer is a highly convenient feature for programming machines or processes that operate in fixed sequences These machines operate in fixed clearly distinguishable step by step order starting from an initial step and progressing to the final step and then restart from the initial step again At any moment there must be a step counter to keep track of the current step number Every step of the sequence must be accessible and can be used to trigger some action such as turning on a motor or solenoid valve etc As an example a simple Pick and Place machine that can pick up a component from point A to point B may operate as follow Step Action O Wait for Start signal Forward arm at point A Close gripper Retract arm at point A Move arm to point B Forward arm at point B Open gripper Retract arm at point B Move arm to point A oI NIAAA A ON gt TRILOGI Version 6 supports eight sequencers of 32 steps each Each sequencer uses one of the first eight counters Counter 1 to Counter 8 as its step counter Any one or all of the first eight counters can be used as sequencers Seq1 to Seq8 To use a sequencer first define the sequencer name in the Counter table by pressing the lt F2 gt key and s
146. le English en en_language ixt Spanish es es_language ixt Chinese Zn zh_language ixt Users of other international languages can create their own specific language help text by copying the en_language ixt file into a file named as xx_language txt where xx is the two character ISO abbreviation of the language For example to create a Korean language help text you need to copy the en_language txt file into a file name ko_language txt and then edit the file to translate the relevant English text into Korean language Even English language user may modify the content of their pull down menu and on screen display by modifying the en_language it file You can open some of the supplied language files e g English vs Spanish to understand how the English language items are translated to another language When the TRILOGI version 6 x or TLServer 3 x program starts up the program will Automatically try to load the specific language file based on the locale of the users operating system and use the file content throughout the session However if the program fails to find the corresponding language text file then it will use a set of internally defined English language text strings for its entire menu and on screen display For English locale user all TRILOGI 6 x help files are stored in the following folder ec TRiLOGI TL6 public Help However if you start TRILOGI in locale xx then when you attempt to ope
147. lectronics convention bit O refers to the least significant bit right most bit and bit 15 the most significant bit left most bit of the 16 bit integer variable Examples CLRBIT output 2 11 Comments Physical output 28 will be turned OFF Output channel 2 bit 11 Output 17 11 28 See Also SETBIT TESTBIT SETIO CLRIO TOGGLEIO amp TESTIO CLRIO labelname SETIO labelname TOGGLEIO Jlabelname TESTIO labelname Purpose E g Comments Manipulate the logic states of any input output relay timer or counter contact bit within a CusFn The labelname refers to the label names defined in the input output relay timer or counter tables SETIO set a bit to ON CLRIO clear the bit to OFF and TOGGLEIO flio the current logic state of that I O bit TESTIO function returns a 1 if the bit is ON and a 0 if the bit is OFF SETBIT alarm IF TESTBIT alarm THEN ELSE ENDIF This function offers a more efficient way of manipulating the I O bits compared to the SETBIT and CLRBIT function However SETBIT and CLRBIT functions have the advantage that they can use variables to indicate the index and bit position of the bit to be affected whereas the O bit that affected by the commands here are fixed during compile time Note that output bit Changed in custom function will only be updated at the physical output at the end of the ladder logic scan unless a REFRESH command is being executed
148. lly Once the command exchange has been completed you ll send a lt gt tag to end the connection gracefully Note similar to local RS485 communication the source PLC that talks across the network using the lt CONNECTS service should have a different ID O00 to FF from the target PLC that it is trying to talk to E g A PLC with ID 01 should not talk to another PLC with ID 01 even though the other PLC is connected to a remote server By changing the ID of one of them you will avoid the problem of a response string from the other PLC being misinterpreted by the sending PLC as an incoming host link command Examples of using the lt CONNECT gt tags can be found in the sample programs in the following folder C TRiLOGI TL6 usr samples XServer 3 19 Chapter 4 Running The Internet TRILOGI Client Running The Internet TRILOGI Application Basically there are 3 methods that you can start the TRILOGI application as follow 1 If the Internet TRILOGI and JRE have been properly installed on your PC you can just select the short cut item TRILOGI Version 6 2 Application in the Start Menu to start the TRILOGI application T hanewiIN Software gt C HP gt A IAR Systems M Qs A InterActual gt Internet TRILOGI Helps LocalHost Applet htm va Tiserver with Java Console ra TLServer Version 3 0 Internet TRILOGI 5 3 W TRILOGI Version
149. lt will be highlighted again If no text matches the search text the message in the search area will change to Text Not Found ros Custom Function 1 EventCount Control x 1 Initial value of x 0 SETLCD 1 1 Cycle Count STR X Find Find All x Find in All CusF NOTE Highlighting of text found in the editor during a user initiated search or during compilation error tracking now works with JRE Java Runtime Environment 1 5 and 1 6 9 5 4 Function Navigation X C2 call sendNetCmd IF DM 200 _ status 0 Failed to set PLC s ID Probably Ci RETURN ENDIF PRINT 4 lt gt Close Ethernet Connection CALL RdComm4 clear buffer CALL ConnEthernet Connect to UUT via Ethernet N 4 Use Ethernet Port to transfer program IF STRCMP AS lt CONNECTED gt lt gt 0 Order Sales 1 877 TRI PLCS 1 877 874 7527 Inquiry 8 30am to 5 00pm PST Mon Fri Alternatively you can scroll from one custom function to the next one using the Ls and Lz keys However clicking on the e gt gt and buttons allows you to scroll to the previous or the next non empty CusFn All empty functions will be skipped This is useful if you need to browse through all the custom functions to locate something 5 View Other Functions In i TRILOGI version 6 24 a View Other Functions choice box replaces the Copy Text To Lower Pane button in earlier 6 22 or 6 23 vers
150. m function it will be highlighted in the text editor as shown below Also the text Find only in this CusF will be displayed below the command line in the search area indicating a local search Each time the Find button is clicked the next instance of the search text will be highlighted until the text cant be found anymore At this point the message in the search area will change to Text Not 7 10 Found and the next time Find is clicked the first result will be highlighted again K Custom Function 1 EventCount Control X pasl Initial value of X 0 z wae Find Find All SETLCD 1 1 Cycle Count STR X x Find only in this CusF To do a global search simply type the text in the same command line and click the Find All button If the text is found in any custom function within the program it will be highlighted in the text editor as shown below Also the text Find in all CusF will be displayed below the command line in the search area indicating a global search Each time the Find All button is clicked the next instance of the search text will be highlighted until the text cant be found anymore in any custom function At this point the first result will be highlighted again If no text matches the search text the message in the search area will change to Text Not Found res Custom Function 1 EventCount J es gt a5 a Control nitial value of X 0 zes SET
151. m just like an output as follow Start Stop Active i i RLY Active Active Lamp jot In a PLC there are hundreds of internal relays that are supposed to behave like the typical electromagnetic relay Unlike an output e g the Lamp output which has a physical connection out of the PLC when an internal relay is turned ON it is said to be energized but you will not see any changes in the PLC s physical I Os The logic state is kept internally in the PLC The contact of the relay can then be used in the ladder diagram for turning ON or OFF of other relays or outputs A relay contact in the ladder diagram can be Normally Open NO or Normally Closed NC and there is no limit to the number of contacts a relay can have 8 4 3 Out Coils A PLC output is really just an internal relay with a physical connection that can supply electrical power to control an external load Thus like a relay an output can also have unlimited number of contacts that can be used in the ladder program 4 Timer Coils A timer is a special kind of relay that when its coil is energized must wait for a fixed length of time before closing its contact The waiting time is dependent on the Set Value SV of the timer Once the delay time is up the timers N O contacts will be closed for as long as its coil remains energized When the coil is de energized i e turned OFF all the timer s N O contacts will be opened immediately However if the co
152. mputed using the number of steps the stepper motor travels from one edge to another edge The center position can be easily determined using such data too STEPCOUNTABS ch Purpose STEPHOME Purpose Returns the absolute position of the stepper motor ch This function returns a zero if a STEPHOME command had just been executed and the stepper has not been moved since ch Set the current position counter of stepper ch to zero This indicates a new Home position of that stepper motor This command should be executed only when the stepper has reached a particular position to be regarded as the home position All STEPMOVEABS Command executed subsequently will be relative to the defined home position STEPMOVE ch count r Purpose To activate the PLC s built in stepper motor pulse generator channel ch to output count number of pulses The speed and acceleration parameters for the motion is defined by the STEPSPEED statement on the same channel ch which must be executed at least once before the first STIEPMOVE command is issued After executing the STEPMOVE command the PLC hardware will take over the actual pulse generation operation The user s program will continue to execute even though the pulse generation is not yet completed The internal relay r can be used to signal to the other parts of the ladder program regarding the status of pulse generation as follow 11 29 Important Examples Comments S
153. mstances STEPSTOP 2 Motion aborted by STEPSTOP command will not trigger the end motion relay r specified in the STEPMOVE Command STEPCOUNT STEPSPEED STEPMOVE STEPSPEED cA pps acc Purpose To set the soeed pps and acceleration retardation acc parameters for the PLC s stepper motor motion controller pulse generator channel ch ch should return a value of between 1 and 8 Speed pps is based on no of pulse per second pps output by the pulse generator The acceleration acc determines the total number of steps taken to reach full acceleration from standstill and the 11 3 Examples Comments STR n STR n d Purpose Examples Comments number of steps from full soeed to a complete stop The stepper motor calculates and performs the speed trajectory according to these parameters when the command STEPMOVE is executed STEPSPEED command should be executed at least once before executing any subsequent STEPMOVE command to control the pulse generation The defined parameters will be remembered until another STEPSPEED statement operating on the same stepper channel is executed again STEPSPEED 2 2000 20 The PLC s Stepper motor controller channel 2 is configured to send out pulses at 2000 pulses per second when SIEPMOVE instruction is executed It follows a linear acceleration trajectory which takes 20 pulses to reach the full soeed of 2000 pps This is equivalent to an acceleration of Vy 20007 a
154. n Upctr function For g to generate a clock source of period 0 05s use Clk 01s to feed to an Upctr counter with Set Value 4 The counter s contact completion flag will be turned ON once every 5 counts 0 1 2 3 4 which is equivalent to a 0 05 sec clock source b Replacing a Drum Controller A drum controller can be replaced easily by a sequencer if the timing of the drum s outputs can be divided into discrete steps Assuming a drum controls two outputs with the timing diagram shown in the following figure oOo Somes oe Sr a Q S 3 S e S655 q i eres Se eS ess 4 0 Seeosastiessecsdseneh This can be replaced by an 8 step sequencer Step 1 e g Seq1 1 turns ON and latch Output A using Latch function Step 2 turns ON and latch Output B Step 4 turns OFF Output A using the Clear function and Step 6 turns OFF Output B All other steps 3 5 7 0 have no connection 3 Program Example Assume that we wish to create a running light pattern which turns on the LED of Outputs 1 to 4 one at a time every second in the following order LED1 LED2 LED3 LEDA LED4 LEDS LED2 LED1 all LED OFF and then restart the cycle again This can be easily accomplished with the program shown in Figure 6 9 8 17 Clk1 Os Seg Paice Segz LED1 OLUT Seg2 6 Seg2 2 LED QUT Sega 7 Sege 3 LEDS QUT Seqe 6 seqe 4 LED QUT Seqe 5 st
155. n an online help file TRILOGI will first check if there exist a folder c TRiLOGI TL6 public xx_Help If it finds it then the help files will be loaded from this locale specific folder But if it cannot find the xx_Help folder it will then load the help files from the default folder ec TRiLOGI TL6 public Help Hence for those who wish to experiment with providing their own locale specific help files they should copy all the help files from the default folder into the new locale specific xx_Help folder and then make changes to files in the new folder When they press lt F1 gt in TRILOGI the help files will be loaded from the Xx_Help folder ll Installing TRILOGI 6 x on Windows 98 Me NT 2000 XP or Vista 1 In the root directory on the Internet TRILOGI 6 x CD ROM you should find a folder x86 Windows which is where all the setup files for PCs running MS Windows are located 2 Since Internet TRILOGI requires a Java Run Time Environment JRE on a PC in order to run properly you have to first determine if your PC already has a JRE installed You can check the java version on your PC by going to Control Panel and find if there is an icon named Java Double click on the Java icon and check the installed Java version If your Java version is 1 4 2 or higher you don t have to install JRE again 3 On the other hand if your PC does not already have a JRE installed then you have t
156. n_ 101 dCusf Decrease Fn 102 I l dCusf Timl Outl OUT Timl TIM Custom Function 101 Z getTimerSV 1 IF Z gt 100 RETURN ENDIF lt MAXIMUM 10s setTimerSV 1 Z 5 Increase the current SV by 5 0 5s SETLCD 1 1 T1 SV STR getTimerSV 1 4 Custom Function 102 setTimerSV 1 getTimerSV 1 5 Decrease SV by 5 SETLCD 1 1 T1 SV STR getTimerSV 1 4 Comments The getTimerSV 1 function returns the current set value of the Timer 1 This value is read into variable Z in CusFn 101 but used directly in CusFn 102 for changing the Set Value of Timer 1 The setTimerSV statement uses the value of its second argument to update Timer 1 s SV accordingly Note that changes to the set value SV will be updated in the program EEPROM memory and is non volatile However EEPROM has a typical life span of about 100 000 to 1 000 000 erase write cycle Exceeding this limit will wear out the EEPROM and resulting in a read error when the PLC operates Hence you should NEVER write a program that excessively changes the set value of the timer or counter e g put it in a non differentiated form of CusFn which executes every scan of the ladder program and continuously changes the content of the EEPROM Al 6 3 Using a Potentiometer As An Analog Timer A cheap potentiometer can be connected to the PLC A D input and provide a user adjustable knob as an analog Set Point inp
157. nd return the response to the PLC host link command 2 TLServer send the host link command to remote TLserver or Xserver and return the response to the PLC lt gt 3 18 Description This service was originally developed for an M series PLC to communicate with other PLCs via TCP IP protocol using the Xserver This same capability is now also ported to TLServer 2 1 and 3 x It allows your PLC to login to another remote TLServer or XServer via the LAN or the Internet and your PLC can then use the NETCMDS command to exchange data with the PLCs that are connected to that remote server You execute this command by first sending the sting lt CONNECT XXX XXX XXX XXX 9O8O gt to the TLServer where XxXX XXX XXX XXx is the IP address of the remote TLServer or XServer Then followed by the username and password needed to login to the remote server Once the connection is established the TLServer will return the response string lt CONNECTED gt to the PLC When the PLC receive the lt CONNECTEDSsS string it can use the TBASIC NETCMDS command to read or write data to the remote PLC as if the remote PLC is on the same local network Multiple NETCMDS commands can be executed but there should not be more than 2 seconds delay between each command This is because If the XServer does not receive any serial string from the PLC for more than 2 seconds it will terminate the lt CONNECTS session automatica
158. nd that by appending these comments to variables no new variables are being created For Example AS Some String corresponds to AS or 1 A string variable such as A can have different comments each time it is referenced in the same program because the compiler ignores the comments anyways Although in most cases it may be best to limit a variable to one comment to avoid potentially overwriting data since no new variables are actually create as mentioned above For Example If a string variable A was named AS _one string in one part of a program and named AS two string in another part of the program then they will still both refer to AS If each variation has different string data then the data that was stored in the last variation that was updated will be the data in AS Then if the previous variation is accessed it wont contain the data that was originally stored in it Special Variables EMINT EMLINT amp EMEVENT The TIOOMD and T100MX PLCs are originally designed to be used with a third party server software named EMIT 3 0 made by emWare Inc of Salt Lake City USA However we have decided to depart from the EMIT platform for all future PLC design and we no longer support the later version of EMIT server Anyway there are some special variables set aside for data exchange with the EMIT and these may now be freely used as additional memory in your TBASIC program q emInt 1 tO emInt 16 Th
159. net Installation and problem with Firewalls Notes to Dial Up Users If you are testing the Internet capability of TLServer using dial up connection you must connect to the Internet first before starting TLServer so that TLServer can report the correct Internet IP address to you You will not see the local host IP address 127 0 0 1 only the Internet IP address will be shown The moment TLServer is running it is ready to accept connection from the TRILOGI client You can also configure TLServer s communication port setting add remove users from the system and set up TLServer to query the PLC for outgoing email requests and process them accordingly The following sections explain the function of each button Remember you can also call up their context sensitive help by pressing lt F1 gt key after pressing the relevant button on the TLServer front panel Il Serial Port Setup Serial Port Setup 1 Setting Up and Test Serial Communication This dialog box allows you to configure the serial port of the host computer to match the settings on the PLC for proper communication Most of the items here are self explanatory If you have more than one PLC connected to the host computer via RS485 all the PLCs must have the same serial port settings as the TLServer The open Pot button allows you to test whether the communication port is available to TLServer You can also click the sera button to temporarily relinqui
160. ng screen Login To TLSever Servers IP Address port DetectID 1 PLC Only 1D Hex M Use Http Proxy Server Username samples Password V Memorize Username amp Password Cancel OK The Servers IP Address port text field allows TRILOGI to login to any remote or local TLServer or Xserver simply using the IP address and port number of these servers Since TLServer and TRILOGI are often running on the same PC for users convenience there is a predefined default IP address Localhost 127 0 0 1 9080 which should be used when both TLServer and TRILOGI client are running on the same PC There is also a default user defined in TLServer with the username samples and no password which is what we will use for now Next click on the Detect ID button If all go well the ID 01 will appear in the box next to the Detect ID button Otherwise you will receive an error message that explains what did not go right If you have received an ID correctly you can then click the OK button TRILOGI will Compile the program and then begin transferring the compiled codes into the PLC Just follow the steps on the screen until the entire program transfer procedure is completed Then click on the Yes button when you are asked if you wish to Reset all I Os Before you actually turn on the physical inputs to the PLC to test the program we would like to show you how you can actually control the PLC
161. nication with the serial port you will have to execute another SETPROTOCOL function that set it to mode 0 or 5 assuming it has been written into the program or you must reset the controller by turning OFF the power and then ON again If you execute a SETPROTOCOL using the 1ST Scan then you must turn on DIP switch 4 before powering up the PLC so that the SETPROTOCOL command will not be executed and you can regain control of the PLC using TRILOGI SETPWM n x y Purpose To set channel n of the PLC s Pulse Width Modulation PWM outout with duty cycle represented by x 100 and at a frequency in Hz given by parameter y n must range between 1 and 8 Once set the PWM channel will latch the set value until the next SETPWM statement on the same 11 26 channel is executed x should range between 0 and 10000 If x is more than 10000 the duty cycle will be set to 100 Examples SETPWM 1 4995 2000 Comments PWM channel 1 will be set to operate at 49 95 duty cycle for PWM that can resolve up to 0 01 The actual resolution will depend on the PLC s PWM resolution The PWM frequency is set to 2000 Hz or nearest For a 10 bit PWM the best resolution is about 1 1024 0 1 This means that in the above example the PWM will be rounded to 50 Please check the target PLC s manual for the actual resolution SETSYSTEM n data Purpose Allow changing of certain default system s parameters 1 of wait states multiple of 0 15s w
162. nt to use the continuous CusFn function for such purposes It is far better to use the built in clock pulses to trigger a differentiated Custom function dCusF You can choose a suitable period from 0 01s 0 02s 0 05s 0 1s 0 2s 0 5s 1 08 and 1 minute for the application Other periods can also be constructed with a self reset timer The Custom function will only be executed once every period controlled by the system clock pulse or the timer as follow Run Clk 0 1s A_Function dCusF For example you don t need to update the value of a variable displayed on the LCD screen any faster than the human eye can read them So using a 0 5s clock pulse may be sufficient and this will not take up too much CPU time for the display For slow processes such as heating a 1 0s clock pulse to monitor temperature change is more than sufficient IMPORTANT i When the CPU scans the ladder logic up to a circuit that contains a CusFn and the execution condition of the circuit is TRUE the corresponding CusFn will be immediately executed This means that the CPU will not execute the remaining ladder circuits until it has completed execution of the Current CusFn Hence if the CusFn modifies a certain I O or variable it is possible to affect the running of the remaining ladder program ii Note that the INPUT n variables contain data obtained at the beginning of the ladder logic scan and not the actual state of the physical input at the time of th
163. nters 11 22 Examples Comments Related See Also The new S V is also stored in the program EEPROM and hence is non volatile see sample program set_TCSV PC4 n should be between 1 and 128 value should be between 0 and 9999 SetCtrsSv 10 1234 SetTimerSV 3 GetTimerSV 3 10 Counter 10 will assume q S V of 1234 S V of Timer 3 will be increased by 10 The present values P V of timers and counters can be read or written directly as integer variables TimerPV n amp CtrPV n But the Set Values can only be changed by these two functions GetCtrSV _ GetTimerSV _ SETDAC n x Statement Purpose Examples Comments To set channel n of the PLC s Digital to Analog Converter DAC with the 16 bit integer result of the expression x n must range between 1 and 16 Once set the DAC channel will latch the set value until the next SETDAC statement on the same channel is executed SETDAC 5 A B 16 DAC channel 5 will be set with the value of A B 16 A run time error will result if n is less than 1 or is greater than 16 The actual number of DAC channels depends on the PLC model in use SETHIGH16 v data Purpose Examples See Also To assign the upper 16 bit of a 32 bit integer variable v to data The lower 16 bit of v is unaffected This can be used to construct the value of a 32 bit integer data using two 16 bit data obtained from either the EEPROM or the DM n A DM 2 SETH
164. ntly selected circuit The Current circuit number will be adjusted to reflect the change Find lt Ctr F gt The Find command allows you to quickly locate a ladder logic circuit that contains a particular label name This is useful for searching for the activity of a particular I O in the program The Find command can also be used to search for a keyword in a TBASIC program When this command is executed you will be further prompted to select the options of either searching for a ladder logic label or finding a text in a Custom Function Find Label Control Label Name Po Find Find All F2 key select from I O Table Type CusFn Search Text Here Find Ladder element you can enter into the text field a string that partially or fully matches the label name you wish to locate You can also press the lt F2 gt key to open up the I O table and pick the label name from the I O table Find Text in CusFn It is now possible to search for text within a custom function and when the option Find Text in CusFn is selected the custom function editor window will Open automatically to the first custom function You can either search for text within the current custom function local search or in all of the custom functions in your program global search To do a local search simply type the text in the command line below the Find and Find All buttons and then click the Find button If the text is found in the current custo
165. o add new ladder 7 4 Circuits and custom functions to this program as well as modify those unprotected ladder circuits and custom functions Of Course you will still be able to compile simulate and transfer the protected program to the PLC as usual A view protected file can be unprotected by selecting the Un protect command from the File menu and supplying the unlocking password Note that this unlocking password is strictly for un locking the viewing restriction and it has nothing to do with other username and or password required for interacting with the PLC This View Protection command is extremely useful for OEMs who wish to allow end users of their equipment to modify or append to the PLC s program for ease of interfacing to other equipment but without revealing the core content of the PLC program to the end user Besides being able to protect the OEM s intellectual property it will also help to prevent the end users from mistakenly modifying the core program which can lead to unexpected result Write Compiled Code to Disk This new feature is added since TRILOGI version 5 32 You can now write the compiled program code to a disk file so that you can send the compiled code with a CO5 extension to your end customer to upload to the M series PLC using a standalone TL5 Uploader program This allows you to protect your source program file content while giving the end users of your equipment the ability to upgrade the PLC
166. o display some alphanumeric text on a PLC s LCD display To get help on the syntax of this Command you can highlight the command itself and then press the lt F1 gt key to instantly bring up the help file for this command This makes it very simple to check the syntax of any command Alternatively you can also go to the Help menu and select TBASIC Keywords to obtain help for any TBASIC commands 5 11 44 45 After you have entered the TBASIC statements please close the editor by clicking on the x box or press the lt ESC gt key When you have finished creating all the circuits press lt Enter gt key or lt ESC gt key at the last blank Circuit to end Ladder Edit mode and we are ready for some interesting simulation exercises We can make our program more comprehensive to other users by utilizing the Comments feature of TRILOGI Open the Circuit menu and select Inset Comment A comment editor window will be opened up to allow you to add your comments to any part of the circuit When you are done with your comments just press lt ESC gt key or close the comment editor window and the comments you just entered will be inserted between the circuits Each comment occupies a circuit position and there is no limit to the number of lines a comment circuit may have However if you wish to keep data file Compatibility with the old DOS TRILOGI Version 4 x you should limit the comment to no more than 4 lines per comment an
167. o install Java Run Time Environment JRE Version 1 4 2 on your PC BEFORE installing the TRILOGI Client Server bundle First double click on the file j2re 1_4 2 06 windows i586 p exe to install the JRE Please follow all instructions provided by the Install Shield program and install it preferably in the given default path NOTE Previous versions of Trilogi were only compatible with JRE version 1 4 2 however Trilogi version 6 20 and up is also compatible with JRE version 1 5 and 1 6 in most cases depends on the users operating system and the JRE build 4 After you have installed JRE 1 4 2 double click on the SetupTL exe to install Internet TRILOGI 5 All TRILOGI Version 6 x files will be installed in the following default folder C TRILOGIIL6 You normally would not need to go directly to this folder to run TRILOGI This is because during installation of TRILOGI a program Group folder Internet TRILOGI 6 x will be created in the Start Menu to provide short cuts to the TLServer program the TRILOGI application and the TL6 Applet starter as illustrated in the following picture T hanewiIN Software gt C HP gt FR IAR Systems gt M Qs gt InterActual gt Internet TRILOGI Helps LocalHost Applet htm ra Tiserver with Java Console rO TLServer Version 3 0 Internet TRILOGI 5 3 TRILOGI Version 6 1 ff Internet TRILOGI 6 gf Uninstall Internet TRILOGI 6
168. o start in a different locale and in the above example TRILOGI is forced to start in Chinese language locale and it will load the Chinese text from the zh_language ixt file You can use the forced locale method to test the program in other language mode easily without having to actually change the locale of the O S This feature is tested to work on system with JRE 1 4 2 and up JRE versions above 1 4 2 should now work for Asian language font such as Chinese Japanese and Korean HELP When running TRILOGI you can get on line help any time by pressing the lt F1 gt A Help window will open to show you the typical key mouse actions You can also click on the lt More Help gt button to get context sensitive help loaded into your web browser Trilogi version 6 2 and up now uses the default browser of your computer to display help data If the config tl6 line does not contain the path to an alternative browser in the Browser Path line which it doesn t by default However If you do not want to use the PCs default browser then you ll need to use the Notepad program to manually edit the config tl6 file in the C TRILOGI TL6 directory For example If you wanted to use Internet Explorer as the browser for Trilogi you will need to Modify the first line in config tl6 as follows Browser Path C Program Files Internet Explorer IEXPLORE EXE to match the correct browser path info There is no need to configure the applet br
169. o the Internet However by default most NAT routers built in Firewall will block any incoming attempt to access the TLServer Fortunately you should be able to configure the router to perform what is known as Port Forwarding i e to forward any external TCP IP packets that are destined to a certain port number to a designated workstation on the home network In that case you should configure your router to forward port number 9080 to the PC that runs the TLServer assuming the TLServer is configured for port 9080 Please refer to your router s helo manual for details A2 4 Appendix 3 PLC to Modem Communication Setup A remotely located M series PLC can be connected to a host PC via public switch telephone network PSTN radio or cellular phone network This can be accomplished by using two analog modems one connected to the PLC s RS232 serial port and another modem connected to the remote host PC as follow Public Telephone Network L T100MD e Internal or Extemal T100MX Extemal RS232C There are a some technical issues that need to be handled carefully in order to successfully implement the modem linked host communications as described in the following sections 1 Modem Connection Modem 1 The host PC may use any internal or external modem that can communicate at 2400 bps or faster Connect the modem to the PC as instructed in the modems manual and connect the phone line to the phone jack on the back o
170. o trigger another custom function at the end of the delay For the TIOOMD and TIOOMX the minimum delay provided by this function is 10ms and the resolution of the time delay is 10ms This means if you execute DELAY 155 the actual delay will be rounded to 160ms and for DELAY 154 the actual time delay will be 150ms FOR NEXT Purpose syntax Examples Comments See Also GetCtrSV n To execute a series of instructions for a specified number of times in a loop FOR variable x TO y STEP z NEXT where variable may be any integer variable A to Z only and is used as a counter x y and z are numeric expressions STEP z is an optional part of the statement x is the initial value of the counter y is the final value of the counter Program lines following the FOR statement are executed until the NEXT statement is encountered Then the counter is incremented by the amount specified by STEP If STEP is not specified the increment is assumed to be 1 A check is performed to see if the value of the counter is greater than the final value y if STEP is positive or smaller than the y if STEP is negative If it is not greater the program branches back to the statement after the FOR statement and the process is repeated If it is greater execution continues with the statement following the NEXT statement This is called a FOR NEXT loop A run time error will result if STEP is evaluated to be 0 FOR I 1 TO 10 FOR
171. of Sequencer 5 reaches number 20 Seq1 1 Out OUT Outs OUT To create the normally open contact Seql 1 left click on the icon When the I O table pops up scroll to the Special Bit table and select the item 1 SeqN x When prompted to select a sequencer choose Sequencer 1 and another dialog box will open up for you to enter the specific step number for this sequencer We have thus far been creating ladder circuits only by clicking on the ladder icons A short cut method of choosing elements to be created without using the mouse does exist Observe the icon carefully and you will notice a small numeral at the lower right hand corner of each icon that corresponds to the shortcut key You may wish to try this short cut for the remaining part of Circuit 3 Press the lt 7 gt key and the Output table will immediately pop up for selection of a coil Pick Outl from the Output table and the Out1 coil will be connected Circuits 4 5 and 6 are very similar to Circuit 3 and you should have little problem creating them Next we are going to create a circuit containing a special function called Custom Function as follow Seq1 4 EventCount After you have created the Seq1 4 contact click on the icon and select the item E dCusf Diff Up Custom Funcs from the popup menu to connect to a Custom Function coil that is differentiated up also known as one shot meaning that the custom function will only run
172. of range legal Opcode Please Inform Manufacturer Timer or Counter Out of Range 9 18 Chapter 10 TBASIC Statements Functions Operators and Variables What are TBASIC Statement and Functions 1 STATEMENT A STATEMENT is a group of keywords used by TBASIC to perform certain action A statement may take 0 1 2 or more arguments The following are some TBASIC statements PRINT LET IF WHILE SETLED etc FUNCTION A FUNCTION acts on its supplied arguments and return a value The returned value may be an integer or a string A function can usually be embedded within an expression as if it is a variable or a constant since its content will be evaluated before being used in the expression E g AS Total is STRS B C STRS n is a function which returns a string and therefore can be used directly in the above string assignment statement The most distinguishable feature of a FUNCTION is that its arguments are enclosed within parenthesis and e g ABS n ADC n MIDS AS n m STRCMP AS BS Note Statements or functions and their arguments are NOT case sensitive This means that commands such as PRINT and PriNt are identical However for clarity seeks we use a mix of upper and lower case characters in this manual DELIMITER A TBASIC program consists of many statements Each statement usually falls on a different line The new line therefore acts as a delimiter which separates one statement fr
173. of the Relay table that contains up to 512 elements and the Timer table that contains up to 128 timers all other columns contain 256 elements each Every column has its own vertical scroll bar You can use the mouse to scroll each column independently to locate the desired I O 3 The label names for the inputs Outputs relays timers and counters defined earlier in the I O tables automatically appear in their respective columns To the left of each label name column is an LED lamp column that indicates the ON OFF state of respective I O A red color lamp represents the ON state of an I O whereas a dark gray color lamp represents an OFF state The I O number is indicated in the middle of the lamp 4 The simulator requires the use of the mouse to work properly so it is important to remember the mouse button actions as follow Turn ON the I O when pressed Turn OFF when button is released Toggle the I O when pressed once l e OFF becomes ON and ON become OFF Left Mouse Button Right Mouse Button 5 13 Our ladder program requires us to push the Start button momentarily You can simulate this action by moving the mouse pointer to the Start label or the LED lamp and press the LEFT mouse button once and then release the button The action starts At this time notice that the relay RUN is latched ON and the timer Duration begins to count down from the value of 1000 every 0 1sec and the Output 1 8 are
174. offers a way to clear the I Os if it hinders your viewing of the ladder program V Circuit Menu 1 Insert Comments Comments are specific remarks used by a programmer to explain various Characteristics of a program segment and are ignored by the compiler TRILOGI Version 6 x allows comments to be freely inserted between circuits Execute this command and the Comment Editor will be opened The comment editor allows you to enter any text you like that best describes the working of the circuit All standard text editing keys including cut and paste are applicable to the Comment Editor 7 20 NEW In previous versions of Trilogi you would press lt ESC gt key or click the x button to close the comment window and automatically save the changes when you had finished editing it Trilogi 6 2 allows you to save and close the comment the same way as before or by clicking the new K__ button It is now also possible to exit the comment and discard any changes made since it was last opened by clicking on the new Abort _ button Once a comment has been created it is assigned a circuit number and is treated like any other circuits You can edit it by pressing the lt spacebar gt when you are in Browse mode alternatively you can move it around copy it to another destination or delete it entirely using Commands in the Circuit menu Insert Circuits This command enables you to insert a new circuit just before the
175. om another Some statements such as IF THEN ELSE ENDIF soan multipole statements and should be separated by proper delimiters To make a program visually more compact the colon symbol may be used to act as delimiter E g IF A gt B THEN C D 5 ELSE C D 5 ENDIF may be written more compactly as IFA gt B C D 5 ELSE C D 5 ENDIF TBASIC Integer Constants Variables amp Operators The TBASIC compiler in TRILOGI Version 6 supports full 32 bit integer computations However only variable A to Z are 32 bits in length which allow them to represent number between 2 to 2 the remaining system variables and data memory DM n are all 16 bit variables which means that they can only store number between 32768 to 32767 However all numerical Computations and comparisons in TBASIC are carried out in 32 bit signed integer regardless of the bit length of the variables involved in the numerical expression 1 Integer Constants These may be entered directly in decimal form or in hexadecimal form by prefixing the number with the symbol amp H e g 12345678 amp H3EF 1007 decimal If the result of an expression is outside the 32 bit limits it will overflow and change sign Care must therefore be exercised to prevent unexpected result from an integer overflow condition A constant may be used in an assignment statement or in an expression as follow A 12345 IF A 30 2345 123 gt 100 THEN ENDIF
176. ommands to the modem Whenever a user wants to communicate with the PLC he she will first use the TLServer to dial and connect to the PLC s modem and when the connection is established he she will then be able to use the TRILOGI client or the TRi ExcelLink program to communicate with the PLC The fact that the PLC is connected via modem and not via direct RS232 is totally transparent to the client programs To prevent unauthorized access to the PLC you may need to use the TBASIC command SETPASSWORD to set a protective password The great flexibility of the M series PLCs becomes even more apparent when you realize that you can easily program the PLC to automatically dial in to the TLServer to perform a number of tasks such as using the PLC s File Service to save or append data to hard disk files send email to anyone via the Internet or even synchronize its real time clock with the host PC A number of examples have been included in the C TRILOGI TL6 usr samples FileService_Modem folder when you installed TRILOGI version 6 x All these examples make use of a powerful yet easy to use custom function that was written entirely using the standard TBASIC commands see source code listing in the text box below You only need to create the following simple ladder circuit to use this function assuming it is function 10 A8 3 D ATDT 892 store the phone number IF TESTIO Connected THEN already connected IF TESTIO DialModem c
177. on 6 x and its accompanying TLServer 3 x is that in version 6 x all data file storage and communication are conducted using the international standard Unicode UTF 16 instead of the ASCII code found in the lower versions of TRILOGI software When used with Unicode aware Operating System such as the Windows 2000 XP and Vista it is now possible to create program that uses non Latin based characters such as the Chinese Japanese Korean also known as CJK Thai Hebrew and Arabic etc in their comments and I O label fields TRILOGI version 6 x still includes some enhanced capabilities such as an EEPROM manager that allows reading writing of the PLC s data EEPROM directly within the TRILOGI software Internet TRILOGI version 6 x and TLServer 3 x also allow user to Customize their menu and on screen display so that the menu screen display and some online help texts may be shown in other international languages including the CJK There is even an option in the language text file for you to increase the text size by 1 or 2 points to make it clearer to display some international characters such as Chinese or simply to make it easier to read the menu and help text Also TLServer 3 15 and up has a larger window size to allow more characters to be displayed which is useful for languages that use more characters Currently the program is supplied with the following language files Language ISO Abbreviation Language specific fi
178. onnection no longer needed IF DM 3991 0 used as timer for modem attention PRINT 1 clear serial out buffer WHILE INCOMM 1 lt gt 1 clear whatever data in serial in buffer ENDWHILE ELSE IF DM 3991 5 PRINT 1 get modem attention ELSE IF DM 3991 gt 18 Wait 5 second to gain attention PRINT 1 ATH hang up modem command CLRIO CONNECTED DM 3991 0 ENDIF ENDIF ENDIF DM 3991 DM 3991 1 increment the timer ENDIF RETURN ENDIF IF TESTIO dialModem RETURN ENDIF If DM 3998 gt it means a dialing action has started If DM 3998 gt 38 it means more than 38 seconds has passed and connection still not established then retry IF DM 3998 0 Use this DM as a flag WHILE INCOMM 1 lt gt 1 clear whatever data in serial buffer first ENDWHILE PRINT 1 D Dial the number DM 3999 1 RETURN ENDIF A INPUT 1 IF LENCA DM 3998 J DM 39998 1 also use it to track the time out IF DM 3999 28 28 seconds has lapsed PRINT 1 ATH A3 4 ENDIF IF DM 3999 gt 30 DM 3990 0 ENDIF RETURN ENDIF SETLCD 4 1 A IF STRCMP MID A 2 7 CONNECT 8 is connected DM 3998 for next round of connection DM 3991 reset timer for hang up modem use SETIO Connected set an I O bit to indicate connection ENDIF All you need to do is to copy and paste this custom function to your own Ladder BASIC program then create an I O with label name DialModem this may
179. op seq2 Figure 6 9 The 1 0s clock pulse bit will advance increment Sequencer 2 by one step every second Sequencer 2 should be defined with Set Value 8 Each step of the sequencer is used as a normally open contact to turn on the desired LED for the step A Stop input resets the sequencer asynchronously When the sequencer counts to eight it will become Step 0 Since none of the LED is turned ON by Step O all LEDs will be OFF Chapter 9 Introduction to TBASIC Custom Functions Overview TRILOGI Version 6 x Supports user created special functions known as Custom Functions the symbol CusFn will be used throughout this manual to mean Custom Functions Up to 256 CusFns can be programmed using a special language TBASIC TBASIC is derived from the popular BASIC computer language widely used by microcomputer programmers Some enhancements as well as simplifications have been made to the language to make it more suitable for use in PLC applications There are three simple ways to create a new CusFn 1 From the Edit pull down menu select the item Edit Custom Function and select the function number from a pop up CusFn selection table that may range from 1 to 256 The selection table allows you to define unique and easily identifiable names for each custom function Once you have selected the custom function the editor window will open up with the contents of that particular custom function 2 You may also use the
180. or the right time to turn on This is also a remark line To perform a software reset of the PLC from within a CusFn All the variables will be reset to zero or inactive and all the hardware outputs such as DAC and PWM will be turned OFF The effect is the same as the Master Reset MaRST function in the ladder logic The first scan bit 1st Scan will also be turned ON for one scan time However if the program is stuck at some dead loop such as WHILE FOR NEXT in a CusFn then MaRST would not be executed since the ladder program would not have a chance to scan the ladder rung containing the MaRST function If this command is used by an interrupt service function then it is possible to get the system out of the dead loop since the interrupt function can interrupt the dead loop and reset the PLC Unconditionally ends the execution of the current CusFn and return to the caller which is either the ladder program or another CusFn which has executed a CALL command Use of the RETURN statement is optional if there is no conditional ending required After executing the last statement the CusFn will return to the caller automatically CALL RSHIFT i n Statement Purpose Examples To shift the integer variable i 1 bit to the right i must be either an integer variable a DM n or a system variable such as relay n output n etc RSHIFT instruction permits more than one variable to be chained together before performing a bit shi
181. out channel 0 of the PLC with ID 05 connected to COMM 3 of this PLC The response string will be assigned to AS Special If the last character of x is a character NETCMDS will send out the string without the character It will not append the FCS and to the outgoing string and it will not send out the carriage return ASCII 13 character It will also NOT check the response string for FCS This allow NETCMDS to be used to interface to third party ASCII devices with different command response formats E g A NETCMDS 3 Hello World The string Hello World will be sent out of serial COMM port 3 AS will receive the full returned string without applying any FCS check on the return string OUTCOMM n x Purpose This statement can be used to send an 8 bit byte of data x via Comm port n This command is added because PRINT n command cannot be used to send out CHRS 0 Zero is treated as the end of a string in TBASIC and will be ignored if you use PRINT n statement to send out CHRS 0 Examples OUTCOMM 2 225 11 12 PAUSE Purpose To set a breakpoint for executing the CusFn This is used mainly for debugging a CusFn By Inserting a PAUSE statement at the place of interest you can suspend the program execution when PAUSE is encountered after which you may examine the values of the relevant variables You can continue to perform on line monitoring of the PLC that has been pa
182. ow whereas a closed contact allows current to flow through it to the next element The simplest contact is an On OFF switch which requires external force e g the human hand to activate it Limit switches are those small switches that are placed at certain location so that when a mechanical device moves towards it the contact will be closed and when the device moves away from it the contact will be open If a contact is connected to a load and the contact is closed the load will be turned ON This simple concept can be illustrated by the most basic ladder diagram as follow Switch Lamp j OUT The vertical line on the left is the Power line current must flow through the Switch contact in order to turn ON the load Lamp In fact there should be a second vertical line on the right end of the ladder diagram to provide a return path for the current flow but this is omitted to simplify the circuit diagram Now if instead of wiring the switch to the lamp directly as suggested in the above diagram you could connect the switch to the PLC s input and connect the lamp to the PLC s output and then write the above ladder program to perform the same job Of course it makes little sense to use a PLC if that is all you want to do We will see how a PLC can simplify wiring shortly Note The contact Switch shown in the above diagram is termed a Normally open N O contact 8 1 Now let s say if there are 3 switches that must work to
183. owser path since the TL6 Applet automatically uses the same browser in which it was loaded to open the help files Hence the applet does not need to know the browser path at alll Running TRILOGI Applet Using Web Browser 1 Before you could run the TRILOGI Applet in a web browser make sure that the TLServer 3 15 is already running 4 2 2 Next start up your Internet Browser It should be either an Internet Explorer version 5 0 or later Netscape Navigator Communicator Version 4 5 or later or Mozilla Firefox version 1 5 or later 3 a Next check the TLServer front panel for its IP Address If you are running TLServer on a PC without network connection it will probably show IP Address 127 0 0 1 9080 If you have an Internet connection before you start up TLServer then you will see the Internet IP address of your PC If your PC has both a local area network connection as well as a direct Internet connection you will see two IP addresses being reported Although localhost address 127 0 0 1 may not be reported but it is always there as long as both the Client and the Server reside on the same computer Always use the localhost IP address 127 0 0 1 if both the Client and the TLServer are running on the same computer Now simply key in the IP Address including the port number in your browser s Address for IES or URL for Netscape text entry area For localhost connection enter http 127 0 0 1 9080
184. pctr function Counter s Present oy Value P ON Counter s contact ly ee Each time when the execution condition of an Upctr function changes from OFF to ON the present value of the designated counter is affected as follow a If the counter is inactive load the counter register with the number 0001 2 3 4 b If the counters present value PV is equal to the Set Value SV defined in the Counter table load the counter register with number 0000 and turn on the counters contact also known as the completion flag c Otherwise increment the counter PV register by 1 Reset Counter RSctr When the execution condition of this function changes from OFF to ON the counter will reset to inactive state This function is used to reset both a reversible Counter and an ordinary down counter coil Sequencer Functions AVseq RSseq and StepN Please refer to the later section in the chapter on Using TRILOGI Sequencers Latch Relay Function Latch Latching relay is convenient for keeping the status of an execution condition even if the condition is subsequently removed The program elements that are assigned as Latching Relays will remain ON once they are energized Only Relays and Outputs may be assigned as Latching Relays On selecting Latch function you can use the left right Cursor keys or click on the left right arrow keys to move between the Relay and Output tables The selected rela
185. pecial Variables view screen SETLCD 1 1 This is a 1x20 LCD Display SETLED n m value Purpose To display the integer value on the PLC s built in 7 segment LED displays starting from the nth digit and occupying m number of digits Leading zeros will be added to the left of the display if value occupies less digit than that specified by m However if m is less than 1 e g m 0 then value is treated as a single 8 bit ASCII character to be displayed rather than as a numeric value Special symbols may be displayed on the LED panel if the LED driver is able to display the corresponding ASCII character n must be between 1 to 16 The digit position is counted from left to right i e the leftmost LED digit is digit 1 TRILOGI supports up to 16 LED digits The actual number of LED on the PLC may vary from O to 16 in this case only the available digits will be effective Value 11 24 Examples Comments may be a 16 or 32 bit integer number Once set the LED display will latch the set value until the next SETLED statement on the same digit is executed On the TRILOGI simulator the result of the SETLED is displayed together with the Special Variables screen which may be viewed by pressing the lt V gt key while in the simulation mode SETLED 5 4 89 This command is not implemented on any M series PLC LED digit 5 to 8 counting from left to right displays 0089 SETPASSWORD string Purpose Example Comments
186. pened any text editing program It is best to use a text editor that interprets carriage returns as new line characters as well so that each custom function is displayed as it would be in the Trilogi Custom Function Editor instead of as one long line that is very difficult to read A good editor to use is Wordpad or Microsoft Word To export Custom Functions just choose the Custom Functions option from the Print Control Panel and click on the button as shown in the Print Control Panel below You will then be prompted to save the Custom Functions as a txt file 7 7 Print Control Panel Print Page setup Print Preview Print emeei ctions Tab spaces 5 From He To 32 Export NOTE You can select the range of Custom Functions you want to export to a xt file just like you can select the range of Functions you want to print Exit Execute this command to exit orderly from the TRILOGI program You will be prompted to save the current file if the contents have been edited and the changes have not yet been saved 7 8 Edit Menu 1 Abort Edit Circuit Changes made to the current ladder circuit can be aborted if you execute this command before pressing lt Enter gt to accept changes made to the current circuit If changes have already been accepted by pressing the lt Enter gt key then this command will have no effect This command is useful if you wish to completely abandon changes
187. quencer to Step N StepN In certain applications it may be more convenient to be able to set the sequencer to a known step asynchronously This function will set the selected sequencer to step N regardless of its Current step number or logic state The ability to jump steps is a very powerful feature of the sequencers Reversing a Sequencer Although not available as a unique special function a Sequencer may be stepped backward by decrementing its step counter using the DNctr command on the counter that has been defined as a sequencer This is useful for creating a reversible sequencer or for replacing a reversible drum controller 2 Other Applications a Driving Stepper Motor A sequencer may be used to drive a stepper motor directly A two phase stepper motor can be driven by four transistor outputs of the controller directly for small motors with phase current lt 0 5A or via solid state relays The stepper motor can be driven using a sequencer that cycles through Step 0 to Step 3 full stef mode or Steo O0 through Step 7 half step mode Each step of the sequencer is used to energize different phases of the stepper motor A clock source is needed to drive the stepper motor through 8 16 its stepping sequence The stepping rate is determined by the frequency which is equal to 1 period of the clock source Clock pulses with periods in multiples of 0 01 second can be generated easily using the CIk 01s bit and a
188. quotation character index for FOR NEXT loop must be A Z 2 Run Time Errors Certain errors only become apparent during the execution of the program e g A B C This expression is perfectly OK except when C 0 then you would have attempted to divide a number by zero which does not yield any meaningful result In this case a run time error is said to have occurred Since run time errors cannot be identified during compilation TRILOGI also checks the validity of a command during simulation run and if a run time error is encountered qa pop up message window will report to the programmer the cause and the CusFn where the run time error took place This helps the programmer locate the cause of the run time errors to enable debugging The possible run time errors are listed in the following table and they are generally self explanatory Run Time Error Message Divide by zero Call stack overflow Circular CALL suspected FOR NEXT loop with STEP O SET BIT position out of range CLR_BIT position out of range TEST BIT position out of range STEPSPEED channel out of range legal Pulse Rate for STEPMOVE legal acceleration for STEPMOVE STEPMOVE channel out of range STEPSTOP channel out of range ADC channel out of range DAC channel out of range LED Digit within 1 12 Only PWM Channel out of range LCD Line must be 1 4 Only PM channel out of range System Variable Index Out of range Shifting of A Z Out
189. re TBASIC Statement and Functions TBASIC Integer Constants Variables amp Operators String Variables and Constants Special Variables EMINT EMLINT amp EMEVENT Chapter 11 TBASIC Keyword Reference SO OOS OS OT E ae e ABS x ADC n ASC x CALL n CHRS n CLRBIT v n CLRIO SETIO TOGGLEIO TESTIO CRC16 DELAY FOR NEXT GetCtrsv n GetTimersv n GETHIGH 1 6 v GOTO n HEXS n HEXS n d HEXVAL x HSCDEF ch fn_num value HSCOFF ch HSTIMER n High Speed Timers IF THEN ELSE ENDIF INCOMM ch INPUTS n INTRDEF ch fn_num edge INTROFF ch LEN x8 8 9 8 14 9 9 9 7 9 11 9 14 9 14 10 1 10 2 10 8 10 10 11 1 11 1 11 1 11 1 11 2 11 2 11 2 11 3 11 3 11 4 11 4 11 5 11 5 11 5 11 6 11 6 11 7 11 7 11 7 11 8 11 9 11 9 11 9 11 9 LET LOAD_EEP addr LOAD EEP addr LSHIFT i n MID x n m NETCMD ch x OUTCOMM n x PAUSE PIDcompute ch E PiDdef ch Imt P I D PMON ch PMOFF ch PRINT n x y Zs PULSEFREQUENCY ch PULSEPERIOD ch PULSEWIDTH ch READMODBUS ch DevicelD address READMB2 ch ID addr var count REFRESH REM or RESET RETURN RSHIFT in SAVE_EEP data addr SAVE_EEPS data addr SETBAUD ch baud_no SETBIT v n SetCtrSV n value SetTimerSV n value SETDAC n x SETHIGHI6 v data SETIO labelname SETLCD n offset x SETLED n m value SETPASSWORD string SETPROTOCOL
190. read See section 4 String Variable Comments below for more details 3 String Operators i Assignment Operator A string variable A to Z DM and system variables etc may be assigned a string expression using the assignment statement AS Hello Welcome To TBASIC ZS MIDS AS 3 5 Concatenation Operators Two or more strings can be concatenated joined together simply by using the operator e g MS Hello AS welcome to BS If AS contains James and BS contains TBASIC MS will contain the string Hello James welcome to TBASIC iii Comparison Operator Two strings may be compared for equality by using the function STRCMP AS B However the integer comparator such as lt gt etc cannot be used for string comparison iv Functional Operators TBASIC supports a number of statement and functions which take one or more string arguments and return either an integer or a string value e g LEN x3 MIDS A x y PRINT 1 A SETLCD 1 x VAL x Please refer to the next chapter for detailed descriptions of these operators 4 String Variable Comments NEW With TRILOGI version 6 2 and above you can now attach comments to any variable name of any length to make program easier to read The compiler will ignore any alohanumeric characters A to z O to 9 and that are attached behind the variable name following an underscore character It is important to understa
191. receiving valid commands All data between the lt command parameter gt tag and the lt gt tag will be treated as data for the requested service Since the PLC is the one that initiates the service request it does not need to be linked to the TLServer all the time unless it needs to request a service from the TLServer This makes it possible for a remote PLC to connect to the TLServer via the telephone line and modem to perform the required file or email services then disconnects itself from the TLServer so that other PLCs can take turns to connect to the TLServer to request for services Note All the files created or used in the write append read actions are located in the directory lt trilogi base directory gt FileService Hence the default path is C TRiLOGI TL6 FileService You may also read write files that are located inthe sub directory below the _ FileService directory provided that the sub directory already exists The currently supported files and emails services are described below 1 Write data to E g To save data of DM 1 to DM 10 to a file name file testWrite txt execute the following statement from a custom function Format PRINT 1 lt WRITE testWrite txt gt Write data request SWRTTE FORI 1 TO 10 filename gt data dataidata z PRINT 1 DM I REM delimited by space characters data NEXT eer PRINT 1 send a CR character PRINT 1 lt gt End of Service request lt gt
192. ress e g O01RIOOO0 to query the states of inputs 1 to 8 If you have more than one PLC connected you should not use the IR since all connected PLCs will try to respond simultaneously thus resulting in a gibberish return string To change the ID of a PLC e g from 01 to 05 you can send the command string 01IWO0500 to the PLC In TLServer 2 0 and above there is also a _Change PLCID button that does this for you 3 4 automatically You can click on the Detect ID button to check the current ID and then the Change ID button to write the new ID to the PLC Changing Communication Settings Most likely you may want to leave the comm port settings at their default values 38 400 bps 8 data bits 1 stop bit no parity Some reasons for changing the comm port settings may be due to the need to change the PLC s serial port to lower values e g for communication via radio using 9600 bps Changes to the comm settings are saved to the TLServer configuration file TLserver cfg when you quit TLServer One other scenario is when you need to power cycle an M series PLC with DiPswitch 4 turned ON to halt the CPU in order to disable any execution by the Ist Scan pulse Since the PLC s COMMI port is set to 9600 bps when power ON with DIP Switch 4 set you will need to change the baud rate temporarily in order to communicate with the PLC e g to blank out a program that causes trouble However do remember to change the ba
193. rivative PID Controller function The function PIDcompute will make use of the parameters defined here for the corresponding channel ch ch channel number 1 16 Imt Maximum saturation limit for the computed result P Proportional Gain Kp I Integral Gain k D Differential Gain Kp Transfer Function of a PID Controller are defined as follow KI G s Kp Kps 1 Porportional Band 1 Kp Proportional Gain K Integral Gain Integral Time Constant 11 14 Important See Also PMON ch PMOFF ch Purpose Example See Also All four parameters Imt P I amp D can be either 16 or 32 bit integer constants or integer variables For the Imt term the computed controller output value by the PlDcompute function is not allowed beyond the Imt value i e Imt represents the saturation point of the computed controller output PlDcompute function implements Integrator anti windup feature which will avoid integrating the error signal when output is already saturated When this statement is run the integral and differential terms of channel ch is set to zero Hence PIDdef should be run only once during initialization and not repeatedly executed Otherwise the PiDcompute function will not run properly because of the loss of integral and differential data PiIDcompute PMON enables Pulse Measurement Function at channel ch whereas PMOFF disables the ch
194. s Special See Also READMB2 Purpose Parameters register data The communication baud rate is the default baud rate of that Comm port unless it has been changed by the SETBAUD command ch PLC Comm port number 1 to 3 using Modbus ASCII or 1 1to 13 using Modbus RTU ID device ID of the MODBUS device 1 to 255 addr zeto offset address of the holding register in the MODBUS device relay 3 READMODBUS 3 5 101 The relay will contain the 16 bit data obtained from the MODBUS device with ID 05 and from register offset address 101 in MODBUS term this refer to the 40102 holding register Reading it into the relay channel allows bit level manipulation by ladder logic If can of course also be read into any data memory This command automatically checks the response string received from the slave device for the correct LRC and the slave address The status of the operation can be checked by the user program by testing the STATUS 2 function which will return a O if there is any error or if the slave device is not present This command by default uses MODBUS function 03 to perform the read which means that it is designed to read from holding register addresses 4 xxxx You can force it to change to using function 04 in order to read from addresses 3 xxxx by executing SETSYSTEM 6 4 only for CPU with firmware revision r47 and above READMB2 WRITEMB2 WRITEMODBUS STATUS 2 NETCMD SETSYST
195. s 3 Email data to whoever yahoo com with the subject PLC Email Test recipient execute the following statements Format PRINT 1 lt EMAIL wnoever yahoo com gt change it to your own email lt EMAIL email PRINT EON Sender triuser hotmail com it can be anything PRINT 1 Subject PLC Email Test Sender sender PRINT 1 Hello this email is sent by your friendly TRILOGI email PLC bers subject PRINT 1 Don t wory everyting is working out great today data data data PRINT 1 lt gt data Note lt gt e Sender field should be in email format such as Xxx yyy zzz but it does not need be a valid email address 3 16 4 Read Data from File Format lt READ filename gt lt gt 5 Read Real Time Clock From TLServer Format lt READ RTC gt lt gt Subject field is optional and may be omitted totally The TLServer will first save all the data it received into a temporary file named Email txt in the default directory After the TLServer receives the end of service tag lt gt from the PLC and it will then send out the email to the recipient email address This email service will make use of the SMIP server defined in the Setup Emails portion of the TLServer configuration so make sure that you have defined a correct SMIP server before testing the email service function When the email has been successfully sent via the SMTP server the
196. s then the HSC counter variable HSCPV c will increment decrement according to direction of rotation When value is reached the specified custom function activates immediately All High Soeed Counters are disabled automatically when the PLC is reset unless they are enabled by the HSCDEF statement However if more than one HSCDEF for the same channel ch is executed only the last executed HSCDEF statement will take effect Hence you should put the next HSCDEF statement within the CusFn triggered by the first HSCDEF By chaining the HSCDEF statement from one CusFn to another you can control the motion of the machine using the HSC value to execute a series of CusFn one by one Within these CusFn you can program what to do to control the motion E g changing the speed putting on the brake change direction of motion etc You can use the SETIO CLRIO for digital ON OFF control and setDAC setPWM for proportional control HSCPV 1 0 HSCDEF 1 19 3310003 SETLCD 1 1 STRS HSCPV 1 6 Enable High Speed Counter 1 and make it activate function 19 when the counter reaches 33 100 003 Present value of HSC 1 was cleared to 0 before activating it Note that TRILOGI Version 5 x does not 11 6 See Also HSCOFF ch Purpose HSTIMER n Purpose IF THEN Purpose Syntax perform simulation of the High Soeed counter operation since there is no High Speed Counter inputs on the simulator screen HSCOFF Disable H
197. s I O from TRILOGI software First click on Controller menu and select On Line Monitoring You should see the Full Screen Monitoring window 5 17 that looks identical to the Programmable Logic Simulator screen that you have seen earlier while testing your program on the simulator The logic states of the inputs outputs relays timers and counters that you see on the Full Screen Monitoring screen are linked to the PLC s actual inputs Outputs relays timers and counters When performing on line monitoring TRILOGI software continuously sends out serial communication commands to retrieve the data from the PLC and display them on the screen Next ensure that the Control check box on the monitoring screen is checked selected You will now be able to remotely trigger any of the PLC s input by clicking on its label name Try to click on the Stat input once and you should see the running lights on the PLC outputs Click on the Stop input and the running light should pause The running light will also be reflected on the Output column of the Full Screen Monitoring window Please note that when you click on an input label TRILOGI actually only manages to change the input bit for only one scan time Thereafter the PLC will update the Input bit using the actual logic states of the physical input Next pause the PLC by pressing the Pause button You should see t
198. s do not support Unicode in its internal memory In such case you cannot use this command to open the matching source file You would have use the File gt Open Local Drive command to manually open the file for monitoring purpose 6 Get PLC s Hardware Info 7 14 8 You can find out the PLC s firmware version number the maximum of input outputs relays timers and counters supported on this PLC as well as the total amount of program memory available The same info will be displayed when you try to transfer a program to the PLC Set PLC s Real Time Clock Set Target PLC s Real Time Clock Month Day Year 1 7day fF fs fre fr Mon fr fas Hour Min Sec Set PLC s Clock Cancel The PLC s real time clock RTC which includes both date and time can be set quickly using this command When you run this command a dialog box that contains the year month day hour min sec and day of week are displayed for you to enter the value The dialog box is initially filled with values taken from the client computer s own calendar and clock You can change any of the field to the desired values and then click on the Set PLC s Clock button to write them to the PLC The dialog box will be closed after the TRILOGI has transferred the real time clock data to the PLC You should use on line monitoring to verify that the data has indeed been properly written into the PLC Note that the Year field is restricted to only bet
199. s that provide greater flexibility for printing See below for details 7 6 Wider I O Table Previously the I O Table label names could only be 10 characters but Trilogi 6 2 and up allows label names of up to 16 characters see the lOTable section for more details It is now possible to print an I O Table with label names up to 16 characters and still fit all of the information within the page width The only difference is that Relays 257 to 512 will be printed on a second page to provide more room Export the I O Table Now you can export the I O Table to a csv file that can be opened by any program that has csv compatibility If you use Microsoft Excel you can open the csv file and the I O table contents will automatically be displayed in an Excel spreadsheet This provides limitless possibilites for printing the contents of the I O Table and for integrating them into other documents To export the I O Table just choose the I O Tables option from the Print Control Panel and click on the __ Export button as shown in the Print Control Panel below You will then be prompted to save the I O Table as a csv file Print Control Panel Print Page setup Print Preview Print OREIN NOTE You can select the range of I Os you want to export to a csv file just like you can select the range of I Os you want to print Export Custom Functions Now you can export custom functions to a txt file that can be o
200. s to be made to some local workstation and hence will not direct the packet via the proxy server to the Internet Therefore in order for the client to make connection to the Internet via the proxy server the TLServer port address should be set to 80 In addition the TRILOGI client should also be configured to access the TLServer via a Http Proxy Server as described in the document Log In to TLServer 4 TLServer and TRiLOGI On The Same Local Area Network If the TLServer is running on a workstation that is part of a local area network it is unlikely that the workstation will have a direct connection to the Internet unless the System Administrator has deliberately configured it for that purpose When the TLServer starts it will report the IP Address of the workstation which is the Intranet IP address and NOT the Internet IP address Now if the TRILOGI client is running on another workstation which is also part of the same local area network then it is quite simple TLServer can be assigned any unused port number above 1024 and the TRILOGI client can access TLServer from any other workstations However avoid A2 3 setting TLServer to port 80 since by default port 80 is for accessing the Internet via the HTTP proxy server How to access TLServer running on a Private LAN from the Public Internet If the workstation that TLServer is running on does not have a direct Internet connection to the Internet then it will normally not
201. sh the port to other applications that uses the serial port such as WinTRILOGI 3 5x Note that you will need to close an opened port before you can change its parameter 3 3 The Command String text entry field allows you to test communication with the PLC using its native or MODBUS ASCII protocols If you enter a string here and press lt Enter gt the ASCII string will be sent to the PLC connected to the serial port and the response string will be displayed in the bottom text box If the serial port is not yet opened this command will automatically open it Note that only multi point host link commands are accepted here The only point to point command acceptable here is the IR Command which queries the ID address of the PLC Serial Communication Setup amp Test Port Name COM5 v Baud Rate 38400 ENE Data Bits Stop Bits 4 lel Parity None l Time Out ms 500 Close Port E 5 o O Command String Press lt Enter gt to Send IR Response Strings amp Modem Messages Clear COM5 opened at 38400bps Please close port before changing any parameters IR01 Change PLCID Close F1 Help If you have only one PLC connected to your TLServer computer then you can test the communication now using the following command string Command String IR Response String IRO1 The response string tells you that the ID address of this single PLC is 01 You can then try other host link commands using this ID add
202. sical I O In the case of the internal bit rising edge contacts a rising edge will be detected if the internal bit has changed from off to on from one ladder logic scan to another any internal bit status changes that happen during an I O scan wont matter for internal bits Here are some examples of this for the physical I O Ex1 In the circuit shown below if Inout is off for an I O scan and then on for the next I O scan a single pulse one shot will be sent to Output and Output1 will be turned on for one program scan time turned off on the next I O scan On the same I O scan that Output is turned off and alll following I O scans whether Input is still on or has been turned off a rising edge will not have been detected and Outputl will remain off For a new rising edge to be detected Inout must be scanned as off first and then scanned as on in a following I O scan Inputt LOUT Ex2 In the circuit below when Input goes from the off status to on status as described previously a single pulse will be sent to a Latch function that will latch Output to the on status The actual Latch function will only be activated for a single scan time just as Output was in the previous example but it will permanently latch Output to on until Output is unlatched using the Clear function This way Output will remain on even though Input has only sent a single pulse and Output will not be affected by any further rising edge detect
203. sical wires to implement the above circuits both controlsW1 and controlSW2 will have to be of multiple poles type But if you use a PLC then these two switches only need to be of single pole type since there is only one physical connection which is to the input terminal of the PLC But in the ladder diagram the same contact may appear as many times as you wish as if it has unlimited number of poles The above example may be simple but it illustrates the basic concept of logical AND and OR very clearly controlsW1 and controlsW2 are connected in series and both must be TRUE for the outcome to be TRUE Hence this is a logical AND connection On the other hand either one of the two parallel branches may be used to conduct current hence this is a logical OR connection 8 2 NEW A new type of contact available for the F Series PLCs only is the Rising Edge contact which looks like this e in the ladder logic toolbar and like this when placed in a ladder logic circuit This tyoe of contact will detect a change of status from off to on and then send a single pulse out one shot This contact can be used for any physical input or output or any intemal bits relay counter timer In the case of physical inout and output rising edge contacts a rising edge will be detected if the I O has changed from off to on from one I O scan to another any I O status changes that happen during a ladder logic scan wont matter for phy
204. st have a corresponding line label marked as n where n must be a constant within 0 255 Note that the label is local only to the present CusFn i e another CusFn may have a label with the same n but the GOTO n will only branch to the line label within the same CusFn 156 SETBIT 0 3 GOTO 156 An error message will appear during compilation if the destination label is undefined To return a string that represents the hexadecimal value of the numeric argument n If the second format is used then this function will return a string of d number of characters AS BS AS will contain the string 4D2 BS will contain the string OO004D2 HEXS 1234 HEXS 1234 7 HEXVAL STR VAL HEXVAL x3 Purpose Examples Comments _ See Also To return the value of a hexadecimal number contained in the argument xS B HEXVAL 123 100 B should contain the value 29100 amp H123 291 HEX STR VAL HSCDEF ch fn_num value Purpose Important Example Comments Enable and set up parameters for the High Speed Counters channel ch These counters operate independently of the ladder logic scan time and can capture high speed input pulses generated by position encoders ch Channel number 1 8 fn_num Custom Function to trigger when value is reached value trigger when HSC reach this 32 bit integer value If the PLC supports quadrature encoder input
205. t S ant clock To use any of these bits enter the ladder editor Hee cee and create a contact when the I O table pops M 0 15 Clock u TEN 0 25 Clock up scroll the windows until a Special Bits menu emg 0 55 Clock pops up This menu is located after the Counter Ae ee Table and before the Input table as shown RTC Error below 1 Clock pulse bits The 8 clock pulses supported by TRILOGI are Clock Pulse Period Ladder Symbol 0 01 second Clk 01s 0 02 second Clk 02s 0 05 second Clk 05s 0 1 second Clk 0 1s 0 2 second Clk 0 2s 0 5 second Clk 0 5s 1 0 second Clk 1 0s 1 minute Clk 1min A clock pulse bit is ON for the first half of the rated period then OFF for the second half Duty cycles for these clock pulse bits are therefore 50 as follow Clk 0 1s 0 1 second Clock Pulse ae i _0 05s i 0 05s eo ti i q i The clock pulse bits are often used with counter instructions to create timers Additionally they can be used as timing source for Flasher Circuit A reversiole counter can also work with a clock pulse bit to 8 6 create secondary clock pulses of periods that are multiples of the basic clock pulse rate 2 Seqn X These are special Sequencer contacts which are activated only when the step counter of a Sequencer N reaches step X E g a Normally Open contact eq2 6 is closed only when Sequencer 2 reaches Step 6 At any other step this contact is opened 3 Normally ON
206. te a problem with the communication setup e The PC s modem must be able to emulate the COM port of the PC in order for the TLServer modem function to work Some of the newer computers employ win modem or soft modem which may only work with Windows dial up networking These kinds of modems are implemented in software and they do not necessarily emulate a standard PC COM port properly They also demand quite a bit of CPU horsepower to process the communication Therefore these types of modem may not work too well with the TLServer If your built in soft modem does not work properly with TLServer you should get an external modem e To setup TLServer to dial a modem first close the active COM port by clicking on the Close Port button Select the COM port where the modem is connected you can find out the which COM the modem is connected to by checking the Control Panel gt Modems gt Properties then click to select the Modem checkbox You will then be able to enter a telephone number to dial The 3 buttons Connect Hang Up and Special become enabled when you select the Modem mode Note that the Baud Rate field now becomes the DTE speed which specify the line rate between the PC and the modem this has nothing to do with the actual baud rate between the modems which will be automatically negotiated based on the quality of connection Normally you should leave the DTE speed set to the highest value 115200 unless your mod
207. teger variable DM 1 was named DM 1 _one_integer in one part of a program and named DM 1 _ two_integer in another part of the program then they will still both refer to DM 1 If each variation has different integer data then the data that was stored in the last variation that was updated will be the data in DM 1 Then if the previous variation is accessed it wont contain the data that was originally stored in it lll String Variables and Constant A string is a sequence of alphanumeric characters 8 bit ASCII codes which collectively form an entity 1 String Constants A string constant may contain from O to 70 characters enclosed in double quotation marks e g TBASIC made PLC numeric processing a piece of cake 102 345 00 From TRILOGI Version 6 1 Onwards you can also represent a non printable character or ASCII character which is gt 127 in a string constant What you do is to enter the character as an escape sequence which is in the format of XX The backslash character Y denotes that this is an escape sequence and XX is the hexadecimal value of the character E g character A can be written as 41 and character Z can be written as 5A For example a string written as BF D8 D6 C6 C4 F7 actually contains only 6 ASCII characters that are all above 127 These are the GB codes that represent the 3 Chinese characters HIRE 2 String Variables TBASIC supports a maximum of
208. the SAVE_EEPS command Examples X Load_EEP 5 FOR I COI I Load_EEP I 10 NEXT Comments 1 String saved in EEPROM string location 5 is loaded into X 11 10 See Also LSHIFT i n Purpose Examples Comments See Also 2 Strings saved in EEPROM string locations 11 to 15 are loaded into AS to ES SS 1 to SS 5 represents AS to ES SAVE_EEPR for explanation of how the data EEPROM area are organized in the M series PLC s to provide storage area for both integers and strings To shift 1 bit to the left the integer variable i which must be either an integer variable a DM n or a system variable such as relay n output n etc LSHIFT instruction permits more than one variable to be chained together before performing a bit shift The parameter n indicates the number of channels to be chained starting from i Upward n if only one variable is involved LSHIFT relay 2 3 The relay channels 2 3 and 4 which represent relays number 17 to 64 are Chained together in the following manner LSHIFT 15 0 15 0 15 0 Relay 4 Relay 3 Relay 2 Bits are shifted from the lower channel towards the upper channel Bit 15 of Relay 2 will be shifted into Bit 0 of Relay 3 and so on Bit 15 of the highest channel Relay 4 will be lost
209. the lt F1 gt key You can also select the Content item from this Helo menu to bring up the content page of the entire on line TRILOGI help files On the content page you can find the links to the Ladder Logic Editor and the entire TBASIC language reference There is a TRILOGI Upgrade link in the Helo menu that allows you to obtain the latest Internet TRILOGI upgrade setup program from the Internet Simply follow the instruction to enter the website using the supplied username and password to obtain upgrade On TRILOGI version 6 1 and up there is also a special command called Chinese LCD Code Converter on the Help menu This is to help generate the escape sequences for special LCD model that can display Chinese characters Its function will be covered in the Chinese LCD installation and user guide and is not needed by non Chinese LCD users Instant Help for TBASIC Keywords A convenient feature was implemented in previous versions of TRILOGI Version 6 x which allows you to easily get help for the syntax of a known TBASIC keyword NEW However TRILOGI 6 2 has taken this feature one step further with the new custom function editor E g Just like with previous versions of TRILOGI 6 x you can find the syntax for the keyword READMODBUS by simply selecting the READMODBUS keyword in the custom function editor and then pressing the lt F1 gt key instead of navigating through the help file links Previously the h
210. the custom function to be edited and the lower pane will be a browser that displays some information about Triangle Research our products or software update information see below The lower pane can also be used to display TBASIC keyword help or provide help information about a selected I O label name when the lt Fl gt key is pressed ts Custom Function 32 CheckPLC kada Control men Find Find All 32 CheckPLC DM 300 A 10 read UUT power consumption 1 r i lt lt lt gt gt gt sar ani 3 4 Rename Function A s A ADC 13 C uae gt a View Other Functions v LLL S ET 2 Order Sales 1 877 TRI PLCS 1 877 874 7527 a Keyword Helps x ah Inquiry 8 30am to 5 00pm PST Mon Fri UR IN 4 Edl Undo Abort 4 Il I pl The following functions have been added to the custom function editor Trilogi 6 22 or higher is required where explicitly mentioned otherwise Trilogi 6 2 is sufficient 1 Split Pane Window The upper pane is used as a text editor for writing TBASIC code and the lower pane can either display information about Triangle Research as shown above provide immediate helo for any TBASIC keyword or I O label referred to in the Custom Function e To use the lower pane for help on TBASIC keywords simply select the keyword from the Select Keyword drop box or highlight
211. the selected text is the name of a custom function and lt F1 gt key is pressed a special read only popup window will appear which displays the content of the selected function This enables the programmer to view the code of another custom function CALLed by this function without leaving the current function 9 3 to EE Custom Function 7 xFPLCProg X C2 call enaa IF DM 200 _ status 0 Failed to set PLC s ID Probably CO RETURN ENDIF Control View Custom Function 20 sendNetCmd Input string X output string X PRINT 1 01 Xs PRINT 4 lt gt Close Ethernet Connectio CALL RdComm4 clear buffer CALL ConnEthernet Connect to UUT via N 4 Use Ethernet Port to transfer IF STRCMP T CF 0 T MID X 3 2 ELSE IF STRCMP T CI 0 T MID X 3 4 ELSE IF STRCMP T WA 0 OR STRCMP T RA 0 T MIDS X 4 2 ELSE Feet ENDIF lt lt lt lt lt lt meg Order Sales 1 877 TRI PLCS URN Inquiry 8 30am to 5 00pm P US 2 Non Modal The custom function editor is not modal anymore This means you can place the custom function editor in front side by side or behind the ladder editor This makes for easier reading of the program code 3 Search Function It is now possible to search for a word or phrase in the current c
212. the text in the editor and press lt Fl gt to display the syntax of the keyword For example in the following screenshot the code SETLCD is highlighted 9 2 and if the lt Fl gt key was pressed the syntax for SETLCD would be displayed as it is in the screenshot X X 1 Initial value of X 0 SSma 1 1 cycle Count STR X SETLCD nz offset x To display the string expression x on Line 7 on builtin alphanumeric Liquid Crystal Display LCD or compatible Vacuum Fluorescent Display VFD x may be formed by concatenation of various strings using the operator e g Temp STRS A 3 CHRS 223 C Integers must be converted to string using the STRS or HEXS function to be accepted by this function Special case if n 0 the string x will be sent to the LCD s Instruction Register which allows KI keeno GGG Rename Function View OterFunctons 7 rerworanes e Version 6 24 also added the following features If the selected text is an I O label name and lt Fl1 gt key is pressed the lower pane will display its I O type and the I O number FoR I 1 to 10 A A ADC 3 NEXT DM 301 A 10 read UUT ADC power IF TESTIO ASE 0 I O test not started IF TESTIO FPLC SETLCD 1 1 F series PLCs Test Vew onerancine gt rennan Undo e Also starting from Version 6 24 if
213. times for half the period and not at all for the other half period certainly not the intended outcome Timers Contact Updating Process All the timers contacts of the PLC like the inputs and outputs are updated simultaneously at the beginning of every ladder logic scan and not at the rung that contains the TIM coil So if you are using self reset timer please note that if a timer times out its contact will be ON from the beginning of the ladder logic rung until the rung that contains the self reset circuit Thereafter the timer contact will be OPEN since the coil has been self reset Hence please note that you should place the self reset timer rung after all the ladder rungs that utilize the said timer contact This allows those ladder rungs which use the timer contact to have a chance of being executed before the self resetting rung clears the timer A pulse will be sent to Out 5 periodically determined by the Set Value of timer T1 TI Out5 Out TI TIM TRILOGI Sample programs There are many well documented demo as well as practical TRILOGI program examples included in the following TRILOGI installation folder lt TRILOGI installation folder gt usr samples When you click on TRILOGI s File gt Open Local Drive command you will be able select the users folders where program files are stored By default only two users are defined Administrator and samples as follow Al 3
214. tocol 21 File transfer protocol 23 Telnet protocol 25 Simple mail transfer protocol 80 Hypertext transfer protocol This TLServer Email capability is first implemented in TLServer 1 0 and is carried forward to Version 2 0 and above This method depends on the TLServer to periodically scan each configured PLC for the state of their email request flags and hence require that the TLServer be constantly connected to the PLC s via the serial port Another email support function available only to TLServer version 2 0 and above is described in the next section File and Email Services NEWI TLServer version 3 15 offers a whole new look to the Email Setup which has all the same features as before plus a couple of additions including Port No specification optional Authentication and a Test Email function to test the settings you have entered See below for descriptions of the additions A PLC program raises an email request flag by setting the variable emEVENT 1 to a non negative value see explanation on Writing TRILOGI Programs that Can Send Emails in the later part of this section whenever it needs to send an email The TLServer upon sensing that an email request flag has been raised will extract the sender recipient and message strings from the PLC s internal variables and send them out using the pre defined SMIP outgoing mail server A single TLServer can service the email requests for one or more max
215. tring variables Only AS to DS will be extracted in this example since the message contains one line of body text only as indicated in emEVENT 1 TLServer will then contact the SMIP server to send out the email In addition after processing the email request the TLServer will set the emeEVENT 1 variable to a value of 1 no email Hence there is no need for the TRILOGI program to worry about clearing the email request flag after the email has been sent In addition this provides a way for the PLC program to know whether the TLServer is functioning properly and whether the email request has already been processed However do take 3 14 note that even if the eMEVENT 1 has been reset it does not guarantee that the email has been correctly dispatched to the recipient Success of emailing is subject to the proper configuration of the TLServer the network quality and availability of the SMTP server at the moment when TLServer tries to send out the email For urgent situations you may consider sending out multiple emails periodically until the user has attended to the machine Files and Email Services Starting from version 2 0 the TLServer provides a number of File and Email Services to the PLCs via the serial comm port Basically a PLC can send service requests to the TLServer using tags which are ASCII characters enclosed between the lt and gt characters and the TLServer will perform the service requests upon
216. ual I Os which will be updated only during the I O update cycles The logic states of physical inputs are copied into the INPUT n variables during input scan and the physical outputs are set to the logic states contained in the OUTPUT Nn variables during output updates Therefore one potential error that traditional BASIC programmers tend to commit is to attempt to poll for a change in the variable INPUT n within TBASIC such as the following x WHILE INPUT 1 ENDWHILE This will result in an endless loop since the value of the variable INPUT 1 will never change during execution of the custom function regardless of the actual logic states of physical inout 1 to 8 The only way to force upon a physical I O update is to use the REFRESH command but it is Al not a good practice for ladder logic programming to update physical I Os in the midst of a program execution The REFRESH command is meant more for forcing an immediate output to be turned ON or OFF during time critical situations Hence it is important to allow a ladder logic program to finish its scan so that the physical I Os can be updated You should never hog the CPU within a particular custom function as this will mean the rest of the ladder program don t have a chance to be executed in a timely manner The Difference Between CusFn and dCusF It is very important to understand the difference between the two formats of the custom functions once you understand ho
217. ud rate setting back to 38400 bps after you have reset the PLC with the DIP switch 4 OFF otherwise you may have problems communicating with the PLC later on since changes to comm settings are automatically saved NOTE The F series PLCs will be forced to the default baud rate of 38400 bps with 8 data bits 1 stop bit and no parity when started in pause mode for all 3 serial ports The F series PLCs will NOT be forced to 9600 bps as for the RS232 port on the M series PLCs Modem Support a Dial Modem TLServer 2 x and 3 0 incorporates support for dialing a modem connected to the PC s COM port This is useful if the PLC has to be located at a remote location but yet still has access to the public telephone line or to a cellular phone You can then connect the PLC to a standard analog modem such as the US Robotic 33 6Kops or Hayes Acura smart modem The TLServer can then dial the phone number of the remote modem and make a connection Once a connection is established the remote PLC is immediately accessible to client applications such as Internet TRILOGI or TRi ExcelLink etc over the Internet Intranet or localhost as if it were connected to the TLServer via the serial port directly Notes e Due to the time delay for modulation demodulation process as well as transmission delay two way communications via modem tends to be noticeably slower than connection made by direct cable connection This 3 5 is Quite normal and does not indica
218. unsure about this then you should contact your ISP or System Administrator for help Auth Username If Authentication is required you will need to provide the correct Username This is provided by your ISP and you should contact your ISP or System Administrator if you don t Know what it is or if you don t know if you need it 3 1 Auth Password If Authentication is required you will need to provide the correct Password This is provided by your ISP and you should contact your ISP or System Administrator if you don t Know what it is or if you don t know if you need it PLC ID column For you to select PLCs with ID from OO FF 256 in total to set the email service period Check Every seconds this allows you to define how often the TLServer should check the PLC the email service period for the state of the outgoing email request flag Simply click on field next to the PLC ID of interest to open up a text entry field as shown in the figure for ID 02 Enter a non zero value in seconds to define its email servicing period Note Both SMTP Server and email service period definitions will be saved to the hard disk when you exit TLServer program They will be reloaded when you start TLServer again This email service period does not determine how often the PLC will send email since email will only be sent when the email request flag is set even if you had set a very short email service period It only affects how quickly the em
219. urns a signed value which can vary from limit to limit We choose the 50 D A output 4096 2 2048 as the mean control point so that negative values from PIDcompute means D A output will be lt 2048 positive values means D A output will be gt 2048 Al 12 Appendix 2 PLC amp PC Hardware Setup and Configuration PLC to PC Connection 1 Single PLC to One PC Running TLServer The simplest configuration will be when there is only one PLC and one PC involved You simply connect the PLC s RS232 port to the any of the RS232 serial port COM1 to COMB8 of a PC and run the TLServer on it If you use other than COMI on your PC you will need to configure TLServer s serial port to match the communication port number Multiple PLCs to One PC Running TLServer You can connect multiple M series PLCs to a single PC running TLServer by connecting every PLC s RS485 in a daisy chain manner to the PC s RS232 port You do need to purchase a RS232 to RS485 converter such as the Auto485 adapter to connect the PC s RS232 port to the RS485 network Please refer to the PLC s User Manual for details on installation issues regarding electrical specifications and termination requirements when connecting the PLCs on an RS485 network Internet TRILOGI can log in to the TLServer and have immediate access to all the PLCs on the RS485 network just by specifying the ID address of the PLC concerned Up to 32 standard M series PLCs can be networked to a
220. used Program execution can also be continued by pressing the lt P gt key during Simulation or On line Monitoring PiDcompute ch Purpose Example This function computes the output for the PID compensator controller using the P J and D Gains defined in the PIDdef statement for the same channel ch The integral and differential values are stored within the channel s internal data space and will be automatically used by the PID computation routine The PIDCcompute function uses the Imt max limit term of PIDdef statement to limit the results of its computation If the absolute value of the computed result is greater then Imt then the result will be set equal to Imt for ve number and to Imt for negative value When this happens the integral term will not accumulate the current error to prevent an integrator windup which is very undesirable for the system ch channel number 1 16 Err Closed loop Error i e Set point value Feedback Value The controller may obtain feedback from ADC High Speed Counters PULSEFREQUENCY or other means The obtained result is then scaled and subtracted from the desired set point value to get Err All computations are performed in 32 bit integers and the function returns a 32 bit integer that can be assigned to any variable Any scaling for actual output DAC or PWM will be computed by the user within the same CusFn and sent to the output PLC PID Controller A D 2
221. ustom function local search or in all of the Custom functions in your program global search To do a local search simply type the text in the command line below the Find and Find All buttons and then click the Find button If the text is found in the current custom function it will be highlighted in the text editor as shown below Also the text Find only in this CusF will be displayed below the command line in the search area indicating a local search Each time the Find button is clicked the next instance of the search text will be highlighted until the text cant be found anymore At this point the message in the search area will change to Text Not Found and the next time Find is clicked the first result will be highlighted again 9 4 K Custom Function 1 EventCount x He Initial value of X 0 SETLCD 1 1 Cycle Count STR x Find Find All x Find only in this CusF To do a global search simply type the text in the same command line and click the Find All button If the text is found in any custom function within the program it will be highlighted in the text editor as shown below Also the text Find in all CusF will be displayed below the command line in the search area indicating a global search Each time the Find All button is clicked the next instance of the search text will be highlighted until the text cant be found anymore in any custom function At this point the first resu
222. ustom Functions From f1 iz To print first select the item from the choice box and define the range you wish to print and then click on the Print button For Ladder Circuits the range indicates the circuit numbers For I O Tables the range indicates the I O number up to 256 and for Custom Functions the range is the function number You can use the Print preview button to check the pagination of the printing on screen You can select paper size and print orientation etc by clicking the Page setup button Empty custom functions will be automatically skipped to save paper When you select to print the Ladder Circuits a special No of Element textbox appears This textbox is for you to enter the maximum number of series element that can be printed on the paper width Changing this number affects the scaling of the ladder diagram when printed The smallest number is 5 and largest number is 13 Use a smaller number if you wish to have a larger printout However please note that if your ladder program contains circuits with more elements than that indicated by the Width parameter the out of page part of those ladder circuits will not be printed NOTE Trilogi v6 2 introduces an improvement in printing where leading and trailing white spaces of each custom function are automatically removed during printing to save the number of printed pages NEW Trilogi v6 22 introduces some improvement and some additional feature
223. ut device A scale can be drawn around the potentiometer to provide visual indication of set point value Assignment e A potentiometer is connected to A D 5 Use it to provide a timing range of O to 10 00 seconds e Pressing the test input turns ON output 1 for a duration determined by the potentiometer reading after that turns output 1 OFF Fn 10 Custom Function 10 HSTIMER 1 lt Define Timer 1 as High Speed Timer 0 01s base TimerPV L1 ADC 1 1000 4096 Set the timer running with value proportional to A D value Comments To take full advantage of the resolution of the A D converter the timing range of 0 10 seconds is more finely divided when timer is defined as high speed timer using the HSTIMER command The time base is now 0 01s This means that for maximum value of 10 00s the timer should count down from 1000 The next statement in CusFn 10 computes the ratio of the A D input with respect to its full scale value of 4096 and multiplies it to the maximum timing value of 1000 Ie if the potentiometer wiper is at half way the A D reading will be around 2048 the computation will results in a timing value 2048 1000 4096 500 or 5 00 second Note that TRiLOGI 6 x does not support floating point arithmetic Hence the multiplication must be carried out before the division Otherwise if you compute 2048 4096 1000 the result of the integer division of 2048 4096 0 and the whole expression yields
224. ution should be taken when programming the baud rate of the Host link port because if a wrong baud value is set the host PC may not be able to communicate with it If this happens suspend the PLC using its hardware switch and reset the PLC and re load the program with correct setting SETBAUD 3 3 Set serial port 3 to 9600 To set the bit n of the integer variable v to 1 n is an integer constant or variable of value between O and 15 v may be any integer variable or a system variable such as relay n outpurt n etc However if v is a 32 bit integer SETBIT will only operate on the lower 16 bits Following digital electronics convention bit O refers to the least significant bit rightmost bit and bit 15 the most significant bit leftmost bit of the 16 bit integer variable Please refer to page 10 4 in Chapter 10 TBASIC Statements Functions Operators and Variables for the mapping between O bits and the variables SETBIT output 2 11 outout 28 will be turned ON Output channel 2 bit 11 Output 17 11 28 CLRBIT TESTBIT SetCitrSV n value SetTimerSV n value Purpose Change the Set Value S V of the Counter n or Timer n to value This statement to allow the user to modify the S V of the PLC internal timers and counters without changing the source program A IBASIC function can be written easily to make use of a few digital or analog inputs to modify the SV of these internals timers cou
225. value is also displayed on the simulated LCD panel There you have it You have just completed creating your first LADDER BASIC program and simulated its action on the TRILOGI built in Simulator and you are now ready to see how the actual program will behave in the real world PLC Ill Transferring Your First Ladder Program To The PLC After having tested your ladder logic program on the simulator you are probably eager to try out the program on the actual PLC Here are the quick steps 1 Connect the DB9 programming cable from the PC COM port to the PLC s COMM port Then Connect power to the PLC 2 Run the TLServer as described in Chapter 3 TLServer must be running before you can have any kind of communications with the PLC 5 16 Click on the Setup Serial Port button and test the communication with the PLC by entering the IR string into the Command box You should receive an IRO1 response from the PLC provided the default ID 01 has not been changed If you face any communication problems with the PLC then you will have to troubleshoot it first by making sure that a the correct COM port is used and b no other program e g a PDA cradle is currently controlling the COM port that is used with the PLC Next click on the Controller menu and select Program Transfer to PLC You will be asked to login to the TLServer If no one has changed the default info you should see the followi
226. w the ladder logic scanning process works as described in the last section If you use the CusFn the custom function will be executed EVERY SCAN of the ladder logic program as long as its execution condition is ON On the other hand the dCusF known as the differentiated or one shot format is executed only ONCE when its execution condition goes from OFF to ON The execution condition must go OFF and then ON again for the function to be executed again It is not difficult to see that the differentiated format is used far more frequently than the other one since most custom functions involve arithmetic and when a condition is ON you most likely want the computation to be performed ONCE and not repeatedly in every scan of the ladder logic You can easily understand the difference between the two formats if you run the following sample program Clk1 0s Clk1 Os Custom Function 1 A A 1 Custom Function 2 B B 1 Run the program in simulator and press the lt V gt key to view the changes in the variables A and B You will see that B is incremented by Al 2 one every second while A is incremented wildly for 0 5s and then stops for 0 5s Try it It can be very educational If you want to periodically check the status of an analog input or the real time clock you should use a clock pulse 0 1s 1 0s etc as shown in the example and connect to a dCusF Connecting to non differentiated version would mean checking thousands of
227. ween 1996 and 2096 Month is between 1 and 12 Day is between 1 and 31 Hour is between 0 and 23 Min and Sec are between 0 and 59 If you enter an illegal value TRILOGI will beep and the cursor will be put at the offending text field Correct the mistake and then click on the Set PLC s Clock button again to transfer the values to the RTC EEPROM Manager This command allows you to read write the data EEPROM content from and to an M series PLC with firmware r47 and above and all F series PLCs The EEPROM manager also allows you to save or load the data to and from the PC s hard disk When the EEPROM Manager is selected you will see the following screen 7 15 PLC Data EEPROM Manager Get INTEGER EEP data from PLC Get STRING EEPdata from PLC TRONS Write EEP Butters to PLC Integer EEP Buffer 1 ABC Machine Tool 2 Temperature 3 Start and Stop Buttons 4 Color of the Wall 5 Alarm is activated 6 FF FF FF FF FF FF FF FF FF FF FF FFIFFIFF 7 FF FF FF FF FF FF FFIFFAFFAFFAFFAFF FFIFF Retrieving EEP Integer 1 to 5 Load from File into Buffer Save Buffer to File Help There are two buffer areas The left dark blue text area is a buffer to hold 16 bit Integer EEPROM dota the right text area is to hold the String EEPROM data You can manually enter data in the buffer areas that are to be written to the data EEPROM or if you retrieve data EEPROM integer or string from the PLC the data will be
228. y I O the effect can be viewed on the simulator screen immediately E Programmable Logic Simulator Fn 10 Executed Iof x aois J T f JS T T T Meee conto start 2 0949 Duration p 18 Emerstop FudRevy 0w AO However if the computation affects only the variables than you may need to examine the internal variables An I O or internal relay bit that has been turned ON is indicated by a RED color rectangular lamp which simulates a LED being turned ON You can pause the logic simulator at any time by pressing the lt P gt or lt Ctrl P gt key or by clicking on the Pause button Likewise the simulator engine can be reset by clicking on the Reset button 2 Simulation of ADC Inputs Along the top edge of the Programmable Logic Simulator screen you will find 8 text fields adjacent to the label ADC1 8 The programmer can enter the expected ADC values for ADC 1 to 8 in these text fields In effect these simulate the potential signal strength at their respective ADC input pins These values will be captured by the TBASIC program when an ADC n command is executed in a custom function for ADC n For M series and F series PLCs the ADC input values should range between 0 and 4092 9 12 Note values entered at the ADC input text field_will only be updated when the user press the lt Enter gt key or the lt TAB gt key to ensure that only finalized entries are used by the TBASIC program Otherwise imagine if you
229. y or output will now be assigned as a Latching Relay You will be able to see the label name of the program element above the Latch symbol in the ladder diagram Although latch relay can be used in place of self latching Seal circuits a latch relay in an interlock section will not be cleared when the interlock occurs Only a self latching circuit as shown in the following will be cleared in an interlock section Start Stop CR1 4 e Ly CR Clear Relay Function Clear To de energize a program element that has been latched by the Latch function it is necessary to use Clear function On selecting Clear choose the output or relay to be de energized When the execution condition for that circuit is ON the designated output or 8 11 relay will be reset In the ladder diagram the program element label name will be shown above the Clear symbol If the execution condition for Latch and Clear functions are both ON at the same time then the effect of the designated bit depends on the relative locations of these two functions Remember that an output or relay bit energized by Latch will remain ON until it is turned OFF by Clear It is recommended that Clear circuit be placed just after the Latch circuit for the same output or relay controlled by these two functions This ensures that Clear function has higher priority over Latch function which is normally so in hardware latch relay or other industrial PLCs 5

Download Pdf Manuals

image

Related Search

Related Contents

Manual Marcador Polo  DINAMYK 9-36    PBI-DS-Dash-gastec-LM II-ES  "取扱説明書"  翻訳版【PDF:1.82KB】  ficha tecnica  Lab 9.3.5 Troubleshooting Routing Issues with show ip route and  Targus CitySmart 14"  NHRC-4/MVP Installation and Setup Guide  

Copyright © All rights reserved.
Failed to retrieve file