Ewon Flexy 205 IDE Basic Questions

Hello I have a couple basic questions about the IDE in the ewon flexy 205.

  1. I am running the following scripting in the cyclic section. The code scans a bunch of statuses and then gives an flag if ANY are in alarm. It also adds them up. I need to know should I run this scripting in INIT with a timer or leave in the cyclic section. It needs to scan at least every second
    $NumRows = 16
    For i% = 1 To $NumRows
    A$ = “BPRO_DIA_R” + STR$(i%)
    B$ = “BPRO_SOV_R” + STR$(i%)
    C$ = “BPRO_LL_R” + STR$(i%)
    J% = GETIO A$
    k% = GETIO B$
    L% = GETIO C$
    If j% = 1 THEN q% = q% + 1
    IF q% > 0 THEN DIA_STATUS_FAIL@ = 1 ELSE DIA_STATUS_FAIL@ = 0
    If k% = 1 THEN r% = r% + 1
    IF r% > 0 THEN SOV_STATUS_FAIL@ = 1 ELSE SOV_STATUS_FAIL@ = 0
    If l% = 1 THEN s% = s% + 1
    IF s% > 0 THEN LL_STATUS_FAIL@ = 1 ELSE LL_STATUS_FAIL@ = 0
    Next i%
    If i% >= 16 THEN i% = 1
    SETIO “DIAP_NUM_ALMS”, q%
    SETIO “SOV_NUM_ALMS”, r%
    SETIO “LL_NUM_ALMS”, s%
    q% = 0
    r% = 0
    s% = 0
    $NumAlms = 96
    For t% = 1 To $NumAlms
    D$ = “BPRO_ALM_” + STR$(t%)
    M% = GETIO D$
    If M% = 1 THEN V% = V% + 1
    Next t%
    If i% >= 16 THEN i% = 1
    SETIO “TOT_NUM_ALMS”, V%
    V% = 0

  2. Im trying to log a tag value only when the value changes either from a 0 to a 1. Im trying to use the following scripting but it says syntax error. Again I need to know if Im to use the INIT section - alot of people online are saying not to use the cyclic section - but doesnt INIT run only once once the IDE is running??

this is not working -

ONCHANGE “BPRO_SC_RMS_RESULT”, LOGIO “PRO_SC_RMS_RESULT”
ONCHANGE “BPRO_SC_TEMP_RESULT”, LOGIO “BPRO_SC_TEMP_RESULT”
ONCHANGE “BPRO_SC_UPSCALE_RESULT”, LOGIO “BPRO_SC_UPSCALE_RESULT”
ONCHANGE “BPRO_SC_ZERO_RESULT”, LOGIO “BPRO_SC_ZERO_RESULT”

Hi Royale,

We strongly recommend keeping the cyclic section blank because it can lead to stability issues.

The cyclic section executes with each processor cycle resulting in extremely fast execution. Having a file write execute in the cyclic section can cause a new execution to occur far before the main execution is done.

You should be able to run this whole section in the init section with an ontimer though.

For example if you do something like this
tset 1, 1

ontimer 1, “goto function”

in the first part it is saying it is timer 1, and that it will trigger every 1 second(s). Next there’s the ontimer section that will get called every time that timer 1 is triggered and go to the sectio of code called function.

rg-0006-01-en-programming-reference-guide.pdf (874.1 KB)

You could also do an onchange for those other functions with an if statement saying if they = 1 then the value = value + 1

thank you can you comment on this code its saying it cant find the functions - do I need to define the return values in the function declaration? the reference book is vague. and can I use for loops in a function?
Tset 1,1
Tset 2,1
Tset 3,1

ONTIMER 1,“goto DIA_FUNC”
ONTIMER 2,“goto ALM_FUNC”
ONTIMER 3,“goto SC_STATUS_FUNC”
ONCHANGE “BPRO_SC_SELFCHECK_DONE”, “Goto SC_FUNC”

FUNCTION DIA_FUNC
$NumRows = 16
For i% = 1 To $NumRows
A$ = “BPRO_DIA_R” + STR$(i%)
B$ = “BPRO_SOV_R” + STR$(i%)
C$ = “BPRO_LL_R” + STR$(i%)
J% = GETIO A$
k% = GETIO B$
L% = GETIO C$
If j% = 1 THEN q% = q% + 1
IF q% > 0 THEN DIA_STATUS_FAIL@ = 1 ELSE DIA_STATUS_FAIL@ = 0
If k% = 1 THEN r% = r% + 1
IF r% > 0 THEN SOV_STATUS_FAIL@ = 1 ELSE SOV_STATUS_FAIL@ = 0
If l% = 1 THEN s% = s% + 1
IF s% > 0 THEN LL_STATUS_FAIL@ = 1 ELSE LL_STATUS_FAIL@ = 0
Next i%
If i% >= 16 THEN i% = 1
SETIO “DIAP_NUM_ALMS”, q%
SETIO “SOV_NUM_ALMS”, r%
SETIO “LL_NUM_ALMS”, s%
q% = 0
r% = 0
s% = 0
Endfn

FUNCTION ALM_FUNC
$NumAlms = 96
For t% = 1 To $NumAlms
D$ = “BPRO_ALM_” + STR$(t%)
M% = GETIO D$
If M% = 1 THEN V% = V% + 1
Next t%
If i% >= 16 THEN i% = 1
SETIO “TOT_NUM_ALMS”, V%
V% = 0
Endfn

FUNCTION SC_FUNC
If BPRO_SC_SELFCHECK_DONE@ = 1 THEN
LOGIO “BPRO_SC_PROBE_RESULT”
LOGIO “BPRO_SC_UPSCALE_STATUS”
LOGIO “BPRO_SC_ZERO_STATUS”
Else
Endif
ENDFN

FUNCTION SC_STATUS_FUNC
SETIO “BPRO_SC_RMS_STATUS”, “PRO_SC_RMS_RESULT”
SETIO “BPRO_SC_TEMP_STATUS”, “BPRO_SC_TEMP_RESULT”
ENDFN
Rem — eWON user (end)
End
Rem — eWON end section: Init Section

Hey Royale,

One thing we could do is get rid of 2 of the timers if they’re all going to be triggering every 1 second and just do it like this:

Ontimer 1, “@DIA_FUNC()”
Ontimer 1, “@ALM_FUNC()”
Ontimer 1, “@SC_STATUS_FUNC()”
ONCHANGE “BPRO_SC_SELFCHECK_DONE”, “@SC_FUNC()”

Then change the first lines of the function to look like this:

FUNCTION DIA_FUNC()
FUNCTION ALM_FUNC()
FUNCTION SC_STATUS_FUNC()
FUNCTION SC_FUNC()

Here’s a for loop example though: