ATTENTION: Due to increased demand and order volume, processing time may take an additional 1-3 business days.
HomeCommunitySubjectHow to Interface Stepper Motor with PIC16F877A Microcontroller?

How to Interface Stepper Motor with PIC16F877A Microcontroller?

8-bit Microcontrollers - MCU 14KB 368 RAM 33 I/O PIC16F877A is a 40-pin enhanced flash microcontroller. You'll learn how to interface a stepper motor with a PIC16F877A microcontroller in this post.

183

Mar 29, 2022

Andy Cocker

PIC16F877A a basic Introduction

 

8-bit Microcontrollers - MCU 14KB 368 RAM 33 I/O

PIC16F877A is a 40-pin enhanced flash microcontroller. You'll learn how to interface a stepper motor with a PIC16F877A microcontroller in this post.

 

PIC16F877A-I/P

24In Stock
Min.: 1 Mult.: 1
Quantity Unit Price Ext. Price
1+ $6.92525$6.93
10+ $6.53326$65.33
100+ $6.16345$616.35
500+ $5.81457$2907.29
1000+ $5.48545$5485.45
Unit Price:$6.92525
Subtotal: $6.93
Looking for a better price? Want a lower wholesale price? Please send an RFQ, and we will respond immediately.
Quick Links

PIC16F877A Pinout

PIC16F877A Pinout

PIC16F877A CAD Model

Symbol

PIC16F877A Symbol

Footprint

PIC16F877A Footprint

3D Model

PIC16F877A 3D Model

PIC16F877A Block Diagram

The following diagram of PIC16F777A is given below

PIC16F877A Block Diagram

Specifications

Microchip Technology PIC16F877A-I/P technical specifications, attributes, parameters and parts with similar specifications to Microchip Technology PIC16F877A-I/P.

PIC16F877A-I/P Tech Specifications

Microchip Technology PIC16F877A-I/P technical specifications, attributes, parameters and parts with similar specifications to Microchip Technology PIC16F877A-I/P.

Product Attribute Attribute Value
Factory Lead Time7 Weeks
MountThrough Hole
Mounting TypeThrough Hole
Package / Case40-DIP (0.600, 15.24mm)
Number of Pins40Pins
Data ConvertersA/D 8x10b
Number of I/Os33I/Os
Watchdog TimersYes
Operating Temperature-40°C~85°C TA
PackagingTube
SeriesPIC® 16F
Published1997
JESD-609 Codee3
Pbfree Codeyes
Part StatusActive
Moisture Sensitivity Level (MSL)1 (Unlimited)
Number of Terminations40Terminations
ECCN CodeEAR99
Terminal FinishMatte Tin (Sn) - annealed
Additional FeatureOPERATES AT 4 V MINIMUM SUPPLY
Terminal PositionDUAL
Product Attribute Attribute Value
Supply Voltage5V
Frequency20MHz
Base Part NumberPIC16F877A
Pin Count40
Supply Voltage-Max (Vsup)5.5V
Power Supplies5V
Supply Voltage-Min (Vsup)4.5V
InterfaceI2C, SPI, SSP, UART, USART
Memory Size14kB
Oscillator TypeExternal
Nominal Supply Current1.6mA
RAM Size368 x 8
Voltage - Supply (Vcc/Vdd)4V~5.5V
uPs/uCs/Peripheral ICs TypeMICROCONTROLLER, RISC
Core ProcessorPIC
PeripheralsBrown-out Detect/Reset, POR, PWM, WDT
Program Memory TypeFLASH
Core Size8-Bit
Program Memory Size14KB 8K x 14
ConnectivityI2C, SPI, UART/USART
Bit Size8
Product Attribute Attribute Value
Access Time20 μs
Has ADCYES
DMA ChannelsNO
Data Bus Width8b
Number of Timers/Counters3Timers/Counters
Address Bus Width8b
Density112 kb
EEPROM Size256 x 8
CPU FamilyPIC
Number of ADC Channels8ADC Channels
Number of PWM Channels2PWM Channels
Number of I2C Channels1I2C Channel
Height4.06mm
Length52.45mm
Width14.22mm
REACH SVHCNo SVHC
Radiation HardeningNo
RoHS StatusROHS3 Compliant
Lead FreeLead Free
0 Products View Similar

Overview

stepper motor is a type of motor that uses electrical pulses to generate mechanical movement. A stepper motor, unlike all other motors, moves in steps. The motor's steps are measured in degrees and can vary depending on the application. It takes one step at a time, and each step is the same size as the previous one.

A stepper motor has three excitation modes: wave drive, full drive, and a half drive. Only one winding is activated at a time in wave drive mode, whereas two phases are energized at the same time in full drive mode. In both wave and full drive modes, however, the number of steps is the same. Half drive mode combines wave drive and full drive, i.e. it alternately energizes one and two phases.

 

Task to Drive a Stepper Motor Using PIC16F877A Microcontroller

The following is a circuit diagram of a stepper motor connecting with a pic16f877a microcontroller:

Stepper Motor interfacing with PC16F877A microcontroller

The ULN2003 transistor array chip is the simplest way to connect a stepper motor to a Pic16F877A microcontroller. This IC  is used for high current torque motors and has seven Darlington transistor drivers. The four input pins  (1B2B3B4B) of the ULN2003  are linked to the lowest significant bits of the microcontroller's PORTD, while the output pins (1C2C3C4C  ) are connected to the stepper motor 's 'live' pins, as shown in the circuit diagram.
The stepper motor 's 'common' pins, as well as the ULN2003  's 'COM' pin, are connected to a 12V  battery supply.

C-CODE for Stepper Motor Interfacing with PIC16F877A Microcontroller

In the mikroC code editor window, type the following code:

  1. void main()

  2. {

  3. TRISD = 0b0000000; // PORT D as output port

  4. PORTD = 0b1111111;

  5. do

  6. {

  7. PORTD = 0b00000011;              // energizing two phases at a time

  8. Delay_ms(500); // delay of 0.5s

  9. PORTD = 0b00000110;

  10. Delay_ms(500);

  11. PORTD = 0b00001100;

  12. Delay_ms(500);

  13. PORTD = 0b00001001;

  14. Delay_ms(500);

  15. }while(1); // loop executed infinite times

  16. }

 

The code above shows how a stepper motor in full drive mode works. The above code will need to be tweaked somewhat for wave drive and half drive modes. The circuit diagram, on the other hand, remains unchanged. The controller's PORTD has been designated as an output port, which is fed to the ULN2003 driver IC. The input pins of the IC receive the combination of bits from the controller's PORTD, allowing it to turn on and off the motor's various coils.

Application of Stepper Motor

Stepper motors are widely employed in our everyday lives. Automobilesdigital photocopiers, computer printers, and other home appliances all use them to move the print head carriage. Industrial machines, security, and medical devices all employ stepper motors.

Datasheet PDF

PIC16F877A-I/P Documents

Download datasheets and manufacturer documentation for PIC16F877A-I/P

Frequently Asked Questions

What does a stepper motor use to generate mechanical movement?
Electrical pulses.
What does a stepper motor do?
Moves in steps.
How are stepper motors measured?
Degrees.
How many steps does a stepper motor take?
One step at a time.
How many excitation modes does a stepper motor have?
Three.
What is the simplest way to connect a stepper motor to?
Pic16F877A microcontroller.
How many input pins of the ULN2003 are connected to the lowest significant bits of the microcontrollers PORTD?
Four.
FAQ
What does a stepper motor use to generate mechanical movement?
Electrical pulses.
What does a stepper motor do?
Moves in steps.
How are stepper motors measured?
Degrees.
How many steps does a stepper motor take?
One step at a time.
How many excitation modes does a stepper motor have?
Three.
What is the simplest way to connect a stepper motor to?
Pic16F877A microcontroller.
How many input pins of the ULN2003 are connected to the lowest significant bits of the microcontrollers PORTD?
Four.

TAGS

Share