OK, tested. Yes, increasing Accel and Decel settings seems to have about the same effect as using AccelComp and DecelComp, at least at the low speeds I can use in our living room.
I've also made a couple additions in the CAN version of the Roboteq script; one for safety, the other for responsiveness.
Because script commands satisfy the Roboteq serial watchdog and the script is constantly sending commands, that watchdog can never be triggered. Thus, if my joystick should stop sending messages, the chair would just continue on and on at whatever last values it had received. I've now added a CANwathcdog timer (using one of the four timers available in MicroBasic) and if a joystick message is not received for 100 msec throttle and steering are forced to 0. At the full speed of this chair, 5.5 mph, that means the chair will runaway on CAN failure for all of 2 cm before coming to a stop. This would not apply to analog joystick input, but should be done for RC if you use the RC inputs of the Roboteq (rather than Woody's RC adapter).
Motor control has priority over the script interpreter, so the more motor commands are sent the more sluggish will be the script. The script, both mine and yours, does
- Code: Select all
SetMotors:
SetCommand (_G, 1, C1) 'THROTTLE
SetCommand (_G, 2, C2) 'STEERING
RETURN 'End of "SetMotors:"
at every cycle of the main loop. However, once the motors have reached the commanded power output, there's no need to keep doing SetCommand (_G,...). So, my script now has:
- Code: Select all
SetMotors:
M1Power = GetValue (_MOTPWR, 1)
M2Power = GetValue (_MOTPWR, 2)
IF (M1Power <> M1Calc) OR (M2Power <> M2Calc) THEN
SetCommand (_G, 1, Throttle)
SetCommand (_G, 2, Steering)
END IF
RETURN 'SetMotors:
where M1Calc and M2Calc are the target values found in MixAccel. As long as the motors haven't reached those targets, the command gets sent, but once there they are not sent. This is especially important in the CAN system because I want the script to see arriving messages ASAP, but it wouldn't hurt to have this in your scripts too. I'll try to remember to do this whenever I post a revision.
Ciao,
Lenny