saarts / MIDI

Code for DIY style USB-MIDI controller
7 stars 3 forks source link

Fader A/D resolution #2

Open daxliniere opened 3 years ago

daxliniere commented 3 years ago

Hey there Saarts!

I was looking through your code and spotted on Line 235 that the analog fader reading is mutliplied by 16.

Would I be correct in thinking that the resolution of the fader is only 1024 points and this is why it's multiplied to match the scale of the MIDI volume control?

If so, what if an external ADC was used? I guess then the map() command could be used?

Love to hear your thoughts.

All thr best, Dax.

saarts commented 3 years ago

Ah, yes. If I remember correctly, atmega32u4 has ADC resolution of 1024. The MIDI protocol specifies that a pitch bend value scales from 0 to 16,383. In the end, the pitch bend value is used for volume control. Therefore I just multiplied ADC value by 16 to send it to the PC. On the PC Arduino acts like a Mackie HUI, I believe. 1024 point precision for 100 mm of travel of the fader is accurate enough, I think. In practice the I was able to get around 0.1 db precision in the DAW. The biggest problem with the accuracy is the friction of the fader. It is hard to make it stop at exactly where we want it if its controlled by the motor and it is hard to make fine adjustments by hand. The static friction is of a lot higher value compared to the dynamic friction, that means, when we are finally able to move the fader, it will move quite a bit. I used quite a dumb method of movement control. Comparing current position to requested position and using two levels of speed. Faster, when the distance is greater, slower when near the target. In the future I will probably experiment with PID. Another idea for the future would be to experiment with different sensitivity areas. Usually it is not that important to be 0.1 accurate at -50db levels. in short, making the fader kind of similar to logarithmic pot by using linear multipliers.

I am still thinking about revisiting the project and making a YouTube video about it. Broke the USB socket, therefore it needs fixing anyway.

daxliniere commented 3 years ago

Yeah, cool. I just bought a 4 channel 16-bit ADC board with I2C interface for a couple bucks. But I was planning on experimenting with the built-in 10-bit ADC first to see if 16-bit is even necessary for 100mm of travel.

There is an Arduino PID library available which could be useful.

Would you like to collaborate on this? I have bought parts for a 4 fader interface and the plan was to add OLED screens for each channel, too. I was vaguely toying with the idea of switching to OSC (Open Sound Control) as I would be able to put RGB LEDs on each of the OLEDs to show DAW track colour.

All the best, Dax.