CASP models can interface with hardware input outputs on embedded micro-controller boards. This example, demonstrates a model that controls stepper motor speed and direction based on voltage applied at ADC input on Arduino Uno board.

Pre-Requisites

  • Arduino Uno R3 board.
  • Stepper motor with driver and suitable power supply, 10K Pot, bread board and sufficient jumper wires.
  • CASP software is installed.
  • Arduino BSP is installed.
  • The project files are located at CASP installed directory ‘CASP/support/examples/hardware_interface/04_stepper_motor’. These are also available for download at this link.

Description

A variable voltage is applied to pin A0 of the target board through a variable resistor. A stepper motor driver circuit control pins are connected to the pins-3, 5, 6, 9 of the target board as shown in the circuit diagram. A model is created to control the stepper motor speed and direction by varying the voltage at pin A0. If the voltage is more than half, the motor rotates in one direction else it rotates in opposite direction. Speed can be varied by varying amplitude of the voltage. Please go through the individual block parameters used in the model along with their documentation for better understanding.

CASP Model

Procedure

  • Run CASP and open the project ‘CASP/support/examples/hardware_interface/04_stepper_motor/04_stepper_motor.prj’ from CASP installed directory.
  • Open ‘Setup Simulation’ window and change the ‘Target Programmer Port’ to which the board is connected.
  • Click Run button to build the model and program the board.