News:

SMF for DIYStompboxes.com!

Main Menu

Arduino - relay

Started by aron, May 04, 2013, 01:08:46 PM

Previous topic - Next topic

aron

So I'm thinking I want to make a simple effects enabler.
I'm thinking a few preset switches, then a number of relays chained off an arduino.
Each effect is connected to a DPDT relay. Then there is some sort of way to tell the arduino which effects will be enabled per patch. There is no "reordering" of effects, just on/off (which is what I usually need anyway).

Just using this thread to assemble links.

The arduino can store data in the EEPROM.
http://modelrail.otenko.com/arduino/persistent-data-on-the-arduino-eeprom

The pinout:
http://arduino.cc/forum/index.php/topic,146315.0.html

Here are a few links to driving a relay with the arduino:
http://playground.arduino.cc/uploads/Learning/relays.pdf

Another one in pictorial form:
http://www.instructables.com/file/FN2HANWFVT7A07U
And matching info:
http://www.instructables.com/id/Arduino-Expermentation-Kit-How-to-get-Started-wi/step13/Larger-Loads-Relays-CIRC11/

hmmm:
http://forum.allaboutcircuits.com/showthread.php?t=57414
"-Instead of a relay use a solid state relay (SSR) this is essentially a relay with a built in optocoupler."
SS relay:
http://www.futureelectronics.com/en/Search.aspx?dsNav=Ntk:PlainTextSearch%7cRelays%7c3%7c,Ny:True,Ro:0,Nea:True,N:562-4294927520
http://www.learnabout-electronics.org/ssr_01.php

5v relay:
http://www.allelectronics.com/make-a-store/item/RLY-625/5VDC-DPDT-DIP-RELAY/-/1.html
how it works:
http://www.engineersgarage.com/electronic-components/dpdt-double-pole-double-throw-relay

This sound intriguing. Anyone know about this?

Some code:
http://arduino.cc/forum/index.php?topic=151836.0

A good link:
http://arduino-info.wikispaces.com/ArduinoPower

earthtonesaudio

If you define your data structures early in the process it can help a lot.
e.g.
N effects to control with a binary (on/off) signal,
for M different presets,
= MxN bits to store.
It's unlikely that space will be an issue but how you access the data can make a big speed difference.   For instance if you have 8 or fewer pedals then you can store all their states in a single byte, which is super-fast.

The number of things you want to control will also influence how you use i/o on the Arduino.  For example if you have 4 effects you can use one pin per effect.  But if you have 40 then you'd need to use a shift register or some other method to turn serial data into parallel control signals.

You can probably get by without interrupts but you may prefer to use them.  Different Arduinos have differing numbers of external interrupt pins available.

Seljer

I've recently worked on a project using 74HC595 shift registers for a large number of outputs on just three output pins and ULN2803 relay driver chips (500mA per output, and you can run them in parallel if you need more current). It works very well.

artifus

here's an uber simple project i stumbled upon and bookmarked recently. basically just triggering a midi note with a foot switch but easily expanded upon.

http://www.instructables.com/id/Ardurino-Midi-Foot-Pedal/?ALLSTEPS

jpwilksch

Hi Aron,

I've been tinkering with the same sort of thing, using PICAXE instead of Arduino. The concept you describe has been the subject of a number of posts in this forum over the years and are usually referred to as programmable loopers or switchers. Invariably the discussion refers to RG's work at some point - http://www.geofex.com/article_folders/rmtswtch/rmtsw.htm, http://www.geofex.com/Article_Folders/pffootsw.pdf, etc. - although these are more logic-based than microcontroller-based.

Things I've learned that you may find useful (sorry if these are obvious to you):
- Use momentary stomp switches
- Buttons/switches need debouncing. Hardware debouncing can vary from a simple cap through to caps, diodes and Schmidt triggers. Software debouncing can vary from a simple 10ms wait and re-read of switch state, to a ring-buffer based debounce that monitors multiple buttons and generates independent button press, release and hold events. You'll likely want to be debouncing multiple buttons at once, so +1 to earthtonesaudio comment on data structures.
- Use signal relays. These are better suited for switching low voltage guitar signals (eg. Takamisawa RY5W-K (Fujitsu), Panasonic TQ2-5V, NEC  EC2-5NA). You'll need to decide if you want latching or non-latching, the former requires a current pulse to change state, the latter requires constantly applied current to maintain one of it's states. I've chosen non-latching for ease of programming :-)
- I've had to adjust my high-level-language-thinking to Microcontroller-thinking based around bit flags, ANDing, ORing, XORing, etc. to write clean code.
- If possible, get a chip with as many I/O pins as you need to have a single input or output per pin. This simplifies programming and I found the extra cost ($10 instead of $6 for a PICAXE) was well worth it.
- You can drive a relay from the microcontroller output using either a BJT- or MOSFET- based circuit. Either is fine, but I think (bit unsure) the BJT circuit will draw more current out of your microcontroller.
- Unless you have dedicated edit/store button(s) for saving patches, you will need some sort of button-hold or double-press recognition to enter an edit mode. This is where the ability to generate button press, release and hold events really becomes handy.
- I haven't used interrupts to detect button presses, so this means I enter a perpetual loop and keep the code in here as lean as possible to avoid any unwanted lag - probably only an issue with the PICAXE's BASIC interpreter ;)

I'll quit my jibber jabber now ;D
J.

aron

Thanks Jeremy! Very helpful!

Aron

caldersm

I have just finished building a four channel programmable looper/switcher.  I even did a PCB, so I could sell it as a kit.  I used an Attiny4313 chip, as they are only about $1.25, instead of using a full blown arduino.  I received my PCB's in last week and soldered it up last weekend.  Came out great.  Have attached a picture of the PCB.  If you have any questions or get stuck, I can try to answer them and help you along.  Or if you are interested in buying the PCB and the programmed chip, then that could be arranged as well.

http://imgur.com/7uiQEVg

Good Luck....the effort is worth it...!!

Steve

jpwilksch

#7
Nice work Steve!

What's the second IC? Quad transistor package?

Also where did you fit the protection diodes for the relays?

caldersm

jp,

The second IC is a ULN2003a....which is a driver for the relays.  I used it because it had built in diode suppression.....served two purposes.  Although I did find out that the aTtiny4313 can sink 40ma per channel.....I was't sure if it would have an issue with all four relays and 8 LED's on at the same time.  I did use 2.4k Ohm resistors to limit the current to about 1.2ma for the LED's....using the bright type.

I am actually working on a second PCB that includes muting of the signal when switching, and also one that the grounds out the SND of each channel, when it is off.  Each step I complete seems to lead me to another enhancement for the next rev.

Steve