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. Fanuc 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

Karel GIN and negative numbers

  • boriskostov
  • January 17, 2024 at 12:49 PM
  • Thread is Unresolved
  • boriskostov
    Reactions Received
    5
    Trophies
    3
    Posts
    50
    • January 17, 2024 at 12:49 PM
    • #1

    Hello,

    I'm writing a Karel program, where I must read GIN and assign them to R[n]. How is thone the processing of negative numbers?

  • PnsStarter
    Reactions Received
    95
    Trophies
    6
    Posts
    337
    • January 17, 2024 at 1:06 PM
    • #2

    Hi boriskostov,

    Group IN/OUT-puts are unsigned 'integers with variable length' up to 16bit.

    However you can use negative values when using the same 'math' on both sides (plc and robot).

    You have to program it by yourself.(search forum or net)

    best

    Backdate/TP-Tools: A small collection of tools that simplify the commissioning and programming of Fanuc robots. (github.com)

  • hoitzing
    Reactions Received
    24
    Trophies
    1
    Posts
    128
    • January 17, 2024 at 1:32 PM
    • #3

    First off it's important to know if you're dealing with 8/16/32 bit integer values since the behaviour of grouped inputs is different for them.

    Reading GIN in a TP program via register assignment (R[n]=GI[m]) will simply give you the unsigned value. To convert to signed representation, subtract 2**p where p is the integer's precision. So for example to get a 16-bit signed integer from a 16-bit GI you need to subtract 2**16=65536: R[n]=GI[m]-65536.

    Reading GIN via KAREL can be a little funky, as the assignment int_var = GIN[n] always reads the grouped input as a 16-bit signed integer. So up to 15-bit precision it'll always be unsigned/positive, but as you exceed 32767=2**15-1, you get negative numbers.

    And to make it more compicated, if you require higher precision than 16-bit you can use multiple GI's to represent a single value (up to 32-bit precision is supported). But this is not worth getting into in this thread unless this is something your application requires.

    Secondly double-check if the negative number that the GI represents is indeed encoded in two's complement if you're getting weird results.

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
  • krc5
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • 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
  • krc5
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • Fanuc
  • karel
  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