I’m a pretty good programmer, but totally new to electronics and microcontroller-based hardware design. I’ve been looking into a good platform to help me get started with a simple hardware-based MIDI sequencer, but I’d like to hear the opinion of more experienced people such as you.
Assuming something like 24 switches, same number of (bi-color) LEDs, 1 or 5 clickable encoders, a 2x16 LCD display, and MIDI in and out, what would you recommend taking a look at?
IF you only have one hour, look onto the PicAxe Series of Chips, if you have more time and want to do more complex things go Ardiuno
really depends what you’re after.
arduino is an easy stard, no soldering what so ever, but much more expensive than using an avr controller on perfboard (arduiono 20$ ?, perfboard 4$).
I think you won’t learn as much with an arduino compared to using the avr directly. (correct me if i’m wrong)
but the start is easier
Never worked with arduino or picaxe… I started with PIC (doesn’t like them so much, but thats more a question of taste)
then moved on pretty quick to atmels AVR series.
concerning bang for the bucks the new 32 bit platforms are great, but since they are quite new theres not sooo much info on the web explaining everything, so i’d stay away from them for the beginning untill you are confortable using registers and setting up peripherals.
so my recommendation would be avr. free toolchain (uses GCC) and loads of ressources on the web.
I’d go for arduino… I’m in the process of designing a midi controller on the arduino. I don’t have any experience in programming but i could get something working with midi out in few hours by modifying some examples. On the internet are a lot of things already out there you can use as a starting point. And if you outgrow the MCU you can easily port your project to something bigger.
@fcd72 More complex as in the code that’s running, or in the hardware you can hook up to it?
@shiftr I assume you’re using pre-built shields for (most of) you project?
PicAxe ist straightforward plain basic, supereasy to learn and lighningfast to code/debug. If it gets a bit more complicated you’d prefer something more sophisticated…
You will need some shift registers (74hc165 / 74hc595) or pwm led drivers, and probably some pollig circuitry (arrange the buttons and switches so it forms a matrix, using a nice bunch of diodes).
You can poll a lot of switches and light a lod of leds with possibly just 3 pins on a micro controller using multiplexers and stuff, but you have to make a trade off between circuitry complexity and size (and cost) of your controller.
Which requires some knowledge about what is possible and what you really need.
A good starting point is something like an arduino indeed.
An invaluable source of constant inspiration is taking a look at the Shuthis Digital Board, its all there: MIDI circuitry (i use the same every time), 74xx165 Shift register 74xx595 Shift register, Pots, LEDs…
@fcd72 Yeah, that’s actually one of the reasons I was considering diving straight into AVR programming. The hardware I’m planning is basically the shruthi-1 control board with more buttons and LEDs and the 4 pots replaced with encoders.
Please notice that the shruthi (or ambika) hardware is convenient when the number of controls and leds is not too high.
I think that when there are a lot of potentiometers, a look at the ambika hardware is quite useful…
And when there are more buttons and leds, the arduinome or the midibox seqv4l is a good inspiration.
(the meeblip uses the same technique as well).
About the encoders : encoders are the same as a bunch of buttons in the same package (3 when it’s a clickable encoder, 2 when it’s not).
About picking a PIC vs AVR : I don’t think there are many differences between both technologies. AVR are convenient because they quite match the arduino series. Picaxe is convenient because the learning curve is very fast at the beginning. I don’t think there’s any particular reason why Olivier picked the AVR side and Wilba picked the PIC side for his sammisch synths.
@MicMicMan Thanks, that’s very helpful.
The PIC compilers are a bit antiquated (they are based on an older version of gcc, and as far as I know, do not support C++, which is the language I can express myself the most efficiently with). Atmel produces very good documentation and application notes.
Regarding what you want to do, I found that using shift registers forI/O scales much better than using diode matrixes and charlieplexing-like schemes- you don’t have to think much every time you want to use more inputs or outputs. Given the price of 74hcxxx and the ability of writing to shift registers using the SPI peripheral on the AVR, it’s a no brainer for me. Look at Anushri or the Shruthi Programmer if you want to see how to multiplex many switches.
Encoders are a bit trickier since they need to be read at a fairly high rate (1kHz) if you want to be sure to detect all steps.
@pichenettes Thanks, using shift registers indeed looks like a fairly straightforward way to add buttons and LEDs. The number of encoders will be limited (the early design only uses a single one so far) so those can be wired to the controller directly.
An additional question: How would you add support for two brightness levels on the LEDs (off, 50% brightness, and full brightness instead of only off and on)?
Edit: I’ve found ways to do this by combining shift registers with software-based PWM but I was wondering if there’s a way to do it that takes less cpu resources.
Tripple slider switch with different resistors? Totally low level though
Use 2 Pins Out Pins from your Shift Register 2 Diodes and 2 different Resistors:
Out A-> Resistor 1 -> Diode |
Out A-> Resistor 2 -> Diode |
but I was wondering if there’s a way to do it that takes less cpu resources
I don’t think so, at least not through an heavy and complicated hardware modification.
But I don’t think such a mod would take a lot of CPU ressources. The trick to get half-lighting is to set a variable ‘y’ to #ff or #00 alternatively each time you update the leds configuration. You just output ‘xx&y’ instead of just ‘xx’ to the 595 and that’s it. With some luck it’s a matter of one memory byte and 2 CPU cycles, maybe 5 if you need to read into the ram, I hope there’s room for this? It’s more complicated to implement such a feature UI-wise.
edit : yes Frank’s proposition works but it means double all the leds, and being able to disconnect all leds from ground.
Another option is to modify the position of the current limiting resistors : you connect them between the leds and ground, and for that purpose you could even use only one resistor array. This way you just have to disconnect the terminal pin of your array from ground, and you can use only one set of diodes instead of 2 sets of diodes.
NapkinTech™ Schematics… this way you can dim the LEDs even in situations when your update Rate of the Shift Registers is loooooooow (less than say 25 Hz)
Before you ask: the Diodes are both necessary as most PICs AVRs et al can source AND sink current on the Digital Lines.
if you need to control 24 bicolor leds maybe you could also consider using 4 * TLC5940