Hello,
The drive motors are connected to an MD22 (dual motor driver) and the C-Control communicates with the MD22 via my E-I2C bus.
To control the motors the controller sends 3 bytes of information to the MD22 control registers (of course the address and command bytes ex. are also sent) and the MD22 does the rest.
The bytes send are speed1 (drive speed right), speed2 (drive speed left) and acceleration.
Speeds control the direction and speeds of the motors:
0 = fast reverse…….128 = stop……..255 = fast forward
Acceleration controls the pull up time:
0 = pull up fast……………………….255 = pull up slowly.
The Wall Hugger program only uses 3 scan angles and 4 movement directions:
Scan angles:
Forward scan (front): Stepper motor at position 50/ fire and read the SRF08
Corner scan (front right): Stepper motor at position 35/ fire and read the SRF08
Side scan (right side): Stepper motor at position 20/ fire and read the SRF08
Movement directions:
Turn left
Bear left
Forward
Bear right
No calculations are done, its just a few IF THEN’s and a few subroutines, but it would be very interesting to try calculation instead of the IF THEN’s .
Here is also a portion of the Wall Hugger code.
Code:
#start
#front_scan
steppermotor_start_position = 50 : gosub steppermotor_control
gosub get_srf08_range
if srf08_actual_range < 45 then goto turn_left
#corner_scan
steppermotor_start_position = 35 : gosub steppermotor_control
gosub get_srf08_range
if srf08_actual_range < 45 then goto turn_left
if srf08_actual_range < 55 then goto bear_left
#side_scan
steppermotor_start_position = 20 : gosub steppermotor_control
gosub get_srf08_range
if srf08_actual_range < 45 then goto bear_left
if srf08_actual_range < 55 then goto forward
goto bear_right
#turn_left
drive_speed_right = 150
drive_speed_left = 106
drive_acceleration = 255
gosub set_md22_speeds
goto start
#bear_left
drive_speed_right = 170
drive_speed_left = 144
drive_acceleration = 255
gosub set_md22_speeds
goto start
#forward
drive_speed_right = 160
drive_speed_left = 160
drive_acceleration = 255
gosub set_md22_speeds
goto start
#bear_right
drive_speed_left = 170
drive_speed_right = 144
drive_acceleration = 255
gosub set_md22_speeds
goto start
Greetings,
H.J. Windt
Lesezeichen