Author Topic: Tech Tip & Sample Codes  (Read 38590 times)

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Tech Tip & Sample Codes
« on: March 22, 2012, 11:15:59 AM »
As per a user's suggestion, we will attempt to post links for sample programs in this forum thread.

The first place to find sample programs is to look in your TRiLOGI installation folder path as follow:

i-TRiLOGI

   C:\TRiLOGI\TL6\usr\samples

WinTRiLOGI

   C:\TRiLOGI\WTL3\

You can find many well-commented ladder logic and ladder+TBASIC sample programs there.

Also if you are new to ladder logic, you may like to download the free PLC programming eBook from our website at:

http://www.tri-plc.com/reqplcbook.htm

All the examples in the book are created using i-TRiLOGI program so you can enter and simulate them immediately using your i-TRiLOGI simulator.

Note: The book main focus is to explain ladder logic programming and it does not cover TBASIC.
« Last Edit: March 22, 2012, 02:29:46 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
PLC-Specific Sample Programs
« Reply #1 on: March 22, 2012, 11:24:29 AM »
« Last Edit: March 22, 2012, 03:13:01 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Modbus Master Sample Programs
« Reply #2 on: March 22, 2012, 01:57:04 PM »
The PLC can easily act as a Modbus master to read or write to any 3rd party devices that support the Modbus RTU, Modbus ASCII or Modbus/TCP protocols.

1)Built-in Modbus functions

Built-in READMODBUS, WRITEMODBUS, READMB2 and WRITEMB2 commands can be configured to use the MODBUS function 03, 04, 06 and 16 to communicate with Modbus slave. The following are sample programs for communicating with the Modbus RTU slave:

http://www.tri-plc.com/trilogi/Built-inModbusMasterFunctions.zip

Program fragment for communicating with a Modbus/TCP server (over Ethernet) is already contained in the TestEthernet.PC6 file that is stored in your i-TRiLOGI samples folder as follow:

   C:\TRiLOGI\TL6\usr\samples\  


2) Modbus functions implemented using TBASIC

Although there is no built-in function to communicate with Modbus RTU slaves using Modbus function code 01, 02, 05, it is possible to create these functions using TBASIC low level INCOMM and OUTCOMM commands.  Sample programs can be downloaded from:

http://www.tri-plc.com/trilogi/TBASICModbus.zip

The zip file also includes two sample programs constructed in TBASIC to use function 04 and 06 in order to run on older T100MD+ PLCs that do not support the Modbus function code 04 or 06.
« Last Edit: March 22, 2012, 03:20:16 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Temperature Measurement
« Reply #3 on: March 22, 2012, 03:11:00 PM »
1) Measuring temperature using 10K Thermistors

Thermistors can be used to measure temperature in many different environments. They are both rugged as well as low cost but are non-linear device.   The application note below explains how to physically connect a 10K Precon thermistor to the PLC using the PLCs on board ADC as well as how to use a look up table and interpolation method to calculate accurate temperature readings from the non-linear thermistor inputs.

http://www.tri-plc.com/appnotes/ThermistorSensor.zip

2) Measuring temperature using LM34 Semiconductor sensor

This is explained in Section 5.3.2 of the Nano-10, FMD or F-series PLC User's Manual. Please download the relevant manual from:

 http://www.tri-plc.com/documentlist.htm


« Last Edit: March 22, 2012, 03:14:22 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Serial Port HMI Sample Projects
« Reply #4 on: March 26, 2012, 01:17:54 AM »
1) MMI6050 As the Master and PLC as Slave
   
    http://www.tri-plc.com/KEPHMI.zip

2) MMI6050 As Slave and PLC as the Master

    http://www.tri-plc.com/MMI6050_as_slave.zip

« Last Edit: March 26, 2012, 01:19:37 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Visual Basic Programs For Communicating with PLCs
« Reply #5 on: June 25, 2012, 11:34:41 AM »
All Super PLCs (Nano-10, FMD and F-series) support both Modbus protocol and the native "Hostlink" protocol. PC programmers can choose protocol that they are most comfortable to work with in order to communicate with the PLC.

To assist users who wish to communicate with these PLCs using the native Hostlink protocol, a few Visual Basic sample programs have been written, tested and posted online which can be downloaded from:

http://www.tri-plc.com/appnotes/AppnoteMain.htm

« Last Edit: June 25, 2012, 11:35:54 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
General purpose Lookup Tables
« Reply #6 on: October 13, 2012, 10:31:00 PM »
Look up Table is a powerful technique used for computing data of a non linear function. For example, the resistance of typical NTC thermistors do not vary linearly with the temperature change. If you supply a constant current source to an NTC thermistor you will obtain a voltage value that can be read by the ADC input, but the readings do not vary linearly with the temperatures and therefore you can't simply use a formula to calculate the temperature corresponding to a particular analog reading.

However, since all thermistor manufacturers supply resistance vs temperature tables for their thermistor, you can therefore compute the corresponding ADC values and enter these values into a "look up table".  When you obtain an ADC reading you can then search the LUT to find the temperature that match the analog reading.

Of course very often the data obtained may not match the LUT data exactly since the table only provide discrete data points, a linear interpolation technique is typically used to find data that fall between two table points.

Other uses of LUT  can be to compute the square, trigonometric or logarithm function and their inverse without floating point support.

To assist user in implementing a LUT quickly, we are providing two LUT examples which can be downloaded from the following link:

http://www.tri-plc.com/download/LookupTables.zip

One of the example implements a square and a square root function, and the other implements a SINE and Inverse SINE function. These two programs are almost identical except for the data values that are stored into the lookup table.

You can copy the standard lookup table functions supplied in the sample program and use them in your program immediately without modification. All you need to modify is the INIT function that populate the lookup table with data that are relevant to your project. Using the supplied code you should find it very easy to implement other look up tables such as COSINE, LOG, pressure sensor, force sensors etc.  
« Last Edit: October 13, 2012, 10:52:03 PM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS