Hi, I am trying to convert analog signal to digital before it is read by Arduino. There are external ADCs but I think what I am asking is different. This is for a standard arduino joystick and just trying to translate the pot output to up/down/left/right (basically, for it to function like 4 separate on-off buttons).
no SPI/serial input (already have plenty of devices on serial and it's slow)
Just need to read when HIGH or LOW. So, from the joystick:
---send signal to pin1 when F-B reading >3.5v (can be 4, doesn't matter, whenever the joystick is pushed all the way up)
---send signal to pin 2 when F-B reading <1.5v
---send signal to pin 3 when L-R reading >3.5
---send signal to pin 4 when L-R reading <1.5v
is there an off-the-shelf solution for this? Or what is the best way to implement this?
I tried bunch of 74 series chips and can easily capture when potentiometer is either low or when high (translate into digital) separately. But, once I try to capture both high and low, it doesn't work: I try to connect the joystick (potentiometer) output to two pins of 74 chips and, while they work one at a time, together, one of them is always on when two IC pins are connected to the same potentiomenter. Tried using pull-up/pull-down resistors, diodes, etc. to no avail.
A [u]comparator[/u] puts-out logic-high when the input is above the reference voltage and logic-low when the input is below the reference. (Or the logic can be reversed by reversing the inputs.) An op-amp can be used as a comparator.
Ron_Blain:
You may want to give this a read. It explains pretty much what you are asking.
Ron
Thank you, Ron. Yes, I can do this inside arduino but I was looking for a way to make this digital input before signal goes into arduino (not to use analog pins at all). Hopefully, I didn't miss anything in the link you shared.
I am looking at the comparators/voltage dividers (from DVDdoug response) now to see how to make this work.
mvoltin:
Thank you, Ron. Yes, I can do this inside arduino but I was looking for a way to make this digital input before signal goes into arduino (not to use analog pins at all). Hopefully, I didn't miss anything in the link you shared.
I am looking at the comparators/voltage dividers (from DVDdoug response) now to see how to make this work.
Then I would look at comparator circuits. A chip like the LM339, LM239, or LM139 will give you 4, 2, or a single comparator on a single chip.
I have also seen the chip or similar offered on ready to go small module boards. Normally with 5.0 volts applied and the joystick centered each axis (X, Y) will have 2.5 volts out. Using 4 comparators like a LM 339 you could look at both X & Y axis and run your comparators out to a few gates.
Well no, many opamps cannot be used as comparators. Best to use a comparator as a comparator.
Among the many issues trying to use opamps as comparators are:
Many opamps are fried or degrade if the two inputs are forced more than 0.6V apart.
Opamp rail voltages can be outside the 0..5V range needed for logic signals and thus need level-conversion on the output.
Many opamps cannot drive the output high enough to register at logic HIGH if powered from +5V.
Many opamps slew too slowly to guarantee a single edged logic transition, leading to multiple interrupts.
Opamps consume more power than comparators.
Opamps can't be wired-AND'd as the outputs are not open-collector.
LM339's are very cheap, quad comparators which will work for most purposes.
Even opamps that can handle the inputs at widely different voltages typically pull significant currents through
those inputs - a real problem if trying to share a reference voltage between several devices. Opamps are not
designed for anything but negative feedback.
This is for a standard arduino joystick and just trying to translate the pot output to up/down/left/right (basically, for it to function like 4 separate on-off buttons).
Well this is what we actually have, this is what it looks like.
With that in mind every place we see 1023 it's 5.0 volts and every 512 is actually 2.5 volts. A window comparator circuit will respond to an output within a range (window).
Using 3 resistors in series we could set the reference points for a window, for example:
Using OUT_1 and OUT_2 my window would be between 1.667 volts and 3.334 volts. I could use those levels to set an upper and lower limit for my window. That does not exclude my need for a comparator. All of this is easier done in the uC rather than using discreet components to get my analog levels to digital prior to my uC. I guess it depends on what is practical and why.