VHDL RC servo controller using PWM

$ 0

This VHDL module controls the position of an RC servo like the TowerPro SG90 motor using pulse-width modulation (PWM).

Category: Tags: ,

Description

The servo.vhd module works with any radio-controlled (RC) model servo that uses PWM. The pulse width and frequency is configurable through the use of generics.

In addition to the ModelSim testbench, the Zip contains an example implementation for the Lattice iCEstick FPGA board. The demo design moves the TowerPro SG90 RC servo back and forth with a smooth sine wave motion.

Entity

entity servo is
  generic (
    clk_hz : real;
    pulse_hz : real; -- PWM pulse frequency
    min_pulse_us : real; -- uS pulse width at min position
    max_pulse_us : real; -- uS pulse width at max position
    step_count : positive -- Number of steps from min to max
  );
  port (
    clk : in std_logic;
    rst : in std_logic;
    position : in integer range 0 to step_count - 1;
    pwm : out std_logic
  );
end servo;

Main article

Click here to read more about how I created this module:
RC servo controller using PWM from an FPGA pin

Download request form

Need the ModelSim/Questa project files?

Let me send you a Zip with everything you need to get started in 30 seconds

How does it work?

Tested on Windows and Linux Loading Gif.. How it works

    Unsubscribe at any time

    License agreement

    MIT License

    Copyright (c) 2022 Jonas Julian Jensen

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    Reviews

    There are no reviews yet.

    Be the first to review “VHDL RC servo controller using PWM”

    Your email address will not be published.