reading adch 5x and average

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I use a attiny24A
At the moment I read the ADC of PA2 and than do an action if the signal is below 125 decimal.

My problem is that when the attiny is working in a eviroment of 70 degrees it is just triggering the signal like it was below 125 decimal

I did a lot of measurements on the incoming signals and the supply voltage, but the incoming signals dont drop and are clean and there are no dips in the supply voltage.

I even connect PA2 with a resistor to 5Volt and 1uF to ground, and still the pin is triggered.

I get a bit confused.

Now I was thinking maybe I can read the ADCH 5 times and take the average of this, but I don't know how to do this?

Can any one give me some help.

I include a piece of the code

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do a loop (that iterates 5 times) that reads the ADC adding the value into a variable. Then divide the variable by 5.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks Steve,

For the quick response. I going to try that it sounds easy.

But I still find it strange that everything works well at room temperature and start failing at 70 degrees.
I did this kind of measurements before but I never had any problems with it even at higher temperatures.

The only differnce I think of now is that when it keeps on working. The measured signal is resistor divided from 12Volts instead of the 5Volts that I use now. This is the same 5Volt I use to power the attiny24A.

But still it is strange.

Greetings,
Patrick

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you take average of conversions made 2,4,8 or 16 times and so on you only need to use LSR instruction (divide by 2) for divisions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

My problem is that when the attiny is working in a eviroment of 70 degrees it is just triggering the signal like it was below 125 decimal

Well, what counts ARE you getting? Map your ADC counts vs. temperature with a steady input signal.

What reference source are you using? Is it stable at that temperature?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys,

If I want decimal value from sensor and convert it to the real temperature value, how can I do it?
Can someone guide me?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. Don't hijack other peoples threads. (Suggest a MODERATOR break this out to a new thread "Convert temperature sensor value".) [moderator: I would but then OP may lose it and just cross post - let's give him a chance to read your reply first so he knows this is going to happen]

2. What sensor? Make and model number?

3. How are you reading the sensor? ADC? What reference voltage etc? Show code you have today.

4. What language are you programming in?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]