Test bench for measuring timing belts lenghts

Showcase your projects! We love to see what people come up with, so please share your creations here.
Post Reply
cacycleworks
Posts: 19
Joined: Sat Jul 06, 2013 9:05 am

Test bench for measuring timing belts lenghts

Post by cacycleworks » Mon Jul 15, 2013 11:51 pm

My business sells aftermarket components for Ducati motorcycles and I always strive for the best quality possible. With the timing belts being such a critical component, I wanted a way to accurately measure their length, which became a long and entertaining process in understanding the fundamentals.

The finished product:
tb_meas_bench_final_1024x465.jpg
And its display:
tb_meas_bench_screen.jpg
The sliding block is attached to the CNC/DRO glass scale with 1 micron resolution. Life might have been simpler if I just settled on the 5 micron resolution scale, but we always want the best, yes? After 4 or 5 attempts at reading the quadrature output from the scale directly with my Arduino, I ended up with the best (or 2nd best) possible option, the LS7166 Quadrature Counter IC, which is also possible the most complicated IC to set up. These folks' notes helped me find out I could skip some steps setting up and that a couple inputs shown as optional required setting to +5V or GND. This still wouldn't have been possible without an o'scope to help!

I used the single trigger mode to capture all the signals using D7 as the trigger. It happened only once and consistently when I ran my init_7166() function.
D6.jpg

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Test bench for measuring timing belts lenghts

Post by andrew » Tue Jul 16, 2013 8:48 am

Well done - it's always interesting to see real-world applications :)

cacycleworks
Posts: 19
Joined: Sat Jul 06, 2013 9:05 am

Re: Test bench for measuring timing belts lenghts

Post by cacycleworks » Wed Jul 17, 2013 12:14 am

Ahhhhh, but there's more!! I was cut off from needing moderator approval. :D :oops:

Then I compiled a master timing sheet for the initializing of the 7166, which by the way is not correct final desired result. Once I got it working, I didn't repeat the misery of setting this up:
7166_ctrl_sm.jpg
Ultimately, the bottom two data lines, D1 and D0, should stay at a steady value until transitioning to something else. So D0 should start off HI, switch to LO right away and then on the 6th and 7th purple dividers later, switch to HI. And so on. I played with this in photoshop until the background was white and the waveforms would show up on the printer. Printed it, made notes and adjustments, then got it to read values from the glass scale.

With careful measuring, I was able to determine the minimum center-to-center ( c-2-c ) length of the sprockets on the bench. Of course, the best hand tools can only guess to about a 20th of a mm (or 50 microns). But after measuring it a dozen or so times and different ways, I came up with 8.616", so went with that.

At about the same time the LI7166 came in, I also got in the Freetronics Eleven, an Arduino Uno compatible clone that has a prototyping area on it, which is where I mounted the 7166 in a socket. BTW, the guy at Freetronics is about as crazy for quality as I am. His boards have gold plated pads so people like me can solder on it reliably! Boards with tin traces can have the trace accidentally lifted off and removed if not careful enough. BTDT.

7166 mounted in the Arduino Eleven with my crazy wiring:
food_box_1.jpg
Wiring diagram for the setup: (note that the chip is mounted to the bottom of the Arduino Eleven so pin locations are flipped on the Arduino diagram)
tb_meas_bench_LS7166_bb.png
The big breakthrough was Friday night, when I tied pins 3 and 4 to +5 and ground. I reset it, moved the block, and it started measuring shorter distances. So I swapped the A and B inputs from the encoder, the yellow and green wires going to pins 6 and 7 of the LS7166.

To help model the bench, I made CAD drawings of the acrylic food box, the Freetronics eleven, and the Adafruit 1.8" TFT shield.

The sketch code for the Arduino is here. It's all open source, so now you can make one, too!   :mrgreen:

cacycleworks
Posts: 19
Joined: Sat Jul 06, 2013 9:05 am

Re: Test bench for measuring timing belts lenghts

Post by cacycleworks » Wed Jul 17, 2013 12:23 am

The work leading up to the finished product:

Keen observers will notice in the CAD drawing of the Freetronics eleven that it is shown with a HCTL-2000 quadrature decoder & counter chip used. And the required wiring even looks pretty. The HCTL-2000 has a 12 bit counter, so the number of microns in the scale's 6+ inches of travel exceeds 12 bits. So I ordered in more ICs from the HCTL family, the 2016 and the 2020.

Well, see they have this pin labeled "CLK". That means clock. I was already looking at having to use an IC because the Arduino all by itself couldn't read the quadrature signals fast enough!! Initially, I set the Arduino to trigger an interrupt on CH A "falling" of the glass scale. Then if CH B is 1, the scale just moved a micron one way. If it's 0, the scale moved a micron the other way. Technically, only reading on CH A falling means I get an interrupt every 4th micron... There's lots of discussion on the intarwebs when it comes to Arduinos and quadrature decoding, sadly all of it to do with reading the output from CNC motors to keep track of position.

I quickly found the scale could be moved fast enough that the Arduino would skip some of the instances of CH A falling!! Grrrr. People said on the internet that the Arduino's interrupt would only take about 5 microseconds.

Out comes the oscilloscope (o'scope):
quad_a_leads_b_to_left_1024.jpg
What you can't see is that I was barely moving the sliding block to the left! And the scope is set to 1 milisecond per division, so that's about 1000 microseconds per trigger. When I move it faster but not trying to go really fast, I can tell it gets down to 5 microseconds pretty handily.

So what's next? The Arduino can't hang with reading the quadrature input directly. I read on the intarwebs that one can use a pair of D flip-flops to read the encoder, which then just sends UP or DOWN outputs to the Arduino. Sweet! I know I've got some 7474 ICs left from when I was a BSEE student... Yep, wasn't too hard to wire up on the breadboard and hook it up. MUCH better performance. I was almost convinced... until one time releasing the springs testing a belt, the block moved super-quickly. Sure enough, the readout was about 0.004" wrong. It managed to skip about 100 down pulses from the D-FF.

I Google, read intarwebs, and find out about the HCTL family of quadrature decoder and counter ICs!! Nice, there I go!! I get in a HCTL-2000 from Amazon or eBay and start setting it up. Oh, yeah, here's where we started this crap out... the CLOCK. Effing clock. So I work on getting the Arduino to output a clock from one of the few remaining pins on the poor damn thing. Turns out data pin 9 is connected to one of the onboard timers AND is also unused in my design! Sweet. Google, read, interwebs, blah blah. I can set up a timer that uses interrupts and route it to pin 9. I get that going, upload the code.... wait.... oh, this is too slow.... I watch the screen draw at like 10 pixels a second. The poor Arduino is fully taxed trying to run a 1 MHz clock.

Google, read, interwebs, blah blah, you can route the Arduino's onboard 16 MHz crystal to a pin but that requires burning new firmware into the processor, could ruin it, blah blah, need a FTDI blah blah. Open the data sheet for the HCTL family again. Oh, it only wants 14MHz. So that won't work.

The BSEE part of my brain was starting to come back to life and I knew we used 555 timer ICs for clocks. Thing is, they're only good to somewhere south of 1MHz... and 1MHz corresponds to a period of 1 microsecond. That's cutting it close! I tweak this 555 timer to very reliably get near 500kHz, or a 2 microsecond period. That took a whole day. And that is about the time that I realized I was going to need a better IC because the HCTL-2000's 12 bits weren't enough. Google, read, interwebs, blah blah, and I see that I can probably get a crystal of my own and then use a D-FF to step down its speed to clock the HCTL. Now I've got 3 components to add to the breadboard.

That was when "Google, read, interwebs, blah blah" showed me the LSI corp LS7166. Datasheet comes up and hmmmm, no clock input?! Sweet! Because it is asynchronous, it is autonomous and can just sit there counting. Hmmm, 20 pins. 6 control pins(!) wth, I don't have that many outputs available. 8 data pins, Ah, ok 2 control pins, phew!

"So Chris, why didn't you just use Calipers like everyone else on the intarweebs?"

Well, actually, that's where I started:
tb_test_bench_proto_assembled.jpg
Shown is a 21 bit "Chinese scale" that needs a 9kHz clock of 21 pulses and replies with a binary number. This actually worked really well. Only over about 10 minutes of reading belts, it would develop an error of 0.001" to 0.002". Continued use continued the error growth. Because these are capacitive, they're not 100% positionally accurate. It's just like the cheapy DRO readout on my lathe. I always measure, double check, and reset the numbers before a final cut. Or it'll be a little bit off.

What about the DRO on my vertical milling machine... the Mitotoyo DRO is like forever accurate. Google, read interwebs, blah blah. That's called a glass scale...

cacycleworks
Posts: 19
Joined: Sat Jul 06, 2013 9:05 am

Re: Test bench for measuring timing belts lenghts

Post by cacycleworks » Wed Jul 17, 2013 11:05 pm

Andrew, if you're still reading, I notice that when I power up my eleven, a reset is always required. And then it is 6 seconds before the shield runs setup(). What am I doing wrong? :)

Thanks,
Chris

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Test bench for measuring timing belts lenghts

Post by andrew » Tue Jul 23, 2013 7:53 am

Reset then six seconds? That's odd.
Can you check ifthe Eleven is getting 5V from power on, and that whatever is connected to the 5V pins isn't pulling more than say 200 mA?

cacycleworks
Posts: 19
Joined: Sat Jul 06, 2013 9:05 am

Re: Test bench for measuring timing belts lenghts

Post by cacycleworks » Wed Jul 24, 2013 10:21 pm

I am powering the DRO glass scale and the LS7166 IC. The behavior is the same if I plug in 12V 1A or run from the wall wart 5V 1A into the USB. (I mention all this in case it makes a difference) We'll see the next time I mess with it if I can try pulling the socket on the IC and/or disconnecting the DRO scale to check for differences in 1st time power on...

Thanks,
Chris

harry56
Posts: 4
Joined: Tue Jul 11, 2017 10:50 am

Re: Test bench for measuring timing belts lenghts

Post by harry56 » Wed Jul 12, 2017 3:34 am



Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests