cancel
Showing results for 
Search instead for 
Did you mean: 

EVAL6480H-DISC and quadrature encoder application

FF1
Associate III

Hi all,

for a stepper based application I've to link the frequency that came from a quadrature encoder to the driving speed of a bipolar stepper motor. This board is equipped by a STM32F105RB processor, I've read inside the RM0008 (the reference manual) that the counter can be configured to act as Encoder Interface (§14.3.16 pag 329/1132). I some trouble to found the pins on this board related the timer that should be theoretically usedto perform the quadrature counter (if some are not directly accessible I'll wire up to perform the testing). From the reference manual these input are called TI1 and TI2 but at what physical pin are associated and where I can found this information?

[SOLVED]

Looking inside the RM0008 Reference Manual (Rev. 19) on page 294/1132 at the Figure 52 all became clear.

0690X000006CGgXQAW.jpg

Thank for now!

Best regards

Fabio

3 REPLIES 3
FF1
Associate III

Dear all,

after some reading I was able to manage a simple test by means of the STM32CubeMx tool.

Make a New project and select the STM32F105RB processor (this is the processor model soldered into the EVAL6480H-DISC board).

From the EVAL6480H-DISC board user manual I know that the PB6 (TIM4_CH1) pin and the PB7 (TIM4_CH2) pin are not used and are also related the TIM4 timer so through the TIM4 option configurator I've selected the "Combined Channel" drop down list box and from this I've selected the "Encoder Mode", hence I think to have enabled the counter to act in a proper way with an external encoder attached to these two pins (I'll solder two wire directly on these pins to perform my testing).

Also by selecting the Configuration tab panel into the STM32CubeMx main window and then press the TIM4 button inside the Control box I've gained access to the configuration option for this timer set to operate as Encoder Mode as I did before.

In order to set the X4 multiplication I've choosed the "Encoder Mode TI1 and TI2", I suppose this should be the right one, I can't see the definitions that are used into the AN4013 Rev4 on §4.3.4 (page 31/37) so the mode3 it's just a my supposition.

At this time I've generated the code from the STM32CubeMx main window (Project->Generate Code) after some seconds the generation step was finished and then I was able to open the design directly from the STM32CubeMx inside the IAR Workbench (that previously I've installed and licensed for the size limited version).

Inside the IAR compiler I've located the main.c source file from the the project design tree on the left of the main window and then, inside, it I've seen the function "MX_TIM4_Init(void)", by pressing the F12 key I was redirected to the function's source code:

/* TIM4 init function */
static void MX_TIM4_Init(void)
{
 
  TIM_Encoder_InitTypeDef sConfig;
  TIM_MasterConfigTypeDef sMasterConfig;
 
  htim4.Instance = TIM4;
  htim4.Init.Prescaler = 0;
  htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim4.Init.Period = 0;
  htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  sConfig.EncoderMode = TIM_ENCODERMODE_TI12;
  sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
  sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
  sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
  sConfig.IC1Filter = 0;
  sConfig.IC2Polarity = TIM_ICPOLARITY_RISING;
  sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
  sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
  sConfig.IC2Filter = 0;
  if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }
 
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }
 
}

so this is the end of my first day into the ST discovering tool and searching in order to use the EVAL6480H-DISC board.

Now the question is:

where I can found a starting design for this board in order to change it and make some starting test also with an extrnal encoder wired to this board?

Some idea?

Thank and regards.

Fabio

FF1
Associate III

Hi all,

I've found an example into the EVAL6480H-DISC folder, on the bottom of the page:

Firmware library for L6480, L6482 stepper motor drivers

After download and unpacked the file there are two folders:

  • stm32f10x
  • user_motion

inside the user_motion folder there are others two folder, but the one with name "project" have inside the demo project.

I've loaded the design but I've a missing file warning concerning a ddf file that I can't found into the library:

Fri Oct 26, 2018 18:43:54: Warning: The device description file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.2\arm\config\debugger\ST\STM32F105xB.ddf defined on the Project->Options->Debugger page does not exist.

To solve this warning, from the project options (or alternatively right click on the project name and then choose Options...), under the Debugger entry you've to manually select the "STM32F105RB.ddf" file..

0690X000006CGgNQAW.jpg

0690X000006CGgSQAW.jpg

Regards.

Fabio

FF1
Associate III

Hi all,

in order to know the board configurations that are set from the example design, inside the IAR Compiler, load the design Workspace cspin.eww from the path "user_motion\project\ewarm6\fwlibraries", then for the EVAL6480H-DISC board select the tab panel fwlibraries_cspin_discoverykit.

0690X000006CGfyQAG.jpg

Now, according to the cspin readme.file (you can found it inside the user_motion\spin\ folder) we can take a look at the compiler preprocessor directives that was set inside the IAR Compiler for this demo project.

To do that simply select Project->Options... from the main menu:

0690X000006CGg3QAG.jpg

the Project Options window will be open then select the C/C++ Compiler entry on the left and you are into the right place:

0690X000006CGg8QAG.jpg

Now simply check that the options are the same as specificified inside the readme,txt file for the EVAL6480H-DISC board. The processor of this board is identified through the source code by the STM32F10X_CL definition.

Into the design file tree list on the left, choose the clock.c source and double click on it, then into the source code window on the right perform a search for the STM32F10X_CL label, you will found the following piece of code that will set the microcontroller frequency to 24 MHz starting from the external 8 MHz crystal clock soldered on the board (this conditional statements look for the STM32F10X_CL label that was already definited by means of the preprocessor directives).

0690X000006CGgIQAW.jpg

Then, for this demo design, the internal clock frequency will be set to 24 MHz.

Bye for now!

Fabio