BYTE* |
conv_table; |
/* NULL if no conversion needed |
*/ |
short |
invert_direction; /* only in driver_version > 2 |
*/ |
}motor_type;
e.g.
motor_type motor0 = {3, 0, TIMER1, 8196, (void*)(OutBase+2), 6, 6, (BYTE*)&motconv0), 0};
int driver_version:
The maximum driver version for which this entry is compatible.
Because newer drivers will surely need more information this tag prevents this driver from reading more information than actually available.
Use driver_version = 2 for hardware versions < MK5 to utilize the two bits for the motor direction setting.
Use driver_version = 3 for hardware version >= MK5 to utilize only one bit (_fbit) for the direction setting.
int tpu_channel:
The tpu channel the motor is attached to. Valid values are 0..15
Each motor needs a pwm (pulse width modulated) signal to drive with different speeds.
The internal TPU of the MC68332 is capable of generating this signal on up to 16 channels. The value to be entered here is given through the actual hardware design.
int tpu_timer:
The tpu timer that has to be used. Valid values are TIMER1, TIMER2
The tpu generates the pwm signal on an internal timer basis. There are two different timers that can be used to determine the actual period for the pwm signal.
TIMER1 runs at a speed of 4MHz up to 8MHz depending on the actual CPU-clock which allows periods between 128Hz and 4MHz (with 4MHz basefrq) up to 256Hz - 8MHz (with 8MHz)
TIMER2 runs at a speed of 512kHz up to 1MHz depending on the actual CPU-clock which allows periods between 16Hz and 512kHz (512kHz base) up to 32Hz - 1MHz (1MHz base)
To determine the actual TIMERx speed use the following equation: TIMER1[MHz] = 4MHZ * (16MHz + (CPUclock[MHz] % 16))/16 TIMER2[MHz] = 512kHZ * (16MHz + (CPUclock[MHz] % 16))/16
int pwm_period:
This value sets the length of one pwm period in Hz according to the selected timer.
The values are independent (in a certain interval) of the actual CPU-clock. The maximal frequency is the actual TPU-frequency divided by 100 in order
to guarantee 100 different energy levels for the motor. This implies a maximum period of
40-80kHz with TIMER1 and 5-10kHz with TIMER2 (depending on the cpuclock). The minimal frequency is therefore the Timerclock divided by 32768 which
implies 128-256Hz (Timer1) and 16-32Hz (Timer2) as longest periods (depending on CPUclock).
To be independent of the actual CPUclock a safe interval is given by 256Hz - 40kHz (Timer1) and 32Hz - 5kHz (Timer2).
To avoid a 'stuttering' of the motor, the period should not be set too slow. But on the other hand setting the period too fast, will decreases the remaining calculation time of the TPU.
BYTE* out_pin_address:
The I/O Port address the driver has to use. Valid value is a 32bit address. To control the direction a motor is spinning a H-bridge is used. This type of hardware is normally connected via two pins to a latched output. The out-
latches of the EyeCon controller are for example located at IOBASE and the succeeding addresses.
One of these two pins is set for forward movement and the other for backward movement.