Author Topic: Tiny weekend project(s)  (Read 6950 times)

0 Members and 1 Guest are viewing this topic.

Offline newbrainTopic starter

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Tiny weekend project(s)
« on: September 25, 2016, 11:33:38 am »
Laziness is the mother of invention.
Switching on and off the amplifier connected to my TV was definitely too tiring and bothersome, and I managed to forget it on more often than not.

So, let's make a simple circuit (or two) to take care of the chore for me.

Luckily, the TV provides a couple of USB ports, whose power is switched on with the TV and switched off after ~5 minutes after the TV.
Double luckily, the ampli (a Pioneer XC-L7 salvaged from the garbage room, including speakers and sub-woofer) includes a display+keys cabled remote unit.
This remote uses the old resistor ladder + ADC trick for its keys, so it is easy to emulate a key-press with a MOSFET or OD MCU port, see the picture: the KEY3 signal is just 5V with 1k \$\Omega\$ in series

Being a week-end project, I can only rely on my components stockpile, so let's see...mmh a 74HC14, some optoisolators, these might come handy!
So after some head scratching you can see the resulting schematic in the Analog (OK, it's not really fully analog) attachment.

It works as follows (for the occasional newbie around):
  • The input signal is fed to an optoisolator so that I don't have to worry about different grounds and ground loops)
  • then, it's squared by the first Schmitt trigger, U1
  • both negative and positive going edges (U2) are derived by the RC networks, with about 50ms time constants
  • The pulses, squared by U3 and U4 are combined in a NAND gate (D1+D2+U5)
  • The resulting signal is then used to drive an open drain MOSFET, that emulate a button press.

Breadboards are evil, but for this kind of slow stuff are quite handy...the circuit works as advertised!
And yes, I'm relying on the HC14 clamp diodes to dump the capacitors charge at the negative edge...

Components count:
  • Resistors: 6
  • Capacitors: 2 + decoupling (not shown in the diagram)
  • ICs: 2  (74HC14 + 4N28)
  • MOSFET: 1
  • Diodes: 2
Total: 13 components (+decoupling, and maybe some protection diodes)

OK, maybe someone smarter than me could devise a way to spare some passives...but that's how I did.

Of course, no PCB: this has to go on an experiment board (stripes).

But something is telling me I had some more stuff around, I rummage a bit more in the bottom of a drawer and come out with a ATtiny 84 I've never used.
It's even overkill, in a DIP 14 and with 8kB of flash...but I'm definitely out of smaller MCUs.

Back to the drawing board (what an exaggeration! ::)).
The result is in Digital.PNG...from 13 components, down to four!

The code is quite simple:
  • Poll the input (using the internal comparator, how convenient) every n milliseconds
  • Whenever a change has been stable for more than 1 second, generate a suitable pulse on the output
  • Rinse and repeat
The only "smart" thing is using the data direction register to simulate an open drain output pin.

I have not yet built the final version, but I'll probably go for the digital one, you know, laziness...

It's not worth a poll, but I'm curious to know which one you prefer!
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16284
  • Country: za
Re: Tiny weekend project(s)
« Reply #1 on: September 25, 2016, 12:01:53 pm »
I did a similar thing using a CD4066 analogue switch, though there all I was looking for was a power on delay of 10 seconds and then a single emulated switch closure. Did that using only 3 of the 4 gates, and fitted it all on a piece of veroboard only 1 hole larger than the DIP IC on all sides. Sure you could do it with one here as well, and even have the rigt operation.

Where is the 5V coming from, I assume the amplifier has a standby 5V rail. Nice thing using CMOS is you can use any rail from 5V to 15V to run it, just has to be reasonably smooth, and you can easily use a RC circuit and zener to run off the higher voltage rails if there is no 5V supply.
 

Offline newbrainTopic starter

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Tiny weekend project(s)
« Reply #2 on: September 25, 2016, 12:19:26 pm »
I did a similar thing using a CD4066 analogue switch, though there all I was looking for was a power on delay of 10 seconds and then a single emulated switch closure. Did that using only 3 of the 4 gates, and fitted it all on a piece of veroboard only 1 hole larger than the DIP IC on all sides. Sure you could do it with one here as well, and even have the rigt operation.

Where is the 5V coming from, I assume the amplifier has a standby 5V rail. Nice thing using CMOS is you can use any rail from 5V to 15V to run it, just has to be reasonably smooth, and you can easily use a RC circuit and zener to run off the higher voltage rails if there is no 5V supply.
I had also some 4066 laying around, but when I saw the HC14 I thought that would be easier. I'm not so sure I could manage with a single 4066 in my case.

The remote unit has got a nice 5V rail for the VFD display controller, when the ampli is off a (dimmed down) clock is displayed so that's no problem!

My first though was actually to simply use a relay off the USB port, but unfortunately the ampli will forget some of the settings if completely disconnected from mains.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Tiny weekend project(s)
« Reply #3 on: September 25, 2016, 01:54:08 pm »
This is probably the absolute crappyest way it *could* be done with minimal discretes.  It needs sharpish rise and fall times on USB Vbus so wont work in real life unless its a blue moon, with the wind in the east and your tongue held just right! :palm:  :scared:


However the simplest non-MCU solution would probably be the correct brand of 74HC05 hex open drain inverter, Diodes Inc. say theirs  has Schmitt triggers on all inputs, + a handful of passives



Of course the sane way to do it is, as you realised, the smallest 5V MCU you've got.  However it my be possible to save one component by using the MCu's internal pullup resistors for the optocoupler.  Parallel a couple of inputs if you need more pullup current than one can provide!
« Last Edit: September 25, 2016, 05:49:00 pm by Ian.M »
 
The following users thanked this post: newbrain

Offline newbrainTopic starter

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Tiny weekend project(s)
« Reply #4 on: September 25, 2016, 04:45:33 pm »
This is probably the absolute crappyest way it *could* be done with minimal discretes.  It needs sharpish rise and fall times on USB Vbus so wont work in real life unless its a blue moon, with the wind in the east and your tongue held just right! :palm:  :scared:

However the simplest non-MCU solution would probably be the correct brand of 74HC05 hex open drain inverter, Diodes Inc. say theirs  has Schmitt triggers on all inputs, + a handful of passives

Of course the sane way to do it is, as you realised, the smallest 5V MCU you've got.  However it my be possible to save one component by using the MCu's internal pullup resistors for the optocoupler.  Parallel a couple of inputs if you need more pullup current than one can provide!
Thanks Ian!
I was not sure I could use the internal pull up with the comparator, but it works perfectly: so it's now down to three components.

Your fully analog circuit is quite clever, but I would be out of luck: no p-channel MOSFETs in my drawers, and the Vusb on the TV seems to switch on and off quite slowly.
One question, though: the 1G resistor is just to keep LTSpice happy, isn't it?

The HC05 solution still uses 13 parts (if I'm not mistaken), you spare the diodes, but there's pull-ups aplenty!
And the only 74xx05 I have is LS, and about 3000km from here...

Screenshots for both solutions included.

Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Tiny weekend project(s)
« Reply #5 on: September 25, 2016, 05:47:21 pm »
Yes, I've gone fairly wild with the pullups on the 74HC05 version as I wanted a separate timing stage for a well-defined pulselength.  If a shorter and more variable pulse is OK you could omit everything to the right of U1C ,U1D and set the timing purely by the differentiator caps, which gets it down to 8 passives total (10 parts).
One question, though: the 1G resistor is just to keep LTSpice happy, isn't it?
Yes the 1G resistor is your basic 'all parts of this circuit are on the same planet' resistor to stop the SPICE engine freaking out.  You can get rid of it if you set the parallel resistance of C2 appropriately. You can also do stuff like removing the sources and load from the main part of the schematic and connecting them by named nets if you want it to look more realistic - e.g for explanations to novices.  I've moved all the stuff needed for simulation off into a box on its own but that's purely cosmetic . . . . :=\

I should point out that a further problem with it is those 10Meg resistors - it wont take much surface leakage to FUBAR it so don't expect it to work well in a humid climate!  :--

 

Offline newbrainTopic starter

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Tiny weekend project(s)
« Reply #6 on: September 25, 2016, 06:30:45 pm »
Now it's installed, and it's working (we'll see with time...)

In the end, even cutting the veroboard was too much hassle, for 3 components: there are enough bypass caps in the remote unit, and the wires are very short... ::)

So I just assembled the whole thing on a narrow 24 pins DIP socket...and taped it to the back of the remote (no space inside, unless I go for SMD).

ATtiny84 code attached, worked at first second (I forgot the sei();) try.
Nandemo wa shiranai wa yo, shitteru koto dake.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf