Hi, I found a very strange thing with Karel looping.
So we tried a simple test loop with 8msec interval. The test code reports the time every loop. I was expecting a nice 16msec interval, but it turned out, it would do 8msec for about 6-7 times before it missed a cycle, see the plot at the attachment.
This is very strange. Is there anybody who also has similar experience?
Thanks,
Jay
PROGRAM ZKAREL
%ALPHABETIZE
%COMMENT = 'ZKAREL//r0b'
%NOLOCKGROUP
%NOPAUSE = COMMAND + TPENABLE + ERROR
TYPE
dpmm_t = STRUCTURE
shutdwn_req : BOOLEAN -- program abort requested status
ENDSTRUCTURE
CONST
LOG_PFIX = 'ZKAREL '
VAR
this_ : dpmm_t -- prog instance
stat_ : INTEGER
inputs : ARRAY[19] OF REAL
pos_log : FILE ---log
time_pos : INTEGER
ROUTINE handle_tp_data(this : dpmm_t;pos_log: FILE) : INTEGER FROM ZKAREL
BEGIN
stat_ = handle_tp_data(this_,pos_log);
END ZKAREL
ROUTINE handle_tp_data
VAR
stat__ : INTEGER
BEGIN
time_pos = 0;
inputs[1] = 1.0
OPEN FILE pos_log('RW','ud1:POS_log.txt')
WHILE ( DOUT[1] = OFF ) DO
CONNECT TIMER TO time_pos
WRITE pos_log(time_pos,inputs[1],CR)
DELAY(16)
ENDWHILE
lbl_hc_break::
CLOSE FILE pos_log
DISCONNECT TIMER time_pos
RETURN (-ABS(stat__))
END handle_tp_data