This version handles the vinyl speed correctly while scratching. I made some modifications. I’m using TIM8 input capture while not scratching and to jump into and out of scratch mode (touch on and off events) because it’s more punctual to measure frequency.
And I’m using TIM3 in encoder mode while scratching, because with that I can count the ticks of both the rising and falling edges of both channels of the encoder, without any interrupt or code. It gives me 4 times the resolution than if I counted the input capture interrupts.
And another video with master tempo and synch working properly.
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.
I wrote about my working HID interface in the previous post. Now I can send data to my laptop in a convenient way in a simple HID report because I wrote a Delphi program to send and receive HID reports years ago.
Next step is to wire the Tascam TT-M1 scratch control unit to the board. As STM32F4 series have quadrature encoder interface in some timers, I can easily count the pulses without any line of code in my main loop or without using more interrupts or processor load.
In my previous post I mentioned that my audio interface crashes after a while. I also mentioned that my guess it is because of the non-scheduling my different USB transefers. So I did it.
I used the SOF (Start-of-frame) interrupt as my 1ms timebase.This interrupt has to be enabled in the USB device configuration part, because it’s disabled by default. In other words simply replaced my HAL_GetTick() function which is based on the counter incremented each 1ms in the SysTick interrupt. My similar function is the USB_GetTick() which is based on the counter incremented each 1ms in the USB SOF interrup.
This is the new waveform I have. The start of the HID report transfer is in a fixed time slot. It comes after 718us always. And it completes of course in the end of the frame.