Page 1 of 1

Problem with Servo timing (Flowcode 6) with ECIO40P16

Posted: Sun Feb 08, 2015 11:59 pm
by paulm
Hi,

I have modified the "Single_servo_motor_control.fcfx" example on the wiki page for Flowcode 6 to try and drive a Tower Pro "SG-5010" Servo motor using the ECIO40P16. The example is "Servo Example 1":-
http://www.matrixtsl.com/wiki/index.php ... tronics%29

The specs of the motor are as follows:-
Rotational Range 180Degree
Pulse Cycle:- 20mSec
Pulse width 600-2400uSec

I modified the example above (see attached) with the timing that is indicated above for the motor, however when I connected the Servo up I noticed the movement was no where 180 degrees rotation of the shaft (it was approx. 70 degrees) and the motor was making a funny noise at the smaller pulse width. At that point I measured the pulse widths with an oscilloscope and found that the pulse width was approximately 0.49mSec @600uSec and 1.1mSec @ 2400uSec setting.

I also measured the pulse period and assumed that this would be 20mSec but this measured approximately 19.7mSec.

The biggest discrepancy is obviously the 2400uSec measuring 1.2mSec.

I have attached the flowcode file. Is there a bug with the timing or am I doing something wrong?

Finally, I noticed in the parameter section of the servo controller that "Divider" is set to yes. I tried setting this to "No" but it would not let me change it. What is this parameter used for and why wont it let me change it?

Regards,
Paul

Re: Problem with Servo timing (Flowcode 6) with ECIO40P16

Posted: Tue Feb 10, 2015 12:51 pm
by paulm
Can anyone please advise?

Re: Problem with Servo timing (Flowcode 6) with ECIO40P16

Posted: Tue Feb 10, 2015 4:39 pm
by Benj
Hello Paul,

I have looked into this and there does seem to be a bit of a timing issue on this device. I will see if I can get this issue resolved.

Here are the timings I am getting.

Max - 2400us = 1068us
Min - 600us = 469.8us
Freq 52 Hz

so this seems to tally up with what your finding.

Interestingly if I change the timings back to the defaults then this is what I am getting.

Max - 2500us = 2270us
Min - 1280us = 1001us
Freq 50 Hz

So the frequency becomes correct but the timings are still a little lower than they should be.

The Divider property should not be visible and is auto calculated based on clock speed so I will also make sure this gets hidden from the user.

Re: Problem with Servo timing (Flowcode 6) with ECIO40P16

Posted: Tue Feb 10, 2015 5:49 pm
by Benj
Hello,

It looks like the problem is to do with the speed of the peripheral. If we divide by 8 then we can do the range 1280 - 2500 quite well. However this doesn't work well for the 600us.

If there is no divide then we can do the 600uS delay well but then the max delay becomes around the 1.2ms you were experiencing.

So the maths is right but the chips only has a 16-bit timer CCP timing peripheral and so it might not be 100% possible.

Have you tried the servo with the default values of 1280 and 2500? My guess is these should work very well in practise to give you 180 degrees of movement.

I will have a think about ways we can try to improve this but I don't imagine this will be something we will fix immediately and might not even be possible due to the limitations of the chips and the way we are bit banging the servo outputs.

Re: Problem with Servo timing (Flowcode 6) with ECIO40P16

Posted: Wed Feb 11, 2015 12:56 am
by paulm
Hi,

yes I have tried the default values of 1280 and 2500.

Since the pulse width is only from 1000uSec to 2270uSec (i.e. net difference 1270uSec) this only represents 127Degrees of movement since the full range of the pulse is meant to go from 600uSec to 2400uSec (i.e. net difference of 1800uSec).

I have verified that the movement is as expected (i.e. 127 Degrees) on the actual Servo.

Regards,
Paul

Re: Problem with Servo timing (Flowcode 6) with ECIO40P16

Posted: Wed Feb 11, 2015 12:23 pm
by Benj
Hi Paul,

I've had a quick go at fixing this issue but can't find an easy way to satisfy all the criteria. I've added the problem to the bugs list and hopefully we can improve this in the future for the ECIO40P16 target.

Re: Problem with Servo timing (Flowcode 6) with ECIO40P16

Posted: Thu Apr 02, 2015 3:10 pm
by Benj
Fix for this now coming in the next release. Seems to be working well now but needs more testing.