Step 3: Source Code

#include <18F458.h>
#device ADC=8
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#define GLCD_WIDTH 128

#define GLCD_E PIN_E0 // Enable
#define GLCD_DI PIN_B5

#define GLCD_CS1 PIN_A1 // Chip Selection 1
#define GLCD_CS2 PIN_B0

#define SERVO PIN_A3

#include <HDM64GS12.c>
#include <graphics.c>
#include <math.h>

char message[] = "EndtaS RaDaR";
float theta = 0, ytheta;

void main() {

int1 enbas;
int mesafe;
int car1, sayac, a;
int16 servopos;



glcd_text57(30, 0, message, 1, 1);

glcd_circle(29, 37, 26, 0, 1) ;
glcd_pixel( 29 , 37 , ON);
theta = 7.85;
servopos = 550;

mesafe = read_adc();
//printf("th: %f -> %u \r\n\n",theta, mesafe);

ytheta = theta;
sayac = 1;
if ( enbas == TRUE ){
sayac = 50;
for ( a=0 ; a<sayac ; a++){
delay_us( 20000 - servopos );
if ( enbas == TRUE ) {
glcd_circle(29, 37, 25, 1, 0);
glcd_pixel( 29 , 37 , ON);

if (ytheta >= 4.51 ) {
ytheta -=.02;
servopos += 12;
enbas = FALSE;
else {
//glcd_circle(29, 37, 25, 1, 0) ;
ytheta = 7.85;
servopos = 550;
//glcd_pixel( 29 , 37 , ON);
enbas = TRUE;

//glcd_pixel( 28+(int)(car1*sin(-theta)+.5), 38-(int)(car1*cos(theta)+.5), OFF);

//glcd_pixel( 28+(int)(car1*sin(-theta-1)+.5), 38-(int)(car1*cos(theta-1)+.5), OFF);

theta = ytheta;

car1 = mesafe / 8;
glcd_pixel( 28+(int)(car1*sin(-theta)+.5), 38-(int)(car1*cos(theta)+.5), ON);
Hello, friend. Thanks for sharing your work. But, I try to compile, and got some errors. <br> <br>I'll apreciate it, if you could help me. <br> <br>Clean: Deleting intermediary and output files. <br>Clean: Deleted file &quot;Radar.ESYM&quot;. <br>Clean Warning: File &quot;C:\Microcontroller software\PICC\Devices\Radar.o&quot; doesn't exist. <br>Clean: Deleted file &quot;Radar.ERR&quot;. <br>Clean: Done. <br>Executing: &quot;C:\Microcontroller software\PICC\Ccsc.exe&quot; +FH &quot;Radar.c&quot; I+=&quot;C:\Microcontroller software\PICC\Devices&quot; +DF +LN +T +A +M +Z +Y=9 +EA <br>*** Error 18 &quot;Radar.c&quot; Line 17(10,23): File can not be opened <br> Not in &quot;C:\Microcontroller software\PICC\Devices\HDM64GS12.c&quot; <br> Not in local &quot;C:\Trabajos Micro2\HDM64GS12.c&quot; <br>*** Error 18 &quot;Radar.c&quot; Line 18(10,22): File can not be opened <br> Not in &quot;C:\Microcontroller software\PICC\Devices\graphics.c&quot; <br> Not in local &quot;C:\Trabajos Micro2\graphics.c&quot; <br>*** Error 18 &quot;Radar.c&quot; Line 19(10,18): File can not be opened <br> Not in &quot;C:\Microcontroller software\PICC\Devices\math.h&quot; <br> Not in local &quot;C:\Trabajos Micro2\math.h&quot; <br>*** Error 12 &quot;Radar.c&quot; Line 35(10,11): Undefined identifier -- glcd_init <br>*** Error 12 &quot;Radar.c&quot; Line 37(16,17): Undefined identifier -- glcd_fillScreen <br>*** Error 12 &quot;Radar.c&quot; Line 39(12,13): Undefined identifier -- glcd_text57 <br>*** Error 12 &quot;Radar.c&quot; Line 41(12,13): Undefined identifier -- glcd_circle <br>*** Error 12 &quot;Radar.c&quot; Line 42(13,14): Undefined identifier -- glcd_pixel <br>*** Error 12 &quot;Radar.c&quot; Line 63(12,13): Undefined identifier -- glcd_circle <br>*** Error 12 &quot;Radar.c&quot; Line 64(13,14): Undefined identifier -- glcd_pixel <br>*** Error 12 &quot;Radar.c&quot; Line 90(13,14): Undefined identifier -- glcd_pixel <br> 11 Errors, 0 Warnings. <br>Halting build on first failure as requested. <br>BUILD FAILED: Wed May 22 02:15:15 2013 <br> <br>
why dosent the video play when i click play? is there even a video, plz post it to youtube and add a link in the reply <br>
good project but can i make it with pic 16f877a and Nokia 3310 GLCD?
Infrared is LiDAR, not RADAR. Please use proper terminology so that when people search for projects they can find what they want.
it just the same. i dont think it needs the right terminology.
a little edgy of a comment. but i am sure you addressed your concern with Sharp directly. <br>you must have gotten a ticket lately.
can it sense more than one object in line?
This needs a video... SOOOOO BADDDDDDDDD
it has a video already. :)
the video won't work for me but this is awesome!!! i'm hopefully going to make me one!!!
please tell me the link <br>
hiii.. I want that circuit diagram and part list toooo...<br>hope can sent at my email: sahl199@yahoo.com<br>thanks<br><br>:)
i need proteus simulation of infrared beam detector circuit,<br>that when receiver is not receiving it should enable relay and turn on LED.<br>a similar circuit is given URL :<br><br>http://www.extremecircuits.net/2010/03/beam-break-detector-for-camera-shutter.html<br><br>contact: xink_25@yahoo.com<br><br>PLZ HELP,,,
awesome project man.Can you send me all the component used on this project more detailed and also with the circuit.thanks for sharing this project.This is my emel address mfdh_90@yahoo.com.
can u also sent me the circuit? thanks
&nbsp;Oks!&nbsp;<br /> Can you please mail me the circuit diagram. The proteus file is hard to understand for me. Please!&nbsp;<br /> My email id is braingreat@gmail.com!&nbsp;<br /> Thanks!&nbsp;
&nbsp;WoAAh .... What a project......&nbsp;<br /> &nbsp;can u tell each and every thing which is used in this project..... under a heading of &quot;PARTS LISTs USED&quot;<br /> THAnks ...
&nbsp;Oks! But where is the sensor GP2D12 connected?&nbsp;<br /> I don't see it anywhere in the schematic diagram!&nbsp;<br /> <br />
its connected to the Pin_A0&nbsp;
&nbsp;Heya!&nbsp;<br /> Nice work!&nbsp;<br /> but I dont understand where have you kept the Gp2D12 sensor from your circuit diagram!&nbsp;<br /> And pls can you tell me how have you simulated the sensor with Proteus and how can I input the position of any obstacle to it!&nbsp;<br /> Thanks in advance!&nbsp;
RV1, the trimmer resistor at the right side of the LCD &nbsp;simulates the output voltage of the sensor. There is no direct sensor simulation in my proteus file.&nbsp;
&nbsp;Thanks for the help!&nbsp;<br /> Now I can work upon the code to understand it and make one for the AT89C51 I intend to use in this project :)
Great project!&nbsp;<br /> But I have just one doubt!&nbsp;<br /> Is the coding given complete?<br /> Because when i tried to compile it using Mplab it gave an error! And I feel that there are some functions being called in it which do not have any definations given!&nbsp;<br /> Do i require to be a Pro member to get the full coding? Or am I doing something wrong?<br /> Pls reply, caus I really wanna make it!&nbsp;
thanks.<br /> <br /> the code is complete but it is for CCS C&nbsp;compiler.<br /> <br /> You would need to make some porting to compile and run it in microchip c or any other c compiler.&nbsp;
Soo... The only thing it does is makes you know when something is in front of the sensor? If i were you, i would add some kind of a progress bar as the sensor scans one wave, and when something is detected, mark the place under the bar, or light a LED or something. If i only knew how.. Great job though!
thanks. the progress of the scan is shown on the graphics LCD. detection mark etc. are cosmetic modifications to the code, the code as well as the circuit schematic is included in the article. Any modification can be made by anyone who is interested. I also would love to see my project to be modified and improved. ;)
omg!!!you have way to much free time(how old are you?you dont have to tell me)
I'm 38 and not working for a company currently. I'm working on my own, trying to improve my latest works, solar lighting products, planning to sell them and form my own company.
oh..... check this <br/><br/><a rel="nofollow" href="http://current.com/items/89321131/12_year_old_may_hold_key_to_solar_energy.htm">http://current.com/items/89321131/12_year_old_may_hold_key_to_solar_energy.htm</a><br/>
Great app there. Can you give me a little more info about the PWM generated for the Servo. I am trying to get the servo rotation between 1ms and 2ms pulse and I get a 90 degree rotation. Your video shows 190degree rotation.
Great project... The servo wich you used is modified? The hs55 have a range 0-90°...
The servo is an unmodified HS55 and it runs like in the videoclip with a nearly 190° range.
is your souce in hi tech C or CCS? and if not what is it in? thanks for the great inspiration
it is written in CCS C. thanks for your comment.
technically its LIDAR not RADAR
I thought the L in Lidar stood for laser.
LIght Detection And Ranging maybe :)
That's it! That makes more sense. Thanks :)
THIS IS A MAN'S WORLD!! dun-dun da dunnn! *rocks out*
This is an interesting project, which makes it a shame the Instructable is so thin. I'm sure if I had all the materials this would provide enough information for me to be able to build my own, but you could have put in a lot more about the context. How does the IR sensor work? What inspired the project? Are you planning to use it in something bigger? Could you replace the IR sensor with an ultrasound one?
thanks friend. Well the instructable is focused only on building the circuit and the source code. Yes the materials are enough to build and run the project. The sensor is a very well designed and produced one and it has got some 20 pages of datasheet. Honestly it can be quite difficult for me to explain how it works. its explained long and well in the datasheet, which is downloadable in the sharp's website. I have tried to build my own IR distance sensor for some time and obtained some good results. Although not as good as this sensor, mine also worked fine and I've used in several robotic projects with success. But due to some tolerances in the components or any other reason, my sensor wasn't an all-times runner. When i build 5 circuits, at most 2 or 3 worked fine. I didn't know why. I've also worked on building an ultrasonic sensor. IT also works fine. Yes the IR sensor can be replaced with an ultrasonic one. The code would need to be modified for sure. The radar circuit is a testbench for the sharp sensors which I'm planning to use in my later robotics projects.
Pretty cool stuff. What sort of azimuth resolution are you getting with this particular sensor? I notice the servo's a bit jerky right as it begins its turn. Any ideas what's causing that? Can you post a larger copy of the schematics? It's difficult to read the pins. Thanks for sharing this project.
well i honestly don't know what azimuth resolution is but the details of the sensor can be found in its datasheets. All I know is it works fine within 3-50cms and it is quite adequate for a robotic radar. the servo control pwm signal which is generated by the microcontroller by software is not so well calculated. that may be causing some variations in the beginning and and in the end of the full swing. By improving that part of the software it can be resolved. I've posted a better gif version of the schematics. Its been a pleasure to share. ;) visit my website www.endtas.com/robot, there are over a hundred projects to see.

About This Instructable


68 favorites


More by hobbyman: Strengthening a 3D Printed Part Steampunk Table Clock Multi symmetrical DMC LOGO for Accesory, Decoration, Ornament or Keyholder
Add instructable to: