Electronics > Microcontrollers

Help with analog input, multiple buttons dilemma

(1/12) > >>

Erwin Ried:
I tried several days to get a solution to my dilemma, maybe some help will be useful. Long history short: I have a electric thing to put towels (http://goo.gl/kCeCZ) uses little energy but montly it is more than 1 towel, so I want to add a timer like an oven to this device to push a button and program let say, 5 hours.

OK. My current idea (I know I can use a mechanical timer or something like that but I wish to make a little device with a small attiny to learn):


The sensor is an inductance sensor to detect when the momentary button is pressed (after relay is connected by the attiny so in this way the relay works like a 'life-supporting' device and the attiny can kill itself).

So the first attached photo shows the current circuit, my small relay board, inductance sensor so I need to finish the software now. Here is the problem. This attiny has 4 analogs, 2 pwm. As I don't have an HV programmer I have 3 analogs, but I am using 1 as an output (2 leds and relay), one analog input pin for the current sensor and I want to connect a 8-dip-switch in the last remaining pin.

Base delay is 10s (instant off), and every switch will add some time to have a total of 16 hours max (8 bits):


Second attached photo shows the dip switch and my test environment with an arduino, I am guessing this is possible with some combination of current dividers and maybe another idea? (attiny IO is 10 bits so I think I can reach 8 bit resolution including some noise of the reads)

Last attached photo shows the attiny in the usb programmer, it is working well but I am debugging first the logic in an arduino because it is a lot easier with the usb serial.

So, any recommendation/idea?

Thanks!

caroper:
If you only have one pin left, and as time is an analogue quantity, why not use a POT, rather than switches and have the ADC set the delay according to the POT setting?


Cheers
Chris

Erwin Ried:

--- Quote from: caroper on May 25, 2012, 11:57:45 pm ---If you only have one pin left, and as time is an analogue quantity, why not use a POT, rather than switches and have the ADC set the delay according to the POT setting?


Cheers
Chris

--- End quote ---

Well because I don't think the pot will be as precise as 8 different switches for the time. If this approach is possible I easily can have at max 256 combinations (1 sec to 16 hours with 5 mins intervals), maybe a pot will work with a wide knob and a little more than 1 degree per 5 mins but I think this can be done with the 10 bits precision of the analog leg

TerminalJack505:
One way to convert the 8-position DIP switch's setting to analog is to use an R2R ladder network.  To keep your circuit as simple as possible, each position of the DIP switch would need to be single-pole, double-throw.  See the first figure on this webpage for the basic idea.  (The op amp's not necessary.)

If your DIP switch is SPST then it won't be as simple since you'll need to introduce extra circuitry.  A MCU with more I/O pins may be your best bet.  Or buy a DIP switch with SPDT switches.  They're not very common, however.

Erwin Ried:

--- Quote from: TerminalJack505 on May 26, 2012, 05:39:37 am ---One way to convert the 8-position DIP switch's setting to analog is to use an R2R ladder network.  To keep your circuit as simple as possible, each position of the DIP switch would need to be single-pole, double-throw.  See the first figure on this webpage for the basic idea.  (The op amp's not necessary.)

If your DIP switch is SPST then it won't be as simple since you'll need to introduce extra circuitry.  A MCU with more I/O pins may be your best bet.  Or buy a DIP switch with SPDT switches.  They're not very common, however.

--- End quote ---

Wow! thanks a lot, I was looking for the "theory" related with this!

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version