Python Forum
Pulling an ADC value and using it - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pulling an ADC value and using it (/thread-1970.html)



Pulling an ADC value and using it - Raudert - Feb-07-2017

Hello, I am typing this from a cellphone so please bear with me. But my issue here is I am trying to read an ADC voltage value using an ADS1x15 ADC converter and then store the values as a variable in order to plug that value into an equation. An example script can be seen below:

ADC_Value = adc.read_adc_difference(0, gain=GAIN)
x_Input = (ADC_Value - 68)*(3/24432)
print(ADC_Value)
print(x_Input)

I am unsure as to what Im missing. I do not get any syntax errors only a value of 0 for my x_Input variable every time it prints. I am working on making a PLC to control an industrial fan and this is my first exposure to programming so please have mercy. 

Thank you,
The Hopeful Noob


RE: Pulling an ADC value and using it - mcmxl22 - Feb-07-2017

To help you we need more of the code. We need the code for
adc()
in
adc.read_adc_difference()
.


RE: Pulling an ADC value and using it - ichabod801 - Feb-07-2017

What version of Python are you using? If you're using 2.x, you need to change one of the values in your division to a float (add '.0' on the end).


RE: Pulling an ADC value and using it - Raudert - Feb-07-2017

That was it. How embarassing haha