getting position of mixing valve lever

Hi,

i have a mixing valve (hope you call it like this in english) with a lever.
The lever moves from left to right and vice versa.
The valve is driven by a 230V motor.

I need some ideas how i can log the leaver position.
Is there some tension sensor or something like this out there?

I attached some pictures.

I need some ideas how i can log the leaver position.

To what level of accuracy? Perhaps a collection of mini lasers and LDRs that get interrupted as the level moves. Or one laser and a series of LDRs in a ring around the lever.

What is the range of motion of the lever? Would a ultrasonic sensor give you enough accuracy?

Can you modify the level in any way? Like adding a linkage that turned a potentiometer?

From left to right its 170mm (6.7in).
So 20 LDRs every 8.5mm (0.35in) would give me 0%, 5%, 10%...

I also thought about ultrasonic on the side of the lever. But at 0% and 100% the lever is tilted.
So i have no idea how to do it.

The linkage/potentiometer solution would be very precious. But where to mount the potentiometer
and also there is the tilt problem.

So looks like a infrared LED/laser on the lever and a semicircle with LDRs in front is the easiest way.
Maybe i can count in 2,5% steps - the positions when the laser is between two LDRs?

Some tips on laser and LDRs?

I would use a rotary potentiometer with a lever the same length as the lever on the valve, positioned so they are parallel and in the same plane, and just connect the ends with a pushrod linkage. Use a potentiometer designed to be panel mounted, and stick a flat sheet to the back of the valve assembly to give you something to mount it on. That should be a ten minute job with parts costing about a quid.

(Or you could go with the laser range finder and so on - that sounds like a lot more fun but might end up costing a little more!)

A hole in the top of the valve lever and a servo linkage would not be a problem.
But what to use as lever on the potentiometer, hm?

What would be the best value for the potentiometer - 10K ?

MrGlasspoole:
But what to use as lever on the potentiometer, hm?

Surely you're joking?

MrGlasspoole:
What would be the best value for the potentiometer - 10K ?

Yes, that would be fine.

I'm not joking. Never so a lever on a poti - only knobs.
I mean are there some to buy?

If not need some aluminum square and need to make a thread from the side for a screw.

Check out one of the sites that has servos and servo accessories: http://www.servocity.com

They might have the parts you need to adapt a potentiometer.

Ok, sometimes I think to complicated.
It's a lot easier. There is a shaft inside until the cover.
On that shaft is a disc and this disc is just pinned. You can see the
disc in the image. The blue one with the red that is there to show
the heat. So i just need to drill a hole in the cover, remove the disc
and couple the potentiometer with a shaft coupling: ACHSKUPPLUNG 2: Achskupplung für Potentiometerachsen, gold bei reichelt elektronik
I make pictures when it's done.

But how is the calculation done.
It just turns 90°. So i think i need to open and close my valve and need to check the digital value (max and min) and at them to
the code.This is what i have for the hole range:

int valvePin = A0;
int valveValue = 0;
int valvePercentage = 0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  valveValue = analogRead(valvePin);
  float voltage = valveValue * (5.0 / 1023.0);
  valvePercentage = valveValue / 10 / 1.02;

  // now print it

  Serial.print("percentage: "); Serial.print(valvePercentage);
  Serial.print(", volts: "); Serial.println(voltage);
  delay(1);
}

But how do i set 400-800 as 100 percentage range?

But how do i set 400-800 as 100 percentage range?

When it is built and you know the analogRead values for both extents of the levers movement then program them into a map() function http://arduino.cc/en/Reference/Map

Ah map is the thing to look for.
So i also need no calculation.
And constrain that i don't get minus values or more the 100.

void loop() {
  valveValue = analogRead(valvePin);
  valveInDig = valveValue;
  valveRange = map(valveValue, 400, 800, 0, 100);
  valvePercentage = constrain(valveRange, 0, 100);
  float voltage = valveValue * (5.0 / 1023.0);

  // now print it
  Serial.print("Dig: "); Serial.print(valveInDig);
  Serial.print(", Range: "); Serial.print(valveRange);
  Serial.print(", Percentage: "); Serial.print(valvePercentage);
  Serial.print(", Volts: "); Serial.println(voltage);
  delay(1);
}

But now i start to think about the potentiometer and resolution if i have only a 90° range.
I also want to log the data to SD. But only if there is change that it's not to much data.
So it don't need to be sensitive and that there is not a change just from vibration. I think
logging 5% steps is enough. It's a mechanical valve from the 80s so anyways it's not the
most exact device in the world :slight_smile:

I think your better to constrain the value from AnalogeRead before mapping. If data going into map is within range then you should always get the desired result.

Hi-de-ho, neighbor.
Home improved and tested and works:

valveRange = constrain(valveValue, 400, 800);
valvePercentage = map(valveRange, 400, 800, 0, 100);