..Is it correct that you're using the dark/light contrast to find the position of a boundary between dark and light parts of an image?

That's right.

Quote

How accurately can you position the sensor? Is it feasible to scan the sensor across the boundary? If so, I suspect you could get a much more precise position for the boundary by interpolating the position of the '50%' brightness point from a sequence of brightness readings in different positions rather than needing a single brightness reading to give you a hugely precise measurement of the proportion of dark/light areas within the image.

Unfortunately 'not really' possible given that a big problem would be the inertia in the hardware used to accomplish a scan. The material is moving at speeds of 20 fpm minimum (can be much faster) but in the direction that everything being equal (which of course cannot be so) will give a constant reading over the time taken to examine the analogue pin i.e. along the threshold of the two colours. Hence there is really just one shot possible and it has to be the best effort. In the current guise, a chart plots the result along the X axis as time passes.I hasten to add: I have lashed together a temporary complete system to test the reliability of using a moving target and the result is indistinguishable from a completely stationary image and so I have no worries with a moving target in principle. I should also mention: The duration that a consistent image will be available for under the sensor is as long as a piece of string in that it could start to be very different within say 1mm movement (prorata time elapsed and speed).

I don't know your setup that well but if you are using dividers or voltage references, think about what kind of resistors /Vref you will need in order to maintain the comparability of 16-bit adc from source to source.

dhenry, I'm slowly working out the route of least resistance (metaphorically) and going over something you said...

Would you be able to explain what your references above mean - thanks.

Is this worth considering or... From my point of view, I am aware that 2ms delay is suggested between analogue reads and then there is a 100µs or so required for an interrupt and would be grateful if you were able to comment.

Unfortunately I am very aware that the opportunity for oversampling is limited - in an earlier post I suggested that one shot is only possible, but needs must where the devil drives.

Here is the maths assuming a 0.5mm maximum permitted image travel 'window' (it is assumed that the image would not change shape beneath the sensor during this time):Minimum speed... 20 feet per min = 6096mm per minTime elapsed for 0.5mm travel... 4.92ms ±

Earlier I indicated that there would be 1mm of 'constant' image available and here I take 0.5mm to be the maximum. Fact is, it is as long as a bit of string in that sometimes 0.5mm might not be available and so I have to play devils advocate.

Another aspect that I am aware of is the permitted frequency of AD reads from this chip and wonder whether, given that there will be an interrupt overhead too (Arduino), and that it will then issue commands over the bus and that the I2C bus is not the fastest (V4 doesn't seem to be available on this chip), will this scupper it?

I am clearly looking at the minutiae, which is not always the best route, but please comment if you have a view.

For a 16-bit adc, the smallest difference it can detect is 1/2^16 = 0.0015% of Vref. For a Vref of 5v, that's about 75uv.

You will find that in an industrial environment, it is incredibly difficult to keep all kinds of disturbances to your circuit to be materially less than 75uv - typical smps has ripples of 10 - 100mv for example. You will also find that to make your software consistent from one build to another, your divider will have to be at least that accurate or you have to compensate for it in software.

What you are trying to achieve is very difficult from an engineering point of view.

It sounds as if, as well as being at the limit of how accurately it's feasible to measure an analog signal, you're also at the limit of how frequently you can take those measurements. This is not encouraging, and you may be constraining yourself into an intractable problem. I still feel that using a single brightness reading requires that reading to have unrealistically fine resolution and interpolating from multiple readings would enable you to get a better resolution.

One way to relax the precision requirements would be to reduce the size of the scanned area. That would mean you have even stricter requirements to get the scanner positioned in the right place and I don't know whether that's feasible.

Is it possible to give a more general explanation of what you're trying to achieve and what overall system this solution has to fit within? It may be possible to apply some lateral thinking, such as applying a vernier technique using multiple sensors, but without any idea what the thing is you're trying to measure the position of, it's hard to know where to start.

I only provide help via the forum - please do not contact me for private consultancy.

It sounds as if, as well as being at the limit of how accurately it's feasible to measure an analog signal, you're also at the limit of how frequently you can take those measurements. This is not encouraging, and you may be constraining yourself into an intractable problem. I still feel that using a single brightness reading requires that reading to have unrealistically fine resolution and interpolating from multiple readings would enable you to get a better resolution.

One way to relax the precision requirements would be to reduce the size of the scanned area. That would mean you have even stricter requirements to get the scanner positioned in the right place and I don't know whether that's feasible.

Is it possible to give a more general explanation of what you're trying to achieve and what overall system this solution has to fit within? It may be possible to apply some lateral thinking, such as applying a vernier technique using multiple sensors, but without any idea what the thing is you're trying to measure the position of, it's hard to know where to start.

As often is the case, this project is relative to how things are currently which is without any feedback or automatic control at all. It would be a shame for the final prognosis to be way under ambition but I don't expect that to happen...

The light 'spot' from these eyes looks something like 4mm x 1.2mm (fuzzy edges) and my experiments have placed the spot so that 4mm x 0.6mm is on one colour and 4mm x 0.6mm is on the other and a 0.5mm image movement would not in principle change this. Unfortunately, turning the sensor through 90 degrees would transform the available sampling 'window' but wouldn't be possible most of the time because the images will not always extend far enough, which is a prerequsite of a linear greyscale to position formula. Another unfortunate byproduct is a worse position resolution relative to greyscale (albeit potentially linear) for any image regardless (we can't win).

You mentioned the accuracy of sensor placement in an earlier post and I think it is worth mentioning that it is not important to put the sensor exactly half on half off the image and this is because only a 'piece of string' reference is required i.e. the inital value will become the 'ideal' and any wander is an error. Ultimately a mV:position ratio will be used to provide user friendly info and of course for any automatic correction (another project using steppers perhaps - I'm excited).

N.B. The current guise takes the first n readings and provides a plot of both extremes and the mean average over which the ADC output is ploted.

I am pleased to say that I have ordered the 1115 chip/breakout that Lefty suggested because I have to get my hands dirty with electronics per se and think it will be instructive to observe the outcome for our project using our hardware in our environment etc. I hasten to add, this project suits me down to the ground - I've always wanted to marry up programming and machinery and get into electronics proper. I'm trying to learn DesignSpark too (now V4) with varying success.

The only one I've had first hand experience with on a arduino is the TI ADS1115 16 bit 4 channel (or 2 differential channels). http://www.ebay.com/itm/4-Input-16-Bit-I2C-Analog-Digital-Breakout-Micro-Controllers-Arduino-/330761041957?pt=LH_DefaultDomain_0&hash=item4d02e4f825

I have a check out sketch code available if you actual try one of these out.