motorized faders via midi usb

Status
Not open for further replies.

Nick1802

Well-known member
hey all

i have looked and looked all over here and google and found very lil that would help me with this project.
what i aim to do with a teensy 3.1 as the brains using midi usb is a 15- 30 liner motorized fader system with 2 rows of back lit buttons above and below the faders.
and to the right i want to try and add around 70 more back lit buttons and 5 endless pots.

i am going with motorized faders so when i change fader pages the faders will move to where they should be and if i use the screen to move them they will move as well. so will need midi back i think :s

i have no idea as to what pins to use or what sketch to use

i want to use this with a pro lighting desk called grand-ma2 onpc.

thank you all in advance for all the help

thanks
nick
 
so far in the stuff that i think i need is
1. teensy 3.1
2. 20x 74hc4051
3. 15x 10k fader
4. 140x buttons

i dont no what gear i will need to have the motors work or what i will need to do

im sure i am missing a lot of stuff that i need to add to the list

any help will be great :)

thanks
nick
 
That is a fairly advanced project and will require external circuitry and code development. If that is your first project, it is unlikely to work. However, if you are willing to make tests with smaller subsystems (reading two faders. Reading and controlling two motorized faders. Reading four buttons. Using an external port multiplier to read a matrix of buttons. And so on) while also learning to write the code for each of those, then you will know enough by the end to combine them all into the one large project that you are thinking of and have it work.

That said, your plan is a good one. People commonly use rotary encoders (also commonly, but inaccurately, called endless pots) when the value can be changed both with the physical controller and also on the computer. But for linear movement, people use ordinary faders and then, when the value changes on the computer, the fader is at the wrong place. Worse, as soon as you move the fader, the value snaps back to the old position before moving with the fader. Motorised faders overcome that by using a motor to move the fader when the value is changed on the computer. They also typically have a capacitive sensor on the fader knob so that as soon as the operator touches the fader to move it, the drive to the motor is cut. You aren't fighting a motor, the value can be overidden at any time.

So for each fader you have
- an analog to digital channel reading the fader voltage
- a capacitive sensor reading whether the knob is touched
- a stepper motor controller which creates control signals for the high-power motor without allowing noise from the currents in that circuit to affect the ADC readings.

I'm more familiar with that for mix automation in audio, but for controlling lighting it is the same principle. Both can use MIDI (but you should check exactly which MIDI commands your lighting desk is expecting to receive. You should also check whether the desk can act as a USB host).

I will reiterate the advice to start small and gain experience. A linear motorized fader is not an inexpensive device. Buying 30 of them and 70 buttons and a pile of LEDs and wire and then hoping there is a ready made sketch somewhere to hook it all up is a recipie for disapointment. You probably know this and were not planning on doing that, but a warning is worthwhile for anyone with little experience reading the thread.
 
this is my 2nd project to work on, my 1st was artnet to led.
i will try in bits a pieces so like you said nantonos, i will be learning the code.
i'm hoping when i get it to the final stages i don't have to install any programs to go between it will be plug and play. hoping
i just had a lil play on the non pc version (which is what i want to base my layout on)
within the midi maping part i can map all these buttons in this pic expit for the fader, wheel and power on the right hand side
4khbae.jpg

and in this video as we described when changing pages the faders move
View My Video
but when i was watching what it was outputting in a window for midi it wasnt sending the new fader position :(
but in the mapping part it can let me set buttons as cmd line and if i can if its even possible make a cmd that move all faders down 1 bit which will then move all the faders to their position. (im guessing)

i have access to 2nd hand motorized faders at work (dont no if they have sensor though) but no buttons and will have to buy a new teensy as the other 1 is soldered into my other project

p.s. does it have to be 10k? or can i use 5k?? as i can find heaps on ebay that are 5k



***update*** i have just had a sec to jump on the desk again and though a macro i can get the desk to change page and send the new fader positions ***update***
 
Last edited:
http://www.mouser.com/ProductDetail/Bourns/PSM01-082A-103B2/?qs=sGAEpiMZZMslBFvnKnOhcgr21wIo31Wl Are very nice 100mm motorized faders with touch sensors from Bourns, as well. I've used them, they work very nicely. That particular model features a pair on snap-in connectors (a 2pin JST-XH for motor control, and a 7-pin JST-XH for everything else - datasheet has pinout descriptions). The only 'problem' with it is that you'll likely need custom cables for it - I've never been able to find a 7-pin JST-XH cable, and ended up hiring a company out here in CA to make some for me. That fader comes in another form with 'PC terminals' where they essentially expect you to make a custom PCB that would solder on directly to the fader.

To drive the motors, you'll need an H-Bridge. The STMicro L293D (plated through hole or DIP socket) or L293DD (SMD) work very nicely - you can control two faders with a single L293. There are a few manufacturers of L293's, but the STMicro ones have built in fly-back diodes. While you're apparently not really supposed to trust those, for these faders I've never had a problem with just using the internal diodes on the L293.

The other thing you'll need (this is why you need the H-bridge) is a 9v power supply. The H-bridge takes your logic-level voltage from the teensy, and boosts it up from that voltage to whatever input voltage you give it. The Bourns faders work from the range of I think 5v to 12v.

You'll also need TWO PWM pins PER MOTOR. That's going to be your biggest issue, I think. I'll run you through the pitfalls of my own testing with motorized faders for Skillet (www.schapiroaudio.com):

First, I tried controlling them directly from a Teensy ++ 2.0 (because it was 5v!) and using digital pins without PWM. This made it difficult to control (5v was moving the faders very slowly, and sometimes not at all). I figured out I needed an H-bridge, and set that up to work. Realized I really needed to use two pins for the motor control - both 'HIGH' or both "LOW" and the motor would be movable, and with the first HIGH and the second LOW, it would move in a direction - flip them (first LOW second HIGH) and it would go in reverse.

The problem then became actually getting it to sit at a particular value, as read by the internal slide potentiometer. You would get what I call 'flutter' due to your main Loop() function not really being capable of updating often enough. Say your fader is currently at position 826 (out of 1024), and you want to move it to position 352. So, you tell the motors to start moving 'down,' and then continue with the rest of your Loop() function. Next time Loop() gets to the fader section, it checks where the fader is, sees that it's at position 519, and says 'OK, keeping going down' and moves on again. Next time through, it sees that it's at position 307. "Oh, better go back up, I need to hit 352." Next time through, it's back towards position 483 ("Better go back down!").

Because you can only sample the fader so often, the fader is unlikely to actually ever exactly reach the position you're trying to get it to reach, and it comes across as a wild oscillation focused around the position you want it at. So the solution is two-fold: First, using PWM pins, means you can control the speed that the motor is moving at. You can slow the fader down, the closer it gets to the position you're aiming for. This is a really simple algorithm. Secondly, don't try and hit that position exactly. Give yourself a bit of a window - say you're trying to hit 352, but you'll really accept anywhere between 347 and 357 as an acceptable stop point. When the user grabs the fader to move it, that tiny difference in value isn't ever really going to be noticeable.

One last thing: There's information out there (I don't remember it offhand) about changing the PWM frequency. On a Teensy ++ 2.0 the PWM frequency defaults to somewhere around 4000hz - this is WELL within a human's audible frequency range, and keeping it at the default will make your faders sound like an dot matrix printer from 1987. Push that PWM frequency as high as you can possibly get it to go (somewhere beyond about 30,000hz is good). You'll still annoy cats and dogs (they can hear that!) but to humans it'll become inaudible.

Hope this helps a bit!
 
Last edited:
This sounds like a really awesome project. I'm really curious to hear how it goes.

Like all projects, of course it's best to prototype with just one or two faders to learn more about how they work and how you'll control them.

When you do scale up, keep an eye on the practical costs and ease of physical construction. Often in these large projects, focusing all the design effort to minimize electronics saves under $40 in chips but ends up costing far more in wiring, connectors, and physical construction. Sometimes minimizing costs results in a system that's incredibly difficult to troubleshoot or repair, and perhaps even prone to breakage (eg, hundreds of wires running all over the place). Sometimes a little extra on the electronics side can be well worth the investment.

But first just prototype 1 or 2, even on just a solderless breadboard.
 
When you get to the point of having 140 buttons in a device, you'll start running into the issue of where to actually put all the wires for those buttons, faders, and encoders! If you're only ever making one of something, prioritizing easy-building is probably better than cheapness and small-size. If you're actually planning to market something, and have the budget for it, you may be much happier handing as much of the build process off to a factory as possible. If you ARE planning on marketing your device, don't forget or skimp on the FCC EMI certification and testing! It's not cheap.
 
Last edited:
sweet thanks for all this info!!
so with the teensy 3.1 i can run 6 motor faders. is there anyway of having more PWM's on the teensy?
just so i no its possible for when i start on the small scale
thanks
nick
 
Niecaude: One big glaring problem with that board! Seems like you can only adjust the PWM frequency up to about 1.6Khz (1600hz), which I expect will be very, very audible through those motors. The PC9635 might be a better fit (from what I can tell from the datasheet, it operates with a 96Khz PWM output frequency: http://www.nxp.com/documents/data_sheet/PCA9635.pdf ) but I doubt Adafruit or someone similar has an easy-to-use breakout board for prototyping on that one.
 
Something like https://www.sparkfun.com/products/9106 might work well, though (32Khz frequency PWM). Just because I forgot to mention it before, human frequency range is around 20hz to 20Khz (if you're young and spritely). As you get older, that range goes way down, usually if you're 30 and can still hear up to about 14-16Khz you're doing pretty well. But you'll want to get that PWM as high as you possibly can, at least above about 24Khz.
 
Hey guys, been looking for the last couple of days trying to find keys similar to the photo I posted earlier. Does anyone no where I could find some?
 
hey everyone
so far on my shopping list
1 * Teensy
2 * PCA9635PW
8 * L293D
21* 74HC4051
170 * cherry mx black + caps (unless i can find buttons similar to the photo i posted earlier)
4 * ALPS STEC11B03 with push button switch
16 * aples rs60n11m9

is there anything else i have forgotten?

i wont be buying all this in bluk will only order lil amounts to get the code working 1st

at the moment i'm still trying to work out if the lighting console will even expect what i want to use the ALPS for so they may not be used.
 
Last edited:
hey all sorry i haven't posted any updates, been pulling big days at work lately.
anyway i have most of the parts i need for small scale, hand full of mx cherry black, soooo many diodes, 4 motored faders, 2 h-bridge, PCA9635PW chip (didn't expect it to be so tiny), 74HC4051
in the coming days I'm going to do a 4x4 matrix on the straight to the teensy and test it on midi
when i get that working i want to add the 74HC4051 chip and make it 8x8

i have a few questions though im sure its out there somewhere on the net but if you guys can help that would be even better :)
1) with the 74hc4051 chips can i combine there channel picking?? hopfully u will be able to see what i mean in the schematic
2) how do i add the 74hc4051 into the coding?
3) can someone look over my schematic and tell me if it looks alright, im sure its not the whole vee, vcc, etc confuse me alot and when i look this up i get 50 differnt answers so i guessed it and im sure its not right :(
4) can the 74hc4051 take touch sense of the faders in/out pin on the 4051 to on of the teensy's touch pins?
5) 1 thing i should has asked early on is the native midi that teensy does is it tone based or data? (if that makes any sense)

hope you guys can help :)
https://www.dropbox.com/sh/qkdmygk320mv5ai/AADEAvQ99jz4KpPCaM9pPH0qa/main board.pdf
 

Attachments

  • main board.jpg
    main board.jpg
    199 KB · Views: 1,215
Last edited:
i have a few questions though im sure its out there somewhere on the net but if you guys can help that would be even better :)
1) with the 74hc4051 chips can i combine there channel picking?? hopfully u will be able to see what i mean in the schematic

The image isn't viewable, but the PDF is good.

The main issue I see is a lack of pulldown resistors. It looks like you're transmitting 1 of 8 signals high into an incredible number of switches in a matrix, then looking to see which of 24 are high. The diodes on each switch are good, but without a pulldown resistor on the other side of the diode, the signal can't reliably be low when none of the switches in that group are pressed. I'd recommend adding pulldown resistors on D1 to D23, so those lines are low when none of the diodes conducts a high signal through a switch.

A lesser issue might be using the 74HC4051 to transmit. Those chips have a small series resistance. This will probably work, but using a chip like a 74HC595 to send 8 strong logic signals might be better.

2) how do i add the 74hc4051 into the coding?

Use digitalWrite() to set the control signals. Wait a brief delay to allow time for the signals to update. 100 microseconds is probably plenty. Then use digitalRead() to see if the inputs are high or low.

Then change the signals on the receive chips and repeat, until you've read all 23 signals. Then change the transmit signals, and repeat the whole process, until you've read all 8*23 combinations. Perhaps store the results into a big array as you do, so when you're done, you can then look at all the data and do whatever you'll do.

When reading the buttons is reliable, you might move it to a function you can call, so you're not tempted to fiddle with known-good code as you do the rest of your project. Or you might structure it so you do one combination of transit & receive per call to the function. Maybe later, you might run that function by checking an elapsedMillis variable or even an IntervalTimer, so it runs automatically and just update the array of numbers. But first, get the code working and well tested before you try to make it run more automatically!
 
The diodes on each switch are good, but without a pulldown resistor on the other side of the diode, the signal can't reliably be low when none of the switches in that group are pressed. I'd recommend adding pulldown resistors on D1 to D23, so those lines are low when none of the diodes conducts a high signal through a switch.

D1-D8 are transmit and D9-D56 are receivers. (D48-D56 will be on a different board
with the pulldown resistors will i need one on each button or just before the teensy?
with the pulldown resistor wont that pull the high to a low and what size pulldown do you recommend i should start with?
or are you talking about at the end of the transmit lines? as on all 6 lines that are on the pdf i have 10k pulldowns

A lesser issue might be using the 74HC4051 to transmit. Those chips have a small series resistance. This will probably work, but using a chip like a 74HC595 to send 8 strong logic signals might be better.

cool i will order one, but for now i will use to 4051 until it arrives.

Then change the signals on the receive chips and repeat, until you've read all 23 signals. Then change the transmit signals, and repeat the whole process, until you've read all 8*23 combinations. Perhaps store the results into a big array as you do, so when you're done, you can then look at all the data and do whatever you'll do.

sweet so the way i have the receivers wired up should work. :)

thanks
 
update
so i have done a 4x2 matrix works fine when i dont have ground connected :S i had ground connected on the write line after the buttons.

so with the lil bit of success i moved onto using the 4051 chip as a receiver. but i cant get it to work :S

Code:
#include <Bounce.h>
// Example of using the 74HC4051 multiplexer/demultiplexer

// Author: Nick Gammon
// Date:   14 March 2013

// where the multiplexer in/out port is connected
const byte sensorreturn1 = 8;  
// the multiplexer address select lines (A/B/C)
const byte addressreturnA = 7; 
const byte addressreturnB = 6;
const byte addressreturnC = 5;

void setup ()
  {
  Serial.begin (115200);
  Serial.println ("Starting multiplexer test ...");
  pinMode (addressreturnA, OUTPUT); 
  pinMode (addressreturnB, OUTPUT); 
  pinMode (addressreturnC, OUTPUT); 
  
  
  }  // end of setup

int readSensor (const byte which)
  {
  // select correct MUX channel
  digitalWrite (addressreturnA, (which & 1) ? HIGH : LOW);
  digitalWrite (addressreturnB, (which & 2) ? HIGH : LOW);
  digitalWrite (addressreturnC, (which & 4) ? HIGH : LOW);
  // now read the sensor
  return digitalRead (sensorreturn1);
  }  // end of readSensor
  
void loop ()
  {
  // show all 8 sensor readings
  for (byte i = 0; i < 7; i++)
    {
    Serial.print ("Sensor ");
    Serial.print (i);
    Serial.print (" reads: ");
    Serial.println (readSensor (i));
    }
  delay (1000);
  }  // end of loop

when using this code it only goes from 0 to 6 instead of 0 to 7 and it doesnt read any button being pushed

i do think it could be the way i have it wired up
i have the buttons connected to 3.3v
the 4051 is on 5v
and the teensy is running off usb power

hope you guys can help

when i did the 4x2 i used the example - keypad - mutikeys

thanks
nick
 
ok so i have gotten out the trusty multimeter and its telling me everything is working the way it should be except when all 3 control pins are on high i only get 1.6v out of each pin instead of the 3.3-3.5v that it is userly putting out

i tested it by making the 4051 stay on one button but the serial print still isnt showing buttons being pressed
 
Last edited:
hey all,
i ended up putting my teensy on a external power witch fixed the teensy not putting out the 3.3v.
im still having issues with the return to the teensy. with the multi its showing that the teensy is receiving 3.28v on the input pin, but the serial monitor is showing

when set to analogRead pin =A0

Sensor 0 reads: 1022
Sensor 1 reads: 796
Sensor 2 reads: 724
Sensor 3 reads: 460
Sensor 4 reads: 704
Sensor 5 reads: 426
Sensor 6 reads: 242
Sensor 7 reads: 157
Sensor 0 reads: 1022
Sensor 1 reads: 808
Sensor 2 reads: 742
Sensor 3 reads: 467
Sensor 4 reads: 705
Sensor 5 reads: 431
Sensor 6 reads: 245
Sensor 7 reads: 163

but when its set to digatalRead pin = 14

Sensor 0 reads: 0
Sensor 1 reads: 0
Sensor 2 reads: 0
Sensor 3 reads: 0
Sensor 4 reads: 0
Sensor 5 reads: 0
Sensor 6 reads: 0
Sensor 7 reads: 0
Sensor 0 reads: 0
Sensor 1 reads: 0
Sensor 2 reads: 0
Sensor 3 reads: 0
Sensor 4 reads: 0
Sensor 5 reads: 0
Sensor 6 reads: 0
Sensor 7 reads: 0

how do i get digital sensor 0 to read 1? and in the analog y are 1-7 so high when it should be 0?
 
worked out y they where so high(i think). was couse i didnt have the unused pins grounded. still cant get the digatalread to work though :( .
my work around in the mean time for it using analogread is:
Code:
for (byte i = 0; i <=7; i++){
	if (readSensor(i) <950 ) {
	   Serial.print(i);
	   Serial.println(" Button is not pressed...");
	} else {
	   //Button is pressed
	   Serial.print(i);
	   Serial.println(" Button is pressed!!!");
	}
  }
looks to work alright

and have the faders reading alright (yeppie)

now im working on the touch sensers in the faders but at the moment im having quite a bit of trable with them
at the moment its reading over 3000 give or take 20ish when connected via the 4051 and when i touch the slider it looks like its changing but very little

when i bypass the 4051 its just over 2000 and when touched jumps by around 20

i dont no if i am ment to have anything eles

hope any 1 can help. im stuck

thanks in advace
nick
 
hey all,
still cant workout the touchRead() :( every thing that i can find require 2 pins or have the person be grounded somehow and both i don't see working with the project that im working on.


this is the code i have at the moment

Code:
#include <Encoder.h>

const byte sensor0 = 16;// where the multiplexer in/out
const byte sensor1 = 14;// port is connected
const byte touch0 = 0;
const byte addressA = 2; // the multiplexer address
const byte addressB = 3; // select lines (A/B/C)
const byte addressC = 4;
Encoder myEnc0(9, 8);

void setup ()
  {
  Serial.begin (115200);
  pinMode (addressA, OUTPUT); 
  pinMode (addressB, OUTPUT); 
  pinMode (addressC, OUTPUT); 
  }
long oldEnc0  = -999;

int readSensor0 (const byte which)
  {
  digitalWrite (addressA, (which & 1) ? HIGH : LOW);
  digitalWrite (addressB, (which & 2) ? HIGH : LOW);
  digitalWrite (addressC, (which & 4) ? HIGH : LOW);
  delay(200);
   return analogRead (sensor0)*0.125;
 } 
int readSensor1 (const byte which)
{
  digitalWrite (addressA, (which & 1) ? HIGH : LOW);
  digitalWrite (addressB, (which & 2) ? HIGH : LOW);
  digitalWrite (addressC, (which & 4) ? HIGH : LOW);
  delay(200);
  return analogRead (sensor1);
 }
int readtouch0 (const byte which)
{
  digitalWrite (addressA, (which & 1) ? HIGH : LOW);
  digitalWrite (addressB, (which & 2) ? HIGH : LOW);
  digitalWrite (addressC, (which & 4) ? HIGH : LOW); 
  delay (200);
  return touchRead (touch0);
}
void loop (){
  encoder_read();
  button_scan();
}  
 void encoder_read() {
  long newEnc0;
  newEnc0= myEnc0.read();
  if (newEnc0 != oldEnc0) {
    Serial.print("Enc0 = ");
    Serial.println(newEnc0);
    oldEnc0 = newEnc0;
  }}
	
 void button_scan() {
  for (byte i = 0; i <=7; i++) {
    Serial.print ("IC 0, Sensor ");
    Serial.print (i);
    Serial.print (", reads: ");
    Serial.println (readSensor0 (i));
    if (readSensor1(i) >950 ) {
	   Serial.print("IC 1, Sensor ");
           Serial.print(i);
	   Serial.println(" is pressed!!!");
	}
    Serial.print ("IC 2, Sensor ");
    Serial.print (i);
    Serial.print (", reads: ");
    Serial.println (readtouch0 (i));
    }}

sometime soon i am going to try and start working on moving the motors on the faders

will post photos of the breadboard soon (it is a but of a mess)

todo's
touch
motor faders move
midi
touch activate send of fader location
midi return to move fader from computer
make pcb
 
hey is anyone reading anything i post???

i have a strange problem with my teensy!!
at the moment im working on getting a matrix of 8*16 to work and this code i have just got working
but when i upload this code
Code:
const byte sensor0 = 20;
const byte sensor1 = 21;
const byte reciverA = 14;
const byte reciverB = 15;
const byte reciverC = 16;
const byte transmitA = 17;
const byte transmitB = 18;
const byte transmitC = 19;
int v=0;
int w=0;

void setup() {
Serial.begin(115200);
pinMode(reciverA,OUTPUT);
pinMode(reciverB,OUTPUT);
pinMode(reciverC,OUTPUT);
pinMode(transmitA,OUTPUT);
pinMode(transmitB,OUTPUT);
pinMode(transmitC,OUTPUT);
pinMode(sensor0,INPUT);
pinMode(sensor1,INPUT);
}

int readKeyboard() {
int j,i,row,col,v, x, code;

code=0;
for(i=0;i<=7;i++) {
for(j=0;j<=7;j++) {
code++;
// address X
  {
  digitalWrite (transmitA, (i & 1) ? HIGH : LOW);
  digitalWrite (transmitB, (i & 2) ? HIGH : LOW);
  digitalWrite (transmitC, (i & 4) ? HIGH : LOW);
}
// address Y
  {
  digitalWrite (reciverA, (j & 1) ? HIGH : LOW);
  digitalWrite (reciverB, (j & 2) ? HIGH : LOW);
  digitalWrite (reciverC, (j & 4) ? HIGH : LOW);
  analogRead(sensor0);
  analogRead(sensor1);
}
//delay(100);

// Read the actual Value
v = analogRead(sensor0);
w = analogRead(sensor1);
/*
Serial.print("Row: ");
Serial.print(j);
Serial.print(",Col: ");
Serial.print(i);
Serial.print("),IC1: ");
Serial.print(v);
Serial.print(" ,IC2: ");
Serial.println(w);
*/
if(v==1023)
{
return code;
}
if(w==1023) 
{
  return (code+64);
}
}
}
}

void loop() {
v = readKeyboard();
if(v>0);
{
 Serial.println(v);
}
delay(100);
}

and start the serial monitor
some times it shows a string of 0's when no button is pushed witch is right but if i upload the code again it some times it does a string of 1's when no button is pushed witch is not right and i dont no what is coursing it :(

i have attached a pdf of how i have it wired up but i forgot to put on it all the unused pins on the 4051's are connected to ground!
HTML:
https://www.dropbox.com/s/3jfw4iboehgbnck/matrix1.pdf?dl=0
 
Status
Not open for further replies.
Back
Top