ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 4192

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Motor Entry

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.

421


C Hardware Description Table

short out_pin_fbit:

The portbit for forward drive. Valid values are 0..7

This is the bitnumber in the latch addressed by out_pin_address.

short out_pin_bbit:

The portbit for backward drive. Valid values are 0..7

This is the bitnumber in the latch addressed by out_pin_address.

If driver_version is set to 3 this bit is not used and should be set to the same value as the fbit.

BYTE* conv_table:

The pointer to a conversion table to adjust differently motors. Valid values are NULL or a pointer to a table containing 101 bytes.

Usually two motors behave slightly different when they get exactly the same amount of energy. This will for example show up in a differential drive, when a vehicle should drive in a straight line but moves in a curve. To adjust one motor to another a conversion table is needed. For each possible speed (0..100%) an appropriate value has to be entered in the table to obtain the same speed for both motors. It is wise to adapt the faster motor because at high speeds the slower one can't keep up, you would need speeds of more than 100% ! Note: The table can be generated by software using the connected encoders.

short invert_direction:

This flag is only used if driver_version is set to 3. This flag indicates to the driver to invert the spinning direction.

If driver_version is set to 2, the inversion will be achieved by swapping the bit numbers of fbit and bbit and this flag will not be regarded.

C.10 Position Sensitive Device (PSD) Entry

typedef struct

{

short driver_version; short tpu_channel; BYTE* in_pin_address; short in_pin_bit; short in_logic;

BYTE* out_pin_address; short out_pin_bit; short out_logic; short* dist_table;

}psd_type;

e.g.

psd_type psd0 = {0, 14, (BYTE*)(Ser1Base+6), 5, AL, (BYTE*)(Ser1Base+4), 0, AL, (short*)&dist0};

psd_type psd1 = {0, 14, (BYTE*)IOBase, 2, AH, (BYTE*)IOBase, 0, AH, (short*)&dist1};

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.

short tpu_channel:

The master TPU channel for serial timing of the PSD communication. Valid values are 0..15

This TPU channel is not used as an input or output. It is just used as a high resolution timer needed to generate exact communication timing. If there are more than 1 PSD connected to the hardware each PSD has to use the same TPU channel. The complete group or just a selected subset of PSDs can 'fire' simultane-

422


Quadrature Encoder Entry

ously. Depending on the position of the PSDs it is preferable to avoid measure cycles of adjacent sensors to get correct distance values.

BYTE* in_pin_address:

Pointer to an 8Bit register/latch to receive the PSD measuring result.

short in_pin_bit:

The portbit for the receiver. Valid values are 0..7

This is the bitnumber in the register/latch addressed by in_pin_address.

short in_logic:

Type of the received data. Valid values are AH, AL

Some registers negate the incoming data. To compensate this, active low(AL) has to be selected.

BYTE* out_pin_address:

Pointer to an 8Bit register/latch to transmit the PSD control signal.

If two or more PSDs are always intended to measure simultaneously the same outpin can be connected to all of these PSDs. This saves valuable register bits.

short out_pin_bit:

The portbit for the transmitter. Valid values are 0..7

This is the bitnumber in the register/latch addressed by out_pin_address.

short out_logic:

Type of the transmitted data. Valid values are AH, AL

Some registers negate the outgoing data. To compensate this, active low(AL) has to be selected.

short* dist_table:

The pointer to a distance conversion table.

A PSD delivers an 8bit measure result which is just a number. Due to inaccuracy of the result only the upper 7 bits are used (div 2). To obtain the corresponding distance in mm, a lookup table with 128 entries is needed. Since every PSD slightly deviates in its measured distance from each other, each PSD needs its own conversion table to guarantee correct distances. The tables have to be generated 'by hand'. The testprogram included in RoBiOS shows the raw 8bit PSD value for the actual measured distance. By slowly moving a plane object away from the sensor the raw values change accordingly. Now take every second raw value and write down the corresponding distance in mm.

C.11 Quadrature Encoder Entry

typedef struct

{

driver_version;

int

int

master_tpu_channel;

int

slave_tpu_channel;

DeviceSemantics motor;

unsigned int clicksPerMeter;

float

maxspeed;

/* (in m/s) only needed for VW-Interface */

}quad_type;

e.g.

quad_type decoder0 = {0, 3, 2, MOTOR_LEFT, 1234, 2.34};

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.

int master_tpu_channel:

423


C Hardware Description Table

The first TPU channel used for quadrature decoding. Valid values are 0..15

To perform decoding of the motor encoder signals the TPU occupies two adjacent channels. By changing the order of the two channels the direction of counting can be inverted.

int slave_tpu_channel:

The second TPU channel used for quadrature decoding. Valid values are master_tpu_channel +|- 1

DeviceSemantics motor:

The semantics of the attached motor.

To test a specific encoder via the internal RoBiOS function the semantics of the coupled motor is needed.

unsigned int clicksPerMeter:

This parameter is used only if the the connected motor powers a driving wheel. It is the number of clicks that are delivered by the encoder covering the distance of 1 meter.

float maxspeed:

This parameter is used only if the connected motor powers a driving wheel. It is the maximum speed of this wheel in m/s.

C.12 Remote Control Entry

With this entry the default behavior of the (wireless) remote control can be specified.

typedef struct

{

int version; short robi_id;

short remote_control; short interface; short serspeed;

short imagemode; short protocol;

} remote_type;

e.g.

remote_type remote = {1, ID, REMOTE_ON, SERIAL2, SER115200, IMAGE_FULL, RADIO_BLUETOOTH};

int 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.

short robi_id;

The user defined unique id (0-255) for this EyeCon. This id is just for information and will

be displayed in the main menu of the RoBiOS! Is is accessible via OSMachineID(). It can temporarily be changed in Hrd/Set/Rmt

short remote_control:

The default control mode for the EyeCon. Valid values are:

REMOTE_ON (the display is forwarded to and the keys are sent from a remote PC), REMOTE_OFF (normal mode),

REMOTE_PC (only the PC sends data i.e. button press is activated only) REMOTE_EYE (only the EyeCon sends data i.e. display information only)

short interface:

424