You are here

Custom App: Motor dont stop

1 post / 0 new
CTSchorsch
Offline
Last seen: 4 months 2 weeks ago
VESC Free
Joined: 2018-07-13 09:55
Posts: 101
Custom App: Motor dont stop

Dear all,

i have a Problem with a custom app and FW 3.53:

This is the Custom app Thread

static THD_FUNCTION(dpv_thread, arg) {
        (void)arg;

        chRegSetThreadName("app_dpv");
        static bool first=true;
        static unsigned char motorSpeed=SPEED_MIN;

        for(;;) {


                if (stop_now) {
                        is_running = false;
                        return;
                }
                commands_printf("Trigger: %d",palReadPad(HW_HALL_TRIGGER_GPIO, HW_HALL_TRIGGER_PIN));
                if ( ! palReadPad(HW_HALL_TRIGGER_GPIO, HW_HALL_TRIGGER_PIN)) {


                        if (first) {
                                commands_printf("Trigger");
                                commands_printf("TargetSpeed: %d, MotorSpeed: %d", targetSpeed, motorSpeed);

                                first=false;
                        }
                        if (motorSpeed != targetSpeed) {

                                if (targetSpeed == 0) {
                                        motorSpeed = 0;
                                } else if ( motorSpeed < targetSpeed ) {
                                        motorSpeed ++;
                                } else if (motorSpeed > targetSpeed ) {
                                        motorSpeed --;
                                }
                                commands_printf("Motorspeed: %d", motorSpeed);
                        }

                        mc_interface_set_duty(motorSpeed/100.);
               } else {
                        first=true;
                        motorSpeed = SPEED_MIN;
                        mc_interface_set_duty(0);
                        mc_interface_release_motor();
                }

                // Run this loop at 100Hz
                chThdSleepMilliseconds(50);

                // Reset the timeout
                timeout_reset();
        }
}

I use GPIOC Pin 13 as trigger to start the motor with mc_interface_set_duty() and stop the motor with mc_interface_set_duty(0) and mc_interface_release_motor()..

I print out the status of the GPIO pin and this is correct. but the motor dont stop :(

See someone my mistake ? It works with older firmwares

Regards

Georg