LED Sequential Array based on Analog/Digital Input - Beginner Knowledge Level

Discussion in 'The Projects Forum' started by razor367, Sep 12, 2016.

  1. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    I have solid soldering/wiring skills, however I need expert input on how to go about this project.

    Long story short, I need to construct a circuit which will light a series of LEDs based on the input voltage received from an ultrasonic or RF sensor. Ideally, one LED would turn off once the criteria for the next LED is met. There are a total of 4 LEDs.

    It seems that using a microcontroller would be the best option for changing the continuous analog signal voltage into a discrete digital signal. This would require programming, but if it is the best design practice, I can learn. To this end, I have identified potential candidates (Microchip PG164130 In-circuit debugger and Microchip PIC18F13K22 microcontroller, MB1240 Ultrasonic rangefinder). I would pair this with 4VDC LEDs and a VDC power supply for tabletop testing with a bread board.

    Any ideas? Am I making this too complex/simple? Please ask for more detail/clarification, if needed.
     
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,797
    1,103
    For the display control, consider using an LM3914. This analogue IC will light up to 10 LEDs in turn as its input voltage increases between definable limits.
     
  3. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    Regarding LM3914, would this be programmable with the PG164130? What would be best for programming this particular component?
     
  4. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    It's not programmable, it's normally hardwired.
    You use the components as listed in the data sheet to get the operating range and characteristics you want.
    If you give us more specifics about the criteria for each LED to light, we can help you with that.

    To convert the AC to the required DC for the LM3914, you can use a Schottky rectifier circuit.
     
  5. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    Each LED should fire based on a defined voltage range received from the sensor. The voltage output of the sensor is 0-3.5VDC. I have to play with the circuit in application to define those ranges, but I can rough in cutoff values (0V-1V, 1.1V-1.75V, 1.85V-2.75V, 2.85V-3.5V).
     
  6. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,797
    1,103
    Your ranges are discontinuous. If that is essential, then the LM3914 would not be suitable. For the LM3914 there is a small overlap between adjacent ranges.
     
  7. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    Your range values means all the LEDs would be ON (or OFF) at the small voltage gap between them.
    Is that what you want?
    If not then there's needs to be a slight overlap between the ranges.
    Since the LM3914 has equal spacing for the voltage levels, you can't use that for your unequal steps.

    For that you could use a quad comparator chip such as the LM339 with the CD40147 priority encoder to make a 4 level window comparator.
    You connect the 4 comparator outputs to inputs 1, 2, 4, and 8 of the CD40147.
    That will generate 4 outputs where the highest input voltage generates a unique encoder output high to turn OFF (or ON as desired) one of the four LEDs.
     
  8. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    The gaps are not necessary. An LED needs to fire once a threshold is reached, then de-energize when that range is exceeded, thereby firing the next LED in the sequence (the next voltage range up).

    However, I don't believe the output of the sensor is a linear response, so I would need a setup that would allow for unequal voltage range definition.
     
  9. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    What supply voltages do you have available?
     
  10. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    I have a VDC power supply up to 30V. In application, I would have up to 48VDC.
     
  11. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    You can do the ADC and a bunch of programming or you can do this in analog with an enlarged (4 stage) window comparator. In the analog design the trigger voltages are set with resistors, or variable resistors. The easiest way is to set it up as a bar graph, but the lower voltage LEDs can be suppressed with appropriate circuitry. You are better off to characterize the sensor and then calculate the resistors than putting in 4 potentiometers and adjusting for a while.

    Oh wait...crutschow already said that.
    Never mind.:oops:
     
  12. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    Yes, if I could keep programming out of the loop, the project would move much more quickly. I can calculate the resistance needed at each window easily enough.

    I notice there is a CD40147BE and CD40147BEE4. Looking at a the datasheet, I am not able to discern the difference. Is there a significance for this application?
     
  13. #12

    Expert

    Nov 30, 2010
    16,284
    6,797
    The suffixes are usually about what kind of package the chip is in...plastic, metal can, ceramic, etc.
     
  14. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    So continuing to pretend that I know only the rudiments of circuit design... Can someone explain more about suppressing the lower voltage LEDs?
     
  15. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    The comparators' outputs are set to go low at or above each set point.
    Each comparator output is connected to the 1, 2, 4, 8 respective inputs of the priority encoder (lowest voltage to 1, etc).
    (All other encoder inputs are tied high).
    The priority encoder will then generate one low output for the highest voltage comparator low output with all the other encoder outputs being high
    If you look at the truth table in this data sheet you will see how that works. (Note that the device has negative logic. i.e. a 0 is a high level and a 1 is a low level).

    Edit: Actually since your first range starts out from 0V you only need three comparators, set to trip at 1V, 1.85V, and 2.85V (or do you want something to happen above 3.5V?).
    The 1 input on the priority encoder when then just be tied to low.
     
    Last edited: Sep 13, 2016
  16. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    I am waiting on the sensor to arrive to characterize the behavior. For worst case, let's assume that the sensor is never idle (no output of 0VDC, floor of something like 0.1VDC).

    Thinking ahead, is there a way to "stabilize" the voltage output of the sensor (if the output flutters between a narrow voltage range wither due to design or environmental conditions)?

    This seems to be coalescing in my mind, thanks largely to the input from all of you here!
     
  17. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    Normally you add some hysteresis to the comparator operation so that is doesn't jitter at its set point..
    That takes care of any small noise the signal may have.
     
  18. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    Just a double check on the circuit build. This is what I have on the breadboard. I am characterizing the sensor and will change out the fixed value resistors based on the sensor curve. Have I built the wiring correctly to perform as described?
    Untitled.png
     
  19. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    When I said connect to inputs 1, 2, 4 and 8 on the CD40147, I meant the data inputs, not the physical pin numbers.
    You need to look at the data sheet for that.
    For example input 1 is pin 11, thus IC1-13 goes to IC2-11 (IC2 being the CD40147)

    It looks like you also have the Sensor GND as driving the comparators.

    All the comparator outputs need a 10kΩ pullup resistor to +5V.

    Those resistor values will give even valued steps, which is not what you stated you wanted.
    For that you likely want a separate pot and resistor for each comparator

    Also, as I noted in my edit in post #15, you only need to use three comparators, not four, for your voltage ranges.
     
  20. razor367

    Thread Starter New Member

    Sep 12, 2016
    26
    0
    I have a question regarding the -Vin to the comparators. The sensor has 5V input, GND, and Vout (sensing signal) terminals. What should the -Vin be connected to if not the sensor GND (this would be tied to the breadboard GND)?
     
Loading...