Author Topic: Help with analog input, multiple buttons dilemma  (Read 22281 times)

0 Members and 1 Guest are viewing this topic.

Offline Erwin RiedTopic starter

  • Regular Contributor
  • *
  • Posts: 201
  • Country: no
Re: Help with analog input, multiple buttons dilemma
« Reply #50 on: July 03, 2012, 04:49:10 am »
Hey! at the end I was not able to squeeze 8 bits using resistors and with the 10 bit analog pin as you predicted. Also the coil to detect when the button was down was not reliable, I don't think if it is the analog reference or what, but setting the reference to the internal 1.1V was very sensitive but consumption was not stable enought using the 220V-5V power adaptor as source (with independent supply, sensing the button was very stable).

So in conclusion (like to sum up all this topic) first I decided to take the idea proposed here about using a button to set the timer, and I use the eeprom to save the previous value, so in conclusion it works very nice:


About the switches, the best combination for 8 switches provided a nearly 1 decimal value of difference, having perfect resistors:
http://screencast.com/t/k3pt0pumD2s

But I was unable to replicate the same perfection in real life, always had more than 8 collisions. For 7 resistors, the minimum difference was 2, so in conclusion 6 switches is the safest option:
http://screencast.com/t/xUsaeI9ef

Those values were found by a solver in excel after a lot of hours of processing, so probably they are nearly perfect solutions for the problem.
« Last Edit: July 03, 2012, 04:51:09 am by Erwin Ried »
My website: http://ried.cl
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: Help with analog input, multiple buttons dilemma
« Reply #51 on: July 03, 2012, 05:11:16 am »
Glad to see you finished the project.  Even if the DIP switch idea didn't work out.
 

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5121
  • Country: nl
Re: Help with analog input, multiple buttons dilemma
« Reply #52 on: July 03, 2012, 06:40:21 pm »
Hi,

Good to see that you have a working product, thanks for posting the results.
Also nice to see that the things I pointed out came to be a reality.
That's probably only because I tried the same stuff and failed learned from that  ;)
Happy toweling!
Keyboard error: Press F1 to continue.
 

Offline Erwin RiedTopic starter

  • Regular Contributor
  • *
  • Posts: 201
  • Country: no
Re: Help with analog input, multiple buttons dilemma
« Reply #53 on: July 07, 2012, 03:22:47 pm »
Hehe, well, I didn't understand a lot the resistor ladder things in first place, then realized about the limitations, but a lot later (that's why I was trying to do it anyway) but always there is something new to learn :)

May I ask you both a final question, I am getting some irregularities in the behaviour (timer usually works but sometimes it just hangs) SO, I am thinking about adding some caps to smooth the input, I measured the voltage of the cheap 220V to 5V adaptor I used, and for a 30 mins timeout period looks like this:


As you can see at startup Voltage reaches 10V (I think this is bad for the uC probably) sometimes I get a reset at the start, then it is a bit noisy but near the second 1400 there is a small drop (I turn both leds on 10 mins near the end of timeout). Also the timer in the Attiny need some calibration, it is fairy unprecise = +/-11%


Will this smoothing caps in parallel fix the issue? what do you think?

Or should I replace the supply for another one... like a more expensive one? (this one is very cheap, like 1.6 usd)
« Last Edit: July 07, 2012, 03:26:59 pm by Erwin Ried »
My website: http://ried.cl
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: Help with analog input, multiple buttons dilemma
« Reply #54 on: July 07, 2012, 07:03:25 pm »
The caps won't hurt, obviously.  I assume you're using one of those wall adapters with a switching regulator in the plug.  If so then the caps are pretty much necessary since the voltage source is so far away from the load.  I don't know if they'll bypass that 10V spike or not, though.

The timer inaccuracy sounds like a software issue.  Off the top of my head, I think the internal RC oscillators should be something like +/- 2% accurate.
 

Offline Erwin RiedTopic starter

  • Regular Contributor
  • *
  • Posts: 201
  • Country: no
Re: Help with analog input, multiple buttons dilemma
« Reply #55 on: July 07, 2012, 07:28:08 pm »
The caps won't hurt, obviously.  I assume you're using one of those wall adapters with a switching regulator in the plug.  If so then the caps are pretty much necessary since the voltage source is so far away from the load.  I don't know if they'll bypass that 10V spike or not, though.

The timer inaccuracy sounds like a software issue.  Off the top of my head, I think the internal RC oscillators should be something like +/- 2% accurate.

In fact Caps help a lot but not with the spikes >10V!, and yes I am using those wall adapters.

About the timer, I think in this case it should be calibrated:
http://forums.adafruit.com/viewtopic.php?t=5078

(I needed to calibrated another tiny in the past for this accelerometer datacollector but because the serial port was throwing garbage, not due long time precision, in oscilator serial data was a bit weird, then it worked nicely... but because that time I used just a 3V cell I didn't needed caps)


I used a slighly better wall adapter (like 2.5 usd) not one of the best, but at least it seems best  built and voltage + regulator is very clean now! I hope this closes the case for the towel's timer :P
My website: http://ried.cl
 

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5121
  • Country: nl
Re: Help with analog input, multiple buttons dilemma
« Reply #56 on: July 07, 2012, 08:28:39 pm »
The red line (New PSU+ Caps) still does some nasty things at the beginning and end (12 volts spike?), so if your uC is happy with the 4V from the LM317 i'd leave it in.
Keyboard error: Press F1 to continue.
 

Offline TerminalJack505

  • Super Contributor
  • ***
  • Posts: 1310
  • Country: 00
Re: Help with analog input, multiple buttons dilemma
« Reply #57 on: July 07, 2012, 08:37:49 pm »
Yep, you're right about the +/- 10%.  I never realized it was that bad.

Atmel has an app note (AVR053) on using their various programmers/debuggers to do the calibration.  I've never tried it.  It seems like I've used avrdude to do it before, though.
 

Offline Erwin RiedTopic starter

  • Regular Contributor
  • *
  • Posts: 201
  • Country: no
Re: Help with analog input, multiple buttons dilemma
« Reply #58 on: July 07, 2012, 09:13:16 pm »
Yes, with 4V works wonderfully! no more resets or hangs

About the auto calibration, I have a cheap ($4 usd) programmer from ebay, avrasp one, it is a pain to calibrate but it is once in each chip life :) so, not so bad. You need to set a serial terminal with the tiny
My website: http://ried.cl
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf