Posts by PnsStarter

    hi ath,

    you can't run( ..but you can load from mc,ud1) prog from a device like MC oder UD1.

    When you load from e.g MC, it's loaded into memory AND then it's (also) accessable at your MD-device. (as far as I know)

    So in Karel you need at least two programs:

    1. program that loads another one from a device

    2. and your 'main' program

    Hi RD24,

    Registers are "dynamic" Types.

    Convert type first.


    you can "trunc" R[2] like this:


    R[2] = R[11] / R[12]


    R[2] = R[2] DIV 1


    FOR R[1] = R[2] TO R[3]


    <lines of program>

    ENDFOR


    Best regards

    Hi ChrisFS,

    I think the behavior, and the error messages are correct.

    Quote

    OPEN FILE LOG_FILE('AP', fn)fstatus = IO_STATUS(LOG_FILE)

    fstatus is always zero whether USB plugged in or not

    That the status is zero is ok, only when writing there is an error.

    We want to append text to the file, in 'AP' mode it doesn't matter if the file exists or not.


    And the second error is also correct.

    as you have written: 2014 -->FILE-014 File not found

    E.g. Windows would tell you in this case also "File not found"... and not "USB stick not inserted" ;)


    ---

    You can evaluate the error when you write to the file and then set a status variable that tells you or the program that no USB drive is present.

    ---

    Alternatively you can use (from Karel manual)

    Code
    DOSFILE_INF('UD1:', DF_MANUFNAME, value, status)


    DF_MANUFNAME' vendor name

    value -->manufacturer name but not of interest here.


    check "status" ...

    ---

    But I strongly advise not to write a background program to monitor if the USB stick is inserted...


    best regards

    Hi,

    I had trouble with motion commands like this:

    Code
    1:J P[1] R[10]% FINE ACC R[11]    ;

    I had success removing the register statements and using (direct) values instead:

    Code
    1:J P[1] 100% FINE ACC 105    ;

    Hi,

    without the source it is"problematic".

    Did the progam work (sometimes)?



    Maybe there is a problem with a file:

    Are you opening/using files?

    Or,are you communicating via sockets or pipes etc?


    the karel built ins are:

    IO_STATUS

    CLR_IO_STAT


    [in] file_id :FILE

    status: IO_STATUS(file_id)

    will return an integer different from "0" if an errror exists


    CLR_IO_STAT(file_id)

    will clear the errror


    --> FCTN-->ABORT All | will clear the error too


    best regards

    PnsStarter

    Quote

    Karel has special Constants:

    MAXINT +2147483647

    MININT -2147483648

    I have done some research on these issues.

    - Behavior of Karel/Karel variables

    - Behavior of TP programs or registers


    Error inside Karel manual:

    ----

    2.1.6 Predefined Identifiers

    ...

    MAXINT INTEGER +2147483647

    MININT INTEGER-2147483648

    ...However,the predefined identifier MININT is an exception to this rule. This identifier must always be used in place of its value, -2147483648. The value or number itself can not be used...

    ----

    The above statement is wrong.


    The value -2147483648 (MININT) can be used normally and is displayed correctly.

    It turns out that the value of MAXINT is always 2147483646.

    However, if the value is stored after the two's complement, it should be 2147483647.

    In Karel, however, the maximum integer value is 2147483646. If the bits are set to the "regular value of MAXINT, i.e. 2147483647, and then assigned to a Karel integer variable, the value is uninitialized.

    So not all (regular)values are possible.


    In TP, however, it behaves differently with the registers.

    Calculating and setting with MaxINTEGER works. Also the overflow behaves as expected.

    Only the display on TP and in the web interface is not "nice".


    Here are some comparisons TP / Karel


    Karel:

    --

    value = MININT; --> value -2147483648

    value = -2147483648; --> value -2147483648

    --

    value = MAXINT; --> value +2147483646

    value = 2147483646; --> value +2147483646

    IF value = MAXINT ... --> true


    value = 2147483647 ; --> value *****

    value = MAXINT +1 ; --> value *****

    value = 2147483646 +1 ; --> value *****

    IF UNINIT(value)... --> true

    -- no more calculation possible, only query if UNINIT works

    --> recognition is possible, but "calculating" becomes "messy"


    TP

    R[1] = -2147483648; --> R[1] -2147483648

    R[1] = -2147483647-1; --> R[1] -2147483648


    R[1] = 2147483646; --> R[1] 2147483646

    R[1] = 2147483646+1; --> R[1] ******* (2147483647)

    R[1] = R[1] +1 ; --> R[1] -2147483648


    -- Calculation and overflow works as expected

    -- The display is ***** not nice


    When a program with ascii upload is played to the controller with the following code:


    : R[1] = 2147483647;

    it will be displayed like this:

    : R[1] = ******; --> When the LS prog is downloaded it contains the stars and cannot be uploaded anymore. It is like with uninitialized positions in TP programs.


    I hope I could help a little further and/or bring light into the darkness.

    best regards

    PnsStarter

    Quote

    I don't know why, but in my mind, the value of an IO would remain the same from the start of a task scan until the end of that same scan.

    All programs share the CPU time.

    The programs can and are interrupted in between. At which point this happens in the program cannot be predicted.

    Quote

    Overall everything works fine except sometimes, where it seems that there is a gap between KAREL variables and GI.


    ((Why is this a problem?))

    At the time you read the input, it had a certain value. And this value is correct at this time.

    If you have to keep the value "synchronous" with the PLC, you have to program a handshake.