mirror of
https://github.com/k3ng/k3ng_rotator_controller.git
synced 2024-12-29 17:38:56 +00:00
56e6ed8233
FEATURE_STEPPER_MOTOR Removed OPTION_STEPPER_MOTOR_MAX_50_KHZ. Too much overhead from interrupts. Implemented faster digital writes using digitalWriteFast library (library now included in Github) Added OPTION_STEPPER_DO_NOT_USE_DIGITALWRITEFAST_LIBRARY to disable digitalWriteFast library use
1.2 KiB
Executable File
1.2 KiB
Executable File
Notes
Notes down the observations, experiences and occurrences during the development of the repo.
Useful for explaining certain decisions.
speed of digitalWriteFast:
On Arduino Uno clone, 16MHz
digitalWriteFast is so fast that
void loop() {
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
}
The above did not result in 50% duty cycle.
Rather, the pin stays low for quite some time until the program loops again.
Took around 600ns for the program to repeat
So, the below was done instead:
void loop() {
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
// ... and it goes on, multiple times
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
digitalWriteFast(pinNum, HIGH);
digitalWriteFast(pinNum, LOW);
}
It only took 250ns to toggle, meaning it took only 250ns/2= 125ns to set or clear the pin/port.
speed of digitalWrite:
On Arduino Uno clone, 16MHz
It took 12.56us to toggle, meaning it took 12.56us/2= 6280ns to set or clear the pin/port.
50 times slower than direct port manipulation!