Homepage Wiki Forum Buy

Steppermotor

From GNUBLIN

severity (level) requirement Gnublin family
Gnublin logo advanced.png Kernel compile, Toolchain Alle

Contents


This article explains how to control the steppermotor from the TMC222 starter-kit via I2C.

You can get the steppermotor here.

Module motor.jpg

Quickstart

There is a small demo application for the stepper motor on the Gnublin Distribution (since 18.1.13) available which is called gnublin-step which allows the motor to drive to a absolute position:

root@gnublin:~# gnublin-step -p 3200

The motor makes a complete rotation. If you want to rotate back you can enter the following command:

root@gnublin:~# gnublin-step -p 0

You always set a absolute position with this application. A complete rotation is position 3200, two rotations 6400 and so on.

If you want to specify the I2C address of the stepper-module you can to this with the parameter -a

root@gnublin:~# gnublin-step -a 0x60 -p 3200

The full function overview of gnublin-step is shown in the software-chapter.

Preparation

What do we need?

  1. steppermotor Starterkit (Attention, the steppermotor needs a power supply of 8V - 29V)
  2. or steppmotor and TMC222 controller
  3. or steppmotor and GNUBLIN Steppermotor Module

In the new Gnublin Distribution everything is already prepared. If you use the old ELDK file system it can be necessary to do two more stepps:

  1. I2C Device i2c-1 (if it doesnt exists in /dev you can create it with the command mknod /dev/i2c-1 c 89 1)
  2. i2c-pnx module (marked as builtin in the new Gnubli-Kernel)


Connect the Hardware

At first you should connect the I2C interface.

If you use the GNUBLIN Steppmotor Module you just have to connect the ribbon cable wit GNUBLIN. Note: The red wire has to be on GPIO0 / GPIO1. Therefor you only have to connect the lines SDA, SCL, VCC and GND of the Gnublin with the lines of the starter-kit board.

Owner of the steppmotor Starterkid just have to connect the lines SDA, SCL and GND of GNUBLIN with your module. (You can find the interface discription of your GNUBLIN here). You need an external power suppley four the motor (8-29V DC). Therfore you have connect the positive pole of your power suppley with VNC on the TMC222 PCB and GND with the ground of ur power suppley.

After this you can already start to control the steppermotor.

Software

gnublin-step

The demopropram is already included in the newest version of the Gnublin Distribution it's called gnublin-step and is automaticly installed. It gives you the opportunety to go to a absolut position of the motor.

The demo application can be run in every directory. Here you see an example call:

root@gnublin:~# gnublin-step -p 3200

The motor take a complete rotation. If you want to go back just type:

root@gnublin:~# gnublin-step -p 0

Parameters

Parameter Function Range default
-h Shows the help
-f <i2c-device> Set i2c-device /dev/i2c-1
-j Output in Json-Format 0
-b Output in raw-format (minimal) 0
-a <i2c-address> Set the I2C-address of the module 0x60
-p <position> Set the desired position
-i <Irun> Set moving-current integer: 0 - 15 15
-d <iholD> Set the hold-current integer: 0 - 15 1
-x <vmaX> Set the max. speed integer: 0 - 15 8
-n <vmiN> Set the minimal speed integer: 0 - 15 0
-o <new_address> Burn a new address in the module 0x62 - 0x76

Explanation of the important parameters

-p <position> This set the position where the motor should drive to. By pluging in the controller the current position is 0, the position 3200 is a full turn, 6400 are two turns and so on.

-i <Irun> This parameter defines the induction current for the motor movement. This table shows the currents you can set:

Irun / Ihold Einstellung Spitzenstrom (mA)
0 59
1 71
2 84
3 100
4 119
5 141
6 168
7 200
8 238
9 283
10 336
11 400
12 476
13 566
14 673
15 800

-d <iholD> In the current for the hold position can be set here. A high current represent a high hold torque but also a high power consumption. The values are the same as in the table above.

-x <vmaX> The maximal possible speed of the motor is given here. The value range starts by 0 (slow) and ends by 15 (fast).

-n <vmiN> This parameter sets the minimal speed of the motor. The value is interpreted in the relation 1/32 to 15/32 to the maximal speed. The value 0 set vmin equal to vmax. This graphic shows the speed up behaviour of the controller:

Velocity step.png

If the controller gets a new position the motor starts by vmin and goes up to vmax and slows down to vmin again until the new position is reached.

-o <new_address> A new slave-address can be written in the OTG (one-time-rogrammable) memory of the chip.

Attention: if a bit in the OTG is set there is no way to erase it!

Examples

  • fast from A to B
root@gnublin:~# gnublin-step -x 15 -p 3000
  • precise from A to B
root@gnublin:~# gnublin-step -x 1 -n 1 -d 15 -p 0
  • maximal power
root@gnublin:~# gnublin-step -x 8 -i 15 -d 15 -p 3000
  • ... power saving
root@gnublin:~# gnublin-step -x 8 -i 1 -d 0 -p 3000
  • Steppmotor-Controller with new Address
root@gnublin:~# gnublin-step -a 0x76 -x 8 -i 1 -d 0 -p 3000
In other languages