Pages: [1]   Go Down
Author Topic: URGENT! Bizarre Analog Read Bug??  (Read 499 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
HacknMod.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad

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:
The code was too large to place here, so I've attached the file.


* new_code.pde (15.2 KB - downloaded 6 times.)
Logged


Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24353
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Note, the odd-looking assembly code just helps power a 60v VFD 8 segment display.
Oh-oh!
Time to get out the oscilloscope.
Logged

"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.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24353
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
int binary_numbers[11][8] =
16 bits to hold one bit?
Ass-biter.


Code:
int code_list[23][9] =
Ditto.
« Last Edit: June 21, 2011, 02:16:03 am by AWOL » Logged

"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.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
HacknMod.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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? 



Logged


Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24353
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
HacknMod.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?)
Logged


New Jersey
Offline Offline
Faraday Member
**
Karma: 48
Posts: 3417
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
HacknMod.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Pages: [1]   Go Up
Jump to: