cancel
Showing results for 
Search instead for 
Did you mean: 

STEVAL-PCC009V2 + EVAL6480H with cSpin and minimum wait time between sending the cSPIN_Set_Param() command (IAR C/C++ IDE)

FF1
Associate III

Dear all,

after some time I'll be able to correctly run the demo applications that came with the cSpin firmware libraries (search about STSW-SPIN005 on the ST site).

The first part of this post is about how to set the demo design and compile it, the last part is about the main title question, I've written also the first part with the aim to help someone that get trouble in it because I've not found any helpful info into doc and support.

FIRST PART - GETTING STARTED

After unpacking the "en.STSW-SPIN005 - firmware library cSPIN discovery.zip" file you found two folder:

stm32f10x

user_motion

at the path:

...\user_motion\cspin

there is a readme.txt file, inside this one there are no info how to set the STEVAL-PCC009V2 board, but if you try to load the example design into the IAR environment

...\user_motion\project\ewarm6\fwlibraries\cspin.evw

you can see two projects, in this case the right one have name "fwlibraries_cspin_pcc009v2-Debug".

On the project Options (ALT+F7) and the C/C++ Compiler category, the processor, through the source code of the design, will be identified with the STM32F10X_CL directive; change it to STEM32F10X_MD because the STM32F103RBT6 (the processor soldered into the STEVAL-PCC009V2 board) is a Medium Density type. This is important to avoid a wrong configuration of the system clock and a conseguent code stuck in waiting for the PLL startup, this take some time to figure it out. To discover it you can run the application through the ST-Link debugger and then after some time stop the debug (pause) the code is waiting to the PLL configuration.

After that select the General Options category and into the Processor variant select the Device option button and the ST STM32F103RB device because the predefinited ST STM32F103VB is not correct.

Also you have to change into the file clock.h the clock type, make sure the following change is made:

/* Uncomment the line corresponding to the desired System clock (SYSCLK)

  frequency (after reset the HSI is used as SYSCLK source) */

#define SYSCLK_HSE

/* #define SYSCLK_FREQ_24MHz */

Now save and exit from the IAR IDE and run the "SPINFamily Evaluation Tool 3.2" application tool, set the application parameters and export the cspin_configuration.h header file, save it in a safe place, don't overwite the original file which came with the library, instead rename the original file because it will be useful later.

After performing the original cspin_configuration.h file backup overwrite it with the one generated with the "SPINFamily Evaluation Tool 3.2" tool. This file shall be copied inside the:

...\user_motion\cspin\inc

folder.

Now close the "SPINFamily Evaluation Tool 3.2" and open the project with the IAR IDE, if you try to perform a compilation some error arise fue to missing parameters, what I've found here is that some parameters are not correctly written from the tool, so:

cSPIN_DC_CONF_PARAM_IGATE

cSPIN_DC_CONF_PARAM_TBLANK

cSPIN_CONF_PARAM_IGATE

cSPIN_CONF_PARAM_TBLANK

was not compiled, to overcome this, use the settings from the original file (that the reason why I've suggested to take a backup copy), now try again to compile, no error arise, just some warnings.

Now you have a design, with your custom parameters that is able to compile inside the IAR IDE.

To perform some checking I'll suggest to put a series of define to enable or not some part of the code use to perform the example that are listed inside the UM1756 (User manual - EVAL6480H-DISC and EVAL6482H-DISC: high power stepper motor driver based on the L6480H/L6482H and STM32™) this is not for the STEVAL-PCC009V2 board, but at the end of this document, §5.4 (Using the EVAL6480H-DISC or EVAL6482H-DISC with the firmware library), there are some info about the demo application, can be useful to better understand what the project make.

SECOND PART - COMMAND TIMING QUESTION

Now the most important question for me.

Running the design will give me no movement of the motor shaft.

To perform this first test I've definied some label used to debug the single portion of the code example, in this way I'm able to selectively use only some part of the whole code.

Despite this point, the main issue I've found, was related the cSPIN_Registers_Set() function called into the main.c file, used to set the parameters inside the L6480 drive.

In order to discover what may be wrong I've checked the STATUS register every sent command so I've written into the code a cSPIN_Get_Status() command between each cSPIN_Set_Param() command.

With this change the demo is working properly so my thinking now is about some sort of timing violation between two consequent sending command to the L6480 drive (uncommenting the GetStatus call work only for two commands in sequence, for more command the motor is not running then i think no parameters are set due to command error), so my question is if someone have found this trouble and what should be the best way to solve it.

From the L6480 datasheet, on page 51/75 is written:

"Any attempt to write the register when the motor is running causes the command to be ignored and the CMD_ERROR flag to rise (Section 9.1.24 on page 59). When when SYNC_EN bit is set low, BUSY/SYNC output is forced low during command execution, otherwise, when the SYNC_EN bit is set high, BUSY/SYNC output provides a clock signal according to the SYNC_SEL parameter."

this is related to sending command when the motor is running I'm not sure if the same behavior also occurs when a command, not related to some moving functions, is involved.

Into the L6480 datasheet, page 63/75 related to the Command management section I can't found any info about timing constraints between consecutive commands transmission, may be I've missed something throught the various manual reading I did, so I kindly ask some help if someone have encountered same issue as described above and how this was solved.

Thank and

best regards.

Fabio

1 REPLY 1
FF1
Associate III

THIRD PART - PROBLEM WITH THE EXPORTED cspin_config.h FILE FROM THE DEMO GUI

There are also some trouble with the cspin_config.h caming from the demo GUI application.

Some parameters are not correctly written (others are not written at all, see my previous post) and also bad converted by some macro inside the example code of the demo project inside the IAR IDE.

To avoid any trouble and loss of time look at the registry page as shown into the demo GUI software and then write the parameters directly as written into the registry page inside the IAR design example, e.g.;

ORIGINAL SOURCE CODE

cSPIN_RegsStruct.KVAL_ACC   = Kval_Perc_to_Par(cSPIN_CONF_PARAM_KVAL_ACC);

MODIFIED CODE

cSPIN_RegsStruct.KVAL_ACC   = 0x30;

in other words skip or carefully check the conversion made by the code; as suggest, to avoid any trouble during your first testing, do not use the cspin_confi.h settings generated through the demo GUI application to load the application specific parameters, insted use the value that you found into the registry page in the demo GUI and assign them to the cSPIN_RegsStruct fields.

Here below an example how to do it:

/* Acceleration rate settings to cSPIN_CONF_PARAM_ACC in steps/s2, range 14.55 to 59590 steps/s2 */

   // cSPIN_RegsStruct.ACC = AccDec_Steps_to_Par(cSPIN_CONF_PARAM_ACC);

       cSPIN_RegsStruct.ACC = 0x242;

/* Deceleration rate settings to cSPIN_CONF_PARAM_DEC in steps/s2, range 14.55 to 59590 steps/s2 */

   // cSPIN_RegsStruct.DEC = AccDec_Steps_to_Par(cSPIN_CONF_PARAM_DEC);

       cSPIN_RegsStruct.DEC = 0x242;

Best regards

Fabio