m

Changing Faceplate SP button range

On the default emerson faceplate the sp up and down button change the sp of the PID block by 1 or 1/10 depending on how many decimal places are chosen in the PV scale. I would like to change this to be a % of the sp scale. Here is the modified code, Range is the new variable. I have tried many different data types and still come out with a type mismatch error when I try to use the buttons. Am I on the right track (I kept the if statement there just to minimize the adjustments to the original code)?

Private Sub IncSP_Click()

  On Error GoTo ErrorHandler
  Dim sngSp As Single
  Dim lngCmdStatus As Long
  Dim strCmdStatus As String
  Dim Range As Single
 
  'read the value to increment
  sngSp = frsReadValue("DVSYS.@mod@/pid1/sp.f_cv", lngCmdStatus, strCmdStatus, False)
 
  If lngCmdStatus = 0 Then
    'if the read status is ok
    Range = "DVSYS.@mod@/pid1/sp_hi_lim.f_cv" - "DVSYS.@mod@/pid1/sp_lo_lim.f_cv"
    If pn_decpt <= 1 Then
      sngSp = sngSp + Range / 100
    Else
      sngSp = sngSp + (Range / 100)
    End If
    frsWriteValue CStr(sngSp), "DVSYS.@mod@/pid1/sp.f_cv", lngCmdStatus, strCmdStatus, False
    If lngCmdStatus <> 0 Then
      'if the write status is not ok
      MsgBox strWriteReturnError + vbNewLine + strCmdStatus + " (" + CStr(lngCmdStatus) + ")."
    End If
  Else
    'if the read status is not ok
    MsgBox strReadReturnError + vbNewLine + strCmdStatus + " (" + CStr(lngCmdStatus) + ")."
  End If
  Exit Sub
ErrorHandler:
  frsHandleError
End Sub

Thank you!

2 Replies

  • HI tklatt,

    Is this the code you have copied from under the excisting button? (and made some changes?)

    Should you declare : pn_decpt ?

    Do you have the formats correcct sp is float and you use single values...?.

    You should also  check for under/over shoot of the increment...

    Niklas Flykt 

    Klinkmann Oy

    Key Account Manager safety products

    nikfly@gmail.com

  • In reply to Niklas Flykt:

    This is indeed the code I copied from the existing button and made some changes.

    pn_decpt is declared elsewhere in the code

    I have tried long, single, double, integer, variant as the object types for the Range variable and still get error 13, type mismatch. Float is not an option.

Related