@@ -44,20 +44,18 @@ const uint8_t DRV8825_COUNTERCLOCK_WISE = 1; // HIGH
4444### Constructor
4545
4646- ** DRV8825()** Constructor.
47-
48- with steps per rotation as parameter.
49- This parameter is optional and if set to zero, steps will not be counted.
5047- ** bool begin(uint8_t dirPin, uint8_t stepPin)** set the direction pin and step pin.
51- Both pins are set to LOW. For direction this is DRV8825_CLOCK_WISE.
48+ Both pins are set to LOW. For direction this means DRV8825_CLOCK_WISE.
5249
5350
5451### Direction
5552
5653To define in which way the motor will turn.
5754
58- - ** void setDirection(uint8_t direction = DRV8825_CLOCK_WISE)**
55+ - ** bool setDirection(uint8_t direction = DRV8825_CLOCK_WISE)**
5956switch direction between DRV8825_CLOCK_WISE (0 = default) or
6057DRV8825_COUNTERCLOCK_WISE (1).
58+ Returns false for other values.
6159- ** uint8_t getDirection()** returns DRV8825_CLOCK_WISE (0) or
6260DRV8825_COUNTERCLOCK_WISE (1).
6361
@@ -75,24 +73,40 @@ This also updates the position and the steps counters.
7573default to zero.
7674Returns the last value of internal steps counter.
7775- ** uint32_t getSteps()** returns the steps made since start of the program or the last ** resetSteps()** .
78- - ** bool setPosition(uint16_t pos = 0)** to calibrate the position of the motor. Default to zero.
79- Works only if stepsPerRotation > 0
80- Returns false if pos > stepsPerRotation.
81- - ** uint16_t getPosition()** returns the position % stepsPerRotation.
82- Value = 0 .. stepsPerRotation - 1
76+ Its purpose is to have an indication of usage (wear and tear).
77+ - ** bool setPosition(uint16_t pos = 0)** to calibrate the position of the motor. Default value is zero.
78+ Works only if stepsPerRotation > 0.
79+ Returns false if pos > stepsPerRotation.
80+ Note: it does not rotate the motor to a position.
81+ Note: there is no relation between position and steps.
82+ - ** uint16_t getPosition()** returns the position which is kin the range 0 .. stepsPerRotation - 1.
8383This value can be converted to an angle in degrees or radians.
8484
85+
86+ #### Some math
87+
88+ ``` cpp
89+ // angle in degrees.
90+ float angle = position * (360.0 / stepsPerRotation);
91+
92+ // angle in radians.
93+ float angle = position * (2.0 * PI / stepsPerRotation);
94+
95+ // wear and tear math.
96+ float rotations = getSteps() * (1.0 / stepsPerRotation);
97+ ```
98+
8599Note the behaviour of steps changed in 0.1.1.
86- This is done as the library added position functions.
100+ This is done as the library added the position functions.
87101
88102
89103### Configuration
90104
91105- ** void setStepPulseLength(uint16_t us = 2)** configures the pulse length of one step.
92- It is defined in microseconds, default is 2 which is almost the 1.9 from the datasheet.
106+ This is defined in microseconds, default is 2 which is almost the 1.9 from the datasheet.
93107Normally these need not to be changed.
94- - ** uint16_t getStepPulseLength()** returns the set value.
95- Default = 2.
108+ - ** uint16_t getStepPulseLength()** returns the set value in microseconds.
109+ Default the value = 2.
96110
97111
98112## Operational
@@ -140,7 +154,7 @@ Some will only be worked on if requested and time permits.
140154 - reset pin RST 8.3.6
141155 - other?
142156- if stepsPerRotation is set to zero, should pos be set to zero?
143- - NB it will not be updated anymore .
157+ - NB it will not be updated any more .
144158- do we need steps counter?
145159
146160#### should
0 commit comments