tttapa / Control-Surface-Motor-Fader

Arduino motorized fader controller, and example code for integration with the Control Surface library.
https://tttapa.github.io/Pages/Arduino/Control-Theory/Motor-Fader/
GNU General Public License v3.0
107 stars 10 forks source link

Motorized fader guidance #6

Open PJordan2820 opened 3 years ago

PJordan2820 commented 3 years ago

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 commented 3 years ago
  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:

https://github.com/tttapa/Control-Surface-Motor-Fader/blob/9b20111e7eb25f09a17da3a1a4eb6438c0d54247/Motor-Controller/main.cpp#L101-L103

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

https://github.com/tttapa/Control-Surface-Motor-Fader/blob/9b20111e7eb25f09a17da3a1a4eb6438c0d54247/Motor-Controller/main.cpp#L111-L112

You'll also have to tune the PID controllers:

https://github.com/tttapa/Control-Surface-Motor-Fader/blob/9b20111e7eb25f09a17da3a1a4eb6438c0d54247/Motor-Controller/main.cpp#L193-L203

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

If you want to use MIDI over USB, you have to use a USBMIDI_Interface: https://github.com/tttapa/Control-Surface-Motor-Fader/blob/9b20111e7eb25f09a17da3a1a4eb6438c0d54247/MIDI-Controller/MIDI-Controller.ino#L14

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.