Jump to content

Oh noes! Not another amp...


markiemrboo

Recommended Posts

You are correct sir!

 

I remember doing this in one of my digital logic classes. All of our switches had to be debounced, and we did it with a simple NAND circuit. I think it was two NAND gates that it needed. I still have some built on my breadboard actually, but I don't remember the pin-outs for the NAND ICs off-hand.

 

EDIT###

SR-Latch-style debounce:

0405bpfig1.gif

 

Oh, I know. I just wanna use a PIC :P and the debounce can be done in software. I could also make it so that it saves the state of the switch, so that in the event of power loss it will switch back on itself. It would be just like an ordinary latching kind of switch! That might be a neat 'feature'. I also would still have pins spare. Maybe I could get a temperature sensor and make the power light flash, or the unit automatically turn off the power if the heatsink gets over, say, 60-65C! It all seems quite yum.

Edited by markiemrboo

Share this post


Link to post
Share on other sites

  • Replies 82
  • Created
  • Last Reply

Top Posters In This Topic

I was thinking of how nice it would be just to plug speakers in to my comp instead of a million wires. Guess you guys haven't seen my old monitor setup? Anyway, I like just one big thing instead of a thousand small things.

 

 

So a million wires into one box instead of into several separate boxes then :lol:

Edited by jammin

Share this post


Link to post
Share on other sites

The PIC stuff arrived yesterday! Woo! I have built the programmer on to strip board. It didn't work at first, and took me several hours checking the circuit over...and over... and over to realize that it was just because the serial cable I have does not pass pins "straight through", so say... pin 2 was actually pin 3 and vice versa (null modem cableness). I tested continuity and mapped which pins were going where, swapped them around on the connector..... and it started working! The green LED lights up dimly when programming / reading.

 

The caps are sexy! Mr Fox thought that was funny when I told him :wub: They are a nice blue colour, but turn purple-ish at certain angles in the light... they don't photo too well though :D

 

2003647188910782777_rs.jpg

 

2003612066436334095_rs.jpg

 

 

I have written some preliminary really inefficient code for it. MPlab seems to like to crash alot for me, but it does have a fairly good simulator. It simulates OK, and at the moment it's currently flashed on to the 675 and verifies fine (aka the programmer actually works!). I haven't tested it yet though. I think I may build a prototype later today and see how well it works.

 

I'm feel I am of getting the hang of the PIC's asm language already. I'm particularly proud of the delay loop, which I think (my maths isn't superb) should be exactly 1000uS (1ms) for the millisecond delay, and only 4uS out on the Xms loop (up to 255ms) when running at 4MHz. Again, I haven't actually tested this but should be able to verify it with the 1 second LED flashes upon button press.

 

I say inefficient because it sits there continuously checking for a button press. My next task is to put the switch on an interrupt pin, so I can put it to sleep and when it receives the interrupt it'll wake up, debounce the button, toggle the state, and then just go back to sleep until the next button press. This would involve moving the switch from GP3 to GP2, but I haven't made the actual proper PCB yet, and it's only a 2 second rerouting job anyhow.

 

power_button_v1.txt

 

 

edit - I have just now quickly built a prototype and tested it..... and........ it works great as it is to be honest! The LED flash could probably do with a bit of tweaking but that's about it really! It seems to switch really quite nicely even though the I accidently left in the 1ms debounce instead of 5ms. The LED that lights up solidly will be the relay which switches the power, and the other LED that blinks is the power buttons light ring. A short video of it in action can be found here.

 

I am now going to look at interrupts and test that out though I think. I will post the code for that one too, for anyone who cares :lol:

Edited by markiemrboo

Share this post


Link to post
Share on other sites

I have discovered that I can't seem to put the PIC to sleep with my current programmer, which is quite unfortunate. It fails to program properly / verify. I'm not honestly sure why. I guess at some point during the programming something happens that starts to actually run the code on the chip, and, well, if it puts itself to sleep programming won't happen.

 

 

I have monkeyed around some more, both with an interrupt version and the polling version and changed a few things:

  • I've improved the debounce / button checking from a fixed delay to something which should "adapt" somewhat. It is now looping until at least 20ms have passed with the switch being looked at every 1ms. If the state of the switch changes in this period it will restart the loop. A fixed delay is probably fine really!
  • It debounces on the release of the switch now.
  • I made the LED blink better, from 1s between each to 250ms.
  • Set the output pins explicitly low (led and relay off) after setting them up.

I also discovered that the chip does actually have a timer which I could have used, and I am sure the code could be improved further but, well, what I have at the moment seems to be working just fine.

 

Here's another video with the real button in use. The LED in the background is still pretending to be the mains switching relay :)

 

power_button_int.txt

Edited by markiemrboo

Share this post


Link to post
Share on other sites

Me again!

 

Today I have made the proper PCB for the power switch and tested it out. It is working really, really well and I am very happy with it. Upon firing it up to test, I found a fault with the yet-again-new-improved code. I forgot to include the Debounce routines :blush: The great thing is, of course, I didn't have to scrap the lot and make ANOTHER PCB, it was a simple case of adding the code back, recompiling and flashing the PIC! I love it!

 

Here are a couple of pictures. Not all that interesting, but hey! The PCB is exactly the same size as the flip-flop version. I have left a trace available on a pin should I want to maybe hookup an IR receiver as well. Looks a bit empty on the top of the PCB as most of the resistors / caps are on the back in SMD form.

 

2005898758725188165_rs.jpg

 

2005850590296794722_rs.jpg

 

Here is the source code. Managed to learn how to get MPLAB to compile it in to relocatable modules and learnt a few other things while doing some coding for my next project ;) I'm sure there's more to learn yet. I'm enjoying it though.

 

Push_Button_Latching_v3.zip

 

I can now go back to focusing on the case for the darn thing! I will try my hardest to get that done by the end of this week. It's been ages since I started this project :unsure:

Share this post


Link to post
Share on other sites

But...you'd have an amp.

 

I've already got an amp. I'm currently using my other LM3886 based DIY amp... along with my DIY pre amp :thumbs-up: :P

 

I do have a commercial unit (Cambridge Audio) sitting on top of my cupboard as well, which I no longer use.

Edited by markiemrboo

Share this post


Link to post
Share on other sites

"Dude! Just buy a Dell!"

:lol: Awesome analogy. I was trying (and failing) to come up with one myself.

 

Half the fun is having built it yourself!

 

"Dude, yer gettin' a Dell!" :P

Share this post


Link to post
Share on other sites

I'd equate that to:

 

"Dude! Just buy a Dell!"

 

:lol:

 

You would have a computer... but it wouldn't be much fun :D

 

:lol: exactly.

 

In his defense though, I think he only said that because it seems that he thought I was totally amp-less while working on this and not because he can't see the point in me building one myself :) .... I think.... I hope......

Edited by markiemrboo

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...