News:

  • October 18, 2026, 11:55:41 PM

Login with username, password and session length

Author Topic: Getting started with an encoder  (Read 7150 times)

RaymondC

  • Full Member
  • ***
  • Posts: 27
Getting started with an encoder
« on: February 03, 2021, 09:43:55 PM »
Hello,

I have a working machine based on a BRX Do-more PLC and some SureStep stepper motors. I recently added an encoder to one of the motors so I can implement some custom error detection and handling logic. This is my first time using an encoder with the BRX PLCs. My intent is NOT to use a PID closed loop on the motor but, as I said, implement some custom logic.

I am doing my research on using encoders with Do-more PLCs but was hoping for a few tips to push me in the right direction and save me many hours.   :)

All I need to know is how to configure an encoder in the PLC that is not necessary tied to the motor on which it resides and how to do some basics like resetting and reading the encoder values.

Thanks.

Ray

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 702
  • Hmmm...
    • Host Engineering, Inc.
Re: Getting started with an encoder
« Reply #1 on: February 04, 2021, 10:37:30 AM »
  • Pull up the Dashboard (View --> Dashboard). This creates a tab called Dashboard.
  • Click on the HSIO tab on the top left of your BRX PLC image. This pulls up the "Setup BRX High Speed I/O" dialog.
  • The top box is labeled "Input Functions (Counter/Timer/Pulse Catch)". Your encoder will use one of these 3 customizable Functions. Press one of the <Function> buttons. This pulls up the "Setup BRX High Speed Input Function" dialog.
  • By default the "Disabled" tab is displayed. On this tab are various Help buttons that you can press to read about the 3 kinds of custom settings available; Counter, Timer, or Pulse Catch. Also notice the tabs across the top corresponding to these 3 kinds of custom settings. In your case, you'll probably want to use the Counter. Click on the Counter tab at the top to enable this setting and display the Counter configuration dialog.
  • The first thing to notice is the Device Name. By default it is "HsCtrTmr1." But you can change it to something that makes a bit more sense. This name is going to be used in your ladder program. Here, in the use of this function, you can use as many as 5 input pins to accomplish various things. By default "Up Counter" is selected as using the first HS Input 1 (X1) of your BRX. The button to the right highlights in red showing you that it will count the rising edges of the encoder pulse. Pressing this button will change whether you want to count rising, falling, or both edges of your pulse. If you choose a quadrature encoder, then this button will then show you 1X, 2X, or 4X, again, telling it how you want to count the edges of your quadrature encoder pulses.

At this point, it is up to you to configure your hardware the way you want. You choose which high-speed input pin(s) you want to use on your BRX PLC. Also, if your encoder is a quadrature (requiring at least two inputs), then you can choose that as well ("Quad Counter"). If you choose that, then you'll now have two inputs available to designate for wiring (Count A, and Count B). Also, you can hardwire a reset pulse by clicking "Enable Reset Input" and choosing an input on your BRX PLC. You can also enable scaling and have the count represented in scaled values instead of raw pulses by clicking the "Enable Scaling."

After setting up the hardware in this manner, you <OK> out of the dialogs and write the configuration down to the PLC.

When you program you ladders, you can reference the asynchronous counter using the name you have it as a structure that has individual members like:
  • $HsCtrTmr1.Acc (signed double-word) - the raw count
  • $HsCtrTmr1.ResetLevel (bit) - when ON holds the raw count at Reset Value, OFF lets it count
  • $HsCtrTmr1.ResetEdge (bit) - a transition to ON resets the raw count to the Reset Value (normally zero unless you told it otherwise).
  • ...etc.

Hope this gets you off to a good start. Feel free to ask questions here, or email me at support@hosteng.com
There are two types of people in the world; those that can extrapolate from incomplete data sets.

RaymondC

  • Full Member
  • ***
  • Posts: 27
Re: Getting started with an encoder
« Reply #2 on: February 04, 2021, 12:31:37 PM »
Thank you. Greg. This helps a lot.

Ray