Servo Motor Interface with PSoC 3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Fellow Community Members,

   

 

   

Recently I got a chance to lay my hands on a simple servo motor (of type TS-53), which had to be interfaced with PSoC 3. Thought of sharing it on the forum.

   

 

   

This interface required the PSoC to give a PWM signal with the high pulse varying between 1ms and 2ms. 1 ms corresponding to 0 degrees and 2ms corresponding to max rotation possible (close to 150 degrees in my case).

   

The dead time between the two pulses was 40ms.

   

The on-board potentiometer available on CY8CKIT-001 was used to vary the position of the shaft.

   

 

   

The project is attached along with this post. It may come handy if someone is working on similar servos.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

That is a pretty nice and short project!

   

I took the opportunity to change some things, have a look into it.

   

And if anybody has an idea for improvements post your suggestions or show up your code!

   

 

   

Bob

View solution in original post

0 Likes
10 Replies
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

That is a pretty nice and short project!

   

I took the opportunity to change some things, have a look into it.

   

And if anybody has an idea for improvements post your suggestions or show up your code!

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Looking for an actual datasheet with control specs was fruitless, but I found the following -

   

 

   

http://www.princeton.edu/~mae412/TEXT/NTRAK2002/292-302.pdf

   

 

   

and this

   

 

   

http://www.electro-tech-online.com/custompdfs/2011/10/PWM.pdf

   

 

   

0 - 2 mS all, 20 or 40 mS dead time.

   

 

   

Regards, Dana.

Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I din't yet look into your supplied datasheets but GRAUPNER's servos are suggested to run with

   

1 (not 0!!) to 2 ms and a suggested repitition rate of 20ms. Some servos assume at 50ms a loss of connection ad go into a hold or a programmed position.

   

 

   

Bob

Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

... and found this     http://en.wikipedia.org/wiki/Servo_(radio_control     ) in Wikipedia

   
   

Bob

ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Typo on  my part, concur its 1 - 2 mS.

   

 

   

Regards, Dana.

Anonymous
Not applicable

Thank you Bob, for restructuring and making the code readable.

   

I had initially assumed that the "dead time" had to be held constant at 40ms, hence used to update the period too.

   

Apparently the dead time has to be optimal. If the control signal is fed too quickly, the servo will buzz and jitter. I found it happen when the dead time was set to less than 10ms. On the other hand, if the repeat signal is too slow (more than 70ms), the servo will shut off between signals and its position will not remain constant.

0 Likes
Anonymous
Not applicable

Thanks for sharing the resource Dana!

   

That's a very useful piece of info.

   

 

   

 

   

Regards,

   

Gautam

0 Likes
Anonymous
Not applicable

 Hello,

   

I am a student and new to PSoC. My current project requires me to write a code in C++ to drive a servo motor using PWM (PSoC5).

   

I am not only new to PSoC but also new to C++. 

   

Any help would be appriciated.

   

Thanks alot and hope to hear back from some of you.

   

Nabil Ahmed.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Writing code in C++ for PSoCs is a bit complicated, using simple C is much more easier. Download from the Cypress website Creator 3.0 and start with ADC-example, look for PWM-example and put them both together with a self-written closed-loop and you are done!

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Reference material attached that may be of help.

   

 

   

When you select a component in Creator, if you right click it, pick find example project,

   

you can add that to your workspace or open in a new window. Then cut and paste

   

code into your design. So a PWM is a natural fit for servo controller, the example

   

use of a PWM will help you.

   

 

   

Regards, Dana.

0 Likes