1
\$\begingroup\$

Can Altera GPIO pins read the analog output of a light sensor? The light sensor output is analog and I want the Altera to turn an LED on whenever the signal of the sensor is greater than some specific value.

Can I do that directly, or do I have to connect the output of the sensor to an ADC? How would I go about that?

\$\endgroup\$
  • \$\begingroup\$ Seems like it has audio and video inputs, but no general purpose A/D? You could probably use the microphone input to read the voltage, but you may need to scale it appropriately. You could also build a V/F converter and use the GPIO pin to measure the frequency. \$\endgroup\$ – John D Nov 25 '14 at 18:53
  • 1
    \$\begingroup\$ If you're going to that much trouble, you could just add a A/D \$\endgroup\$ – Scott Seidman Nov 25 '14 at 19:39
  • \$\begingroup\$ Use an A2D like the other guys said, or try this old 1 bit d2a approach. electronics.stackexchange.com/questions/59341/… \$\endgroup\$ – Some Hardware Guy Nov 25 '14 at 22:58
  • \$\begingroup\$ NO it is not, this question is more specific :) \$\endgroup\$ – MCubbed Nov 26 '14 at 15:43
2
\$\begingroup\$

If your Altera has LVDS inputs, you've got a fairly good comparator. It's possible to make a crude Sigma-Delta (or PWM) DAC and thus get a crude ADC. It's not going to be a very good ADC- noisy and the default reference is the crummy digital supply rails and range will be limited, but if all you need is a few bits it might work for you.

\$\endgroup\$
2
\$\begingroup\$

You can use the LVDS as an analog comparator, simply by connecting positive pin to your "specific voltage value" which has to be less than 2.5 V and the negative pin to your sensor.

\$\endgroup\$
1
\$\begingroup\$

No you can't sample analog values with digital inputs.

You can either connect an ADC, and to do that you will have to refer to the datasheet of your chosen ADC, or use a comparator to compare the incoming voltage with a reference voltage, and output a digital HIGH / LOW signal which a digital pin can read.

\$\endgroup\$
1
\$\begingroup\$

As the current answers reflect, no, you can't do this directly: you need to implement an ADC that can convert the analog level from the sensor to a digital value that can be read by the digital input pins of the Altera.

However, if turning an LED on if the sensor has a value higher than some threshold is really the only thing you need to do, there's a much easier way: with a comparator. That's a circuit with two inputs A and B, which outputs a high signal when A > B and a low signal otherwise (it's a bit simplified, but that's basically it). You can then connect the output of that comparator circuit to your LED.

If you google "op-amp comparator circuit" you will find some nice circuits that can do what you want.

\$\endgroup\$
0
\$\begingroup\$

No, the GPIO pins are digital. There are no onboard ADCs in the Cyclone IV series.

\$\endgroup\$
  • \$\begingroup\$ Actually, many of these can be operated as differential pair comparators and used to build an ADC. \$\endgroup\$ – Chris Stratton Nov 26 '14 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.