MCP236 latency

General discussion of the MCP motion controller product line
Post Reply
larry
Posts: 5
Joined: Fri Mar 29, 2019 9:17 am
MCP236 latency

Post by larry »

Hi,

I have an MCP236 controlling a voice coil. I need a fast response time in my control. However, I am seeing 80+ms latency in any sort of commands that I issue over serial. I also tried writing a simple script that activates the voice coil on an analog input. The latency on that was also 80ms.
Is this normal input-> controller latency?
I am trying to get sub 1ms latency, is this possible?

Thanks,
Larry
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: MCP236 latency

Post by Basicmicro Support »

The likely cause of what you are seeing is the maximum allowed acceleration rate. The MCP will not let you change the duty from +100% to -100% in less than 100ms(eg 200% duty). At lower duty cycle changes you can get faster response(eg 50ms for a 100% duty change, 25ms for a 50% duty change etc). The user can decrease the acceleration/deceleration rate but they cant make it any faster than that.
larry
Posts: 5
Joined: Fri Mar 29, 2019 9:17 am
Re: MCP236 latency

Post by larry »

Hi,

I'm not sure if it is the maximum acceleration limits.
I tested PWM input, and that has around 20ms response.
My test setup: MCU Sends pwm signal and turns on an LED, and I film it using my iPad's 240fps camera (which gives me a 4ms time resolution). The motor does not move at all for 4 frames, and then starts accelerating slowly. 4 frames means 20.8 ms of delay.
Since the PWM sets the current, even with the acceleration limits, I should have seen some sort of movement.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: MCP236 latency

Post by Basicmicro Support »

Unfortunately that isnt MCP latency(mostly). The motor isnt going to start instantaneously when you apply power. Every motor has a mechanical time constant. That is how fast it will react to an input. Every motor also has friction(note that static friction from a dead stop is much higher than rolling friction once it gets going). Meassuring the latency of the mechnical system has more to do with specifications of the motor(mechanical time constant and static frioction) than the electronics. 20ms for a change in the mechanical state is actually pretty good. Most motor time constants are in the 100s of miliseconds range.

The electrical time constant of the Motor is also a factor. this is the time it takes current to rise to 63 precent of the expected value based on winding resistance and voltage. For example I have a motor with a 1ohm resistance and a 15mHenry inductance. Its electrical time constant is 15ms(L/R). Lets assume the static friction of the motor and any other load attached(gear box etc...) requires 20% maximum current to start turning(this will fall off once the motor starts moving and is probably on the low side buy this is just an example). That would mean the electrical time consts tells me this motor will not start spining for 4.76 milliseconds(15ms / 63 * 20.

To measure the latency of the MCP(eg the electronic latency) you need to use an oscilloscope to measure the time it takes for a change in the PWM input to cause a change in the motor PWM output.

I would estimate this would take at most 3.6ms. 1ms worse case is from your PWM input period(1khz input). Another 1ms is because commands are processed at a 1khz rate so worse case is another 1ms delay. Then when the command is queued the motor interrupt will process it when it checkes on its next cycle. That is checked 625 times a second(1.6ms). The actualy latency from input PWM cycle to input PWM cycle could be anywhere from just over 1ms to the maximum 3.6ms.

Post Reply