Reading linear scales

I am pondering a project that would read two linear scales, do some processing on the results and send a single result as a standard distance output to a DRO display.

I assume I will need to read interrupts (2 each?) on both scale inputs. I am presently using Nano Everys, but can certainly change.

Also, can an Arduino send an appropriate linear scale data stream to a DRO ?

Sorry if this is not clear, but thanks.

Kevin

Oh? Why?

1 Like

What sort of scales? If you have picked some out, post links.

How and what about the scales would cause an interrupt?

Like these, or similar. Optical, 9-pin connector, etc. Just like I have on my lathe and mill.

VEVOR 1 Axis Lathe Linear Scale 150mm with Accuracy 0.0002 Inch Optical Length Precision Linear Scale Aluminum Body for Mill Milling Lathe Machine with Accessories | VEVOR US

For $40 you can buy a Wixey DRO with 5' of scales.


The initial links I've seen reading these used interrupts to read the outputs. If not necessary, great !

Thanks, but not what I'm looking for. I need to read data from two different scales, and send to an existing DRO.

ok, i looked at the link you provided, now, tell us what the DATA is you want to read and how do you intend to "read" it?

  • to aarg.

Are you reading analog volts on each device like from load cells?
From the AVR datasheets you find that when switching from analog pin to analog pin the single on-chip ADC has to clear before iy can get a good read so recommended practice is to read twice and only save the second. If you read that same pin again and again they're all good.
A 10 bit read takes aboy 105 microsecs, an 8 bit read takes less, link to a complete tutorial on AVR Analog Inputs.

You might get 4 or 5 good reads per ms while switching back and forth which is so slow in cpu terms (>3000 cycles per read) that polling is the better way to collect. During conversion the cpu goes quiet by default at least while sampling, that's from full datasheets.

If you are reading from sensors on a serial bus, you might use an interrupt but those have like 85 cycles overhead and text even at SPI speed is coarser than that.

OTOH have a look at the very cheap RPi Pico with dual core AMD 133Mhz MCU )3.3V easier-to-burn pins, runs about $5 ea.

You can make your own analog measures by seeing how many digital reads it takes to drain a piece of wire 1 microamp per read until the pin goes low (1.1V Ref on AVR). Reading the port PINx register takes 1 cycle but the 32 bit count++ and while loop take a few more but 50K reads/sec is in the park of possible, small values at low res can be determined to meet or exceed minimums very quickly.

What matters most are the requirements you need to meet. How to do it is second to that.

You could summarize that as, a possible reason for using interrupts is that you need them for hardware timed reads. I guess, for the usual reason which would be increased bandwidth and good real time performance. I just thought scales didn't sound like something that would need a high frequency response.

1 Like

A similar idea is sitting idle here.
Why don't You connnect those scales directly to the DRO? Wrong connector, wrong type of communication? Do they use 9 pin DSUBs?
My scales are different, magnetic, and Ebay no name and USB a, I guess the name is.

Re: connect direct to DRO. I need to process the output from the two scales first, then send a single result to a DRO.

I bit of a pipe dream, but a good challenge. :slight_smile:

Not sure, yet, if interrupts would be required. The scales have 0.0002" resolution, so a fast moving scale could generate a pretty fast pulse train.

Doing what?

Calling for interrupts is common among people not knowing much about that. For ignorant people the unknown is either the reason for failure or the miracle solution, and both are always wrong. Being a support guy for many years...

Pulse train?

0.0002" is 5/1000's of an inch. EDIT: Wrong! It is 1/5000"! 2 tenths of 1/1000!
If you would convert say 6 inches to mm's so close then use 25.4001 mm per inch. That works to .010" tolerances or did 40 years ago.
Oh but 2 tenths?

I see where interrupts might count, you HAVE to catch ALL the pulses, IF it works that way. Do you know that you can get a 133MHz dual-core AMD board for about $5 or could not long ago? Watch 2 slides with 2 threads on 1 set of pins and memory, programming choices include Arduino and micro-Python... the Raspberry Pi Pico.
Faster to insanely faster (600 MHz Teensy 4.1 last I looked) are options for data capture, the Teensy has an on-board micro-SD slot and a for-real FPU!

Adding them together, then display the sum

Or, more generally, doing a math operation on both values to display the results.

or one of TI's LaunchPad's boards, like Clough42 used for his electronic lead screw.

1 Like

???