Go Down

Topic: URGENT! Bizarre Analog Read Bug?? (Read 745 times) previous topic - next topic

joe426

I'm building a GPS puzzle for my girlfriend which I need to finish urgently (I'm using it to ask her to marry me)!  Part of it includes a temperature sensor (analog output 0-5v).  When I run a simple "read this pin" sketch which converts the voltage to degrees C, it works just fine. However, when I integrate it into my overall program, I can't get a decent reading :(

I attempted to smooth the input as an attempt to solve the issue, but that didn't work either.  I also just tried to simply READ the pin within the program and it doesn't work.  Ideas?

Datasheet for temperature sensor: http://www.national.com/ds/LM/LM35.pdf.  Note, the odd-looking assembly code just helps power a 60v VFD 8 segment display.

Thank you for the help!! 

Code: [Select]
The code was too large to place here, so I've attached the file.


AWOL

Quote
Note, the odd-looking assembly code just helps power a 60v VFD 8 segment display.

Oh-oh!
Time to get out the oscilloscope.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nick Gammon


Note, the odd-looking assembly code just helps power a 60v VFD 8 segment display.


What assembly code?

Anyway to save wading through all of that, which pin are you reading exactly?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

AWOL

#3
Jun 21, 2011, 09:07 am Last Edit: Jun 21, 2011, 09:16 am by AWOL Reason: 1
Yes, it wasn't the
Quote
odd-looking assembly code
that I was worried about (there isn't any) but the
Quote
60v
I was "Oh-oh!" -ing.


Do yourself some favours:
Code: [Select]

int LOAD        = A0;      // "submits" the data which has been loaded into the shift register
int temp        = A1;      // reads the temperature value
int photo_in    = A2;  // input from the photocell
int blank       = A3;
int key1        = A4;
int key2        = A5;

int vfdpwr        = 0;
int orange_leds   = 1;
int blue_button   = 2;
int orange_button = 3;
int air_pump      = 4;
int white_leds    = 5;
int blue_leds     = 6;
int reed_in       = 7;
int toggle        = 8;
int boost         = 9;      // the boost pin controls how much voltage is being sent to the VFD

If these look like constants, then they ought to be constants.
Code: [Select]
int binary_numbers[11][8] =
16 bits to hold one bit?
Ass-biter.


Code: [Select]
int code_list[23][9] = Ditto.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

joe426

Thanks for the rapid responses guys!  I was thinking there might be some electrical interference as well.

@Nick Gammon - It's pin A1.  I was referring to the 5 or so lines starting with: "TCCR1B = 0"

@KE7GKP: 
Quote
temperature readings more than once every 5-10 minutes?
- I need to tell when her finger is placed over the sensor for about 3 seconds (enough to cause the temp to rise)

@AWOL and others: Okay, I'll make those constants, and optimize the others good idea. 

Crap! I have an old scope, so I'm not so sure it'll help.  I haven't tried deactivating the VFD via software, then taking the temp - that could definitely be the issue.  If it is the issue, how on earth do I solve it quickly? 




AWOL

Quote
I was referring to the 5 or so lines starting with: "TCCR1B = 0"

That's not assembler.

I'd go with the suggestion of turning the display off whilst taking readings.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

joe426


I'd go with the suggestion of turning the display off whilst taking readings.


Will do and report back!  If that's the problem, any suggestions on how to solve it? (I also have a photoresistor going into an analog pin via a voltage divider, and it's not having any issues.  Maybe I need to add a pull down resistor to the temp sensor instead of wiring the Vout directly to the A1 pin?)

wildbill

Quote
When I run a simple "read this pin" sketch which converts the voltage to degrees C, it works just fine. However, when I integrate it into my overall program, I can't get a decent reading


Might help to separate the possible issues: Can you get the 'overall program' to read the temp correctly without the 60V VFD hooked up?

joe426


Can you get the 'overall program' to read the temp correctly without the 60V VFD hooked up?


I've been away from my setup, but I'm going to try that ASAP.  Anyone have any ideas on if some sort of voltage divider -> Analog pin would help?  Currently the temp sensor is just hooked up to 5v, GND, and Vout going into A1.

Go Up