Errors while Communicating with SPI Daisy Chain Devices

1 point 8 kilo Ω resistors?!!!? Send picture. That’s too much phase resistance. Ask your electronics guy, what to do.

My electronics guy told me to do it this way, the old set up with the same motor had 909 Ohm, the two 1.8k’s are in parallel between red and blue and green and black. The motor twitches and starts to step then gets stuck.

What would be some approriate Krun, Khold, Kacc, ect values for this set up? If I set them all really like (like down to 1) the motor toggles back and forth, almost moving. It seems like either the pulses are happening too fast for the steps to finish or it isn’t reaching full current before switching steps.

I think it is something with the K values or timing in the code…If I turn it to 12 V power supply it gitters in place but if I drop it to 11.6 V it begins to toggle back and forth but the phases are switching too fast to actually complete a step. The SPI clock is set to 1000 kHz which is the only frequency it will set the registers at.

Turning my driver on drops my flag pin to like 15 mV then it pops back up to 1.8 V is that still considered active low? Why would it constantly be flagging?

Edit: Ok so it only drops to 1.8 V if my Kacc is above 3%, otherwise flag sits at 3.3 V. I can set all my other duty cycles to 50+ but for some reason, the Kacc throws a flag which is the duty cycle I need to get motion. If I creep up from almost 0 to 3% the motor comes SOOOOO close to moving, just putting your finger against it without pressing it causing a step to happen. Tried using GetStatus but am not sure how to interpret the bits.

See page 45, OCD_TH Overcurrent detection threashold and the config register (page 39) overcurrent shutdown.
The default is 350mA. You’ll need to turn it up to max 0xF.

Eval board is coming today so all chance of hardware errors will be eliminated (hopefully). It seems like the motor doesn’t energize until it reaches 8 V because of Vboot / Charge pump oscillator so it shouldn’t be setting off the current alarm so easy if that is the case - can’t figure out how to interpret status register.

Btw I changed to 60 Ohm resistors and still no improvement.

I turned it up to max days ago, saw your other forum post :stuck_out_tongue: its at 6000mA

The driver’s voltage range is 8 to 45 volts; It just doesn’t work at less. If I understand your Electronics guys suggestions then the 1.8KΩ resistors are fine. Can you post the current code you are using to initialise the board?

Ok here are the register configuration results as well as the respective code. Register 13 and 14 don’t want to set. Using the old driver since I can see if the registries are setting or not.

Register 1 setting to 0 returned 0
Register 2 setting to 0 returned 0
Register 3 setting to 0 returned 0
Register 4 setting to 0 returned 0
Register 5 setting to 1 returned 1
Register 6 setting to 1 returned 1
Register 7 setting to 3 returned 3
Register 8 setting to 84 returned 84
Register 21 setting to 2 returned 2
Register 9 setting to 15 returned 15
Register 10 setting to 74 returned 74
Register 11 setting to 36 returned 36
Register 12 setting to 36 returned 36
**** Register 13 setting to 419 returned 2147483939****
**** Register 14 setting to 251 returned 2147483771****
Register 15 setting to 91 returned 91
Register 16 setting to 91 returned 91
Register 17 setting to 0 returned 0
Register 19 setting to 15 returned 15
Register 20 setting to 127 returned 127
Register 22 setting to 0 returned 0
**** Register 23 setting to 255 returned 2147483775****
**** Register 24 setting to 11912 returned 2147495432****
Register 9 setting to 1 returned 1
Register 10 setting to 74 returned 74

using System;
using Microsoft.SPOT;
using GHI.Pins;
using GHI.Processor;
using GHI.Utilities;
using Microsoft.SPOT.Hardware;
using System.Threading;

//using Microsoft.SPOT.Presentation;
using Drivers;

public class Program
{


private static InputPort busyPort;
private static dSPIN_RegsStruct_TypeDef dSPIN_RegsStruct;
private static dSpin stepperDriver;
private static InterruptPort _testPort;
private static Random _rnd;
private static InputPort flagPort;

public static void Main()
{


    
        

        try
        {
           
         _rnd = new Random();
        dSPIN_RegsStruct = new dSPIN_RegsStruct_TypeDef();
        UInt32 dSPIN_rx_data = 0;

        Debug.EnableGCMessages(false);
         OutputPort reset = new OutputPort(G30.Gpio.PC2,false);
        
        busyPort = new InputPort(G30.Gpio.PA15, false, Port.ResistorMode.Disabled);
        //stbyPort = new InputPort(G30.Gpio.PC13, false, Port.ResistorMode.PullDown);
        flagPort = new InputPort(G30.Gpio.PC13, false, Port.ResistorMode.Disabled);
        SPI.Configuration _spiConfig = new SPI.Configuration(G30.Gpio.PB7,
            false,
            2,
            2,
            false,
            true,
            1000,
            SPI.SPI_module.SPI1);
           // Cpu.Pin.GPIO_Pin2,false);
        SPI spiPort = new SPI(_spiConfig);
 



        /* Structure initialization by default values, in order to avoid blank records */

        stepperDriver = new dSpin(spiPort, busyPort,flagPort);
        reset.Write(!true);
        Thread.Sleep(10);
        reset.Write(true);
        dSpin.dSPIN_Regs_Struct_Reset(ref dSPIN_RegsStruct);

        stepperDriver.dSPIN_Reset_Device();

        /* Acceleration rate settings to 466 steps/s2, range 14.55 to 59590 steps/s2 */
        dSPIN_RegsStruct.ACC = Macro.AccDecStepsTopar(20);  // 466
        /* Deceleration rate settings to 466 steps/s2, range 14.55 to 59590 steps/s2 */
        dSPIN_RegsStruct.DEC = Macro.AccDecStepsTopar(20);  // 466
        /* Maximum speed settings to 488 steps/s, range 15.25 to 15610 steps/s */
        dSPIN_RegsStruct.MAX_SPEED = Macro.MaxSpdStepsToPar(40);  // 488
        /* Minimum speed settings to 0 steps/s, range 0 to 976.3 steps/s */
        dSPIN_RegsStruct.MIN_SPEED = Macro.MinSpdStepsToPar(20);
        /* Full step speed settings 252 steps/s, range 7.63 to 15625 steps/s */
        dSPIN_RegsStruct.FS_SPD = Macro.FSSpdStepsToPar(40);   // 252

        //The duty cycle values control power to the motor. If the motor is not running as expected
        //it may be because it it underpowered.

        /* Hold duty cycle (torque) settings to 10%, range 0 to 99.6% */
        dSPIN_RegsStruct.KVAL_HOLD = Macro.KvalPercToPar(6);
        /* Run duty cycle (torque) settings to 10%, range 0 to 99.6% */
        dSPIN_RegsStruct.KVAL_RUN = Macro.KvalPercToPar(29);
        /* Acceleration duty cycle (torque) settings to 10%, range 0 to 99.6% */
        dSPIN_RegsStruct.KVAL_ACC = Macro.KvalPercToPar(14);
        /* Deceleration duty cycle (torque) settings to 10%, range 0 to 99.6% */
        dSPIN_RegsStruct.KVAL_DEC =  Macro.KvalPercToPar(14);

        //end duty cycles

        /* Intersect speed settings for BEMF compensation to 200 steps/s, range 0 to 3906 steps/s */
        dSPIN_RegsStruct.INT_SPD = Macro.IntSpdStepsToPar(100);
        /* BEMF start slope settings for BEMF compensation to 0.038% step/s, range 0 to 0.4% s/step */
        dSPIN_RegsStruct.ST_SLP = Macro.BEMFSlopPercToPar(2);
        /* BEMF final acc slope settings for BEMF compensation to 0.063% step/s, range 0 to 0.4% s/step */
        dSPIN_RegsStruct.FN_SLP_ACC = Macro.BEMFSlopPercToPar(15);
        /* BEMF final dec slope settings for BEMF compensation to 0.063% step/s, range 0 to 0.4% s/step */
        dSPIN_RegsStruct.FN_SLP_DEC = Macro.BEMFSlopPercToPar(15);
        /* Thermal compensation param settings to 1, range 1 to 1.46875 */
        dSPIN_RegsStruct.K_THERM = Macro.KThermToPar(1);

        /* Overcurrent threshold settings to 1500mA */
        dSPIN_RegsStruct.OCD_TH = (byte)dSPIN_OCD_TH_TypeDef.dSPIN_OCD_TH_6000mA; //my power supply can't handle more than 1000mA

        /* Stall threshold settings to 1000mA, range 31.25 to 4000mA */
        dSPIN_RegsStruct.STALL_TH = Macro.StallThToPar(4000);
        /* Step mode settings to 128 microsteps */
        dSPIN_RegsStruct.STEP_MODE = (byte)dSPIN_STEP_SEL_TypeDef.dSPIN_STEP_SEL_1;
        /* Alarm settings - all alarms enabled */
        dSPIN_RegsStruct.ALARM_EN = (byte)(dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_OVERCURRENT | dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_THERMAL_SHUTDOWN
            | dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_THERMAL_WARNING | dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_UNDER_VOLTAGE | dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_STALL_DET_A
            | dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_STALL_DET_B | dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_SW_TURN_ON | dSPIN_ALARM_EN_TypeDef.dSPIN_ALARM_EN_WRONG_NPERF_CMD);
        /* Internal oscillator, 2MHz OSCOUT clock, supply voltage compensation disabled, *
         * overcurrent shutdown enabled, slew-rate = 290 V/us, PWM frequency = 15.6kHz   */
        dSPIN_RegsStruct.CONFIG = ((UInt16)dSPIN_CONFIG_OSC_MGMT_TypeDef.dSPIN_CONFIG_INT_16MHZ_OSCOUT_2MHZ) |
            ((UInt16)dSPIN_CONFIG_SW_MODE_TypeDef.dSPIN_CONFIG_SW_HARD_STOP) |
            ((UInt16)dSPIN_CONFIG_EN_VSCOMP_TypeDef.dSPIN_CONFIG_VS_COMP_DISABLE) |
            ((UInt16)dSPIN_CONFIG_OC_SD_TypeDef.dSPIN_CONFIG_OC_SD_ENABLE) |
            ((UInt16)dSPIN_CONFIG_POW_SR_TypeDef.dSPIN_CONFIG_SR_290V_us) |
            ((UInt16)dSPIN_CONFIG_F_PWM_INT_TypeDef.dSPIN_CONFIG_PWM_DIV_2) |
            ((UInt16)dSPIN_CONFIG_F_PWM_DEC_TypeDef.dSPIN_CONFIG_PWM_MUL_1);

        /* Program all dSPIN registers */
        stepperDriver.dSPIN_Registers_Set(ref dSPIN_RegsStruct);


        /* Send dSPIN command change hold duty cycle to 0.5% */
        stepperDriver.dSPIN_Set_Param(dSPIN_Registers_TypeDef.dSPIN_KVAL_HOLD, Macro.KvalPercToPar(0.5)); //Macro.KvalPercToPar(.50)); //Kval_Perc_to_Par(0.5)

        /* Send dSPIN command change run duty cycle to 5% */
        stepperDriver.dSPIN_Set_Param(dSPIN_Registers_TypeDef.dSPIN_KVAL_RUN, Macro.KvalPercToPar(29));// Macro.KvalPercToPar(40)); //Kval_Perc_to_Par(5);



      uint totalSteps = new uint();
        for (; ; )
        {


            UInt32 stepps = (uint)(128 * _rnd.Next(200));
            totalSteps += stepps;

         //   stepperDriver.dSPIN_Go_Home();
            stepperDriver.dSPIN_Move(dSPIN_Direction_TypeDef.FWD, stepps);
   
        //    stepperDriver.dSPIN_Get_Status();
            while (stepperDriver.dSPIN_Busy_SW() == 1)
            {
                Thread.Sleep(1);
            }
            //stepperDriver.dSPIN_Move(dSPIN_Direction_TypeDef.REV, stepps);
            stepperDriver.dSPIN_Get_Status();
            /* Perform SoftStop commmand */
            stepperDriver.dSPIN_Soft_Stop();
            //while (stepperDriver.dSPIN_Busy_SW() == 1)
            //{
              //  Thread.Sleep(1);

           stepperDriver.dSPIN_Get_Status();
       //     stepperDriver.dSPIN_Flag();
            //}
        }
     
        }
        catch (Exception ex)
        { ex.ToString(); }
  }
}

I have the eval board…working on getting it all set up.

Got it running with the eval board!!! Must have been something with the power circuit. However, getting a lot of current even with 900 ohm per phase. Turning my duty cycles to 30% or higher spikes my current.

@hwalker_MIWV, what constitutes a lot of current?

almost 2 Amps