C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
sg90.h
Go to the documentation of this file.
1
11#pragma once
12
13#include "pico/stdlib.h"
14#include "hw/pwm/hw_pwm.h"
15
16
18#define STEP_ns 2000
20#define PHASE_CORRECT false
22#define PERIOD_us 20000
24#define T_MIN_us 500
26#define T_MAX_us 2500
27
32{
36 uint sync_pin;
38 int pos_min_degree = -90;
40 int pos_max_degree = +90;
41};
42
47class SG90
48{
49private:
51 PWM *pwm;
53 uint command;
55 uint sync;
57 int pos_min_deg;
59 int pos_max_deg;
61 float coef_us_per_degree;
62
63public:
69 SG90(struct_ConfigSG90 sg90_config);
75 void set_pos(int pos);
76};
77
The basic PWM function.
Definition hw_pwm.h:23
void set_pos(int pos)
the command to set the position of the motor.
Definition sg90.cpp:16
SG90(struct_ConfigSG90 sg90_config)
Construct a new SG90 object.
Definition sg90.cpp:4
the data set that configures the SG90 motor
Definition sg90.h:32
uint sync_pin
an auxilliary pulse that can be used as a synchro signal. Correspond to the A channel of the PWM slic...
Definition sg90.h:36
uint command_pin
the gpio pin used to command the servo motor. Correspond to the B channel of the PWM slice
Definition sg90.h:34
int pos_max_degree
maximum position in degrees. Typically 180° or +90°.
Definition sg90.h:40
int pos_min_degree
minimum position in degrees. Typically 0° or -90°.
Definition sg90.h:38