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!