Hw stepper motor add

From Sim Innovations Wiki
Jump to navigation Jump to search

Description

hw_stepper_motor_id = hw_stepper_motor_add(name, type, nr_steps, speed_rpm) (from AM/AP 3.5)
hw_stepper_motor_id = hw_stepper_motor_add(name, type, nr_steps, speed_rpm, circular) (from AM/AP 3.6)
hw_stepper_motor_id = hw_stepper_motor_add(type, nr_steps, speed_rpm, hw_id_1, hw_id_2, ...) (AM/AP 3.5)
hw_stepper_motor_id = hw_stepper_motor_add(type, nr_steps, speed_rpm, circular, hw_id_1, hw_id_2, ...) (from AM/AP 3.6)

hw_stepper_motor_add is used to add a Hardware stepper motor.

Named

Info Available from AM/AP 3.5.

Give your hardware objects a name (.e.g. 'Compass' or 'Engine RPM indicator').
Air Manager will present the user with a view where the assignment of pins can be done.

Arguments

hw_stepper_motor_id = hw_stepper_motor_add(name, type, nr_steps, speed_rpm)
hw_stepper_motor_id = hw_stepper_motor_add(name, type, nr_steps, speed_rpm, circular)
# Argument Type Description
1 name String A functional name to define the stepper motor.
2 type String Type of stepper motor. Can be "4WIRE_4STEP", "4WIRE_6STEP" or "4WIRE_8STEP".
3 nr_steps Number Number of steps for one full rotation.
4 speed_rpm Number Speed of the stepper motor, in rounds per minute.
5 circular Boolean (Optional) Determines if the stepper motor rotate endlessly. Defaults to true.

Direct 4-Wire stepper motor (4, 6 or 8 step)

ULN2003 based stepper motor interface board

Connect a 4 wire stepper motor. Also 4 wire interface boards are supported, like the one shown. You can choose between 4 (4WIRE_4STEP), 6 (4WIRE_6STEP) or 8 (4WIRE_8STEP) step operation.

Arguments

No additional arguments needed.

Return value

Argument Type Description
hw_stepper_motor_id ID This value can be used for further reference.

Example

-- Initiate stepper motor with:
-- 2048 steps
-- 10 rpm speed
id = hw_stepper_motor_add("My stepper motor", "4WIRE_4STEP", 2048, 10)

-- Set position
hw_stepper_motor_position(id, 0.5)

VID66-06

Connect your stepper motor using a VID66-06 chip.

Arguments

No additional arguments needed.

Return value

Argument Type Description
hw_stepper_motor_id ID This value can be used for further reference.

Example

-- Initiate stepper motor with:
-- 2048 steps
-- 10 rpm speed
id = hw_stepper_motor_add("My stepper motor", "VID66-06", 2048, 10)

-- Set position
hw_stepper_motor_position(id, 0.5)

Hardware Id's

Info Hardware Id's are not preferred, try to use named hardware instead.

Define the used pin(s) right away. This is not preferred, since changing of pin assignment can only be done by changing the instrument/panel lua script.

Arguments

hw_stepper_motor_id = hw_stepper_motor_add(type, nr_steps, speed_rpm, circular, ...)
# Argument Type Description
1 type String Type of stepper motor. Can only be "DIRECT_4WIRE".
2 nr_steps Number Number of steps for one full rotation.
3 speed_rpm Number Speed of the stepper motor, in rounds per minute.
4 circular Boolean Determines if the stepper motor rotate endlessly.
... ... ... Depends on type of stepper motor chosen. See below for possible modes.

Direct 4-Wire stepper motor (4, 6 or 8 step)

ULN2003 based stepper motor interface board

Connect a 4 wire stepper motor. Also 4 wire interface boards are supported, like the one shown. You can choose between 4 (4WIRE_4STEP), 6 (4WIRE_6STEP) or 8 (4WIRE_8STEP) step operation.

Arguments

hw_stepper_motor_id = hw_stepper_motor_add(type, nr_steps, speed_rpm, circular, hw_id_a1, hw_id_a2, hw_id_b1, hw_id_b2)
# Argument Type Description
5 hw_id_a1 String Pin 1 of first coil. You can choose to bind to an existing Hardware ID (Hardware_id_list).
6 hw_id_a2 String Pin 2 of first coil. You can choose to bind to an existing Hardware ID (Hardware_id_list).
7 hw_id_b1 String Pin 1 of second coil. You can choose to bind to an existing Hardware ID (Hardware_id_list).
8 hw_id_b2 String Pin 2 of second coil. You can choose to bind to an existing Hardware ID (Hardware_id_list).

Return value

Argument Type Description
hw_stepper_motor_id ID This value can be used for further reference.

Example

-- Initiate stepper motor with:
-- 2048 steps
-- 10 rpm speed
-- On pins A2, A3, A4 and A5 of an Arduino Nano
id = hw_stepper_motor_add("4WIRE_4STEP", 2048, 10, true, "ARDUINO_NANO_A_D2", "ARDUINO_NANO_A_D3", "ARDUINO_NANO_A_D4", "ARDUINO_NANO_A_D5")

-- Set position
hw_stepper_motor_position(id, 0.5)

VID66-06

Connect your stepper motor using a VID66-06 chip.

Arguments

hw_stepper_motor_id = hw_stepper_motor_add(type, nr_steps, speed_rpm, circular, hw_id_dir, hw_id_step)
# Argument Type Description
5 hw_id_dir String Direction pin. You can choose to bind to an existing Hardware ID (Hardware_id_list).
6 hw_id_step String Step pin. You can choose to bind to an existing Hardware ID (Hardware_id_list).

Return value

Argument Type Description
hw_stepper_motor_id ID This value can be used for further reference.

Example

-- Initiate stepper motor with:
-- 2048 steps
-- 10 rpm speed
-- On pins A2, A3 of an Arduino Nano
id = hw_stepper_motor_add("VID66-06", 2048, 10, true, "ARDUINO_NANO_A_D2", "ARDUINO_NANO_A_D3")

-- Set position
hw_stepper_motor_position(id, 0.5)