Hello everyone,
I'm trying to count, how much time the welding process was avtive, so I wrote next program,that I'm planning to call in sps:
bool mem ; bit memory 1
IF ($IN[2371] AND (NOT mem) ) THEN ; if we caught the front of signal 2371
$Timer_STOP[5] = FALSE ; started the timer for 5 seconds
ENDIF
IF ($TIMER[5] >= 5000) THEN ; if 5 seconds already gone
$TIMER_STOP[1] = FALSE ;started welding timer
$TIMER_STOP[5] = TRUE ;stopped timer of 5 seconds
$TIMER[5] = 0 ;set timer of 5 seconds to 0
ENDIF
IF ((NOT $IN[2371]) AND mem) THEN
$TIMER_STOP[1] = TRUE
CWRITE($FCT_CALL, STAT, MODE, "krl_fopen", "timers.txt", "a", HANDLE) ;open file
CWRITE($FCT_CALL, STAT, MODE, "krl_fprintf", HANDLE, "%f, %f, %f, %f, %f, %f, %f, %f, ",$TIMER[1]) ;write to file
CWRITE($FCT_CALL, STAT, MODE, "krl_fclose", HANDLE) ; close file
$TIMER[1] = 0
ENDIF
mem = $IN[2371] ;remembered the last state of 2371
So what the program exactly do: in bg logic it scans for active signal 2371, since its going active - its waiting for 5 seconds (5 second timer), then, start the other timer and counts how much time 2371 was active writing that numbers to timers.txt file
My question - I'm getting the "variable not defined" error in all cwrite lines. Also, Im getting error "The type of sentence is not equal to STAT_T" and "The type of sentence is not equal to MODUS_T". I checked manual many times and my code for writing into file exactly the same, also, i checked another thread: https://www.robot-forum.com/ro…d-hour/msg55503/#msg55503
And as you see, my code seems to be ok. Whats wrong?