9 years, 7 months ago.

Do you have an usage example as well ?

Could you please provide an usage example as well ? thank you, Daniel

Question relating to:

Library for ST's new dSpin stepper motor driver. Works with their demo board L6470EVAL.

1 Answer

9 years, 7 months ago.

I don't have a simple example handy, but here is a quick sample (untested) that should get you going.

#include  "mbed.h"
#include "dSPIN.h"


dSPIN Stepper0(P0_9, P0_8, P0_10, P1_1); //mosi, miso, sclk, cs

int main(){
    //clear flags and get dSPIN to known state
    Stepper0.get_status();
    Stepper0.reset_device();
//set all the motor parameters, ST has a nice windows tool for figuring out hte proper K values for this
    Stepper0.set_param(KVAL_RUN, 1, Memory::kval_run[0]);
    Stepper0.set_param(KVAL_HOLD, 1, Memory::kval_hold[0]);
    Stepper0.set_param(KVAL_ACC, 1, Memory::kval_acc[0]);
    Stepper0.set_param(KVAL_DEC, 1, Memory::kval_dec[0]);
    Stepper0.set_param(CONFIG, 2, Memory::config[0]);
    Stepper0.set_param(MAX_SPEED, 2, Memory::max_speed[0]);
    Stepper0.set_param(ACC, 2, Memory::acc[0]);
    Stepper0.set_param(DEC, 2, Memory::dec[0]);
    Stepper0.set_param(FS_SPD, 2, Memory::fs_spd[0]);
    Stepper0.set_param(ST_SLP, 1, Memory::st_slp[0]);
    Stepper0.set_param(FN_SLP_ACC, 1, Memory::fn_slp_acc[0]);
    Stepper0.set_param(FN_SLP_DEC, 1, Memory::fn_slp_dec[0]);
    Stepper0.set_param(INT_SPD, 2, Memory::int_spd[0]);
//move in a direction at a speed
    Stepper0.run(Direction, speed);
//get the step count from the chip
    StepPos[AXIS1] = Stepper0.get_param(ABS_POS, 3);
}

Accepted Answer