BASIC IDE

Basic IDE scripts have dissapeared, they are running though. I put some calculations for memory tags in the cyclic section, I just read this would be problematic. Is there a way to get my BASIC IDE back to it showing and remove the items on the cyclic section?

Hi @steverb32,

Can you connect to the device and get a backup.tar file from eBuddy with the support files included and send that to me?

Best Regards,
-Tim

Sorry about that, I’m not sure if the file got corrupted, but I took a look at the program.bas section of your backup and it looks like it was empty.

Thats the problem, for some reason it appears empty but the scripts are running. Is there a procedure on just uploading a Basic IDE portion? I have other Flexy (6 in total) which i could get the Original Init Section I was runing, modify it and get my flexy back to where it was.

Yes, we can do this through FTP with a program like Filezilla. First connect to the device that already has the program.bas file you’re looking for, and then push the file to the other devices that you need the file on.

You should just need to enter the local ip address of the device (either connected locally or through eCatcher) with the adm user and your adm password. Then you can grab the program file and push it to your other devices

Tim
I just did that, downloaded from another unit, edited the BAS file with the changes i have for the other (naming change on a report). Are there any examples of doing what I was trying to do on the cyclic section from the init section?

We strongly recommend against coding in the cyclic section just because of how intensive it is on the system. You should be able to do something similar using the Onchange function in the Init section.

Are there any examples?
I used OnChange in the init section
ONCHANGE “PT600_MA@”, “PT600@= 41.325 * ((PT600_MA@ - 4) + 0 )”
but its not doing anything, i need a mA value read from modbus to be converted to a Pvalue.

Try something like this:

Onchnage “PT600_MA”, “@new_calculated_value()”

Function new_calculated_value()
PT600@ = 41.325 * (PT600_MA@ - 4)
Endfn

Tim
Maybe there something im missing
this is my complete IDE
CLS
REM GENERATE REPORT EVERY HOUR
ONDATE 1,“0 0 * * *”,“GOTO GENERATE_REPORT”
ONSTATUS “GOTO SCHEDULEDACTION_END”
GOTO GENERATE_REPORT
END

GENERATE_REPORT:
//Check if SD card is inserted or if there is enough space
SETSYS INF,“LOAD”
SDCardSize$ = GETSYS INF, “SDExtFree”
SDCardSize_Int% = Val SDCardSize$
IF SDCardSize_Int% > 5000 THEN // 5 MB remains
GOSUB READ_LASTTMS
LAST_TIME$ = @GetCurrentTimeStamp$()
EBD_STRING$ = “$dtHT$ftT$et” + LAST_TIME$ + “$st” + LASTTMS$
FILENAME$ = “/usr/sdext/DR_DRACO_” + LAST_TIME$ + “.txt”
WRITEEBD EBD_STRING$, FILENAME$
ActionID% = GETSYS Prg, “ACTIONID”
ELSE
LOGEVENT “EUM Card full or not present”, -1
ENDIF
END

SCHEDULEDACTION_END:
CurID% = GETSYS Prg,“EVTINFO” : REM Get ActionID
REM : Check if it is the right schedule action to save last timestamp otherwise do nothing
If ActionID% = CurID% THEN
SETSYS Prg, “ACTIONID”, CurID%
CurID_Status% = GETSYS Prg,“ACTIONSTAT”
REM Action successfully done --> Write last timestamp in file
IF CurID_Status% = 0 THEN
LOGEVENT “FILE " + FILENAME$ + " SUCCESSFULLY EXPORTED”, 100
@WRITETMS(LAST_TIME$)
ELSE
LOGEVENT “FILE " + FILENAME$ + " NOT SUCCESSFULLY EXPORTED”, 0
ENDIF
ENDIF
END

READ_LASTTMS:
SETSYS PRG,“RESUMENEXT”,1
REM GET LAST TIMESTAMP
OPEN “file:/usr/tms.dat” FOR BINARY INPUT AS 1
LASTTMS$ = GET 1,15
CLOSE 1

Cur_Err% = GETSYS PRG,“LSTERR”

IF Cur_Err% = 33 THEN //REM File does not exist
LASTTMS$= “01011970_000000”
SETSYS PRG,“LSTERR”,0
ENDIF

SETSYS PRG,“RESUMENEXT”,0
CLS

RETURN

FUNCTION WriteTMS($LastTimeStamp$):
OPEN “file:/usr/tms.dat” FOR BINARY OUTPUT AS 1
PUT 1,$LastTimeStamp$
CLOSE 1
ENDFN

FUNCTION GetCurrentTimeStamp$()
REM TIME$ = 19/12/2014 10:03:01
$EWON_TIME$ = TIME$
$GetCurrentTimeStamp$ = $EWON_TIME$(1 To 2) + $EWON_TIME$(4 To 5) + $EWON_TIME$(7 To 10) + “_” + $EWON_TIME$(12 To 13) + $EWON_TIME$(15 To 16)+ $EWON_TIME$(18 To 19)
ENDFN
ONWAN name@ = “Fleet 3 - Draco”

ONCHANGE “PT600_MA”, “GOTO PT600_CALC”
Function PT600_CALC()
PT600@= 41.325 * (PT600_MA@ - 4)
ENDFN

Maybe you can try and put a print statement in the Onchange function to make sure it’s getting to that point. Also you don’t use goto for functions, you’d need to write it like this:

ONCHANGE “PT600_MA”, “@PT600_CALC()”
Function PT600_CALC()
PT600@= 41.325 * (PT600_MA@ - 4)
Print PT600@
ENDFN

Does it seem like there’s still errors showing up or that the value isn’t calculating right?

Tim

What I ended up doing was using the ONTIMER with a TSET 1 of 10 seconds and put everything before my report creation part. It works as it should.

TSET 1,10

This is the code

ONTIMER 1,"@VAR_CALC()"

Function VAR_CALC()

PT600@= 45.325 * (PT600_MA@ - 4)

TT600@= ((140+20)/(20-4)*(TT600_MA@-4)-20)

FT600@= ((345-0)/(20-4)*(FT600_MA@-4)+ 0)

FT2000_SCFM@= FT2000@ * ((PT2027@ + 14.7)/(14.7))*((59+459.67)/(TE2032@ + 459.67))

FT2000_MMCFD@= (FT2000_SCFM@ * 60.0 * 24.0)/ 1000000

FT600_SCFM@ = FT600@ * ((PT600@ + 14.67)/(14.7))*((59+459.67)/(TT600@+ 459.67))

FT600_MMCFD@ = (FT600_SCFm@ * 60 * 24)/ 1000000

ENDFN

Thanks

Steve

1 Like

Ok that works too, glad to hear you got it working!

@Tim_hms, I’ve noticed that from time to time if you place an “onchange or such” deeper in the script… it doesn’t work…

If you copy the

ONCHANGE “PT600_MA”, “GOTO PT600_CALC”

on top of the script with the other onchanges/ondates and such it’ll work…

My 2 cents… :slight_smile:

Is it throwing errors in the console section?

I noticed that yes if you place it deep in the script after the report scripting it doesnt work as well, and it seems to be with anything, also it doesnt seem to like two TSETS in a row, so i have learned to space them out and place the the ONTIMER call right after. This seems to work out well.
Thanks
Steve

Hi Steve,

One thing to look out for is to make sure that you’re using different timers with your TSETs. Just to make sure, you’re not using TSET 1,x more than once are you?

TSET 1,10 //timer 1 for 10 seconds
TSET 2,5 //timer 2 for 5 seconds

Tim
Yes Im aware that i have to use different timers for different things but for example
TSET 1, 10
TSET 2, 60
ONTIMER 1, “@FUNCTIONCALL1()”
ONTIMER 2, “@FUNCTIONCALL2()”

will not seem to work as well as
TSET 1, 10
ONTIMER 1, “@FUNCTIONCALL1()”

TSET 2, 60
ONTIMER 2, “@FUNCTIONCALL2()”

Thanks
Steve

Hi Steve,

I just tried doing it both ways and didn’t seem to notice a difference. Is your code in the Init section or the cyclic section?

-Tim

Correctly,

@Tim_hms, if you load the backup in a Ewon, you’ll see…
=> Just to point out the same problem as @steverb32 is having…

OnTimer 3, “Goto WriteToSiemensPLC”) down the script just in front of the “WriteToSiemensPLC” (line 194), and you’ll will see that the “WriteToSiemensPLC” block will never be triggered anymore…

BR
Peter