logo Welcome, Guest. Please Login or Register.
October 23, 2017, 08:26:04 PM
Home Help Search Login Register
 News: You can search the forum for answers to your question in a previous discussion. Please click on the "Search" button above and enter the keyword to search. To get to the full discussion of a listed message, please click on the TITLE of the message listed in the search listing.

  Internet PLC Forum
  General
  Technical support
(Moderator: support)
  HST
? previous next ?
Pages: [1] Go Down Reply Notify of replies Send the topic Print
   Author  Topic: HST  (Read 74 times)
artkraft
Newbie
*

Posts: 18



I'm a llama!

View Profile
HST
« on: October 05, 2017, 09:59:20 AM »
Reply with quote

How do I use a Cf to create 2 HST and keep that setting with loss of power or reset. I understand that I need HSTIMER 2. I have this CF called on 1st scan
// Initialize parameters
Setsystem 4,3 ' Enable enhanced high-speed counter modes

// Setbaud 1, 6
Setbaud 3, 4  '19200 baud to HMI panel

DM[200]=192
DM[201]=168
DM[202]=0
DM[203]=210
DM[204]=9080

//Set_IPAddr 200

DM[205]=255
DM[206]=255
DM[207]=255
DM[208]=0

//Set_Subnet 205

//SetSystem 252,0
Can I add syntax here ?
Report to moderator   Logged
garysdickinson
Expert Member
****

Posts: 363



Old PLC Coder

View Profile E-Mail
Re:HST
« Reply #1 on: October 05, 2017, 02:16:04 PM »
Reply with quote

Art,

You probably need to add the following sort of statements to your startup up CF to enable the high speed counters #1 and #2:
Code:
' InitHSC - Initialize High Speed Counters that are used by the turbine flow sensors
'
' The first argument is the high speed counter number 1..3
'
' The second argument is the custom function to be called when the counter reaches the
' value specified by the third argument. This custom function is responsible for
' keeping the running total of gallons and for resetting the high speed counter back to 0
' to start counting the next gallon.
'
' The third argument is the number of pulses per gallon
' &H7ffffff is a really large positive integer that effectively disables the interrupt from ever
' being called. The interrupt mechanism is buggy in F91.2 (Fx series PLCs).
' I am periodically polling the high speed counters and directly managing their count values
' without using the interrupt CFs mechanism as a work-around for the F91.2 issues.
'
HSCDEF  1, TotalizeProdFlw,  &h7fffffff
HSCDEF  2, TotalizeBrineFlw, &h7fffffff

' Reload counter values from EEPROM
'
HSCPV[1] = Load_EEP32(HSC1EEPAddr)
HSCPV[2] = Load_EEP32(HSC2EEPAddr)


You will need to add a CF to save the count values of your high speed counters to non-volatile memory.  You have to decide when to save the count values. You can set up a CF that saves the values periodically or based on the power fail interrupt. The CF to save the values would look something like this:
Code:
Save_EEP32 HSCPV[1], HSC1EEPAddr
Save_EEP32 HSCPV[2], HSC1EEPAddr


Gary D*ckinson
Report to moderator   Logged
artkraft
Newbie
*

Posts: 18



I'm a llama!

View Profile
Re:HST
« Reply #2 on: October 05, 2017, 06:04:00 PM »
Reply with quote

I have HSC I want High Speed Timer
Report to moderator   Logged
support
Global Moderator
*****

Posts: 3044





View Profile WWW E-Mail
Re:HST
« Reply #3 on: October 05, 2017, 11:48:13 PM »
Reply with quote

If you put HSTIMER 2 on an INIT custom function invoked by 1st.Scan then every time the PLC is reset the high speed timer 1 and 2 will be enabled.

However, the present values of the timers are not saved when power is lost.

If you need to keep the present values of these two timers you could set up a power failure interrupt (see INTRDEF function) and inside the power failure interrupt service routine  you can save the present values of the two timers to FRAM area.

Inside the INIT function you will then load the timer's present value from the FRAM location that holds the previous data. This way the high speed timer can resume its count down after a power failure or reboot.
Report to moderator   Logged

Email: support@triplc.com
Tel: 1-877-TRI-PLCS
garysdickinson
Expert Member
****

Posts: 363



Old PLC Coder

View Profile E-Mail
Re:HST
« Reply #4 on: October 06, 2017, 12:15:06 AM »
Reply with quote

Art,

Sorry, I misread your question.

About all that makes sense for High Speed Timers is to put the "HSTIMER 2" statement in a custom function that is called on the first scan of the ladder logic. 

I see no reason to save the PV (present value) for a TIMER and attempt to restore it after the PLC reboots.

The Set Value of the TIMER is defined by in the I/O table and will be initialized when the PLC restarts. 

If, however, your program changes the SV for TIMERs and COUNTERs during the execution of the code and you need to restore the changed SV, then you need to save to EEPROM and restore the SV of these items. 

I do change the SV for TIMERs and COUNTERs to values other than what is defined in the "I/O Table" while the PLC is running.  I have clients that need to customize the behavior of a PLC based system for specific clients.  Rather than writing a different PLC program for each of these customers, I have the PLC read the system configuration from an ASCII text file stored in the PLC filesystem.  This configuration file can be changed either via the HMI attached to the PLC or by uploading via FTP a new configuration file.

I do use High Speed Timers in my PLC programming.  But I am very careful to ensure that the worst case scan time through my ladder logic program is less than the time-base of the TIMERs to ensure that the TIMER is reasonably accurate. 

Sorry for not reading your question correctly.

Gary D*ckinson
« Last Edit: October 06, 2017, 12:23:00 AM by garysdickinson » Report to moderator   Logged
Pages: [1] Go Up Reply Notify of replies Send the topic Print 
? previous next ?
Jump to: 


Login with username, password and session length

Powered by MySQL Powered by PHP Internet PLC Forum | Powered by YaBB SE
© 2001-2004, YaBB SE Dev Team. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!