Here is the Python code to control motor by using RPi3 and Copley motor driver. After installing gtkterm on Raspberry Pi 3 this code runs on Python 3 and the motor rotates 100000 counts incrementally for each running.
#This program is written by Mustafa Güler who is Electrical and Electronics Engineer
#at Teknolus Enerji located in METU Technopolis MET Campus.
#The main goal of this program is to make communication between RPi 3 Model B and
#Copley Motor Driver via serial communication protocol
import serial
import time
#Defining the port parameters
port = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=3.0)
#Defining the Copley parameters
#Variables____________________bytearrays____________________________________________Copley Parameters
get_actual_motor_position = [103, 32, 114, 48, 120, 51, 50, 13] # g r0x32
absolute_move = [115, 32, 114, 48, 120, 99, 56, 32, 49, 13] # s r0xc8 1
set_position = [115,32,114,48,120,99,97,32,49,48,48,48,48,48,13] # s r0xca [desired position; i.e. 100000]
abort_move = [116, 32, 48, 13] # t 0
initiate_move = [116, 32, 49, 13] # t 1
initiate_homing = [116, 32, 50, 13] # t 2
amplifier_reset = [114, 13] # r
disable_amplifier = [115, 32, 114, 48, 120, 50, 52, 32, 48, 13] # s r0x24 0
get_bus_voltage = [103, 32, 114, 48, 120, 49, 101, 13] # g r0x1e
get_amplifier_temperature = [103, 32, 114, 48, 120, 50, 48, 13] # g r0x20
get_serial_baud_rate = [103, 32, 114, 48, 120, 57, 48, 13] # g r0x90
set_function_gen_to_sine = [115, 32, 114, 48, 120, 57, 56, 32, 50, 13] # s r0x98 2
set_freq_for_function_gen_Hz= [115, 32, 114, 48, 120, 57, 57, 32, 49, 13] # s r0x99 1
set_current_amplitude = [115, 32, 114, 48, 120, 57, 97, 32, 49, 48, 48, 13] # s r0x9a [current value; 100 for x0.01A]
while True:
#Read the port information
read_port = port.readline()
#"s r0xca 100000" set position
port.write(bytearray(set_position))
print('set_position>>>', read_port)
time.sleep(1)
#"t 1" initiate move
port.write(bytearray(initiate_move))
time.sleep(2)
print('initiate move>>>', read_port)
#"g r0x32" get actual motor position
port.write(bytearray(get_actual_motor_position))
print('actual motor position>>', read_port)
time.sleep(1)
port.close()