Ewon Technical Forum

Full Version: Script execution pauses after some time!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
We installed eWon on one of our machine to send machine parameters to could and eWon does it successfully.
But after few days, we noticed that the execution of the script to upload the data somehow pauses for unknown reason/s. Would anybody help us locate the problem? The script that we are using for the same is attached.
We are using eWon Flexy 202 with FLB3204 GSM 4G Card to get internet connectivity. This problem arises once or twice a day.

Thanks in advance..
Hi,

There is actually a little bug in the firmware 13.2s1 that prevents to detect properly the MQTT disconnection.
So, when your 4G disconnection is down for a while, the Flexy MQTT client continues to publish data and sometimes when the Internet connection comes back, the messages are not published anymore till you disconnect/reconnect the MQTT broker.

This issue will be fixed in the next firmware 14.0.

As a work-around, I have modified your script to detect the error when publishing the data and make a DISCONNECT/RECONNECT.

Code:
SETSYS PRG,"RESUMENEXT",1
 MQTT "PUBLISH", "Altizon/Datonis/mqttfx/event",Data123$,1,0
 MQTT "PUBLISH", "Altizon/Datonis/mqttfx/event",Data12$,1,0
ErrorReturned = GETSYS PRG,"LSTERR"
IF ErrorReturned=28 THEN  //ERROR while publishing --> No connection --> Better to close and open
 MQTT "CLOSE"
  SETSYS PRG,"RESUMENEXT",0
 GOTO CONNECTMQTT
ENDIF
 

Here is the whole script updated :


Code:
Rem --- eWON start section: Cyclic Section
eWON_cyclic_section:
Rem --- eWON user (start)
Rem --- eWON user (end)
End
Rem --- eWON end section: Cyclic Section
Rem --- eWON start section: Init Section
eWON_init_section:
Rem --- eWON user (start)
SETSYS INF, "LOAD"
//SerNum$ = GETSYS INF, "SERNUM"
CONNECTMQTT:
MQTT "OPEN","mqttfx","telemetry.datonis.io"
MQTT "SETPARAM","PORT","1883"
MQTT "SETPARAM","username","2tet1tt4eb248e2t314fc964cd43bta374a6a76c"
MQTT "SETPARAM","password","2c7822fcc25ca0b549a0a199e01e87468bdee77b4bc68d931de4e072f57c0754"
//MQTT "subscribe", "Altizon/Datonis/SerNum$/httpAck", 1
MQTT "CONNECT"
PRINT "DONE"
TSET 1,5
ONTIMER 1, "GOTO T1"
ONMQTT "GOTO MqttRx"
GETSYS PRG,"EVTINFO"
END

T1:
ConnStatus% = MQTT "STATUS"

IF ConnStatus% = 5 THEN

PRINT "OKK"
b% = GETSYS PRG, "TIMESEC"
c%=b%-19800
TIMESTRING$ = Str$(c%) + "000"


Filler_Production_Current@ = Filler_Production_Counter@ - Filler_Production_Prev@
Filler_Production_Prev@ = Filler_Production_Counter@

Labeler_Production_Current@ = Labeler_Production_Counter@ - Labeler_Production_Prev@
Labeler_Production_Prev@ = Labeler_Production_Counter@

 //Filler
  Data123$ = "{" + '"data":' + "{" + '"Filler_Bottle_Type":' + STR$(Filler_Bottle_Type@) + ', "Filler_Operating_Mode":' + STR$(Filler_Operating_Mode@) + ","
  Data123$ = Data123$ + '"Filler_Production_Counter":' + STR$(Filler_Production_Counter@) + ', "Filler_Machine_Speed":' + STR$(Filler_Machine_Speed@) + ","
  Data123$ = Data123$ + '"Filler_Design_Speed":' + STR$(Filler_Design_Speed@) + ', "Filler_Bowl_Level":' + STR$(Filler_Bowl_Level@) + ","
  Data123$ = Data123$ + '"Filler_Bowl_Pressure":' + STR$(Filler_Bowl_Pressure@) + ', "Filler_Product_Temperature":' + STR$(Filler_Product_Temperature@) + ","
  Data123$ = Data123$ + '"job.value":' + STR$(Filler_Production_Current@) + "},"
  Data123$ = Data123$ + '"thing_key": "5d2t4e8fdd",' + '"access_key": "2tet1tt4eb248e2t314fc964cd43bta374a6a76c",'
  Data123$ = Data123$ + '"timestamp":' + TIMESTRING$ + "}"
 
 
 //Labeler
  Data12$ = "{" + '"data":' + "{"+ '"Labeler_Bottle_type":' + STR$(Labeler_Bottle_type@) + ', "Labeler_Operating_Mode":' + STR$(Labeler_Operating_Mode@) + ","
  Data12$ = Data12$ + '"Labeler_Production_Counter":' + STR$(Labeler_Production_Counter@) + ', "LF0096":' + STR$(LF0096@) + ","
  Data12$ = Data12$ + '"LF0269":' + STR$(LF0269@) + ', "LF0272":' + STR$(LF0272@) + ","
  Data12$ = Data12$ + '"LF0310":' + STR$(LF0310@) + ', "LF1095":' + STR$(LF1095@) + ","
  Data12$ = Data12$ + '"LW0032":' + STR$(LW0032@) + ', "LF1200":' + STR$(LF1200@) + ","
  Data12$ = Data12$ + '"LF1193":' + STR$(LF1193@) + ', "LF1201":' + STR$(LF1201@) + ","
  Data12$ = Data12$ + '"Labeler_Temperature_Motor":' + STR$(Labeler_Temperature_Motor@) +', "Labeler_Temperature_VaccumPump":' +STR$(Labeler_Temperature_VaccumPump@) + ","
  Data12$ = Data12$ + '"Labeler_Current_R":' + STR$(Labeler_Current_R@) + ', "Labeler_Current_Y":' +STR$(Labeler_Current_Y@) + ","
  Data12$ = Data12$ + '"Labeler_Current_B":' + STR$(Labeler_Current_B@) + ', "Labeler_Vibration_Motor":' +STR$(Labeler_Vibration_Motor@) + ","
  Data12$ = Data12$ + '"Labeler_Vibration_GearBox":' + STR$(Labeler_Vibration_GearBox@) + ', "Labeler_Vibration_VaccumPump":' + STR$(Labeler_Vibration_VaccumPump@) + ","
  Data12$ = Data12$ + '"job.value":' + STR$(Labeler_Production_Current@) + ', "LW0036":' + STR$(LW0036@)+ "},"
  Data12$ = Data12$ + '"thing_key": "439d18551a",' + '"access_key": "2tet1tt4eb248e2t314fc964cd43bta374a6a76c",'
  Data12$ = Data12$ + '"timestamp":' + TIMESTRING$ + "}"
 
 
 SETSYS PRG,"RESUMENEXT",1
  MQTT "PUBLISH", "Altizon/Datonis/mqttfx/event",Data123$,1,0
  MQTT "PUBLISH", "Altizon/Datonis/mqttfx/event",Data12$,1,0
 ErrorReturned = GETSYS PRG,"LSTERR"
 IF ErrorReturned=28 THEN  //ERROR while publishing --> No connection --> Better to close and open
  MQTT "CLOSE"
   SETSYS PRG,"RESUMENEXT",0
  GOTO CONNECTMQTT
 ENDIF
 

// PRINT "Message data = " + Data123$
// PRINT "Message data = " + Data12$
PRINT TIMESTRING$
 // PRINT "OK"
ELSE
 PRINT "Error : Flexy not connected"
ENDIF
END

MqttRx:
MqttReadNext:
  MessageQty%=Mqtt "READ"
  IF (MessageQty%>0) Then
      MsgTopic$=MQTT "MsgTopic$"
     MsgData$ =MQTT "MsgData$"
     Print "Subscribe Message Received:"+MsgTopic$+" "+MsgData$"
     GOTO MqttReadNext
  ENDIF
END

//MyLable:
//data123$ =" {"Data": { "voltage": "+STR$(Test@)+", "current": "+STR$(Test1@)+" }},"thing_key": "411a6c535e","access_key": "6ec19df9df14656ce6d15c6df35b769fb67d7t1a","timestamp": 1548147234000
//PRINT "OK"      
END


Rem --- eWON user (end)
End
Rem --- eWON end section: Init Section
Hi Simon,

I hope you're all keeping well?

I'm using the latest FW 14.2 and my script exceution is also turning off and I cannot pin down why??  i was using teh FW14 PR and thought it might be related to that, but still have the issue.

its a new projext and i'm not doing that much yet to be honest.  I am reading a lot of tags from the PLC 300+ 

Can send you the whole project if needed?

Code:
em --- eWON start section: Cyclic Section
eWON_cyclic_section:
Rem --- eWON user (start)
Rem --- eWON user (end)
End
Rem --- eWON end section: Cyclic Section
Rem --- eWON start section: Init Section
eWON_init_section:
Rem --- eWON user (start)
ONTIMER 1, "GOTO MyCode"
TSET 1,1
//ONDATE 1,"0 0 * * *","GOTGOTOGOTGO DailyUpdate"
//
System_No_Of_Gen@ = 10
System_Gen_kW_Rating@ = 2500
System_All_Gen_kW_Rating@ = System_Gen_kW_Rating@ * System_No_Of_Gen@

Print System_All_Gen_kW_Rating@
//
//ONDATE 1,"0,30 * * * *","GOTO Logging"  // logio every time minute = 0 or 30
//
//ONCHANGE "MCP_All_Load_SP","GOTO Setpoint"
//ONCHANGE "System_No_Of_Gen", "GOTO System"
//
///ONCHANGE "MCP_All_kWH","T1_MCP_All_kWH@ = MCP_All_kWH@"
//
END
Rem --- eWON user (end)
End
Rem --- eWON end section: Init Section
Rem --- eWON start section: MyCode
Rem --- eWON user (start)
MyCode:
MCP_All_kW@ = Gen_kW_1@ + Gen_kW_2@
Print MCP_All_kW@
If System_Test_Bit@ = 1 THEN // Test email
//Test_Bit@ = 0
//Base_DO1@ = 1
//System_External_Start_Stop@ = 1
Goto SIM
ELSE
eWon_Base_DO1@ = 0
//System_External_Start_Stop@ = 0
ENDIF
END
Rem --- eWON user (end)
End
Rem --- eWON end section: MyCode
Rem --- eWON start section: SIM
Rem --- eWON user (start)
SIM:
Gen_kW_1@ = Gen_kW_1@ +100
Gen_kW_2@ = Gen_kW_2@ +50
If Gen_kW_1@  >= 2500 Then
Gen_kW_1@ = 0
ENDIF
If Gen_kW_2@  >= 2500 Then
Gen_kW_2@ = 0
ENDIF
//Print Gen_kW_1@
END
Rem --- eWON user (end)
End
Rem --- eWON end section: SIM
Rem --- eWON start section: Logging
Rem --- eWON user (start)
Logging:
T100_MCP_All_Export_kWH@ = MCP_All_Export_kWH@
T101_MCP_All_M3@ = MCP_All_M3@
//
T10_Gen_kWH_1@ = Gen_kWH_1@
T11_Gen_M3_1@ = Gen_M3_1@
T12_Gen_Running_Hours_1@ = Gen_Running_Hours_1@
//
T13_Gen_kWH_2@ = Gen_kWH_2@
T14_Gen_M3_2@ = Gen_M3_2@
T15_Gen_Running_Hours_2@ = Gen_Running_Hours_2@
//
T16_Gen_kWH_3@ = Gen_kWH_3@
T17_Gen_M3_3@ = Gen_M3_3@
T18_Gen_Running_Hours_3@ = Gen_Running_Hours_3@
//
T19_Gen_kWH_4@ = Gen_kWH_4@
T20_Gen_M3_4@ = Gen_M3_4@
T21_Gen_Running_Hours_4@ = Gen_Running_Hours_4@
//
T22_Gen_kWH_5@ = Gen_kWH_5@
T23_Gen_M3_5@ = Gen_M3_5@
T24_Gen_Running_Hours_5@ = Gen_Running_Hours_5@
//
T25_Gen_kWH_6@ = Gen_kWH_6@
T26_Gen_M3_6@ = Gen_M3_6@
T27_Gen_Running_Hours_6@ = Gen_Running_Hours_6@
//
T28_Gen_kWH_7@ = Gen_kWH_7@
T29_Gen_M3_7@ = Gen_M3_7@
T30_Gen_Running_Hours_7@ = Gen_Running_Hours_7@
//
T31_Gen_kWH_8@ = Gen_kWH_8@
T32_Gen_M3_8@ = Gen_M3_8@
T33_Gen_Running_Hours_8@ = Gen_Running_Hours_8@
//
T34_Gen_kWH_9@ = Gen_kWH_9@
T35_Gen_M3_9@ = Gen_M3_9@
T36_Gen_Running_Hours_9@ = Gen_Running_Hours_9@
//
T37_Gen_kWH_10@ = Gen_kWH_10@
T38_Gen_M3_10@ = Gen_M3_10@
T39_Gen_Running_Hours_10@ = Gen_Running_Hours_10@
//
LOGIO "T100_MCP_All_Export_kWH"
LOGIO "T101_MCP_All_M3"
//
LOGIO "T10_Gen_kWH_1"
LOGIO "T11_Gen_M3_1"
LOGIO "T12_Gen_Running_Hours_1"
//
LOGIO "T13_Gen_kWH_2"
LOGIO "T14_Gen_M3_2"
LOGIO "T15_Gen_Running_Hours_2"
//
LOGIO "T16_Gen_kWH_3"
LOGIO "T17_Gen_M3_3"
LOGIO "T18_Gen_Running_Hours_3"
//
LOGIO "T19_Gen_kWH_4"
LOGIO "T20_Gen_M3_4"
LOGIO "T21_Gen_Running_Hours_4"
//
LOGIO "T22_Gen_kWH_5"
LOGIO "T23_Gen_M3_5"
LOGIO "T24_Gen_Running_Hours_5"
//
LOGIO "T25_Gen_kWH_6"
LOGIO "T26_Gen_M3_6"
LOGIO "T27_Gen_Running_Hours_6"
//
LOGIO "T28_Gen_kWH_7"
LOGIO "T29_Gen_M3_7"
LOGIO "T30_Gen_Running_Hours_7"
//
LOGIO "T31_Gen_kWH_8"
LOGIO "T32_Gen_M3_8"
LOGIO "T33_Gen_Running_Hours_8"
//
LOGIO "T34_Gen_kWH_9"
LOGIO "T35_Gen_M3_9"
LOGIO "T36_Gen_Running_Hours_9"
//
LOGIO "T37_Gen_kWH_10"
LOGIO "T38_Gen_M3_10"
LOGIO "T39_Gen_Running_Hours_10"
//
END
Rem --- eWON user (end)
End
Rem --- eWON end section: Logging
Rem --- eWON start section: Setpoint
Rem --- eWON user (start)
Setpoint:
Gen_Load_SP_1@ = MCP_All_Load_SP@
Gen_Load_SP_2@ = MCP_All_Load_SP@
Gen_Load_SP_3@ = MCP_All_Load_SP@
Gen_Load_SP_4@ = MCP_All_Load_SP@
Gen_Load_SP_5@ = MCP_All_Load_SP@
Gen_Load_SP_6@ = MCP_All_Load_SP@
Gen_Load_SP_7@ = MCP_All_Load_SP@
Gen_Load_SP_8@ = MCP_All_Load_SP@
Gen_Load_SP_9@ = MCP_All_Load_SP@
Gen_Load_SP_10@ = MCP_All_Load_SP@
END
Rem --- eWON user (end)
End
Rem --- eWON end section: Setpoint
Rem --- eWON start section: System
Rem --- eWON user (start)
System:
System_All_Gen_kW_Rating@ = System_Gen_kW_Rating@ * System_No_Of_Gen@
Print System_All_Gen_kW_Rating@


System_All_Gen_kW_Rating@ = System_Gen_kW_Rating@ * System_No_Of_Gen@

END
Rem --- eWON user (end)
End
Rem --- eWON end section: System
Hi,

What do you mean by "turning off" ? Does it switch to "STOP" on its own ?
I see in your script that you just call the "GOTO MyCode" every second. All the rest is commented. Is it what you want ?

Simon
(07-05-2020, 12:38 PM)simon Wrote: [ -> ]Hi,

What do you mean by "turning off" ? Does it switch to "STOP" on its own ?
I see in your script that you just call the "GOTO MyCode" very second. All the rest is commented. Is it what you want ?

Simon

Hi Simon,

Yes the running / stopped switch turns off automatically. I noticed via another post to set the execution to 'autostart'  this has helped, but the ewon drops connection or reboots often.
Hi,

Then this would require a deeper analysis.
Could you report that to your local support contact (distributor/hms) or directly through the HMS support platform - https://mysupport.hms.se.
We would need the backup, including the support files, to start checking what is going on.

Thanks in advance

Simon
(11-05-2020, 10:35 PM)simon Wrote: [ -> ]Hi,

Then this would require a deeper analysis.
Could you report that to your local support contact (distributor/hms) or directly through the HMS support platform - https://mysupport.hms.se.
We would need the backup, including the support files, to start checking what is going on.

Thanks in advance

Simon


Ok Simon will do.

Many thanks!
I am seeing this same thing. My code will be running along and sending in data. Then it will just stop. No idea why. I slide the slider over and all is well again.
The problem is most likely the unexpected reboots.
Try selecting “auto run” from the drop down menu next to the “RUN” button in the IDE.

Obviously doesn’t fix anything, but if all is ok then it will keep the script execution working.

Never had to do this on FW 11>13 but looks like in FW 14 auto run is disabled by default??
Hi,

It has always been disabled by default ;-)
Ok thanks Simon, I’ll have to check my older projects! I’ve never set any of them to auto run!

Cheers M