Giter Club home page Giter Club logo

attiny85-servo-control's Introduction

ATTINY85 Servo Control

GitHub

An RC servo control using an AVR ATTINY85 microcontroller. The control offers an interrupt driven full 8-bit resolution for a standard RC servo. The control is setup via the 8-bit Timer/Counter1 as it offers the the required prescaler (CK/32) to get a 250 kHz timer frequency from an 8 MHz clocked CPU. This allows for approximately 256 steps (8-bit) over a 1 millisecond period.

Features

  • The servo can be moved to 256 positions within its 1ms-2ms duty range
  • A standard RC servo normally operates a total angle of approximately 90° (+/- 45°)
  • This is done via a 50 Hz PWM signal with a duty cycle of 5% (minimum position) to 10% (maximum position)
  • This means a 20 millisecond PWM signal with a duty cycle of 1 ms to 2 ms
  • To get the full resolution of the 8-bit microcontroller, the 8-bit Timer/Counter1 is setup so that it takes the 8-bit range (256 steps) for the complete duty cycle variation, i.e. 1 millisecond
  • With this setup a resolution of 0.35° per step is possible which is enough for a smooth servo motion
  • A potentiometer can be attached (configured in function Init_ADC via the MUX bits for PB3) and used to control the servo position (tested with a 10kΩ potentiometer)
  • An LED attached to LED_PORT indicates the servo center position (use a 200Ω resistor for the LED)
  • The pins for servo and LED can be configured by the corresponding macros (SERVO_PORT, LED_PORT). Do not use VCC, GND and RESET pins

Example Breadboard Configuration

Obviously, before use, the code main.c needs to be programmed on the device via any ISP programmer.

Credits

Prerequisites

  • For the code to work the CPU needs to run at 8 MHz (this is NOT the factory default)
  • The fuse CKDIV8 has to be unset, otherwise the CPU would run at 1 MHz
  • As an alternative the CKDIV8 could be left as is (factory default), but then the prescaler for the 8-bit Timer/Counter1 has to be set to 4 (using the CS1x bits in the 8-bit Timer/Counter1 control register TCCR1). This alternative is untested.

drawing

Setting of fuses in ATMEL Studio 7 - CKDIV8 unchecked for 8 MHz clock speed

Additional information



Distributed under the MIT license. See LICENSE for more information.

attiny85-servo-control's People

Contributors

chiefenne avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

attiny85-servo-control's Issues

read two analog signals

Hello

i have a two way thumbgas which outputs two hallsignals between 0.9V to 4.2V

I tried to initialize ADC alternated with two pins before read, but failed
How to read both ADC Pins?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.