Shop OBEX P1 Docs P2 Docs Learn Events
How to compare two sensors with one 0-5v vs 5v-0 — Parallax Forums

How to compare two sensors with one 0-5v vs 5v-0

Currently have a hydraulic height control thst uses 2 sensors. One on each end of a 20' header. The left sensor is 0-5v and the right sensor is reversed at 5v-0.
The left sensor controls a cylinder that tilts the header left/right.
The right sensor controls seperate cylinder that raises complete header up/down.
Wanting to change from on/off solenoids to proportional ones. Each valve has seperate coils for each movement....
Not sure how to make a variable scale with sensors going in opposite direction.

Comments

  • ElectrodudeElectrodude Posts: 1,660
    edited 2018-01-03 04:09
    Do you want to feed these signals to a microcontroller, or do you want an analog voltage representing the difference or something?

    You could flip the 5-0V sensor to 0-5V using an op amp in inverting mode with a bias. Or, you could just feed both to an A/D (e.g. MCP3208) connected to a Stamp or Propeller and do it in software.
  • Hi sport270

    What you've described is a form of closed-loop control system.

    https://en.wikipedia.org/wiki/Control_system

    Now is time for us to understand wich type of feedback you actualy have to control it.

    The first question that arises, is about the values you've used (0-5V; 5-0V) to describe the feedback.

    If the sensors does a suddenly switching, from 0 to 5V (or 5V to 0, in case of the other one). it means that they are digital in nature, as logic gates transitioning from "0" to "1", then from "1" to "0", in 5v powered cmos logic.

    With that kind of sensor, you can only sense two positions from each one; full stop upward/full stop downward at the lift sensor, full stop leftward/full stop rightward at the tilt sensor.

    If this is the case, and your intention is to have some means of knowing "where" the cilinders are positioned, at any given moment (or position, appart from their full stop positions), then you also need to change the sensors, so they can provide enough information to your control system, to improve in the decision taking process, and get full control of the operational parameters of your equipment.

    Henrique
  • Sensors are analog. Current span is .3v-2.8v
    Reason one is reversed is i used same sensor setup for both sides and when mirrored from left to right side it reverses the direction of the sensor. It will take me a little bit but I will draw out the current physical arraingment of sensor and control process, it will explain things better.
  • kwinnkwinn Posts: 8,697
    If we assume that the range of the two sensors are identical (which is not necessarily so) the math is simple. Sensor 1 at min reads 0.3v and at max 2.8v, for a range of 2.8 – 0.3 = 2.5v. The change from the zero position is Vin – Vmin.

    Lets assume Sensor 2 reads 4.5V at min and 2.0v at max, for a range of 2.0 – 4.5= - 2.5v. Since we are looking for the change from the zero position we can use Vmin – Vin rather than the above formula which would require either taking the absolute value of the result or multiplying it by -1.
  • sport270 wrote: »
    ... Current span is .3v-2.8v
    That would be voltage, not current.


Sign In or Register to comment.