This is the continuation of the hooking up post. I had some experiments with the encoder interface. I set up another timer, to read the encoder interface TIM3 value regulary (each 5 ms). I found out, that the resolution of this method is far from enough. And the latency is 5ms or more.
The counter value fluctuates between 23 and 24 for the 5ms period. Now I only have 2 values between 0 and +8% pitch positions. It means that my pitch granularity is 4%. I cannot recognize if I move the pitch slider between 0-4%. It is obviously not enough for correct beatmixing, I need 0-4%- 0,1% or 20-80 values for the pitch range. I need to modify my original idea and not using the encoder interface mode.
Input Capture instead of Encoder mode:
I reconfigured TIM3 to use Input capture mode. The time base (resolution) is 1us. The reconfigured timer interrupts each time I have a rising edge on the encoder square wave, and the counter counts the elapsed time between them in microseconds. At each interrupt, I also read the level of the second encoder channel to calculate the direction of the rotation.
The base frequency of Tascam TT-M1 square wave is around 1220Hz if the platter turns with 33 1/3 RPM. Of course it depends on the radius where I put the unit. With this 1220 Hz base frequency the timer measures usually 840us between rising edges.
The fluctuation is between 832-848. I am using a running average of 256 values, that filters out somefluctuation. I need to work on it later, but now I have a somewhat constant 840 value for the turning platter of my Technics 1210. I have almost 70 different values for my 0% – 8% pitch range. That is better than 0,2% resolution. I could double the resolution by setting up my TIM3 to 0.5us time base. I’ll see later if it makes sense.
Emulate a touch sensitive jogwheel:
To emulate a proper MIDI controller jogwheel I have to implement:
– jogwheel touch and release for scratch
– jogwheel move back and forth for pitchband and scratch
– sense if the platter is still and does not generate interrupt
– pitch slider position
This is a bit difficult because the turntable platter turns during normal operation, however the midi jogwheel is not. I have to substract the rotation which is more complicated than it sounds, and I have to incorporate an intelligent handling of touch event.
I have to send out a MIDI note on and off message each time I touch the vinyl to reproduce the scratch function of an MIDI controllers touch sensitive jogwheel. The software changes from pitchband to scratch because of this event. In a later post I may will describe how I sense if the vinyl has been touched.
If I have Input Capture interrupt, and no Update Interrupt for TIM3, than the platter moves. The direction is read as I mentioned. The speed of the rotation can be calculated with the TIM3 counter value. If I’m not scratching and the vinyl platter is not touched, I have to substract the normal speed average from the current one, because the jogwheel of the MIDI controller is still.
If the platter is still and not rotating, I have no Input Capture Interrupt. So I set up the TIM3 perdiod to overrun each 10ms. I am using TimeBase mode also with the Input Capture mode, so I have an Update interrupt each 10ms. This way the lowest frequency I can measure is 100Hz. If the plater moves slower than this, I consider it to be still.
The pitch slider position should be calculated from the average of the rotation speed. But only when the vinyl is not touched. So if the speed changes slowly enough, than it is the pitch slider that has been moved.