Skip to main content

The future of AI in business and its potential to transform industries

Interfacing of DC motor with PIC18 controller

interfacing DC motro intro page

DC motors are rotary motors that convert electrical signals into mechanical motion.

DC motors are also one of the most useful peripheral devices in the embedded domain, we can use the DC motors from our academic projects to toys and gadgets sold in the market.

In this article, we will talk about the interfacing of DC motor to the PIC18F4520 controller.

We will cover the topics in the following ways:-

  • About the Task
  • Required components
  • software tools
  • circuit diagram
  • writing code for the controller
  • uploading the hex file to the controller
  • Simulating the project

About the project

In this interfacing task, we will control the rotation of the DC motor with a push button. When the push button is pressed the motor will rotate in a clockwise direction otherwise it will rotate in an antilock wise direction.

Required components

For the simulation, the components which are required are:-

Software tools

The software tools required for this project are
The circuit diagram for the interfacing is given below

interfacing DC motor circuit diagram

In the circuit diagram you can see, the L293D motor driver is connected to the C0 and C1 pin of the PORTC and the push button is connected to the B0 pin of the PORTB. The DC motor is connected to the output pin of the motor driver.

Writing code for the controller

After connecting all the circuit components, now open your MPlab IDE and write the code given below.

code

#include <xc.h>

#define _XTAL_FREQ 20000000

#define button RB0
#define relay RC0

void main()
{
    TRISB0=1;
    TRISC0=0;
    
    if(button==1)
    {
        relay=1;
    }
    else
    {
        relay=0;
    }
}

After writing the code all you need is to run, execute and generate the HEX file.

Upload Hex file to the controller

To upload the generated Hex file all you need is to double click on the controller and select the program file.
Don't forget to change the clock frequency from 4 to 20 Mhz.

how to upload HEX file to controller

Simulate the project

To simulate the project all you need is to click on the play button on the bottom left corner of the simulator.

Video


Popular posts from this blog

Top 7 domains to expertise after learning python

Top 7 domains to expertise after learning python Python is one of the most popular programming languages. It is an object-oriented, dynamic semantics and high-level programming language. It's high-level built-in data structure combined with dynamic binding and dynamic typing makes it attractive for rapid application development. Often programmers fall in love with python because of the increased productivity it provides. Python is one of the most readable languages in the world right now. This language is very popular among developers and is widely used by many programmers to create application and programs. The implementation of this programming language is simple and at the same time, the language has a very clean structure as compared to other languages.  So if you mastered your python concepts and skills, you can dominate these 7 domains. Machine learning / Artificial intelligence Desktop GUI Data analytics and data visualization  Web development Game development Mobile ap...

Different domains of Artificial intelligence(AI)

Artificial intelligence is a computer system that is able to perform tasks that ordinarily require human intelligence. Artificial intelligence systems are critical for companies that wish to extract value from data by automating and optimizing processes or producing actionable insights. There are certain domains of artificial intelligence on which we can create our expertise Machine learning Deep learning Robotics Expert systems Fuzzy logic Natural language processing Computer vision  1. Machine learning Machine learning is a subset of artificial intelligence. Machine learning enables computers or machines to make data-driven decisions rather than being explicitly programmed for a certain task. These programs or algorithms are designed in a way that they learn and improve over time when are exposed to new data. Different types of machine learning models Supervised learning Unsupervised learning Reinforcement learning Use cases Product recommendation on a shopping website. spam fil...

Top 5 free machine learning courses with certificate

In the era of 21st-century artificial intelligence, machine learning and data science became the most demanding and highest paying skills. After the covid-19 pandemic situation, the working style of the corporate sectors and the business had completely changed, now most of the business deals are made on the basis of data analysis, or when it comes to making the businesses automation the people hire a  machine learning engineer.    Hence it becomes really important for those who work in the corporate sector or a student pursuing a degree to get a job should update himself with these skills.  So, I listed you Top 5 machine learning courses from one of the leading organisations with completion certificates at free of cost. 1. Machine learning in the cloud with AWS batch About This course describes how to run and accelerate your machine learning applications in the cloud using AWS batch. AWS Batch is a fully managed service that allows you to easily and efficiently run b...