User manual
RP6 ROBOT SYSTEM - 4. Programming the RP6
as
70⋅5=350
counted encoder-segments per second (corresponding to ca. 8 up to
8.7 cm/s – depending on the real encoder resolution). The minimal controllable rota-
tional speed is around
10⋅5=50
and the maximal rotational speed is approximately
200⋅5=1000
. Chapter 2 already mentioned the reasons for this speed limit, but we
even recommend to limit it to a value of 160 for continous movements and use 200
only for short times!
getLeftSpeed() and getRightSpeed()
These macros allow you to read the measured rotational speed. They will return val-
ues with the same unit as described above.
void changeDirection(uint8_t dir)
This function will set the motors rotational direction. As already discussed, first the ro-
bobt will decelerate, then change the direction and finally accelerate to the previous
setpoint speed.
The following parameters are supported:
FWD – ForWarDs
BWD – BackWarDs
LEFT – rotate left
RIGHT – rotate right
The macro:
getDirection()
allows you to read the current direction.
Example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "RP6RobotBaseLib.h"
int main(void)
{
initRobotBase(); // Initialize the Microcontroller
powerON(); // Activate Encoders and Motor current sensors!
moveAtSpeed(60,60); // Set desired speed
startStopwatch1(); // Start Stopwatch1
while(true)
{
if(getStopwatch1() > 4000) // Have 4000ms (= 4s) passed by?
{
// Change moving direction:
if(getDirection() == FWD) // If we are driving forwards,
changeDirection(BWD); // then set direction to backwards!
else if(getDirection() == BWD) // If we are driving backwards,
changeDirection(FWD); // then set direction to forwards!
setStopwatch1(0); // Reset Stopwatch1
}
task_motionControl(); // Automatic motion control
task_ADC(); // has to be called for the current sensors.
}
return 0;
}
- 100 -










