Configuring an Encoder

2015-04-23
2024-05-25
  • chris.beard - 2015-04-23

    Hello,

    I am trying to add an encoder into an AxisGroup so I can use it for a Master for a Gear and I am getting a bit stuck.

    Could someone please explain the Module Parameters to me such as "dwRatioTechUnitsDenom" etc.

    Also how would i then set up the Encoder as the Master?

    Thank you

     
  • Kim - 2015-07-21

    Late reply but I'll post anyway to help others in the same situation who comes to this forum.

    Why not solve this using a Free Encoder object?
    It doesn't matter if the encoder value comes from a high speed counter of an I/O-node or if it comes from a true EtherCAT encoder, they both end up in the Free Encoder anyway.

    Setting up a Free Encoder

    1. Right click SoftMotion General Axis Pool, choose Add Device, select Free Encoders and finally SMC_FreeEncoder. Make sure you select the correct version matching your runtime target (check "Display all versions" at the bottom if you want older versions to appear).

    2. Rename your newly free encoder to something fitting, in this example I'll call it EncMaster.

    3. EncMaster wants the encoder input in EncMaster.diEncoderPosition. Either map this directly in the I/O-mapping of your slave, or you can copy it by code at the start of the motion cycle.

    4. Double click the EncMaster to access the settings, use the first tab SoftMotion: Encoder to setup scaling for your encoder just as if it was a motor. If you want to use it for following, then I'd suggest you set it up with the same values you are using for the motor that will be slaving to it.
      Please note you need to select the correct bitwidth of the encoder, otherwise rollover/offset won't work.

    5. In the tab I/O-mapping, make sure Bus cycle task is set to your Motion task.

    6. Done! You can now use EncMaster as an axis reference for gearing operations and much more.
      Actual position/velocity (in your preferred user units) can be read from EncMaster.fActPosition or EncMaster.fActVelocity just as for any motor.
      Kim Hansen
      Beijer Electronics Automation AB

     
  • jhenley - 2015-11-13

    Hey Kim,

    I am trying to do something similar where I am connecting a external encoder to use as positioning. I was trying to use the same setup that you described. When you say you have to map the diEncoderPosition either in the I/O mapping or by code, do you map it to the target position of the slave?

     
  • Kim - 2015-11-13

    No, that's not what I mean.

    I'll try to explain it some more by doing a practical example.
    Let's say you have a simple incremental encoder in your machine.
    You connect this to a Beckhoff EL5152 module which has a EK1100 bus node.
    The encoder value can now be retrieved from that slave.

    But in order for it to be used as a FreeEncoder, you need to somehow copy that encoder value from the Beckhoff slave into the FreeEncoder's .diEncoderPosition input.
    There are two ways of doing this.
    1) Map it directly to the FreeEncoder in the EtherCAT I/O Mapping tab of the EK1100. In my post above, I would map it directly to EncMaster.diEncoderPosition.
    2) Map it to a variable of your own choice, then manually copy that variable into EncMaster.diEncoderPosition every motion cycle by code.

    The 2nd choice might be more useful since you have a chance to alter the value if needed (f ex. byteswap, or you get the value in 3 bytes and need to combine them yourself etc. etc).

    Also, this will only create a proper encoder object.
    If you want to slave against it, then look up the PLCOpen MC_GearIn and MC_GearOut instructions.

    One last thing:
    When selecting the bitwidth of the encoder in the FreeEncoder settings, always choose the same OR LOWER setting, otherwise rollovers won't be handled properly.
    F ex: If you have a 29bit encoder source value, you should set bitwidth to 24, otherwise you will get an error on rollover.

    Kim Hansen
    Beijer Electronics Automation AB

     
    • genn - 2021-08-07

      What is the purpose of free encoder?.Can anyone help me out to solve the below issue? The issue is that the internal encoder overflows even we reset its position(If we continuously run it in the same direction)

      https://forge.codesys.com/forge/talk/Motion/thread/8abf72a7ad/

       
  • Anonymous - 2016-03-18

    Originally created by: ph0010421

    Hello
    I'm currently struggling with this.
    I have added an EtherCAT slave (a TR Electronics EtherCAT encoder).
    In the CoE Online Window, I can see the Timestamp and Position change.

    I've mapped the Position to the FreeEncoder's diActPosition but it is always zero.

    Maybe someone has a suggestion?

    Thank you
    Ph

     
  • eschwellinger

    eschwellinger - 2016-03-18

    Hi,

    Copy the rawdata to the EncoderAxis:
    LineEncoder.diEncoderPosition:= di_yourEncoderRawInput_from_EthercatProcessdata;

    BR
    Edwin

    IMG: SMC_FreeEncoder.jpg

     
  • Anonymous - 2016-03-18

    Originally created by: ph0010421

    Thank you Edwin for the fast response.
    I need to use the free encoder as a master axis (MC_Cam In for example).
    Will this method work?

     
  • eschwellinger

    eschwellinger - 2016-03-19

    Hi,

    yes this will work use the encoder axis like a regular axis.
    BR
    Edwin

     
  • Anonymous - 2016-03-19

    Originally created by: ph0010421

    Great. Thank you. Excellent support.
    Paul

     
  • Vergo77 - 2017-11-06

    Hello all,
    I know thi is an old thread, but I have another issue on this case.

    I've configured whit success one free encoder as a master by a gear function (I also tried awith a cam).
    My problem now are the acceleration and deceleration ramps, how can I fix a ramp values to limit the acceleration and deceleration on a free encoder?

    Thanks
    Roberto.

     
  • eschwellinger

    eschwellinger - 2017-11-08

    Hi,
    hm.. maybe I do not understand the problem.
    On an Encoder the ramps are given by the input/speed/ of the encoder signal, right?
    Maybe you want to filter These values?
    See the chapter here:

    https://help.codesys.com/webapp/sm-edt- ... on=4.3.0.0

    BR
    Edwin

    IMG: LogicalAxis.jpg

     
  • yofi - 2024-05-25

    I have a raspberry pi trying to add encoder to it using that free encoder node.

    I simply dont understand where the encoder channel A/B suppoded to be mapped when i got to I/O mapping on encoder I get nothing to

    where to set the channels for the encoder or is there any blocks from a library or how is it that you use an encoder with Codesys it doesn't seem clear at all

     

Log in to post a comment.