adccommunitymod (AutomationDirect) asked a question.

Math is fuzzy on a DL06 project, help!?!

Created Date: November 03,2014

Created By: jonesjeremya

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

Hi All. problems....:confused: I am working on a DL06 project, HSIO 500 pulse absolute encoder on x0 and x1. Currently my logic seems to work fine, with the exception of the math. Surely I'm just doing something wrong. So, my pulses come in and I keep track of them in CT174 which is a double word BCD. So, 1 revolution CW...bam 500 pulses. 1 rev CCW back to 0, & so on. My trouble is in the match instructions. I want to take my raw pulses and convert them into real numbers, and human measurement. 1 real number will be the scaled millimeter measurement that represents the pulses, the other is the real number is the same measurement but in inch measurement. However, using the Iboxes in my picture, I have an odd problem. My millimeter measurement seems to be acceptable, it rounds to the .05mm which is OK because my resolution is to be .1mm anyway. But when it comes to my inch measurement scaling, the best resolution I can achieve is about .125 ". I can turn the encoder, see each individual pulse, see the "scaled millimeter " measurement changing at an acceptable resolution, but I can only get my "scaled inch " measurement to increase or decrease by .125 increments. I just can't figure it out. I can take the same numbers, mathematical expression and plug them into an Excel sheet and the math comes out spot on. What am I doing wrong here? I sure appreciate any help!


  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: Shimmy

    Have you tried doing the inch conversion to V400 (V400/R351.524824)?

  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: jonesjeremya

    Have you tried doing the inch conversion to V400 (V400/R351.524824)?

    MANY thanks for the suggestion!

    I gave it a go and it gets my inch resolution down to .0078 "

    I was hoping for .004 resolution or better, but I guess this is the limitation of the encoder PPR I chose for this application? I'm still a little foggy as to what is going on with the calculation behind the scenes. My only guess is that it's because I am using a 500 pulse encoder and it's forced to round up or down in order to reach a whole number?. I assume that a 1000 PPR encoder would put me at .0039 resolution?

    Thanks again for the help, VERY MUCH appreciated!

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: bcarlton

    Can you provide the millimeter and inch results from a series of adjacent pulse counts - e.g. 250, 251, 252 ?

    Assuming your measurement is correct - 1 revolution = 36.12 mm - that should have been 1.422 inches. Divided by the 500 encoder count should have been approx .00284 inches per pulse. It would be interesting to see what you actually get.

  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: jonesjeremya

    Well, I thought I was moving on....not so fast.

    So at a very low # of pulses I seem to have a resolution of about .004, but as I turn the encoder to generate pulses that would equal about 60 " of travel suddenly I only have resolution of about .500, the higher # of pulses, the worse the resolution gets.

    For what it's worth, I still have the same resolution on my "millimeter " register.

    I am lost as to why this is happening on the second register? All I need is a total of 6 digits for the HMI, XXX.XXX "

    Perplexed!

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: bcarlton

    Be sure not to overrun the 7 kHz limitation on the inputs.

    But if the millimeter count is correct then the inch count should also.

    How are you determining the resolution problem? Do you stop at some point and the two don't match?

    Are you possibly looking at the results on successive scans of the program? The counter can count faster than the program can execute. A succeeding scan could happen after many pulses have passed depending on the input speed.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: Shimmy

    You should also check your setup. I'm not sure what the HSIO 500 encoder is but I am assuming it is a quad encoder. If so you may want to use mode 20 with quad 4x counting enabled. This should help your resolution (assuming you aren't exceeding the 7k bandwidth of the high speed inputs). If you aren't familiar with quad counting you essentially get 4 counts per pulse instead of just 1. Here is a link to the appendix for the 06 PLC for setting up the mode. Go to page 24 for mode 20.

    http://www.automationdirect.com/static/manuals/d006userm/appxe.pdf

    If it is not a quad encoder use mode 10. I'm curious what happens in mode 10 if you enable 4x counting. You may get double the resolution.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: bcarlton

    If you need faster response to a given measurement/count use the 24 available presets and immediate I/O instructions in interrupts.

    If you need yet faster response try the CTRIO module. It has a 100 kHz limitation and has triggerable outputs.

  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: jonesjeremya

    Thanks guys, here are the answers/responses:

    I have attached a screenshots of encoder pulse at 500, 501, 502. It's WAY off at 20000. I'm most confused by

  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: jonesjeremya

    Thanks guys, here are the answers/responses:

    I have attached screenshots of encoder pulse at 500, 501....It's way off at 20000. I'm most confused by the fact that my "millimeter " register remains accurate and doesn't get all goofy with the higher count.

    I can't imagine why the "inch " register won't calculate properly. I think my math is close. Again, I can take the same expression to Excel and it's correct.

    This is on a bench before mounting on the machine. I'm not getting confused by any real measurements, speeds, etc. I am turning the encoder slowly by hand and the counter which keeps up with the count shows 500 pulses for each full rev CW, and decreases by the same amount when turned CCW.

    I am using both channels A/B of an absolute encoder so I get bidirectional counting which is required. I am set at mode 20. I am looking at still data while monitoring the calculation of my last hand movement of the encoder shaft

    The math just doesn't add up :/

    Thanks for the help!!

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: November 03,2014

    Created by: bcarlton

    You might want to get in touch with technical support directly. I'm suspecting that the difference between what you see on your desktop and from the PLC is the difference in floating point types. The PLC uses 32 bit floating point while your desktop may use up to 128 bit floating point.

    Or I could be totally wrong ...

10 of 15