The lost Optical Encoder Demo Box
January 20, 2016
We recently teamed up with one of our distributors to create a Demo box that showcased our QD145 optical encoder with a Delta Tau PLC and touchscreen panel. It was sent off to a trade show where potential customers would get to spin the encoder and watch on the screen as counts were incremented and decremented and needles on dials spun.
I thought the Optical Encoder Demo box would make for a fantastic topic to write a post on, so that was my plan as soon as the demo box returned from the show.
Well… it never did come back. I would love to tell you that I did such a great job on it that our distributor insisted on keeping it but the truth of the matter is that it was lost in shipping.
What I do have is the code and screenshot of the Optical Encoder Demo box, which should be more than enough to explain the functionality. What I don’t have are pictures, or video of the Optical Encoder Demo box in action, so you will have to use a little imagination on your part.
I mounted the PLC, HMI and encoder to an enclosure that can set on a table. The default screen (shown above) tells a little about the encoder. From this screen you can select a few different screens that allow you to interact with the encoder.
This screen shows Pulse Count, Angle, RPM and direction.
This screen shows mechanical degrees. The needle rotates in conjunction with encoder rotation:
This screen shows the direct read count of the encoder, the needle rotates in conjunction with encoder rotation:
This is sort of a fun screen where rotation the encoder fills tanks in sequence, tank one fills, when tank one is full it “empties” into tank 2, when tank 2 is full it “empties” into tank 3. Tank 3 continues to accumulate until 2 billion counts or so. The Drain button clears the levels on all of the tanks.
This screen indicates status of inputs coming from the encoder. Since I used a 5000 LC encoder, the screen was not be able to keep up real time when the encoder was rotated really fast, and it was nearly impossible to land on Z(Index) and have it light.
The Delta Tau was pretty easy to program, with only a couple hiccups. The manual was a little vague in its explanation of the way two registers were used for some of the counter functions, but a little troubleshooting showed me which bits were activated when the counter set point was hit.
The Ladder Logic
This first rung of code is needed to do some basic housekeeping to ensure that D1022 is properly configured with a “1” on the first program scan. It is set by M1002 and forever latched by M110. The value of 1 tells the high speed input that we want a double frequency selection A/B phase counter.
The second rung sets up our high speed counter and checks the count to see if we have gone negative in value. If so, bit M120 is set high.
Rung three turns on a physical output Y11 if the counter set point has been hit.
Rung four moves the set point of 5000 back into the counter if we have gone negative in value. This allows the needles on our display screens to rotate continuously and not peg out to a high or low value.
Rung five updates Register D300 with our counter value every 10mS via the handy M1011 10 mS clock pulse.
Rung six divides the counter value by 16 and moves the answer into Register D302. This is where we start our math for the degree conversion. The rest is scaled by the configuring the screen register in the screen editor software.
Run seven uses the trailing edge of our 10 mS clock pulse to move the counter value into register D310. This value is held for comparison in time to get RPM.
Rung eight uses the leading edge of our 10mS clock pulse to find the difference in our stored value and put it out to register D312. D312 is then doubled and sent out to register D350.
For any of you interested in repeating the project, I have included the BOM below.
Of course, I also used some miscellaneous wire and hardware to construct the Optical Encoder Demo box, but the list below includes all the big ticket items.
QD145-5/26-5000-0-02-T1-01-02 Optical Encoder
DOP-AS35THTD 3.5” Color touch screen
DVP12C11T Micro programmable Logic controller 8 inputs 4 High Speed outputs
DRP024V060W1AZ CliQ 24 Vdc, 60 Watt power supply
DVPACAB2A30 3 Meter connection cable
From Automation Direct:
DN-R35S1 Din Rail 35mm X7.5mm
WC12C12 N12 Desktop enclosure 12”X12”X9”
DN-T12A Terminal Blocks
DN-EB35MN End Brackets
DN-LAB terminal block labels