Skip to content

Instantly share code, notes, and snippets.

@MinaMal
MinaMal / Function node - Node-RED JavaScript.js
Last active December 11, 2022 10:25
Node-RED JavaScript - Function node
a = msg.payload.value/10
if (a > 31.0)
{
msg.payload.alarm = 1;
}
else
{
msg.payload.alarm = 0;
}
return msg;
@MinaMal
MinaMal / Email node - Node-RED JavaScript.js
Last active December 11, 2022 10:33
Node-RED JavaScript - Email node
var a = msg.payload.value/10;
if (msg.payload.alarm == 1)
{
msg.payload.text = "Critical Temperature Reached: " + a + "°C"
}
else
{
msg.payload.text = "Critical Temperature Reduced: " + a + "°C"
}
msg.payload = msg.payload.text;
@MinaMal
MinaMal / Pump Stop
Created October 3, 2021 13:21
This routine will stop the pump when the control valve is closed or not open
IF #ControlValve1_Closed = true OR #ControlValve1_Open = False THEN
#Pump_Start := False;
@MinaMal
MinaMal / Pump Start
Created October 3, 2021 13:20
This routine will start the pump when the control valve is open.
IF #ControlValve1_Closed = false AND #ControlValve1_Open = True THEN
#Pump_Start := True;
@MinaMal
MinaMal / Pump Start ST Program
Created October 3, 2021 13:04
This routine will start the pump when the control valve is open and stop the pump when the control valve is closed or not open
IF #ControlValve1_Closed = false AND #ControlValve1_Open = True THEN
#Pump_Start := True;
ELSIF #ControlValve1_Closed = true OR #ControlValve1_Open = False THEN
#Pump_Start := False;
END_IF;
@MinaMal
MinaMal / Pump Start ST Program + Comment
Last active March 10, 2023 02:06
This routine will start the pump when the control valve is open and stop the pump when the control valve is closed or not open
(* This routine will start the pump when the control valve is open and stop the pump when the control valve is closed or not open*)
IF #ControlValve1_Closed = false AND #ControlValve1_Open = True THEN
#Pump_Start := True;
ELSIF #ControlValve1_Closed = true OR #ControlValve1_Open = False THEN
#Pump_Start := False;
END_IF;
@MinaMal
MinaMal / DDE Request Method.vba
Created April 18, 2020 13:48
DDE Request Method
Sub Button2_Click()
rslinx = OpenRSlinx()
'Loop through reading the CLX Studio PLC array and put the values in the excel cells
'Cells(2, 1) = DDERequest(rslinx, "Real_array[0]") 'sample
'Cells(3, 1) = DDERequest(rslinx, "DINT_array[0]") 'sample
For i = 0 To 9
@MinaMal
MinaMal / DDE Request Method.vba
Created April 18, 2020 13:48
DDE Request Method
Sub Button2_Click()
rslinx = OpenRSlinx()
'Loop through reading the CLX Studio PLC array and put the values in the excel cells
'Cells(2, 1) = DDERequest(rslinx, "Real_array[0]") 'sample
'Cells(3, 1) = DDERequest(rslinx, "DINT_array[0]") 'sample
For i = 0 To 9
@MinaMal
MinaMal / DDE Poke Command.vba
Last active April 18, 2020 13:53
DDE Poke Command
Sub Button1_Click()
rslinx = OpenRSlinx()
'Loop through reading the CLX Studio PLC array and put the values in the excel cells
'DDEPoke rslinx, "DINT_array[0]", Cells(2, 8)
For i = 0 To 9
If TypeName(Data) = "Error" Then
If MsgBox("Error reading tag Real_array[" & i & "]. " & _
@MinaMal
MinaMal / RSLinx Open and Connect.vba
Created April 18, 2020 13:34
RSLinx Open and Connect
Public Function OpenRSlinx()
On Error Resume Next
'Open the connection to RSLinx
OpenRSlinx = DDEInitiate("RSLinx", "RealParsExcel")
'Check to see if connection was opened
If Err.Number <> 0 Then
MsgBox "Error Connecting to topic", vbaExclamation, "Error"