ASURO Library
2.80
Hauptseite
Dateien
Auflistung der Dateien
Datei-Elemente
lib
motor.c
gehe zur Dokumentation dieser Datei
1
/****************************************************************************/
33
/*****************************************************************************
34
* *
35
* This program is free software; you can redistribute it and/or modify *
36
* it under the terms of the GNU General Public License as published by *
37
* the Free Software Foundation; either version 2 of the License, or *
38
* any later version. *
39
* *
40
*****************************************************************************/
41
#include "
asuro.h
"
42
43
44
45
/***************************************************************************
46
*
47
* sto1 07.01.2006 stochri first implementation
48
*
49
* control the motors
50
*
51
* input range: -127 full power backturn
52
* 0 stop motors
53
* +127 full power vorward
54
*
55
* motor direction and speed can be set with one parameter
56
*
57
* last modification:
58
* Ver. Date Author Comments
59
* ------- ---------- -------------- ---------------------------------
60
* sto1 07.01.2006 stochri first implementation
61
* ------- ---------- -------------- ---------------------------------
62
****************************************************************************/
63
/****************************************************************************/
89
void
SetMotorPower
(
90
int8_t leftpwm,
91
int8_t rightpwm)
92
{
93
unsigned
char
left, right;
94
95
if
(leftpwm < 0)
// Ein negativer Wert fuehrt ...
96
{
97
left =
RWD
;
// ... zu einer Rueckwaertsfahrt, ...
98
leftpwm = -leftpwm;
// aber immer positiv PWM-Wert
99
}
100
else
101
left =
FWD
;
// ... sonst nach vorne, ...
102
if
(leftpwm == 0)
103
left =
BREAK
;
// ... oder bei 0 zum Bremsen.
104
105
if
(rightpwm < 0)
106
{
107
right =
RWD
;
108
rightpwm = -rightpwm;
109
}
110
else
111
right =
FWD
;
112
if
(rightpwm == 0)
113
right =
BREAK
;
114
115
MotorDir
(left, right);
// Drehrichtung setzen
116
117
/*
118
Die Geschwindigkeitsparameter mit 2 multiplizieren, da der Absolutwert
119
der Parameter dieser Funktion nur genau die Haelfte von der MotorSpeed()-
120
Funktion betraegt.
121
*/
122
MotorSpeed
(leftpwm * 2, rightpwm * 2);
123
}
Erzeugt am Mit Nov 27 2013 22:55:08 für ASURO Library von
1.8.2