PIC16F877......line follower...help

Help......the line follower once again!!!

okay so i finally have a few days to myself again and i have decided to try and finish up this line follower that i had been working on last year. I was using the design ideas that Ash provided under the thread started by robo-girl called "help...i need help with the line follower".

Ash could you please give me the type of photo transistors and IR Leds you used. Furthermore could you please help me with the coding. I mean i only like have a week to complete this. I am really struggling with the start of the coding.... i mean how do i actually do the sampling initially so that the line follower knows where exactly it is positioned? Please help.......after all this is just something i am doing for fun and if i dont finish it now i never will! Thanks :smile:

Replies

  • Ashraf HZ
    Ashraf HZ
    preeste
    Help......the line follower once again!!!

    okay so i finally have a few days to myself again and i have decided to try and finish up this line follower that i had been working on last year. I was using the design ideas that Ash provided under the thread started by robo-girl called "help...i need help with the line follower".

    Ash could you please give me the type of photo transistors and IR Leds you used. Furthermore could you please help me with the coding. I mean i only like have a week to complete this. I am really struggling with the start of the coding.... i mean how do i actually do the sampling initially so that the line follower knows where exactly it is positioned? Please help.......after all this is just something i am doing for fun and if i dont finish it now i never will! Thanks :smile:
    Welcome back, preeste ๐Ÿ˜‰

    Just for your info, I did not use photo trans nor IR LEDs. I used the simple LDR and LED combination.
    The sampling really depends on what threshold values you get for each sensor. I've described the coding on how to get it here:
    #-Link-Snipped-#

    Once you know the threshold, you just simply use IF conditions to check whether the robot is on the either side of the line, or right in the middle. This is done by comparing what the value the sensor is currently detecting, and the threshold value. I can't fully remember the C code, but the algorithm would be like this:

    if right_sensor < right_threshold 
    AND if middle_sensor > middle_threshold
    AND if left_sensor < left_threshold
    THEN bot is centered on the line
    The you can repeat for the conditions of the bot being on the left and on the right.

    Can you tell me what your progress is so far? Can you upload pics of your robot if possible?
  • preeste
    preeste
    Hey ASH

    Sorry about the really delayed reply. Was caught up with a whole situation. Anyways i am back.

    Well i built the actual line follower and i used photo transistors and normal LEDs instead of IR ones. I did this cause i had read somewhere that the robot would work better this way. I then started with my whole programming and got stuck. I am using the design of the PIC that was supplied on the microchip website and their ICD1. I also got stuck with the way in which to interface the c coding into mplab. so waiting to get some help there. Would love to post some pictures up but the problem is my camera was lost a few days back. will do that as soon as i replace mine. Tell me something....what type of lDRS and LEDS did you use? and how many?

    Thanks once again for all your help....reALLY APPRECIATE IT.
  • desijays
    desijays
    Im not sure if you can use 'C' in MPLAB to program the 16f877. I was told 'microchip' does not have any 'C' compilers for the 16 series. Though there are third party compilers which you will have to obviously buy. Infact there is one demo compiler that comes with MPLAB. You have to 'check it' during installation though.

    Microchip makes compilers for the 18 series and beyond.
  • Ashraf HZ
    Ashraf HZ
    You can use the free HI-TECH PICC-Lite ๐Ÿ˜€
    #-Link-Snipped-#

    I have not used it before, but I came across a page last year. The instructions include using the version 7 of MPLAB as well as the PICC-Lite. Go directly to step 3:
    #-Link-Snipped-#

    In fact, this page might be useful for you ๐Ÿ˜€ They even provided their C code! Have a read through it carefully.

    Personally, I've used 3 standard bright LEDs and 3 LDRs. I dont know the code for the LDR, but it is similar to this one:
    #-Link-Snipped-#

    I think I used the 2nd smallest one (5mm), and wrapped it with black tubing to shield it from ambient light, so it can only see the reflected LED light.

    I think I'll try getting my hands on some Atmel AVRs.. they seem to have alot of free 3rd party support.
  • preeste
    preeste
    hey .....i was using the compiler that was also free ware off the microchip website called ccs. thank you for that website Ash. I think it may come in very handy. Was hoping to get started on it this week....but looks like i will only be able to start on monday. But thanks and will definetly be needing more help as i go along. Will let u know how its going once i start with the programming.......And yes you are absolutely right about Atmel AVRs having a lot of third party support ๐Ÿ˜€

    Thanks again ๐Ÿ˜€
  • preeste
    preeste
    Hey Ash

    So i am finally back and getting to start on the software. Now as i have mentioned earlier i have 3 sensors connected to the analog inputs of the pin. Now i need to know if this is going to be a problem....when my sensor moves from a white surface to a black line the voltage drop is only about 1 V? is that a problem when using ADC? Please let me know. Do you think i should change my sensors?

    Thanks a lot Ash.
  • preeste
    preeste
    Hi Ash

    Will u take a look at my previous post about the volt drop across my sensors and tell me what u think?

    Thanks man
    ๐Ÿ˜€
  • Ashraf HZ
    Ashraf HZ
    Hey preeste!
    Is it possible to see the schematic diagram on how the sensors are connected to the PIC? And have you shielded the sensor and LED array from ambient light? This will make sure the sensors more sensitive to the LEDs reflecting off the surfaces.
  • preeste
    preeste
    Hey. Yes i did shield the sensors from ambient light. I will put up a diagram of my sensor setup tomorrow.
  • preeste
    preeste
    Hey Ash

    Here is a setup of my sensors. The diagram just shows one sensor and how it would be connected to the analog pin of the PIC. By the way i did shield my LEDs and phototransistors. Do you think u could put up a sensor schematic. Am thinking of using LDRS. By the way did you use timers and interrupts in your program? Please help me with that part as well. Sorry about this. Am attaching the diagram. Thanks a load. Sorry i did not reply earlier. had to go out of town for work. Anyways thanks a lot in advance.
  • Kaustubh Katdare
    Kaustubh Katdare
    Woops! Preeste, it looks like the image file resides on your local computer. Why don't you send it directly to Ash [ ash at crazyengineers dot com ].

    Ash: Please post the picture here, once you receive it from Preeste ๐Ÿ˜€
  • preeste
    preeste
    Thanks Big K for that. Did not realise i had added that to link. WIll email it to him.
  • Ashraf HZ
    Ashraf HZ
    Okayz, here we go. Thanks preeste for the image!

    #-Link-Snipped-#


    What kind of LEDs do you use? Are they specifically Infrared LEDs? And try using a 1M ohm pot, so you can actively adjust the sensitivity of the input to the PIC while testing for the treshold. Here's a possible way to mount the components within their enclosures:

    #-Link-Snipped-#


    The LED is angled slightly towards the detector, so the center of reflection can be clearly seen by the detector when its off the line. This makes a lot of difference when the detector has to know the "edge" of the black line, which is the basis of line following. How much the angle is really done through trial and error. Unfortunately for you, you'd need some sort of infrared screen or goggle to "see" how well the infrared is aligned ๐Ÿ˜› Just gently bend the legs(perhaps by using a nose plier) to test the optimum angle. Ideally, you'd want the center of the beam to be seen by the detector clearly. Thus, when the beam starts to go off the edge of the black surface, the detector will get an input. This will make your life easier when determining the threshold.


    Here's the simple schematic we used. We selected the 20k resistor in line with the LDR. This configuration is pretty robust, easy to troubleshoot and very quick to fabricate. The LED is a super bright variant.

    #-Link-Snipped-#

    Regarding timing, yes, we had a delay of 33ms for the detecting loop (kind of like the refresh rate). Thats what our seniors used. I believe its because of electrical/component delays I suppose. You might need to research about that since perhaps the phototransistors may need different delay durations. Can't help you there!

    Hope these diagrams are useful. Good luck!
  • preeste
    preeste
    Hey. Sorry about the delayed reply. Well i actually was using red LEDs and the drop was only about 2V. When i used infra red LEDS the drop in voltage is much higher. But here is the thing i would prefer to stick to the red leds. I mean atleast i can see whats happening then. I mean is that drop of 2V not adequate for ADC conversions?
  • preeste
    preeste
    And once again thank you for all the effort u are taking. really appreciate it ๐Ÿ˜€
  • Ashraf HZ
    Ashraf HZ
    I think the 2V drop is good enough. However, you really need to see the drop that the ADC on the PIC is seeing, not the multimeter (I assume you using that to measure the voltage drop, yea?). To do this, you'll need to code up a simple program to display the output through Bootloader.. I think we've discussed this before. The range will be from 0 to 255.. 255 being the 5V.

    Get an average value for when the sensor is on the black line, then the average when the sensor is off. Add them, divide by two, you should get the threshold.
  • preeste
    preeste
    Hey.I am using a multimeter. We did have a discussion about that already but here is a problem. I am using the PIC C compiler. What is bootloader? Can i download it off the net? Not actually sure.
  • wssameera
    wssameera
    Hi preeste, I was looking at your line follower bot project. actually i am really interested about it. could you solve your sensor callibration problem?
  • Ashraf HZ
    Ashraf HZ
    Oh gosh, I should really subscribe to this thread! Sorry for the late reply..

    Preeste, To use the bootloader, you need to have already constructed the circuit that I gave Robo Girl last time. You dont need draft a PCB, just use a prototyping board. Once that is set up, you can use a Serial cable to connect the circuit to the computer. The bootloader will read and write to memory locations of the micro C.

    I suggest you set this up first. Your sensors can be added and tested later.. The main focus should be the brain of the robot!

    Regarding the microcontroller, is it a new one? Has it been loaded with a firmware yet?
  • preeste
    preeste
    Hey Ash

    Okay so i do have the correct microcontroller board setup like the one you described to robogirl. Have the firmware loaded too. The problem i am having is using the printf statement with my ccs compiler. How would you do that? Anyways I will get back on it and onto this forum in a few weeks. Going out of town for a few weeks with work. But i will be back soon. I really want to solve this whole thing toooo ๐Ÿ˜€ Once again your help is greatly appreciated.

    Hey Wssameera.....with regards to your enquiry the most honest answer would be to say know. When using the multimeter i can see a drop of about 2V when the light reflects back onto the phototransistors but i still need to figure out how to get a printf reading to see how the analogue pins are reading this values. But as i said i will be away for a few weeks but then i will try again and keep updating this thread.

    Thanks again Ash ๐Ÿ˜€
  • sumith123
    sumith123
    learn some basics from already made line follower robot
    #-Link-Snipped-#

    and try to do alone (never ever copy others project ....just learn from others is best and simple policy)

You are reading an archived discussion.

Related Posts

Everyday, we get lots of new members with really 'odd' user ids ๐Ÿ˜‰ . So, I think it would be interesting to know the reason behind that odd yourname of...
Any high degree in MBA/Marketing online? What would be the top universities that provide Online MBA/ marketing courses, if you have any idea about that please give me information.
๐Ÿ˜”Well it's a matter of fact that MBAs do proclaim themselves as professionals. Well Iam really scrambled here, Can any one help me out?๐Ÿ˜
This blog is mainly for beginners in robotics , this wuld give them a head start towards robotics, plz plz check it out and comment so tat i can improve...
Hello, frndz here is some topics seminar topics... NRAM, Ubiquotous computing,Autonomus computing,Green computing,Millipede,..and so ......... if any body wants email me @......................