Using Arduino Microcontrollers to Sense DC Motor Speed and Position



Similar documents
Eric Mitchell April 2, 2012 Application Note: Control of a 180 Servo Motor with Arduino UNO Development Board

Electronic Brick of Current Sensor

Selecting and Implementing H-Bridges in DC Motor Control. Daniel Phan A

Timer A (0 and 1) and PWM EE3376

Arduino DUE + DAC MCP4922 (SPI)

Arduino Microcontroller Guide W. Durfee, University of Minnesota ver. oct-2011 Available on-line at

Pulse Width Modulation Applications

INTRODUCTION TO SERIAL ARM

DC Motor with Shaft Encoder

ECE 492 SENIOR PROJECT I MINI SUMO ROBOT

Current Loop Tuning Procedure. Servo Drive Current Loop Tuning Procedure (intended for Analog input PWM output servo drives) General Procedure AN-015

Key Words Student Paper, School of Professional Studies

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

How To Control A Car With A Thermostat

BLWR23MDA Series. 24V, 15A Brushless Controller / Motor. User s Guide. 910 East Orangefair Lane, Anaheim, CA info@anaheimautomation.

ETEC Digital Controls PIC Lab 10 Pulse Width Modulation

AirCasting Particle Monitor Bill of Materials

Analog to Digital Conversion of Sound with the MSP430F2013

X8 Option 2 - Technology

Servo Info and Centering

Basic Pulse Width Modulation

Typical ECM/PCM Inputs

Description. Dimensions. Features. precision works better

ECE 492 SENIOR PROJECT 2 MINI SUMO ROBOT

4. Optical position sensor, photo-current measurement

Small Optical Encoder Modules 480lpi Digital Output. Features. Applications VCC 3 CHANNEL A 2 CHANNEL B 4 GND 1

BIODEX ADDENDUM BIODEX EMG/ANALOG SIGNAL ACCESS CONFIGURATION UTILITY SOFTWARE FOR SYSTEM 3 REVISION 2 AND SYSTEM 4 DYNAMOMETERS

Having read this workbook you should be able to: recognise the arrangement of NAND gates used to form an S-R flip-flop.

Experiment 8 : Pulse Width Modulation

Arduino Motor Shield (L298) Manual

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

PHYS 2P32 Project: MIDI for Arduino/ 8 Note Keyboard

Theory of Operation. Figure 1 illustrates a fan motor circuit used in an automobile application. The TPIC kω AREF.

ServoOne. Specification. Option 2 - Technology. x 11. x 8 X 8. x 10. x 9. x 7. x 6 TTL Encoder / TTL Encoder simulation

cs281: Introduction to Computer Systems Lab08 Interrupt Handling and Stepper Motor Controller

Ultrasonic Distance Measurement Module

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Pulse Width Modulation

Interfacing Analog to Digital Data Converters

Points Position Indicator (PPI1) for Points Motors with Common Ground

The quadrature signals and the index pulse are accessed through five inch square pins located on 0.1 inch centers.

Three Channel Optical Incremental Encoder Modules Technical Data

EVAL-UFDC-1/UFDC-1M-16

Microcontroller Programming Beginning with Arduino. Charlie Mooney

Work with Arduino Hardware

Optical Encoders. K. Craig 1. Actuators & Sensors in Mechatronics. Optical Encoders

Application Note AN-1187

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

BLY17MDA Series. 24V, 10A Brushless Controller/Motor. User s Guide. 910 East Orangefair Lane, Anaheim, CA info@anaheimautomation.

Microtronics technologies Mobile:

AN2680 Application note

MDC Series

Transmission electronic controls outline. Inputs- processing- outputs

Arduino project. Arduino board. Serial transmission

AN601 I2C 2.8 Communication Protocol. SM130 SM130 - Mini APPLICATION NOTE

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

Display Board Pulse Width Modulation (PWM) Power/Speed Controller Module

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

TO HANDPHONE BURGLAR ALARM USING PIC 16F877A MICROCONTROLLER

Tutorial. replace them with cell-phone operated module. The advantages of a cell-phone operated bot are:-

3-Digit Counter and Display

Series AMLDL-Z Up to 1000mA LED Driver

EDUMECH Mechatronic Instructional Systems. Ball on Beam System

OPERATING MANUAL. Table of contents. 2 Phase Stepping Motor Driver 2M542. Rev. A. Introduction page 2. Specifications page 2 Timing chart page 3

C4DI Arduino tutorial 4 Things beginning with the letter i

Tire pressure monitoring

Simulation and Analysis of PWM Inverter Fed Induction Motor Drive

Adding Heart to Your Technology

[F/T] [5] [KHz] [AMP] [3] [V] 4 ) To set DC offset to -2.5V press the following keys [OFS] [+/-] [2] [.] [5] [V]

PWM IN AVR. Developed by: Krishna Nand Gupta Prashant Agrawal Mayur Agarwal

Lab Experiment 1: The LPC 2148 Education Board

Accurate Measurement of the Mains Electricity Frequency

Conversion Between Analog and Digital Signals

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

AVR Timer/Counter. Prof Prabhat Ranjan DA-IICT, Gandhinagar

DEPARTMENT OF ELECTRONICS ENGINEERING

Speed Control Methods of Various Types of Speed Control Motors. Kazuya SHIRAHATA

AMZ-FX Guitar effects. (2007) Mosfet Body Diodes. Accessed 22/12/09.

A Surveillance Robot with Climbing Capabilities for Home Security

Table 1 Comparison of DC, Uni-Polar and Bi-polar Stepper Motors

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

Agilent AEDB-9140 Series Three Channel Optical Incremental Encoder Modules with Codewheel, 100 CPR to 500 CPR Data Sheet

POCKET SCOPE 2. The idea 2. Design criteria 3

ABB Drives. User s Manual HTL Encoder Interface FEN-31

HANDLING SUSPEND MODE ON A USB MOUSE

EET272 Worksheet Week 9

Electronics 5: Arduino, PWM, Mosfetts and Motors

Application Information Fully Integrated Hall Effect Motor Driver for Brushless DC Vibration Motor Applications

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

1 of 5 12/31/ :51 AM

The 2N3393 Bipolar Junction Transistor

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

Wireless Security Camera

CHAPTER 11: Flip Flops

Principles of Adjustable Frequency Drives

Programmable Single-/Dual-/Triple- Tone Gong SAE 800

Introduction to Arduino

GT Sensors Precision Gear Tooth and Encoder Sensors

A 5 Degree Feedback Control Robotic Arm (Haptic Arm)

STEPPER MOTOR SPEED AND POSITION CONTROL

Transcription:

ECE480 Design Team 3 Using Arduino Microcontrollers to Sense DC Motor Speed and Position Tom Manner April 4, 2011 page 1 of 7

Table of Contents 1. Introduction ---------------------------------------------------------- 3 2. Rotation Sensors ----------------------------------------------------- 4 3. Speed Detection ------------------------------------------------------ 6 page 2 of 7

1 Introduction Brushless DC motors are a very attractive option for use in systems that require small high torque motors, but they do not provide any feedback. To solve this problem a microcontroller with at least one interrupt pin can be configured to receive feedback from an optical sensor attached to the motor. The Arduino development platform uses ATmega168 and ATmega328 processors, this note will focus on the ATmega328. The ATmega328 has an 8MHz core clock speed, 32KB of flash memory on board and in most Arduino products it is configured to have 8 10-bit analog inputs, and 14 digital input output pins, two of which can be attached to interrupts. Figure 1 Photo of the Arduino Fio, which is being used to interpret motor feedback. Pins labeled A_ are analog inputs, D_ are digital input output pins, the ones marked with an asterisk support pulse width modulated output. 3V3 outputs a constant 3.3Volts, GND the relative ground and AREF can be used to set an external reference voltage for the analog inputs. page 3 of 7

2 Rotation Sensors A photo interrupter can be used to detect rotation by placing a gear with spokes on the drive shaft of the motor so that each spoke will interrupt the beam. A photo interrupter in its most basic form is an led placed near a phototransistor so that when an object comes in between the led and the transistor the source to drain voltage drops. The photo interrupter used here is the Sharp Microelectronics GP1A73AJ000F. It has three pins, Vcc, Vout, and Gnd, with Vcc connected to the system's voltage source and Gnd connected to ground, Vout is near Gnd when the beam is uninterrupted, and near Vcc when the beam is interrupted. This results in a square wave output with a frequency that is proportional to the speed of the motor and the number of spokes on the gear. By routing this signal into one of the interrupt pins on the Arduino, the number of rotations can be calculated and stored in a persistent variable. The following is a simple code example that sets up a pin for interrupts and updates a variable. //Simple interrupts void setup() //attachinterrupt(<interruptpin>,<interruptserviceroutine>,<trigger>); // interruptpin is 0 or 1, for digital pin 2 or 3, interruptserviceroutine is the function to run // trigger is what will cause the ISR to run, can be LOW, RISING, FALLING or CHANGE attachinterrupt(0,updateposition,falling); //Setup pin 13 as an output, to flash the built in led pinmode(13,output); volatile int position = 0; volatile boolean direction = false; //The main program loop that runs while the board is active // This loop flashes the pin 13 led at 1Hz, each delay is 500ms void loop() digitalwrite(13,high); digitalwrite(13,low); void updateposition() if(direction = true) //moving in the positive direction, increment position position++ else //moving in the negative direction, decrement position position--; page 4 of 7

Direction in the above code is being tracked based on a variable, which would be generated by the Arduino when it sent a signal to a motor to move it. To make the system more robust a second photo interrupter can be added such that the spokes will interrupt both at once. When one is interrupted, the ISR will run, it can test a digital input pin connected to the second sensor. Its value at the time of the interrupt will be dependent on the direction the motor is spinning. The following is code that has been updated to detect the motion based on sensor input. This code will detect motor direction without having to infer anything based on the current output configuration. This means even external forces acting on the motor shaft will be properly interpreted by the controller. //Direction Detection void setup() //attachinterrupt(<interruptpin>,<interruptserviceroutine>,<trigger>); // interruptpin is 0 or 1, for digital pin 2 or 3, interruptserviceroutine is the function to run // trigger is what will cause the ISR to run, can be LOW, RISING, FALLING or CHANGE attachinterrupt(0,updateposition,falling); //Setup pin 13 as an output, to flash the built in led pinmode(13,output); //Setup pin 13 as an input, to read the second sensor for input pinmode(4,input); volatile int position = 0; volatile boolean direction = false; //The main program loop that runs while the board is active // This loop flashes the pin 13 led at 1Hz, each delay is 500ms void loop() digitalwrite(13,high); digitalwrite(13,low); void updateposition() if(digitalread(4) == HIGH) //moving in the positive direction, increment position position++ else //moving in the negative direction, decrement position position--; page 5 of 7

3 Speed Detection In order to detect the speed of the motor and compensate for it time must be taken into account. If the time is recorded at each pulse from the photo interrupter and compared to the time of the previous pulse, the motor rpm can be calculated. //Direction and Speed Detection void setup() //attachinterrupt(<interruptpin>,<interruptserviceroutine>,<trigger>); // interruptpin is 0 or 1, for digital pin 2 or 3, interruptserviceroutine is the function to run // trigger is what will cause the ISR to run, can be LOW, RISING, FALLING or CHANGE attachinterrupt(0,updateposition,falling); //Setup pin 13 as an output, to flash the built in led pinmode(13,output); //Setup pin 13 as an input, to read the second sensor for input pinmode(4,input); volatile int position = 0; volatile boolean direction = false; volatile unsigned long time = 0; volatile unsigned int dtime; volatile int rpm; const int spokes = 2; //The main program loop that runs while the board is active // This loop flashes the pin 13 led at 1Hz, each delay is 500ms void loop() digitalwrite(13,high); digitalwrite(13,low); void updateposition() if(digitalread(4) == HIGH) //moving in the positive direction, increment position position++ else //moving in the negative direction, decrement position position--; //millis() returns the time in milliseconds since the board was turned on dtime = millis()-time; time = time + dtime; //use the time calculation and the number of spokes to calculate the rpm of the motor rpm = 1/spokes * 1/dTime * 1000 * 60 page 6 of 7

4 Conclusion Configuration of an Arduino microcontroller to determine motor speed and direction is a fairly simple process. By using two photo interrupters on a motor and one interrupt line on the controller both values can be found reliably. Figure 2 The internal circuitry for the Sharp Microelectronics photo interrupter. With a pull up resistor between Vout and Vcc the circuit operates as described above. page 7 of 7