1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. Kawasaki Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

using BITS32 to send joint positions over EtherCAT fieldbus

  • Vaibhav Shah
  • April 28, 2023 at 10:21 AM
  • Thread is Unresolved
  • Vaibhav Shah
    Trophies
    3
    Posts
    8
    • April 28, 2023 at 10:21 AM
    • #1

    Hello,

    I am writing a PC program that checks the robot joint positions every scan and sends it over EtherCAT to my PLC over a 32bit address. My robot is BX200L-A001 and my controller is E02. This is the snippet of code I am using inside an infinite WHILE loop:

    HERE #pose

    DECOMPOSE joints[0] = #pose

    @Temp = INT(joints[0]*1000) ; <--- This is giving me an error "(P0115) Illegal Function"

    BITS32 101, 32 = @Temp


    I am not using 16 bits to send the joint values since I want a precision of 3 decimals and also I have a 7th axis (positioner) that can have joint values in the thousands.

    Upon browsing here, I found a thread that says that BIT32 can only accept INTEGER values due to possibly a bug. For this reason, I am trying to convert the the REAL values from the "joints" array into integer and then passing that integer value to the BITS32 command. I am getting the "Illegal Function" error on the marked line above. I am assuming that the return type of the INT() function is still a REAL and not an INTEGER. How do I convert a REAL value in the joints array to an integer that can be passed to the BITS32 command?

  • Go to Best Answer
  • HawkME April 28, 2023 at 10:46 AM

    Approved the thread.
  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,770
    • April 29, 2023 at 11:31 AM
    • #2

    What was mentioned in that thread about a 'bug' was a loose statement I made without cause.

    I am pretty sure converting real to whole number may not be possible.

    Even though the real can be changed to an integer value via INT command, I am 100% sure it still remains as a real variable and cannot be transferred to a whole number to be used as @.

    A BX200 and you require 3 decimal places....... :hmmm:

    Strange you would need to monitor for that accuracy as the repeatable accuracy for that robot will never sit in a 3 decimal place arena.

    Anyway, like I mentioned, I don't think there is a solution for converting a real number to whole number in Kawasaki.

    I would contact Kawasaki directly for this and see if they do have a solution available.

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • Alexandru
    Reactions Received
    49
    Trophies
    6
    Posts
    407
    • May 1, 2023 at 4:03 PM
    • #3

    You can create a TCP/IP with the PLC and send directly with a telegram the real value.

  • dm.bogachev
    Reactions Received
    45
    Trophies
    2
    Posts
    86
    • May 1, 2023 at 8:03 PM
    • Best Answer
    • #4

    I have a code example for sending 32-bits numbers, but you should know that it will be correct only for the first 7 digits. (According to the manual)

    Code
    .*********************************************************************************************************************
    .*Wichtiger Hinweis: 
    .*Bei Variablen vom Typ "REAL" werden nur die ersten 7 Stellen einer Zahl beruecksichtig!
    .*Variablen vom Typ "REAL" koennen Zahlen im Bereich von -3.402823*10^38 bis +3.402823*10^38 darstellen.
    .*Da bei 32BIT eigentlich Variablen vom Typ "INTEGER" verwendet werden, welche bis zu 10 Stellen einer Zahl  
    .*berueksichtigen koennen, muss der Zahlenbereich unter Verwendung dieses Beispiel entsprechend limitiert werden.
    .*********************************************************************************************************************  
    .PROGRAM main()
    ;************************************
    ;Real in 32Bit umwandeln
    ;************************************
    ;Im folgenden Beispiel werden die Eingange "1001-1032" ausgelesen und das Ergebnis als Dezimalwert in die Variable "ergebnis" geschrieben.
    startbit = 1001
    CALL bits32_to_real(startbit,ergebnis)
    ;
    ;************************************
    ;32Bit in Real umwandeln
    ;************************************
    ;Im folgenden Beispiel wird der Dezimalwert von "wert" in Binaer umgewandelt und auf die Ausgaenge "1-32" geschrieben.
    wert = 1234
    startbit = 1
    dezimal = 2
    CALL real_to_bits32(wert,startbit)
    .END
    .PROGRAM real_to_bits32(.value,.startbit)
    ;**************************************
    ;.value    = Dezimalwert
    ;.startbit = Startbitnummer
    ;**************************************
    If .value < 0
        SIGNAL (.startbit+31)
        .value = -.value-1
            FOR .i = 4 TO 1 STEP-1
                .byte[.i] = INT(.value/(256^(.i-1)))
                .value = .value - (.byte[.i]*(256^(.i-1)))
            END
        BITS .startbit,8      = .byte[1]
        BITS (.startbit+8),8  = .byte[2]
        BITS (.startbit+16),8 = .byte[3]
        BITS (.startbit+24),7 = .byte[4]    
        FOR .i = 0 TO 30 
        .sigtemp = .startbit+.i    
        SOUT .sigtemp = -.sigtemp                                            
        END                                                                
    ELSE 
        SIGNAL -(.startbit+31)
            FOR .i = 4 TO 1 STEP-1
                .byte[.i] = INT(.value/(256^(.i-1)))
                .value = .value - (.byte[.i]*(256^(.i-1)))
            END
        BITS .startbit,8      = .byte[1]
        BITS (.startbit+8),8  = .byte[2]
        BITS (.startbit+16),8 = .byte[3]
        BITS (.startbit+24),7 = .byte[4] 
    END 
    .END
    .PROGRAM bits32_to_real(.startbit,.value)
    ;**************************************
    ;.startbit = Startbitnummer
    ;.value    = Ergebnis als Dezimalwert
    ;**************************************
      .byte[1] = BITS(.startbit,8)
      .byte[2] = BITS((.startbit+8),8)
      .byte[3] = BITS((.startbit+16),8)
      .byte[4] = BITS((.startbit+24),7)
      IF SIG(.startbit+31) THEN
        .value = (-2147483648+.byte[4]*2^24+.byte[3]*2^16+.byte[2]*2^8+.byte[1])
      ELSE
        .value = (.byte[4]*2^24+.byte[3]*2^16+.byte[2]*2^8+.byte[1])
      END
    .END
    Display More
  • dm.bogachev
    Reactions Received
    45
    Trophies
    2
    Posts
    86
    • May 1, 2023 at 10:22 PM
    • #5

    Also, you can send in one 16-bit word integer part and the other 16-bit word - fractional part and then calculate the result on PLC

  • Vaibhav Shah
    Trophies
    3
    Posts
    8
    • May 2, 2023 at 9:00 AM
    • #6
    Quote from dm.bogachev

    I have a code example for sending 32-bits numbers, but you should know that it will be correct only for the first 7 digits. (According to the manual)

    Code
    .*********************************************************************************************************************
    .*Wichtiger Hinweis: 
    .*Bei Variablen vom Typ "REAL" werden nur die ersten 7 Stellen einer Zahl beruecksichtig!
    .*Variablen vom Typ "REAL" koennen Zahlen im Bereich von -3.402823*10^38 bis +3.402823*10^38 darstellen.
    .*Da bei 32BIT eigentlich Variablen vom Typ "INTEGER" verwendet werden, welche bis zu 10 Stellen einer Zahl  
    .*berueksichtigen koennen, muss der Zahlenbereich unter Verwendung dieses Beispiel entsprechend limitiert werden.
    .*********************************************************************************************************************  
    .PROGRAM main()
    ;************************************
    ;Real in 32Bit umwandeln
    ;************************************
    ;Im folgenden Beispiel werden die Eingange "1001-1032" ausgelesen und das Ergebnis als Dezimalwert in die Variable "ergebnis" geschrieben.
    startbit = 1001
    CALL bits32_to_real(startbit,ergebnis)
    ;
    ;************************************
    ;32Bit in Real umwandeln
    ;************************************
    ;Im folgenden Beispiel wird der Dezimalwert von "wert" in Binaer umgewandelt und auf die Ausgaenge "1-32" geschrieben.
    wert = 1234
    startbit = 1
    dezimal = 2
    CALL real_to_bits32(wert,startbit)
    .END
    .PROGRAM real_to_bits32(.value,.startbit)
    ;**************************************
    ;.value    = Dezimalwert
    ;.startbit = Startbitnummer
    ;**************************************
    If .value < 0
        SIGNAL (.startbit+31)
        .value = -.value-1
            FOR .i = 4 TO 1 STEP-1
                .byte[.i] = INT(.value/(256^(.i-1)))
                .value = .value - (.byte[.i]*(256^(.i-1)))
            END
        BITS .startbit,8      = .byte[1]
        BITS (.startbit+8),8  = .byte[2]
        BITS (.startbit+16),8 = .byte[3]
        BITS (.startbit+24),7 = .byte[4]    
        FOR .i = 0 TO 30 
        .sigtemp = .startbit+.i    
        SOUT .sigtemp = -.sigtemp                                            
        END                                                                
    ELSE 
        SIGNAL -(.startbit+31)
            FOR .i = 4 TO 1 STEP-1
                .byte[.i] = INT(.value/(256^(.i-1)))
                .value = .value - (.byte[.i]*(256^(.i-1)))
            END
        BITS .startbit,8      = .byte[1]
        BITS (.startbit+8),8  = .byte[2]
        BITS (.startbit+16),8 = .byte[3]
        BITS (.startbit+24),7 = .byte[4] 
    END 
    .END
    .PROGRAM bits32_to_real(.startbit,.value)
    ;**************************************
    ;.startbit = Startbitnummer
    ;.value    = Ergebnis als Dezimalwert
    ;**************************************
      .byte[1] = BITS(.startbit,8)
      .byte[2] = BITS((.startbit+8),8)
      .byte[3] = BITS((.startbit+16),8)
      .byte[4] = BITS((.startbit+24),7)
      IF SIG(.startbit+31) THEN
        .value = (-2147483648+.byte[4]*2^24+.byte[3]*2^16+.byte[2]*2^8+.byte[1])
      ELSE
        .value = (.byte[4]*2^24+.byte[3]*2^16+.byte[2]*2^8+.byte[1])
      END
    .END
    Display More

    Thank you so much for this code! I will try and run it today on the robot!

  • Vaibhav Shah
    Trophies
    3
    Posts
    8
    • May 2, 2023 at 12:22 PM
    • #7
    Quote from kwakisaki

    What was mentioned in that thread about a 'bug' was a loose statement I made without cause.

    I am pretty sure converting real to whole number may not be possible.

    Even though the real can be changed to an integer value via INT command, I am 100% sure it still remains as a real variable and cannot be transferred to a whole number to be used as @.

    A BX200 and you require 3 decimal places....... :hmmm:

    Strange you would need to monitor for that accuracy as the repeatable accuracy for that robot will never sit in a 3 decimal place arena.

    Anyway, like I mentioned, I don't think there is a solution for converting a real number to whole number in Kawasaki.

    I would contact Kawasaki directly for this and see if they do have a solution available.

    Display More

    Ahh my apologies for the "bug" statement.

    The reason why I want to have a 3 decimal accuracy is because I want to replicate the position of the robot in our custom software. Even if I lower my resolution to 2 decimal places, the question of JT7 axis still remains because for a linear track of 10m, the max position is 10000.0 mm. So 16 bits would not be sufficient in the future should a customer decide to purchase a robot with 10m track.

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • kawasaki
  • E controller
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download