Atmega168's eeprom addresses, Atmega168’s eeprom addresses – Pololu Orangutan X2 User Manual

Page 25

Advertising
background image

5. ATmega168's EEPROM Addresses

This section details the mega168 settings that can be saved to EEPROM, the format of those settings, and the
addresses to which they should be written. When writing to EEPROM, remember that an EEPROM memory
address can be written thousands of times, but not infinitely many. An automated setup that writes to an EEPROM
memory address over and over could potentially burn out that memory address in a few minutes. Take great care
when performing an EEPROM write from within a loop.

0: ADDR_INIT_CHECK — clear this byte and then reset the mega168 to restore it to factory default settings.

1: ADDR_M1_PWM_FREQUENCY — frequency + resolution of motor 1 PWM. Bits 7 – 3 are unused. Bit
2: set = 8-bit resolution, cleared = 7-bit resolution. Bits 1 & 0 enumerate the PWM clock’s prescaler value: 0
= prescaler 8, 1 = prescaler 64, 2 = prescaler 256, 3 = prescaler 1024. The frequency is calculated as 20 MHz
/ prescaler / 2

bit-resolution

and can be: 19.5 kHz, 9.77 kHz, 2.44 kHz, 1.22 kHz, 610 Hz, 305 Hz, 153 Hz, and

76.3 Hz. The default value for this byte is 4, which corresponds do a frequency of 9.77 kHz.

2: ADDR_M2_PWM_FREQUENCY — frequency + resolution of motor 2 PWM. Default value is 4.

3: ADDR_M1_CURRENT_SENSE — number of M1 ADC samples to average. The mega168 retains this many
of the most recent ADC samples and keeps a running average of these values. This parameter must be a power of
two and cannot exceed 128. Default value is 128.

4: ADDR_M2_CURRENT_SENSE — number of M2 ADC samples to average. This must be a power of two
and cannot exceed 128. Default value is 128.

5: ADDR_M1_CURRENT_LIMIT — motor 1 current limit (0 = no limit). Default value is 0.

6: ADDR_M1_CL_P_CONST — motor 1 proportional current control constant P (7-bit value). If for a given
motor the current exceeds the current limit (and the limit is not zero), one of the following will happen: (1) if P
is zero, the motor will be shut off, or (2) if P is not zero, the pwm for that motor is adjusted according to PWM
= PWM – P * (current – current limit). A P of zero will also cause the motor to shut off if it experiences a motor
fault (otherwise the motor will attempt to recover from a fault). Default value is 5. This parameter must not be
greater than 127.

7: ADDR_M2_CURRENT_LIMIT — motor 2 current limit (0 = no limit).

8: ADDR_M2_CL_P_CONST — motor 2 proportional current control constant P (7-bit value). Default value is
5. This parameter must not be greater than 127.

9: ADDR_M1_ACCELERATION — motor 1 acceleration; 0 = instantaneous (7-bit value). If a motor is
accelerating, a tenth of this value will be added to it’s PWM every 10 ms (or, effectively, the PWM will increase
by this much every 100 ms). Default value is 25.

10: ADDR_M2_ACCELERATION — motor 2 acceleration; 0 = instantaneous (7-bit value). Default value is
25.

11: ADDR_M1_BRAKE_DURATION — time (in 10 ms) motor 1 spends braking at full duty cycle on change
of motor direction when issued an acceleration command (7-bit value). Default value is 10 (i.e. brake for 100 ms).

12: ADDR_M2_BRAKE_DURATION — time (in 10 ms) motor 2 spends braking at full duty cycle on change
of motor direction when issued an acceleration command (7-bit value). Default value is 10.

Orangutan X2 Command Documentation v1.01

© 2001–2010 Pololu Corporation

5. ATmega168's EEPROM Addresses

Page 25 of 27

Advertising