Metal Detector using PIC Microcontroller.

Thread Starter

apollo321j

Joined Dec 30, 2020
28
I have a project to build a metal detector robot with the PIC 16F877A. And I have to write a code in C programming language using mikroC. How should I start? I need some help.
 

Irving

Joined Jan 30, 2016
2,546
Start by writing down exactly what functionality you require, eg what makes a "metal detector robot"?

This sounds like quite a complex project for, what sounds like, a complete beginner. Break it down into sections eg what does the metal detecting bit do, what does the robot do, etc.

Will you construct this from scratch, or start with an off-the-shelf base such as this one?
 

atferrari

Joined Jan 6, 2004
4,577
I have a project to build a metal detector robot with the PIC 16F877A. And I have to write a code in C programming language using mikroC. How should I start? I need some help.
Learn to blink a LED with the micro. LED must be green.

For that, learn to configure the micro. In fact, learn what does mean. By mistake I went ahead blindly with that for two years until I solved that. Hardly a problem again.
 

Thread Starter

apollo321j

Joined Dec 30, 2020
28
Learn to blink a LED with the micro. LED must be green.

For that, learn to configure the micro. In fact, learn what does mean. By mistake I went ahead blindly with that for two years until I solved that. Hardly a problem again.
I don't understand but thank you. My first year in this lecture "Microcontroller and Programming" and The school asks us to do a project. But there is no report format or constraint for project or knowledge, Hence I want to write this post for explore other thinking and project if you made or making.
 

Thread Starter

apollo321j

Joined Dec 30, 2020
28
Start by writing down exactly what functionality you require, eg what makes a "metal detector robot"?

This sounds like quite a complex project for, what sounds like, a complete beginner. Break it down into sections eg what does the metal detecting bit do, what does the robot do, etc.

Will you construct this from scratch, or start with an off-the-shelf base such as this one?
Hi @Irving thank you your kindly response. I will start from your suggestion.Yes I am new in this lecture.I shock a little bit. I think to start with an off-the-shelf base because I'm already going to install the coding and other parts myself.
 

Pushkar1

Joined Apr 5, 2021
416
You've already got great answers. First of all you do not have to worry, it is all easy, you just have to complete this step by step, you will enjoy doing all this.

First of all you have to connect a led with your microcontroller then after that you have to write program for the led. you test your program whether the led is blinking as you want.
 

JohnInTX

Joined Jun 26, 2012
4,654
You can do a lot of your work with a pencil and paper.
First, break the project into smaller parts. For the robot shown above your project might have 4 parts:
  1. An LED to indicate things
  2. A left motor
  3. A right motor
  4. A metal detector.
Next, determine what the robot should do. This should be just a narrative, like you are describing it to someone without being too technical. An example might be:
"This robot drives in a direction until it detects a metal object. Then it stops, turns around and drives in another direction. An LED indicates when metal is detected"​
Add whatever else you would like it to do.​
From the supplied hardware and your project description, you can identify the parts of the program you need and what they should do:
LED:​
turn on​
turn off​
Left Motor - drive at same speed for straight lines, different speeds and/or directions for turns. Braking is nice if the driver supports it.​
OFF​
Run clockwise at some speed​
Run counterclockwise at some speed​
Brake​
Right Motor:​
OFF​
Run clockwise at some speed​
Run counterclockwise at some speed​
Brake​
Metal Detector:​
Sample the detector hardware and return 'Detected' or 'Not Detected'​
Now you have the various functions that the hardware can do for you. Begin to list procedures to do the things required:
Drive Straight and avoid metal:​
Left Motor (CW, Normal Speed)​
Right Motor (CCW, Normal Speed)​
while Metal Detector = Not Detected, wait.​
// Metal Detected:​
Left Motor (CCW,Slow Speed) .// back up​
Right Motor (CCW,Slow Speed)​
Delay a bit​
Right Motor (CW, Slow Speed) // differential motor turns robot​
Delay a bit​
Resume driving straight​
'Drive' the robot around in your mind, listing all of the steps necessary to do a particular action.
When you are satisfied, you will have a list of functions necessary to do the project.
Code and test each function separately. Document how each works.

Now, it is just a matter of stringing together function calls to match the lists of procedures that you figured out on paper. If you have tested each function and know that it will do what it says, programming the actual robot action to fit the narrative above is mostly syntax.

That's how it is done.
Good luck with your project.

 

Thread Starter

apollo321j

Joined Dec 30, 2020
28
You can do a lot of your work with a pencil and paper.
First, break the project into smaller parts. For the robot shown above your project might have 4 parts:
  1. An LED to indicate things
  2. A left motor
  3. A right motor
  4. A metal detector.
Next, determine what the robot should do. This should be just a narrative, like you are describing it to someone without being too technical. An example might be:
"This robot drives in a direction until it detects a metal object. Then it stops, turns around and drives in another direction. An LED indicates when metal is detected"​
Add whatever else you would like it to do.​
From the supplied hardware and your project description, you can identify the parts of the program you need and what they should do:
LED:​
turn on​
turn off​
Left Motor - drive at same speed for straight lines, different speeds and/or directions for turns. Braking is nice if the driver supports it.​
OFF​
Run clockwise at some speed​
Run counterclockwise at some speed​
Brake​
Right Motor:​
OFF​
Run clockwise at some speed​
Run counterclockwise at some speed​
Brake​
Metal Detector:​
Sample the detector hardware and return 'Detected' or 'Not Detected'​
Now you have the various functions that the hardware can do for you. Begin to list procedures to do the things required:
Drive Straight and avoid metal:​
Left Motor (CW, Normal Speed)​
Right Motor (CCW, Normal Speed)​
while Metal Detector = Not Detected, wait.​
// Metal Detected:​
Left Motor (CCW,Slow Speed) .// back up​
Right Motor (CCW,Slow Speed)​
Delay a bit​
Right Motor (CW, Slow Speed) // differential motor turns robot​
Delay a bit​
Resume driving straight​
'Drive' the robot around in your mind, listing all of the steps necessary to do a particular action.
When you are satisfied, you will have a list of functions necessary to do the project.
Code and test each function separately. Document how each works.

Now, it is just a matter of stringing together function calls to match the lists of procedures that you figured out on paper. If you have tested each function and know that it will do what it says, programming the actual robot action to fit the narrative above is mostly syntax.

That's how it is done.
Good luck with your project.

Thank you so much for good explaining. I will complete it know.
 

Thread Starter

apollo321j

Joined Dec 30, 2020
28
You've already got great answers. First of all you do not have to worry, it is all easy, you just have to complete this step by step, you will enjoy doing all this.

First of all you have to connect a led with your microcontroller then after that you have to write program for the led. you test your program whether the led is blinking as you want.
Thank you so much for good explaining. I will complete it know.
 
Top