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

Pre-Requisites

  • Arduino Uno R3 board.
  • Servo, 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/03_servo’. These are also available for download at this link.

Description

The input voltage at pin A0 is varied by connecting an external pot (variable resistance) as shown in the circuit diagram. On the output side, PWM on pin-3 is wired to servo. Logic is modelled to vary the servo angle with respect to the voltage at A0. Please go through the individual block parameters used in the model along with respective documentation for better understanding.

CASP Model

Procedure

  • Run CASP and open the project ‘CASP/support/examples/hardware_interface/03_servo/03_servo.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.