summaryrefslogtreecommitdiff
path: root/n/asserv/src/pwm.c
diff options
context:
space:
mode:
authorschodet2004-11-28 21:03:15 +0000
committerschodet2004-11-28 21:03:15 +0000
commitdc5e9a8ab529223d5c32e5d803b4516a28da9586 (patch)
tree3d47b4b80aa015e15274a3912cf04ce641b2b3f1 /n/asserv/src/pwm.c
parentfa8ff2dec76b1b366207a126dfc360331510c50d (diff)
Test du calcul de position et modification pour les grandes vitesses (non
testé). Modification de commentaires, vérification d'exactitude de calcul, notament sur les nombres de bits, prise en compte de la vitesse max des moteurs.
Diffstat (limited to 'n/asserv/src/pwm.c')
-rw-r--r--n/asserv/src/pwm.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/n/asserv/src/pwm.c b/n/asserv/src/pwm.c
index 7979842..883201f 100644
--- a/n/asserv/src/pwm.c
+++ b/n/asserv/src/pwm.c
@@ -46,14 +46,14 @@ pwm_update (void);
static inline void
pwm_init (void)
{
- /* No timer/counter interrupt. */
- //TIMSK = 0;
- //ETIMSK = 0;
/* Phase correct PWM, TOP = 0xff, OC1B & OC1C with positive logic.
f_IO without prescaler.
Fpwm = f_IO / (2 * prescaler * TOP) = 28912 Hz. */
- TCCR1A = _BV (COM1B1) | _BV (COM1C1) | _BV (WGM10);
- TCCR1B = _BV (CS10);
+ TCCR1A =
+ regv (COM1A1, COM1A0, COM1B1, COM1B0, COM1C1, COM1C0, WGM11, WGM10,
+ 0, 0, 1, 0, 1, 0, 0, 1);
+ TCCR1B = regv (ICNC1, ICES1, 5, WGM13, WGM12, CS12, CS11, CS10,
+ 0, 0, 0, 0, 0, 0, 0, 1);
/* Enable pwm and direction outputs in DDRB. */
DDRB |= _BV (7) | _BV (6) | _BV (3) | _BV (2);
}
@@ -62,7 +62,8 @@ pwm_init (void)
static inline uint8_t
pwm_preproc (uint16_t v)
{
- v += 0x10;
+ // This is a try to correct the optocoupler problem...
+ //v += 0x10;
if (v > 255)
return 255;
else