PicBasic Pro Encoder Programs for PIC18F4331

The programs on this page use an encoder to monitor and control the position of a small DC motor.

Motor and Encoder Used: DCMTR-203, Small 12-24V DC Motor w/ 16 or 35 Slots in the Encoder Wheel. Available at: http://www.encodergeek.com/DCMtr_SMALL.html

Motor Controller Used: Xavien 2 Motor Driver "XDDCMD-1. Available at: http://www.encodergeek.com/Xavien_Amplifier.html

Reference Book: Running Small Motors with PIC Microcontrollers by Harpit Singh Sandhu (Chapter 15)

Program Name
Program
Description
Schematic
for Code
Code
as .pdf
file
Download
PicBasic Pro Code
as .pbp File
encoder1 Uses encoder to track position of motor Schematic Code
PDF
file
4331_encoder1.pbp
encoder2 Sets target position, monitors current
position, and rotates motor to target position
Schematic Code
PDF
file
4331_encoder2.pbp
encoder3 Slows motor as it approaches target position Schematic Code
PDF
file
4331_encoder3.pbp
encoder4 Ramps-up and ramps-down motor power. Schematic Code
PDF
file
4331_encoder4.pbp
encdr4_wo encoder4 program without comments Schematic Code
PDF
file
4331_encdr4_wo.pbp
rpm Program uses Timer0 Interrupt to average motor rpm over one minute Schematic Code
PDF
file
4331_rpm.pbp

Copyright 2015, Cornerstone Robotics / Disclaimer