Fanuc Karel and HTML

  • Greetings I need help.

    I am doing a custom Html page to control Fanuc robot I/O. I am doing this with help of Karel.

    Here are the programs. HTML program for sending data and Karel program for receiving data.

    I don't know why they won't work. Please help me. I picked KAREL 632 during configuration of my cell and Karel is unlocked in TP.

    The HTML page is saved in MC folder in My workcells.



    KAREL

    -------------------------------------------------------------

    PROGRAM prvi -- svaki program mora zapoceti s "PROGRAM" nakon cega slijedi ime programa


    %NOLOCKGROUP -- grupe moraju biti otkljucane da bi program radio


    VAR -- sve varijable koje se koriste u programu moraju se definirati

    object : STRING[12]

    operate : STRING[12]

    INDEX : STRING[12]

    value : STRING[12]


    uobject : STRING[12] -- duple varijable koje ce se koristiti za prebacijavje teksta u velika slova

    uoperate: STRING[12]

    uindex : STRING[12]

    uvalue : STRING[12]


    value_i : INTEGER -- ostale varijable

    value_r : REAL

    index_i: INTEGER

    status : INTEGER

    i : INTEGER

    return_code : INTEGER


    ROUTINE toupper(p_char: INTEGER): STRING -- prebacivanje ulaza u velika slova

    BEGIN

    IF (p_char > 96) AND (p_char < 123) THEN

    p_char = p_char - 32

    ENDIF

    RETURN (CHR(p_char))

    END toupper


    BEGIN

    IF UNINIT(object) THEN object = ''; ENDIF -- provjera neinicializiranih varijabli prije korištenja

    IF UNINIT(operate) THEN operate = ''; ENDIF

    IF UNINIT(INDEX) THEN INDEX = ''; ENDIF

    IF UNINIT(value) THEN value = ''; ENDIF


    uobject = ''

    FOR i = 1 TO STR_LEN(object) DO

    uobject = uobject + toupper(ORD(object, i))

    ENDFOR

    uoperate = ''

    FOR i = 1 TO STR_LEN(operate) DO

    uoperate = uoperate + toupper(ORD(operate, i))

    ENDFOR

    uindex = ''

    FOR i = 1 TO STR_LEN(INDEX) DO

    uindex = uindex + toupper(ORD(INDEX, i))

    ENDFOR

    uvalue = ''

    FOR i = 1 TO STR_LEN(value) DO

    uvalue = uvalue + toupper(ORD(value, i))

    ENDFOR


    IF (uobject = 'DOUT') THEN

    IF (uoperate = 'SET') THEN

    CNV_STR_INT(uindex, index_i)

    IF (uvalue = 'ON') THEN

    DOUT[index_i] = ON

    ENDIF

    IF (uvalue = 'OFF') THEN

    DOUT[index_i] = OFF

    ENDIF

    ENDIF

    ENDIF


    IF (uobject = 'NUMREG') THEN

    CNV_STR_INT(uindex, index_i)

    IF (uoperate = 'SETINT') THEN

    CNV_STR_INT(uvalue, value_i)

    SET_INT_REG(index_i, value_i, status)

    ENDIF

    IF (uoperate = 'SETREAL') THEN

    CNV_STR_REAL(uvalue, value_r)

    SET_REAL_REG(index_i, value_r, status)

    ENDIF

    ENDIF

    return_code = 204 -- povratak NO RESPONSE koda - potrebno

    END prvi -- svaki program mora završiti s "END" nakon cega slijedi ime programa

    -----------------------------------------------------------------------------------------------------------------------------




    HTML PROGRAM

    -------------------------------------------------------------------------------------------------

    <!DOCTYPE html>

    <html lang="hr-HR">

    <head>

    <meta charset=UTF-8>

    <div align="mid">

    <title>FANUC WEB WIZARD - Paletizacija</title> </div>

    </head>

    <body bgcolor="#4169E1">

    <h2>

    <font color="#FFFFFF">

    </fontcolor>Primjeri mogućeg sadržaja:

    </h2>

    <table>

    <tr>

    <h3>1. Postavljanje digitalnih izlaza:</h3>

    <td>

    <form action="C:\Users\kovad\OneDrive\Dokumenti\My Workcells\Projekt_IRM\Robot_1\MC\prvi" method="GET"> <!--link na karel program-->

    <div align="left">

    <input type="hidden" name="object" value="DOUT">

    <input type="hidden" name="operate" value="set">

    <input type="hidden" name="index" value="1"> <!--broj izlaza koji se mijenja-->

    <input type="hidden" name="value" value="ON">

    <input type="submit" value="Upali DOUT[1]">

    </div>

    </form>

    </td>

    <td>

    <form action="C:\Users\kovad\OneDrive\Dokumenti\My Workcells\Projekt_IRM\Robot_1\MC\prvi" method="GET"> <!--link na karel program-->

    <div align="left">

    <input type="hidden" name="object" value="DOUT">

    <input type="hidden" name="operate" value="set">

    <input type="hidden" name="index" value="1"> <!--broj izlaza koji se mijenja-->

    <input type="hidden" name="value" value="OFF">

    <input type="submit" value="Ugasi DOUT[1]">

    </div>

    </form>

    </td>

    </tr>

    </table>

    <table>

    <tr>

  • Place your Ad here!
  • Try:

    <form action="/KAREL/prvi" method="GET">

    You have to use the paths of the robot itself, not the paths of your computer.

    Before You try it, export the .html via Roboguide to the virtual robot. Copying it to the local MC folder doesn't work.

  • Have you tested this using a "raw" browser command first? Typically, for a RoboGuide virtual robot, you should be able to point a browser directly to "http://localhost/KAREL/prvi?object=DOUT", and see that the string variable Object becomes "DOUT". Any errors in the KRL will be shown on the virtual pendant, so make sure you have it active.


    For testing this way, it would also help if you set up a return string to the browser, as shown in the Internet Options manual.

  • Have you tested this using a "raw" browser command first? Typically, for a RoboGuide virtual robot, you should be able to point a browser directly to "http://localhost/KAREL/prvi?object=DOUT", and see that the string variable Object becomes "DOUT". Any errors in the KRL will be shown on the virtual pendant, so make sure you have it active.


    For testing this way, it would also help if you set up a return string to the browser, as shown in the Internet Options manual.

    That was the problem. I fixed it and it worked.

    Thank You!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now

Advertising from our partners