PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Motor
Servo360
Dev
Test Resetting the Angle (1).c
1
/*
2
In practice, your
3
application would most likely check if the result of servo360_getAngle
4
is approaching the thresholds, and then subtract some negative number
5
of turns. This test verifies turning back the turns clock. You may
6
see some rounding errors, but that will not affect angle, speed, or
7
goto navigation. The goal here is just to move the turns way back
8
to prevent rolover in certain variables.
9
*/
10
11
#include "
simpletools.h
"
12
#include "
abdrive360.h
"
13
14
int
main
()
15
{
16
drive_speed
(0, 0);
17
18
int
turns =
servo360_getTurns
(12);
19
print
(
"turns = %d\r"
, turns);
20
21
servo360_setTurns
(12, 500000);
22
pause
(100);
23
24
drive_speed
(32, 32);
25
pause
(2000);
26
drive_speed
(0, 0);
27
pause
(500);
28
29
turns =
servo360_getTurns
(12);
30
print
(
"turns = %d\r"
, turns);
31
servo360_setTurns
(12, -turns);
32
pause
(100);
33
34
drive_speed
(-32, -32);
35
pause
(2000);
36
drive_speed
(0, 0);
37
38
turns =
servo360_getTurns
(12);
39
print
(
"turns = %d\r"
, turns);
40
pause
(500);
41
}
42
drive_speed
void drive_speed(int left, int right)
Set wheel speeds in encoder ticks per second. An encoder tick is 1/64th of a revolution,...
Definition:
speed.c:138
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
servo360_setTurns
int servo360_setTurns(int pin, int turns)
Change the number of turns that have elapsed since the application has started. Use this function to ...
Definition:
servo360_setTurns.c:17
abdrive360.h
This library provides a simple set of functions for making the ActivityBot 360 go certain distances a...
servo360_getTurns
int servo360_getTurns(int pin)
Get the number of times the output shaft has turned in a full circle since the application started (e...
Definition:
servo360_getTurns.c:16
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17