NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » Questions re: debouncing input switches, switch matrix, and latching outputs
December 21, 2009 by iamtheari |
First off, some background on the project I am hoping to put together. This is the whole reason I ordered the Nerdkit - because using a Z80 would have become too much hassle with all the supporting hardware, when the Atmel chip can do it all on one IC. I am a guitarist. I want to build a remote effects-switching system, because nothing on the market does it quite the way I want. Plus, it'll cost less and be a lot more fun to do it myself! Here are the basic requirements for the two-unit system, each unit having its own MCU: A. Remote Control Unit: 8-16 footswitches, SPST momentary. The MCU should be aware of the event of a switch being pressed and be able to determine which switch was pressed. Each switch will act to toggle one relay in the Rackmount Unit. If possible, it should also have talkback LEDs, one per switch, to inform the user which relays in the Rackmount Unit are on and off. The Remote Control Unit will receive power from the Rackmount Unit and send commands to the Rackmount Unit, all through one cable (I am thinking of using Cat-5 because it's cheap and easy to get in any length, but a MIDI cable is also acceptable.) A serial protocol can be used for the communication. B. Rackmount Unit: 8-16 audio relays, DPDT. The MCU should be able to switch just one relay at a time, but should have a way of knowing which relays are turned on (I am probably okay with making the assumption that a command to turn a relay on will keep it on until it is told otherwise, even though that is less robust than a feedback of some sort to the MCU). It will receive commands from the Remote Control Unit over the serial cable that tell it to turn on or off a particular relay. The relays would be controlled by MOSFET transistors or something. The things I have no idea how to do at present: 1. Debounce the input switches.
Thanks to anyone with thoughts or guidance on this. :) |
---|---|
December 28, 2009 by hevans (NerdKits Staff) |
Hi imatheari, It sounds like you have a very interesting project in the works, and it sounds like you have a great idea of how to start. My suggestion is try it! You will learn along the way, and post any issues you come across. Debounceing in software is not very difficult - it is merely a matter of checking the state of the pin several times, and not counting a button press if it toggles too quickly. There is an example of a debounced button on the Motors and Microcontrollers Tutorial. There is no thorough explanation, but the source should be enough to help you get started. Let us know if you run into any problems, there are plenty of people here willing to lend a hand. Humberto |
December 29, 2009 by iamtheari |
Thanks for the response. That video was very helpful, indeed, and I will take a look at the code later. (I have plenty of programming experience so I'm sure I'll be able to dissect it just fine.) One problem down, a few to go. :) |
December 29, 2009 by iamtheari |
Update: I have done some shopping online and have come up with the following ideas:
The relay driver I found has a serial interface that requires 3 data lines (enable, clock, data). So I'm using 4 data pins on the MCU for the switches and 3 pins for the outputs. I am putting the inputs on PB0-PB3 and the outputs on PC0-PC2. I can easily double this up later to use PB4-PB7 and PC3-PC5 to control twice as many relays. PD0 and PD1 are used for the USART, leaving PC6 and PD2-PD7 on both units entirely free and PB0-PB7 free on the switching unit. Now, who wants to teach me metalworking to build the enclosures for these things? ;) |
December 29, 2009 by iamtheari |
Correction, the relay driver part number is 595-TPL9201N for the DIP package. |
Please log in to post a reply.
Did you know that a square wave sounds different than a sine wave? Learn more...
|