Close

Setting up STM 6482 stepper motor driver chip

A project log for WEEDINATOR 2017

An autonomous roving CNC weeding/cultivating machine guided by GPS and coloured markers.

capt-flatus-oflahertyCapt. Flatus O'Flaherty ☠ 07/09/2017 at 13:460 Comments

I really thought that this was going to be relatively easy, but soon a bit of a nightmare started to unfold.

Since we've got quite a few motors running at the same time, doing various different jobs, we want really good control options so that means using the SPI bus with one MCU pin to shift the registers on each motor PCB. Speed, acceleration, torgue, current sensing has to be done via SPI and not PWM or else we'd soon run out of MCU pins. The STM 6482 seems to be the best chip for the job, but it's quite complicated to set up.

After buying the STM 6482 discovery board and playing around on it with a swanky GUI I managed to convince myself that it would be ok. Next stage was to try and get the STM Eval board up and running.

First problem: No software available! Fortunately, after emailing STM, they fixed the broken download link and now I've got a shed load of files to compile into a working system.

Next problem: After literally an hour of arranging the files in the Mbed software the compiler throws out an error: 'Please select your Nucleo board' ...... Very polite but it turns out that the software only supports a narrow range of nucleo boards and my F072Rb aint one of them! Eventually I work out that I need a STMF103RB with 128k of flask to be defined in the software as 'Medium Density, Non Value Line'. Fortunately the boards are not expensive and they're in stock at RS supllies. Meanwhile, my test rig awaits patiently:

The 'build' for the compilation looks quite well documented:

/**
@page cSPIN_Example cSPIN

@verbatim
/**
******************************************************************************
* @file cspin/readme.txt
* @author IPC Rennes
* @version V2.1
* @date November 4, 2013
* @brief Description of the cSPIN Example.
* @note (C) COPYRIGHT 2013 STMicroelectronics
******************************************************************************
* @copy
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
*/
@endverbatim

@par Example Description

This example shows how to use cSPIN firmware library. Main program starts with
clock configuration (system clock config SYSCLK to 24MHz).
The SYSCLK frequency is selected by user in clock.h file.

All used peripherals are then initialized, cSPIN chip is configured (registers are
set with requested parameters).

Different commands are then shown to perform requested operation.


@par Directory contents

- cspin/inc/stm32f10x_conf.h Library Configuration file
- cspin/src/stm32f10x_it.c Interrupt handlers
- cspin/inc/stm32f10x_it.h Header for stm32f10x_it.c
- cspin/inc/clock.h System clock setup related header
- cspin/src/clock.c System clock source file
- cspin/inc/cspin.h cSPIN definitions header
- cspin/src/cspin.c cSPIN routines source file
- cspin/inc/cspin_config.h cSPIN configuration parameters (this file can be generated by the GUI)
- cspin/inc/main.h Main header file
- cspin/src/main.c Main program
- cspin/src/pre_include.h First header file included by the preprocessor

@par Hardware and Software environment


- This example has been tested with :
EVAL6480H-DISC board
EVAL6482H-DISC board.


@par How to use it ?

In order to make the program work, you must do the following :
- Create a project and setup all project configuration
- For the DISCOVERY board :
- Device : ST STM32F105xB
- Library low-level interface: Semihosted. stdout/stderr Via SWO. Use CMSIS library
- Preprocessor defined symbols :
- STM32F10X_CL
- USE_STDPERIPH_DRIVER
- ST_CSPIN_6480H_DISCOVERY
- Preprocessor include directories :
- $PROJ_DIR$\..\..\..\..\..\..\stm32f10x\CMSIS\CM3\DeviceSupport\ST\STM32F10x
- $PROJ_DIR$\..\..\..\..\..\..\stm32f10x\STM32F10x_StdPeriph_Driver\inc
- $PROJ_DIR$\..\..\..\..\..\cspin\inc
- Linker configuration file :
- $PROJ_DIR$\config\stm32f10x_flash.icf
- Debugger :
- ST-LINK, run to main
- Verify download, use flash loader, override default .board file with FlashSTM32F105xB.board
- Add the required Library files :
- startup_stm32f10x_cl.s
- system_stm32f10x.c
- misc.c
- stm32f10x_exti.c
- stm32f10x_flash.c
- stm32f10x_gpio.c
- stm32f10x_rcc.c
- stm32f10x_spi.c
- stm32f10x_tim.c
- Link all compiled files and load your image into target memory
- Run the example


* <h3><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h3>
*/


Discussions