简介步进电动机是一种将脉冲信号变换成相应的角位移(或线位移)的电磁装置,是一种特殊的电动机。一般电动机都是连续转动的,而步进电动机则有定位和运转两种基本状态,当有脉冲输入肘步进电动机一步一步地转动,每给它一个脉冲信号,它就转过一定的角度。
技术规格
接口说明引脚说明我们在扩展板上额外引出了一些引脚,以方便玩家使用跳帽连接驱动芯片上的必要引脚。不用再使用缠人的杜邦线了! 步进电机科普指标术语1、相数:产生不同对极N、S磁场的激磁线圈对数。常用m表示。 动态指标术语1、步距角精度:步进电机每转过一个步距角的实际值与理论值的误差。用百分比表示:误差/步距角*100%。不同运行拍数其值不同,四拍运行时应在5%之内,八拍运行时应在15%以内。 步进电机驱动方式功率放大是驱动系统最为重要的部分。步进电机在一定转速下的转矩取决于它的动态平均电流而非静态电流(而样本上的电流均为静态电流)。平均电流越大电机力矩越大,要达到平均电流大这就需要驱动系统尽量克服电机的反电势。因而不同的场合采取不同的的驱动方式,到目前为止,驱动方式一般有以下几种:恒压、恒压串电阻、高低压驱动、恒流、细分数等。 电机选择步进电机有步距角(涉及到相数)、静转矩、及电流三大要素组成。一旦三大要素确定,步进电机的型号便确定下来了。 1、步距角的选择电机的步距角取决于负载精度的要求,将负载的最小分辨率(当量)换算到电机轴上,每个当量电机应走多少角度(包括减速)。电机的步距角应等于或小于此角度。市场上步进电机的步距角一般有0.36度/0.72度(五相电机)、0.9度/1.8度(二、四相电机)、1.5度/3度 (三相电机)等。 2、静力矩的选择步进电机的动态力矩一下子很难确定,我们往往先确定电机的静力矩。静力矩选择的依据是电机工作的负载,而负载可分为惯性负载和摩擦负载二种。单一的惯性负载和单一的摩擦负载是不存在的。直接起动时(一般由低速)时二种负载均要考虑,加速起动时主要考虑惯性负载,恒速运行进只要考虑摩擦负载。一般情况下,静力矩应为摩擦负载的2-3倍内好,静力矩一旦选定,电机的机座及长度便能确定下来(几何尺寸)。 3、电流的选择静力矩一样的电机,由于电流参数不同,其运行特性差别很大,可依据矩频特性曲线图,判断电机的电流。 TMC260驱动器控制方式TMC260驱动芯片有两种控制方式接口:SPI串行接口和STEP/DIR接口。SPI串行接口使用来设置芯片寄存器和读取芯片寄存器值,驱动电机需要通过SPI接口设置初始化参数和模式,在SPI模式下也可以用来设置通过电机线圈的电流,从而代替STEP/DIR的驱动方式,因此我们可以单独通过SPI接口控制步进电机。只使用SPI接口需要占用CPU时间来查找正弦表值不断发送线圈的电流值。(注:我们的开发者在datasheet中并没有发现具体的这个sin表值的计算,出于科学严谨态度开发者就没有将sin电流计算方式公布,同时也欢迎广大使用者共同开发) SPI控制模式SPI(Serial Peripheral Interface)是一种串行同步通讯协议,由一个主设备和一个或多个从设备组成,主设备启动一个与从设备的同步通讯,从而完成数据的交换。同TMC260或者TMC261通信是发送一个20位命令字和接收一个20位状态字。 STEP/DIRSTEP/DIR模式在默认的情况下是启用的,在每一个信号跳变时,DIR引脚的输入状态电平决定电机前进或者后退,每一个步距角都可以分为整步或者微步运行,一个整步可以分为2、4、8、16、32、64、128或256个微步。在微步控制,DIR输入为低电平状态每一个阶跃信号将会增加内部微步计数器值,一个内部表将计数器的值转换为正弦和余弦值为微步控制电动机的电流。 TMC260控制方式选择SPI模式:SDOFF位置高,STEP/DIR接口失能,通过DRVCTR指定每个线圈的通过电流。
TMC260库使用实例好了,前面说了这么多,难道需要我们的使用者具体去了解这些什么参数怎样设置,寄存器怎样配置,配置什么值,不,我们为使用者做了适配的库函数,只需要知道怎样使用我们的库函数就行了。当然,每一个步进电机的参数不相同,需要使用者自己去调试一些参数,如果觉得这些很麻烦,请直接使用我们的步进电机[混合式步进电机-42BYGH1861A-C]。 注意:请在1.0.X版本的IDE下编译,高版本IDE因库的更新将导致编译失败。 TMC260库文件下载链接 /*************************************************** TMC260 Stepper Motor Driver Shield <http://www./index.php?route=product/product&product_id=1360&search=tmc260&description=true#.Vp9Lrh6OCx8> *************************************************** This example show how to control stepper motors. Created 2015-6-11 By Bruce Hee <Loan.he@> Modified 2015-6-11 By Bruce Hee <Loan.he@> GNU Lesser General Public License. See <http://www./licenses/> for details. All above must be included in any redistribution ****************************************************/ /***********Notice and Trouble shooting*************** 1.Connection and Diagram can be found here <http://www./wiki/index.php?title=TMC260_Stepper_Motor_Driver_Shield_SKU:_DRI0035> 2.This code is tested on Arduino Uno, Leonardo, Mega boards. 3.SHT1x library is created by jonoxer. See <https://github.com/CainZ/TMC260-Stepper-Motor-Driver-Shield> for details. ****************************************************/ #include <SPI.h> #include <TMC26XStepper.h> //we have a stepper motor with 200 steps per rotation,CS pin 6, dir pin 4, step pin 5 and a current of 300mA TMC26XStepper tmc26XStepper = TMC26XStepper(200,6,4,5,800); void setup() { Serial.begin(9600); Serial.println("=============================="); Serial.println("TMC26X Stepper Driver Demo App"); Serial.println("=============================="); //set this according to you stepper Serial.println("Configuring stepper driver"); //char constant_off_time, char blank_time, char hysteresis_start, char hysteresis_end, char hysteresis_decrement tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0); tmc26XStepper.setRandomOffTime(0); tmc26XStepper.SPI_setCoilCurrent(100); tmc26XStepper.setMicrosteps(128); tmc26XStepper.setStallGuardThreshold(4,0); Serial.println("config finished, starting"); Serial.println("started"); tmc26XStepper.SPI_setSpeed(80); //Set 80 revolutions per minute tmc26XStepper.SPI_step(-200); //Sets the number of runs for 200 steps, reverse motor 1 tmc26XStepper.spi_start() ; //Motor starting delay(2000); tmc26XStepper.SPI_step(200); //Sets the number of runs for 200 steps, that motor is turn 1 tmc26XStepper.spi_start() ; delay(2000); tmc26XStepper.SPI_setSpeed(100); //Set 80 revolutions per minute tmc26XStepper.SPI_step(-300); //Sets the number of runs for 300 steps, reverse motor 1.5 tmc26XStepper.spi_start() ; delay(2000); tmc26XStepper.SPI_setSpeed(120); tmc26XStepper.SPI_step(400); //reverse motor 2.0 tmc26XStepper.spi_start() ; delay(3000); } void loop() { //Motor control can be written inside the loop functions, let motor repetitive movements }
/*************************************************** TMC260 Stepper Motor Driver Shield <http://www./index.php?route=product/product&product_id=1360&search=tmc260&description=true#.Vp9Lrh6OCx8> *************************************************** This example show how to control stepper motors. Created 2015-6-11 By Bruce Hee <Loan.he@> Modified 2015-6-11 By Bruce Hee <Loan.he@> GNU Lesser General Public License. See <http://www./licenses/> for details. All above must be included in any redistribution ****************************************************/ /***********Notice and Trouble shooting*************** 1.Connection and Diagram can be found here <http://www./wiki/index.php?title=TMC260_Stepper_Motor_Driver_Shield_SKU:_DRI0035> 2.This code is tested on Arduino Uno, Leonardo, Mega boards. 3.SHT1x library is created by jonoxer. See <https://github.com/CainZ/TMC260-Stepper-Motor-Driver-Shield> for details. ****************************************************/ #include <SPI.h> #include <TMC26XStepper.h> //we have a stepper motor with 200 steps per rotation, CS pin 6, dir pin 4, step pin 5 and a current of 300mA TMC26XStepper tmc26XStepper = TMC26XStepper(200,6,4,5,700); int curr_step; int speed = 0; int speedDirection = 100; int maxSpeed = 1000; void setup() { Serial.begin(9600); Serial.println("=============================="); Serial.println("TMC26X Stepper Driver Demo App"); Serial.println("=============================="); //set this according to you stepper Serial.println("Configuring stepper driver"); //char constant_off_time, char blank_time, char hysteresis_start, char hysteresis_end, char hysteresis_decrement tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0); tmc26XStepper.setRandomOffTime(0); tmc26XStepper.setMicrosteps(32); tmc26XStepper.setStallGuardThreshold(4,0); Serial.println("config finished, starting"); Serial.println("started"); } void loop() { if (!tmc26XStepper.isMoving()) { speed+=speedDirection; if (speed>maxSpeed) { speed = maxSpeed; speedDirection = -speedDirection; } else if (speed<0) { speedDirection = -speedDirection; speed=speedDirection; } //setting the speed Serial.print("setting speed to "); Serial.println(speed); tmc26XStepper.setSpeed(speed); //we want some kind of constant running time - so the length is just a product of speed Serial.print("Going "); Serial.print(10*speed); Serial.println(" steps"); tmc26XStepper.step(10*speed); } else { //we put out the status every 100 steps if (tmc26XStepper.getStepsLeft()%100==0) { Serial.print("Stall Guard: "); Serial.println(tmc26XStepper.getCurrentStallGuardReading()); } } tmc26XStepper.move(); }
TMC260库说明TMC260库解析*TMC26XStepper(int number_of_steps, int cs_pin, int dir_pin, int step_pin, unsigned int current, unsigned int resistor) number_of_steps:每选择一周的步数。 *TMC26XSet_SPICS(int cs_pin) cs_pin:在 SPI总线模式下CS引脚选择。 *setConstantOffTimeChopper(char constant_off_time, char blank_time, char fast_decay_time_setting, char sine_wave_offset, unsigned char use_current_comparator) constant_off_time:时间设定,控制斩波器最低频率,对于大多数应用这个时间适合范围为5us-20us。可设置值为0-15. *setCurrent(unsigned int current) current:设置线圈电流。 *SPI_setCoilCurrent(int Current) Current:设置SPI模式下电机线圈电流大小,注意此时的设置范围0-248。 *setMicrosteps(int number_of_steps) number_of_steps:设置每一步间距的微步数。可设置为0-256。 *setStallGuardThreshold(char stall_guard_threshold, char stall_guard_filter_enabled) stall_guard_threshold:设置失速保护(StallGuard)阈值,以获取合理的StallGuard读数。 *step(int steps_to_move) steps_to_move:设置STEP/DIR模式下前进步数,正负值确定电机运行方向。 *setSpeed(unsigned int whatSpeed) whatSpeed:设置STEP/DIR模式下每分钟的转数。 *SPI_step(int spi_steps_to_move) spi_steps_to_move:设置SPI模式下前进的步数,正负值确定电机运行方向。 *SPI_setSpeed(unsigned int whatSpeed) whatSpeed:设置SPI模式下每分钟的转数。 *tmc26XStepper.move() STEP/DIR模式下电机开始运行。 *tmc26XStepper.spi_start() SPI模式下电机开始运行。 TMC260资料下载 |
|