You are here

Servo Motor Interface with PSoC 3 | Cypress Semiconductor

Servo Motor Interface with PSoC 3

Summary: 10 Replies, Latest post by danaaknight on 14 Nov 2013 04:38 PM PST
Verified Answers: 5
Last post
Log in to post new comments.
dasg's picture
Cypress Employee
730 posts

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.

user_1377889's picture
User
10803 posts

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

user_14586677's picture
User
7648 posts

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.

user_1377889's picture
User
10803 posts

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

user_1377889's picture
User
10803 posts

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

Bob

user_14586677's picture
User
7648 posts

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

 

Regards, Dana.

dasg's picture
Cypress Employee
730 posts

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.

 

dasg's picture
Cypress Employee
730 posts

Thanks for sharing the resource Dana!

That's a very useful piece of info.

 

 

Regards,

Gautam

nabil's picture
User
1 post

 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.

 

user_1377889's picture
User
10803 posts

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

user_14586677's picture
User
7648 posts

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.

Attachments: 
Log in to post new comments.