#avr Logs

Dec 14 2019

#avr Calendar

05:30 PM fuxxy: Simple design - Operate a light with a reed with a pushbutton override. Any suggestions on the circuit diagram? https://ibb.co/f96YJmN
05:35 PM polprog: yeah, why put a microcontroller in there :D
05:35 PM polprog: apart from that you have an unnecesary +5V marker and the leds are wrong way around
05:35 PM fuxxy: I havent figured out a way to trigger a relay with a switch and pushbutton override with discretes
05:35 PM fuxxy: and the attiny's are $.50
05:35 PM polprog: you also wanna check the maths on that BC548 transistor, whether the base resistor is not too big and whether the BC548 itself can handle currents that big
05:35 PM polprog: thats a valid design choice ;)
05:37 PM cehteh: lol
05:38 PM cehteh: at least put reed and pushbutton on single gpio's
05:38 PM cehteh: and yes you doing it waay to complicated
05:38 PM cehteh: ah you doing that
05:38 PM polprog: not sure which way the reed and PB are supposed to work but it can be done with one 74 series logic ic or even without
05:39 PM polprog: do you want them to be an OR?
05:39 PM polprog: if so then you dont need the avr at all actually...
05:39 PM cehteh: input pullup the button and reed saves some external components, but you may want to denoise/debounce it, which prolly can be done in software then
05:40 PM cehteh: you can do that with 2 diodes
05:40 PM polprog: i think if you left just the cap and enabled the pullups interally you wouldnt need to debounce
05:40 PM cehteh: depends on the environment
05:41 PM polprog: i dont think you even need to debounce
05:42 PM fuxxy: I don't think a simple OR would work, the PB is dual-purpose. If the reedswitch doesnt work, the PB will turn the light on, but if the light is already on, the PB will turn it off until the door is closed, or the PB is pressed again
05:42 PM polprog: hmm, thats a tad more complicated then
05:43 PM fuxxy: I'll admit I'm quite the novice, but I've researched latching pushbuttons with transistors for a week and was not able to figure a way to 'override' the reedswitch
05:44 PM fuxxy: unless I put them in series, that is. But then I lose my ability to turn on/off if the switch fails
05:44 PM cehteh: http://tinyurl.com/u5gm3jn
05:44 PM polprog: yes, the "or PB is pressed again" part makes it a bit more complicated
05:45 PM cehteh: is that the logic you want?
05:45 PM cehteh: snubber around the reed .. may put one around the switch as well or leave it out
05:46 PM polprog: because it changes the logic class
05:46 PM polprog: since you need to store the previous state
05:47 PM cehteh: what logic do you want?
05:47 PM fuxxy: cehteh, no
05:47 PM cehteh: pushbutton tristate (on/off/reed?)
05:47 PM fuxxy: The overall gist is think refrigerator switch. But with a way to operate manually regardless of the door position
05:47 PM cehteh: what i shown there will do that
05:48 PM cehteh: ah no you cant turn it off when the door is open :)
05:48 PM cehteh: well yoi need to start with defining the logic
05:48 PM cehteh: shall one be able to turn it on when the door is closed?
05:49 PM polprog: something like the classic "two lights switches in a corridor" case?
05:50 PM fuxxy: This is for the storage bays under my RV. I want the light to come on when door open, and off when door closed. However, if the door is open (and light is on), PB will turn the light off. If the reedswitch is broken, light should still be operable via PB. (Open the door, press the button, light turns on)
05:50 PM polprog: yeah
05:50 PM polprog: so you want a XOR
05:50 PM cehteh: ok that needs SPDT switches or mcu
05:50 PM PoppaVic: and then.. you close the door and now it doesn't go on when you open ;-P
05:51 PM cehteh: pushbutton wont do it easily
05:51 PM polprog: yeah it can be done with SPDT switches
05:52 PM PoppaVic: ..or, you get locked inside - in the dark ;-P
05:52 PM polprog: https://paste.debian.net/1121114/
05:52 PM cehteh: http://tinyurl.com/sndawqz
05:52 PM fuxxy: polprog, agreed, but the whole idea is that I don't want to remember to turn something off - hence the reed switch. I could incorporate a timer into the pushbutton so that it fails off after a set amount of time
05:52 PM polprog: not sure if they do SDPT reed switches but you can simulate one with another relay...
05:52 PM polprog: youre overthinking it
05:53 PM cehteh: actually in the simplest case you just give a shit about the rest
05:53 PM cehteh: http://tinyurl.com/ujuj8jp
05:53 PM polprog: if you are worried that the reed switch fails, just put two
05:53 PM cehteh: well i would put the snubber around the reed as shown before
05:53 PM polprog: thats the 2 switched in a corridor circuit
05:53 PM cehteh: with that the reed should be ultra reliable
05:53 PM cehteh: yes
05:53 PM polprog: ^^^
05:54 PM cehteh: flywheel diode as well
05:54 PM cehteh: and you possibly can just put the snubber across both switches as the paste before the last
05:54 PM fuxxy: I don't quite follow how the snubber would make the reed switch more reliable
05:55 PM cehteh: all mechanical contacts fail because of carking and micro corrosion
05:55 PM cehteh: snubber prevents that
05:55 PM polprog: the relay coil will have transients that will cause sparking
05:55 PM polprog: (since thats how coils work, in simple terms)
05:55 PM fuxxy: cehteh, that's why I was using the transistor
05:56 PM fuxxy: less current across switch == less spark?
05:56 PM cehteh: transistors can fail as well
05:56 PM cehteh: yes you can do that, but then that voltage and current goes over the transistor
05:56 PM fuxxy: correct, but solid state mitigates normal wear
05:56 PM fuxxy: s/normal/mechanical
05:56 PM cehteh: it has other problems
05:57 PM cehteh: when you are upf for that level of reliablility
05:57 PM cehteh: putting an mcu into that wont make it more reliable as well
05:57 PM fuxxy: I'd like for this to last >= 10 years
05:58 PM cehteh: operated 100 times per second? :)
05:58 PM fuxxy: shit, no
05:58 PM fuxxy: maybe 10 times a year :)
05:59 PM cehteh: btw you want to put a snubber/varistor across the relays output as well, that actually worries me more, what kind of light do you switch, how long is the wireing
05:59 PM fuxxy: cehteh, the lights are LED strips, roughly 300mA at 12v
05:59 PM cehteh: long wires?
05:59 PM fuxxy: installed roughly 2-4 feet away from the mcu/relay
05:59 PM cehteh: -> inductance
05:59 PM cehteh: why relay anyway
06:00 PM fuxxy: relay because the lights are 12v
06:00 PM cehteh: dont use a relay for that
06:00 PM cehteh: uln2003
06:00 PM cehteh: relays are not good for that job
06:01 PM fuxxy: I was figuring the relay would be ideal since they're use everywhere else in the chassis
06:01 PM cehteh: and hey that floor light switch you can prolyl operate theled strip directly
06:01 PM PoppaVic: I'm just thinkin' "mercury-switch", or even neomag/magnetic-read.. Certainly car-door switches - and hood switches - work for ages
06:02 PM cehteh: whats the reed switch rated?
06:02 PM PoppaVic: use some LED lights, and the current is minimal.
06:02 PM cehteh: again .. put snubber around it that takes a lot stress from the reed switch
06:02 PM fuxxy: PoppaVic, mercury switch would be nice, I thought of that, but then I have wire flex to consider. The reed switches can be installed and left the F alone
06:02 PM fuxxy: cehteh, unsure, I'll have to look up the amazon link
06:02 PM PoppaVic: fuxxy: same with using magnetic, (but it won't work when yer locked inside ;-)
06:03 PM cehteh: fuxxy: either way get a 10pack of uln2003
06:03 PM cehteh: switch with those
06:03 PM PoppaVic: and wire-flex is no real issue, either: stranded wire with a silicon jacket - make it several gauges heavier, if you like
06:03 PM cehteh: relays are not so reliable as on may think (actually that 10 times/year wont be a problem)
06:04 PM fuxxy: PoppaVic, I can't get inside the storage bay. these compartments are roughly the size of the gym locker I used to get shoved into as a kid
06:05 PM fuxxy: cehteh, they make a uln2003 with a single darlington array instead of four?
06:05 PM cehteh: standard uln2003 has 7 arrays, just dont care
06:05 PM cehteh: you can parallel them for more WROOOM ::D
06:05 PM fuxxy: cehteh, I'd honestly prefer solid state as opposed to relays though
06:05 PM fuxxy: cehteh, ooh, good idea.
06:05 PM cehteh: but you dont need, just use one and forget about the rest
06:06 PM fuxxy: better than $2.50ea for relays
06:06 PM cehteh: anyway for 300mA 12V you can most likely just use reed and normal SPDT .. snubber / diode thats all
06:07 PM fuxxy: wouldnt I then lose the override functionality? I'd still like to disable the light and leave the door open
06:08 PM cehteh: http://tinyurl.com/uv2q4qv
06:08 PM cehteh: led strip ftw :D
06:09 PM cehteh: look at how much current the reed can handle
06:09 PM cehteh: would be nice when its considerably overrated, 500mA 1A or so
06:09 PM cehteh: but that should work reasonable well then
06:10 PM cehteh: the less components the less can fail
06:10 PM fuxxy: one problem with that last circuitjs... If the switch is flipped, it inverts the operation of the reed switch
06:10 PM fuxxy: If the reed is SPDT, and the switch is flipped, when the door is closed the light will come on
06:10 PM cehteh: i saied before you need to make up ypur mins how the logic shall be
06:11 PM fuxxy: I thought I outlined it well, I'm sorry.
06:11 PM cehteh: override only on only off, toggle .. what do you want?
06:14 PM fuxxy: door open, light on. Door closed, light off. - If door is open, pushbutton will turn the light off. Anything in addition to that are failure compensation.
06:15 PM cehteh: ah not on :)
06:15 PM PoppaVic: Personally, I think yer better off with a lights-out timer.
06:15 PM PoppaVic: if it's open too long, open the circuit; reset when it's closed.
06:15 PM cehteh: well i am not completely opposing the use of a mcu
06:16 PM cehteh: but that need lots extra efforts compared to just 2 switches
06:16 PM fuxxy: The button is inside, and the storage bay would never be occupied with the door closed. So If the mcu sees a button press, the reed switch must be broken.
06:16 PM PoppaVic: Only reason I mention the timer is same as his switch.
06:16 PM cehteh: while pushbutton to turn it off is a slight challenge for 2 switches and no active components
06:17 PM PoppaVic: "Molly? did you leave the damned trunk-door open all night!?"
06:18 PM fuxxy: PoppaVic, timer is great, but some of these doors also function as tables. So the need to close the door to get the light to turn on is a lot of effort.
06:20 PM fuxxy: Let me add this UL2003 to the schematic, and get some food, I'll be back. This is exactly the feedback I'm looking for
11:56 PM day__ is now known as day