HowTo: Interface to a Servo Motor

 

Servo Motor Connection

 

 You will need:

  • Servo Motor (In this tutorial, I’m using a Hitec HS322HD Servo Motor)
  • FI40/28 Board
  • 6V DC Power Supply
  • FI Comm.Key Set
  • PC running FIDE

Introduction
There are a few important points to take note before we start.
  1. Power Supply: Please use a 6V DC Power Supply. 6V is the minimum voltage required to power up the Board and is also the maximum voltage allowed to power the servo motor.
  2. All Hitec Servo Motors have an operating range of 4.8V to 6V, with the exception of HS-50, which is powered at 4.8V.
  3. The Servo Motor connection is to a PWM port, in which the power supplied is the same as what you pump in to power up the board (Vin). So if you supply a 6V, the voltage supplied to the servo motor is also 6V, regardless of whether the FI Board is a 3.3V or 5V system.


Now, on to the tutorial!

Make sure that you already have the Servo Motors connected as above. You can connect up to a maximum of 4 servo motors at pins 13-16 (for the FI40 Board).  The FI28 Board can take up to a maximum of 2 Servo Motors at pins 7 and 8.


The FIDE has a built in system library for controlling servo motors. This can be illustrated with the help of syntax helper available within the IDE.

PWM Servo LibraryPWM Servo Library Detail

A onetime initializing of the PWM ports is required before setting the positions of the servo motors.

To do this, we type the following 2 lines of code.

Within the Main Module under Public Sub Main();

 

 FI code boxFI CODE:

'Module1
'Servo Connected to Pin 13
Public Const Servo_Pin As Integer = 13

Public Sub Main()

'Init Servo Motors
OS.PWMServo.Init(Servo_Pin)
'Turn on PWM
OS.PWMServo.State(1)

End Sub
NOTE: If you’re using more than 1 servo motor, you will have to initialize each Servo to set it to PWM mode specifically for servo motor usage. You will only need to set the state once. (1 to turn the PWM ‘ON’, 0 to turn the PWM ‘OFF’) Unless your servo motor has been modified to do continuous rotation, a standard servo motor is capable of sweep movements of about 180 degrees.

Neutral State or “Middle Position” for all Hitec Servo Motors is at a pulse width of 1500usec.

The standard sweep range for 0 to 180 degrees is about 500usec to 2500usec.

The following program first sets the servo to its neutral position. If any jamming occurs at any position, check your servo horn position and affix it properly.

 FI code boxFI CODE:
'Neutral/Middle Position
OS.PWMServo.Position(Servo_Pin, 1500)

 To make the servo motor sweep the entire 0 to 180 degrees and back, continuously, we do the following in a do loop structure.

 

  FI code boxFI CODE:

'Module1
'Servo Connected to Pin 13
Public Const Servo_Pin As Integer = 13

Public Sub Main()

'Init Servo Motors
OS.PWMServo.Init(Servo_Pin)

'Turn on PWM
OS.PWMServo.State(1)

'Neutral/Middle Position
OS.PWMServo.Position(Servo_Pin, 1500)

'Continuous Sweep Movement
Do
OS.PWMServo.Position(Servo_Pin, 2500)
Delay(1000)
OS.PWMServo.Position(Servo_Pin, 1500)
Delay(1000)
OS.PWMServo.Position(Servo_Pin, 500)
Delay(1000)
OS.PWMServo.Position(Servo_Pin, 1500)
Delay(1000)
Loop


End Sub

 

Note: A minimum delay of 10ms (including the pulse instruction) is required between consecutive movements of the same servo to prevent jamming.

 


download source code

 

 
Previous Next
Two New Tutorials
Learn how to control a Servo Motor with the FIDE, as well as adding a wireless peer-to-peer communication link using the EBlue Bluetooth Module.
Hoorah! We've Updated!
3 Cheers to a new tutorial, a FIDE patch, and a Language Reference Update!
New Sensor and Documentation Updates

 

We now carry the distance measuring sensor, SHARP GP2D12, WITH the compatible 3pin connector.

In other updates, we have uploaded the technical paper for our GLCD+RTC Combo complete with example configurations to our FlamingICE Boards. 

Our Hardware Reference now stands at version 1.5 with slight changes to the pin-outs on the FI28 Board. 

 

Christmas Updates

Download the latest FIDE v2.1 and get all the updated documentation that comes along with it!

Check out the new goodies that we have over at our updated Products Page!

Resource Page

Now that FIDE 2.0 is up, we published the Resource Page with 2 major tutorials to boot.

Start clicking and head over to check out those tutorials!

FIDE v2.0 RELEASED!

AIS Cube is proud to release the latest and most complete installment to date, FIDE v2.0. Delivering faster feature packed goodness, whats not to love?

Head over to the downloads tab and grab your copy!

FIDE v1.4.2 PATCH

IMPORTANT: Responding to a bug report, the FIDE v1.4.2 PATCH is a patch for a major bug fix in the FIDE SD Tool. Please ensure that you have FIDE v1.4.2 installed before proceeding with the Patch.

Patch is available over on the Downloads Tab.

FIDE v1.4 Released!
More features with the latest release of FIDE at version 1.4. Extended syntax highlighting range, greater support for FIDE system language instructions...
FIDE v1.3 Released!

FIDE v1.3 is now available for download over at the downloads tab. Featuring bug fixes and other features such as an expanded syntax highlighting coverage, it is highly recommended that you upgrade to the newest version.

AVRIL LE BOB

We have a new project named AVRIL LE BOB up over at the projects page (with videos!!). Check it out today!


Copyright © 2007-2008. AIS Cube. All Rights Reserved.
All trade and/or services marks mentioned are the property of their respective owners.
Joomla! is Free Software released under the GNU/GPL License.