Go Down

Topic: Problems with ATTiny and it's ADC's (Read 6 times) previous topic - next topic

UnaClocker

I'm having some issues with my ATTiny85 chips I'm trying to use in a project. The ADC's don't seem to be working at all for me. When I read them one of them stays around 5-7, and the other stays around 235, neither of which is correct. This ATTiny is running at 3.3v, confirmed with a Fluke multimeter. The ADC's are getting good values in from TMP36 sensors, pins 2 and 3 are both at .719v (again, checked with a Fluke multimeter), which doing the math, (719-500)/10 = a believable room temperature in celsius. I'm using this guide and the library he links to:
http://hlt.media.mit.edu/?p=1695
To program the ATTiny with Arduino.
I've written this simple program that runs on the Arduino:
http://pastebin.com/euvajUyu
And yes, I simplified the program and took out my averaging routines, spitting just an instantaneous ADC reading out the serial port when queried, with no change. "Zone 1" does seem to react to changes in temp, going down to 220 from 235, but still way off. Zone 2 just stays around 5 (4-7, kind of noisy).
Is SoftwareSerial screwing with the ADC? Do I need to do something special to get the ADC to work at 3.3v rather than 5v? I figured it'd just be fine.
I hope someone can help me with this odd issue.
Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

Jack Christensen

Hi @UnaClocker,

I searched for an old thread but couldn't find it, but I think this came up before and the answer was that the HLT core didn't support analog, but Arduino Tiny does (and the support for it here is good XD)

I hope I'm remembering that correctly; I'm sure someone will correct me if not.
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

UnaClocker

Thanks for the suggestion. I tried the Arduino-Tiny core as well, and am actually using it now, since there's not much point in switching back. It didn't help, but I did have a brain fart of sorts. I was thinking the ADC was 8 bit.. It's 10 bit.. So 235ish is totally within the correct range. It's within an acceptable margin of error of the correct reading.
As for the other ADC, I've actually encountered this on past ATTiny projects, and go figure, I forgot about it when designing my PCB for this project. "Pin 4"'s ADC doesn't seem to work, so I ran a jumper over to "pin 2", and changed the sketch to use pin 2. It now reads the same readings on both sensors.
The last time I encountered this, I was running an ATTiny on perfboard, I had a potentiometer going into that bum ADC and was using it to vary a PWM output to control a motor speed. Couldn't figure out why the motor speed wouldn't change until I finally tried a different ADC. That was at least 6 months ago, if not 9..
Oh well. I can move forward on my project now. Thanks for the reply.
Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

Jack Christensen

Sounds like memory failed me on that old thread.

Without actually testing it, I believe the analog channels are 0 through 3, which might be why "4" has an issue. The pin numbers below are the DIP pin numbers:

Code: [Select]
ADC0  Pin1  PB5 (RESET)
ADC1  Pin7  PB2
ADC2  Pin3  PB4
ADC3  Pin2  PB3


MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

UnaClocker


Yeah, I was using this as the reference, it only listed an Analog 1, 2, and 3, no 0, and that first ATTiny core I tried wouldn't accept A1 as a port (pinMode(A1, INPUT)), so I had to use the digital port number, which was 3 and 4 (physically 2 and 3).
I haven't ever tried using the RESET pin for I/O. Will the ICSP programming still work with reset disabled? Very odd that that one ADC won't work for me with two different cores. I haven't found anyone else mentioning it, yet I've run into it in two very different projects now. I even use a "real" ISP programmer now. (USBTinyISP)
Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

Go Up