Subversion Repositories HomeAutomation

Rev

Rev 500 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. #ifndef RC_SERVO_H_
  2. #define RC_SERVO_H_
  3.  
  4. /*-----------------------------------------------
  5.  * Includes
  6.  * ---------------------------------------------*/
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <inttypes.h>
  10.  
  11. /*-----------------------------------------------
  12.  * Defines
  13.  * --------------------------------------------*/
  14.  
  15. /*
  16.  * It is possible to use up to three PWM outputs.
  17.  * In order: OC1A, OC0A and OC0B.
  18.  * They will be named RCS0-RCS2.
  19.  * Define how many that will be used.
  20.  */
  21. #define NUMBER_OF_RCS 2
  22.  
  23. /*
  24.  * For width of the pulse that control the RC servo.
  25.  * Clock pulses.
  26.  * This is adjusted for a 8 MHz clock, to use different speeds recalculate.
  27.  */
  28. #define PWM1_MIN_PULSE   800 // 1000
  29. #define PWM1_MAX_PULSE   2200 // 2000
  30. #define PWM2_MIN_PULSE   20
  31. #define PWM2_MAX_PULSE   50
  32. #define PWM3_MIN_PULSE   20
  33. #define PWM3_MAX_PULSE   50
  34.  
  35. #define STEP1   ((PWM1_MAX_PULSE - PWM1_MIN_PULSE)/256)
  36. #define STEP2   1
  37. #define STEP3   1
  38.  
  39. #define MAX_POSITION 0
  40. #define MIN_POSITION 255
  41.  
  42. /*-----------------------------------------------
  43.  * Functions
  44.  * ---------------------------------------------*/
  45. void rcServoInit();
  46. void setPosition(uint8_t abs_pos, uint8_t servo);
  47. void alterPosition(int8_t rel_pos, uint8_t servo);
  48. uint8_t getPosition(uint8_t servo);
  49.  
  50. #endif
  51.