Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motorized fader guidance #6

Open
PJordan2820 opened this issue Oct 26, 2021 · 7 comments
Open

Motorized fader guidance #6

PJordan2820 opened this issue Oct 26, 2021 · 7 comments

Comments

@PJordan2820
Copy link

Hello Pieter. I hope you are doing well!

I'm really new in the world of Arduino and programming. I want to connect 2 motorized faders with Logic Pro X and I've been investigating a lot on how to do it. I tried following the documentation in this repository, but I'm not sure how proceed. I have several questions and I hope that you could point me in the right direction.

  1. I wanted to use an Arduino Pro Micro, because I can use a USB-C port that way. Would this work? (I also got an Arduino Uno and an Arduino Nano)
  2. I followed the instructions in the hardware section, connecting the recommended capacitors, pullup resistors, and motor driver as indicated... I believe that there are some connections that are not explained since they come as obvious (L293D to ground, the motor terminals to Y1 and Y2, external power supply to VCC2). Am I missing something else that is not explained in the hardware section?
  3. Do I have to make my Arduino Uno or Nano Midi Class Compliant after I upload the code to them?
  4. Since I'm a beginner in programming, most of the code is really hard to understand for my level. (I'm trying to learn as much as I can). Do I have to modify some of the code (comment lines, change values, etc.) to make the project work? Or should it work just uploading it as it is?
  5. I understand that the contents of the repository are: Motor-Controller, MIDI-Controller and a Python Script that allows communication over Serial to change the response of the faders. I'm not really sure what to do with de Motor-Controller and MIDI-Controller sections though. The motor controller section is conformed by 10 files. What I'm currently doing is opening "main.cpp" and uploading it to my board, making sure that the rest of the files remain in the same folder. I did the same with the "MIDI-Controller.ino" file, but I'm guessing that I have to include it in the Motor-Controller folder instead.
  6. I also got a TB6612FNG. Are the circuit and code basically the same?
  7. Is it a good idea to include a diode or transistor as protection? (just in case someone decides to plug a different power supply)

Nothing is really happening when I upload the code,and I'm getting frustrated. I didn't expect motorized faders such a different project from non-motorized ones... There isn't that much documentation on the subject and I don't know where to keep digging.

@tttapa
Copy link
Owner

tttapa commented Oct 26, 2021

  1. I wanted to use an Arduino Pro Micro, because I can use a USB-C port that way. Would this work?

For the MIDI-Controller code, yes.
The Motor-Controller is written for the ATmega328P specifically so it won't work on the Pro Micro without changes.

  1. I believe that there are some connections that are not explained since they come as obvious

Indeed, I only documented the connections specific to the Arduino code, for the non-Arduino specific connections, it's best to look at the typical application diagrams in the datasheet.

Am I missing something else that is not explained in the hardware section?

Bypass capacitors, maybe? See section 10 of the datasheet.

  1. Do I have to make my Arduino Uno or Nano Midi Class Compliant after I upload the code to them?

I'm not sure what you mean, the Uno and Nano do not support MIDI over USB, they only run the motor controller code. A second Arduino (e.g. Pro Micro) will run the MIDI code and communicates with the motor controller Arduino over I²C. You don't need to do anything beyond uploading the code to make the Pro Micro act as a MIDI USB device.

  1. Do I have to modify some of the code (comment lines, change values, etc.) to make the project work? Or should it work just uploading it as it is?

It should work as is, but you might want to change some settings in the Config struct, e.g. enable the test reference to test the motor controller stand-alone:

// Follow the test reference trajectory (true) or receive the target
// position over I²C or Serial (false):
static constexpr bool test_reference = false;

Or change the pin assignments if you're using an Arduino Uno, or change the number of faders:

// Number of faders, must be between 1 and 4:
static constexpr size_t num_faders = 1;

You'll also have to tune the PID controllers:

// The main PID controllers. Need tuning for your specific setup:
PID controllers[] {
// This is an example of a controller with very little overshoot
{
6, // Kp: proportional gain
2, // Ki: integral gain
0.035, // Kd: derivative gain
Ts, // Ts: sampling time
60, // fc: cutoff frequency of derivative filter (Hz), zero to disable
},

Use the Python script to do the tuning.

  1. I'm not really sure what to do with de Motor-Controller and MIDI-Controller sections though.

The Motor-Controller code should be uploaded to an Arduino Nano or Uno, and the MIDI-Controller code should be uploaded to a separate MIDI-capable microcontroller, (e.g. Pro Micro). Both microcontrollers should be connected to the same I²C bus so they can communicate the fader positions, target positions etc.

For tuning the controllers, you only need the Nano or Uno and connect it to the computer running the Python script over USB.

  1. Are the circuit and code basically the same?

The code is the same, but check the datasheet and Sparkfun hookup guide for the circuit. The connections to the Arduino should be similar, though.

  1. Is it a good idea to include a diode or transistor as protection? (just in case someone decides to plug a different power supply)

I usually don't, but that might not be a bad idea, that's up to you.

Nothing is really happening when I upload the code

The Motor-Controller code doesn't do much unless you send commands to it over I²C or Serial, or unless you enable the test_reference option. Otherwise, it just uses zero as the target position, so it should turn on the motor when you move the fader away from zero, but it won't do much else. If it doesn't even turn on the motor, there might be something wrong with the wiring. Another reason could be that it constantly thinks that the fader knob is being touched, you might want to play with the RC time threshold. You can enable the print_controller_signals and open the Serial Monitor of the Uno/Nano to debug, see if the position measurement of the fader works correctly, etc.

@PJordan2820
Copy link
Author

Great! Thank you for your response.
I've uploaded the code to the Pro Micro and Uno boards, and connected the boards to each other.

I enabled print_controller_signals and values are changing when I touch and move the fader. But my computer isn't receiving MIDI messages from the Pro Micro. I feel that it has something to do with the communication over I²C.

I've attached a Tinkercad diagram based on my real circuit. (I've connected "A4" and "A5" (UNO) to "2" and "3" (Pro Micro, since those are the SDA and SCL ports in that board).

Motorized Faders

@PJordan2820
Copy link
Author

Now the Pro Micro is showing values in Serial Control, so I2C is working. But still, my computer isn't receiving MIDI messages. I don't have to do anything with something like Hariless MIDI, do I?

Also, how would I make the fader send MIDI CC 1? Through Sisex messages?

@tttapa
Copy link
Owner

tttapa commented Oct 28, 2021

If you want to use MIDI over USB, you have to use a USBMIDI_Interface:

USBDebugMIDI_Interface midi; // MIDI interface to DAW

Also, how would I make the fader send MIDI CC 1? Through Sisex messages?

What do you mean? How does your DAW communicate with motorized faders? Usually pitch bend is used, not CC or SysEx. You could of course change the MIDI-Controller sketch to send CC or SysEx messages instead, that's explained in the Control Surface documentation, but I don't think that would be useful.

@PJordan2820
Copy link
Author

Sorry for my late response...
I found out what my problem was!

I just had to set up the Arduino as a Mackie Control device (I didn't get why the fader sent pitch bend messages until now) But I moved on just to find another problem. The response of the fader is rather clunky, and if I don't move it ridiculously slow, it starts moving up and down really fast. The only way to stop it is to move the fader in my DAW to +6db or -inf. Any position in between gives the same result.

Does it have something to do with calibration?

@PJordan2820
Copy link
Author

Found out what the problem was. Wrong bypass capacitor value.
The fader is working correctly in Ableton Live 11. But I couldn't make it work in Pro Tools, a message appears saying that the DAW can't communicate with the HUI. And in Logic Pro, the fader won't reach its maximum travel when I move the fader inside the DAW, it is approximately 1cm short. Logic's MIDI monitor shows that the highest value in the output when the fader is at +6dB is 123, not 127.

Also. I'm not sure what to do with PWMA when working with the TB6612FNG. Should I just connect it to VCC? The fader gets stuck at the top if I do it that way.

@tttapa
Copy link
Owner

tttapa commented Dec 5, 2021

a message appears saying that the DAW can't communicate with the HUI

The Mackie HUI is not the same as the MCU. Either way, it might send some SysEx messages to make sure it's connected to the right device. You can find the appropriate responses in e.g. the Logic Control user manual (for MCU), or look for reverse engineering documents of the HUI online.

Also. I'm not sure what to do with PWMA when working with the TB6612FNG. Should I just connect it to VCC?

Looking at the datasheet that would be the right thing to do, but I've never used it so I'm afraid I can't really comment on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants