Sample files for this tutorial
This device communicates over Open Sound Control (OSC) protocol. So prepare the host application (or program) that can send and receive OSC.
First, connect the PC and This device with a ethernet cable. If your PC does not have an ethernet port, you will need to use a USB-Ethernet converter.
To simplify this tutorial, we will assume that the PC and the board are connected peer to peer with an ethernet cable. You can off course connect over a network switch (NOT a router) instead. Routers may make things complicated when they have DHCP functionality, not recommended to get started.
The type of stepper motor that can be used with this device is a "bipolar" one. Power supply capacity and settings may vary depending on the specification of motor. A good example of easily available motor is MERCURY MOTOR's SM-42BYG011-25. It can be purchased from the following sources among others:
Here, we will use this motor as an example for specific setting values. Click here for information about how to connect the board to a motor and to a power supply.
The data sheet of this stepper can be found here. From this diagram, we can see that the wiring pairs are Red - Green and Yellow - Blue.
We need to pair two wires from same coil, so the connection order to the terminal block should look like this.
If you want to run a single motor in the example above, the AC adapter’s capacity of 24V1A is sufficient. The power supply must have DC barrel plug with 5.5mm outer diameter / 2.1mm inner diameter / center positive.
Supplying from the DC barrel jack is sufficient for this size of motor, but if you need to drive much larger motor with high voltage , high current capacity, use the screw terminal block next to the DC jack. Do not connect the power supply before configuring the following DIP switches.
The DIP switch on the board must be set to 1. That is, only the digit 1 is ON, and all other digits are OFF. In this state, the board has the following network settings:
|OSC incoming port||50000|
|OSC outgoing port||50101|
Now you can turn on the power. On the rear side of this device PCB, there are several pins where the power supply voltage is applied, so either attach spacers to the holes on the board or place the board on a non-conductive material.
Set the static IP address for the Ethernet port that this device is connected to. Set it as follows:
Setting the static IP address varies depending on your OS.
Provided that you don’t encounter problems with these settings, you should be able to check the connection with commands such as
ping 10.0.0.101 from Terminal on Mac, or Command Prompt on Windows computers.
Check the connection
From here on, the actual operations will vary depending on your environment, but we will focus on describing the actual Open Sound Control messages that are sent and received.
First, the command
/setDestIphas to be sent to this device to tell where the response messages have to be send back to. The destination address is
10.0.0.101, and the outgoing port is
50000. Until this command is received by the this device, the controller will not send any OSC messages. This is because the operation may become unstable if this device continues to send OSC messages to a non-existent destination.
/setDestIp is received without problems, you should get the following response. The incoming port is
/destIp (int)destIp (int)destIp (int)destIp (int)destIp (bool)isNewDestIp
destIp[0-3]: Each bytes of destIp
isNewDestIp: Indicates whether or not destIp has been changed. 1 if it has been changed, or 0 if the same address has already been set.
Now we're ready to exchange messages.
Get the motor running
Let's send a command to run the motor.
/run (int)motorID (float)speed command sets the motor to rotate at the specified speed.
motorID specifies which motor to run (the number is printed on the this device board). Possible ID values are 1-4 for STEP400, 1-8 for STEP800, and 255. If you set the ID to
255, you can send the command to all motors. This applies to almost all commands that need to specify motor ID.
speed command specifies the speed and the direction of the motor. The range you can set is from -15625.0 to 15625.0 step/s. If you're using a motor with 200 steps per revolution, you can specify
200.0 to make one revolution per second. If you set a negative value, the motor will go backwards.
For example, to make one revolution per second for a motor connected to connector number 1, the OSC message should look like this:
/run 1 200.
Did it work? If something went wrong with the motor and you want to stop it, set speed to
0.0, or send the message
to stop all motors.
In many cases, the motor might not be running smoothly at this point. We will need to make further set up.
In most cases, the reason for lacking motion smoothness is insufficient (or sometimes excessive) drive voltage. This can be adjusted with the KVAL register. The KVAL register sets the voltage to drive the motor in the scale of 0 to 255, where 0 means 0V (cannot turn) and 255 means that the motor drive voltage is almost the same as the power supply voltage. For example, if you are using a 24V power supply and you specify 128 for the KVAL, the motor will be driven at about 12V.
There are four types of KVAL:
|KVAL name||function||initial value at this device|
|KVAL_RUN||Constant speed KVAL||16|
Let's adjust KVAL_RUN while rotating the motor at a constant speed. Send following message to rotate the motor:
/run 1 200.
You can set individual KVALs, for example with
KVAL_RUN, but we are going to try following command which can set all KVALs at once.
/setKval (int)motorID (int)holdKVAL (int)runKVAL (int)accKVAL (int)setDecKVAL
1-4, 255 for STEP400,
1-8, 255 for STEP800. Possible value for each KVAL ranges from 0 to 255. Let's set KVAL to
0 for stopping, and gradually increase the value for acceleration and deceleration to the same value as KVAL for constant speed.
/setKval 1 0 24 24 24
This message specifies the first motor KVAL for holding as 0, and the rest of them as 24 (approximately 9% of the power supply voltage).
Gradually increase the numbers as follows, and from some point the motor should begin to turn quietly.
/setKval 1 0 32 32 32
As you increase the KVALs, the torque will also increase, but the motor will generate more heat as well as the vibration, so make sure to set appropriate adjustments to suit the load.