Subversion Repositories HomeAutomation

Rev

Rev 390 | 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 1
  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 PWM1_CENTER_PULSE ((PWM1_MAX_PULSE - PWM1_MIN_PULSE)/2 + PWM1_MIN_PULSE) /* Pretty much standard to use 1500 */
  36. /*#define PWM1_CENTER_PULSE 1500
  37. #define PWM2_CENTER_PULSE 35
  38. #define PWM3_CENTER_PULSE 35
  39. */
  40. #define STEP1   ((PWM1_MAX_PULSE - PWM1_MIN_PULSE)/256)
  41. #define STEP2   1
  42. #define STEP3   1
  43.  
  44. #define MAX_POSITION 0
  45. #define MIN_POSITION 255
  46.  
  47. /*-----------------------------------------------
  48.  * Functions
  49.  * ---------------------------------------------*/
  50. void rcServoInit();
  51. void setPosition(uint8_t abs_pos, uint8_t servo);
  52. void alterPosition(int8_t rel_pos, uint8_t servo);
  53. uint8_t getPosition(uint8_t servo);
  54.  
  55. #endif
  56.