Need a PIC based Line Following Robot

Status
Not open for further replies.
Hi
Pic and atmega both are available in Kolkata. I always like Pic. If you like to do well in Microcontroller, first stick to one type, learn Assembly Language and afterwords you can try C Language.

Collect the original program and then I may rewrite the program for you if I get time. Pic 12F 675 and 12F 683 are beautiful piece of controllers and I made lot of Program with those.
Microcontroller is the future of Electronics. If you want to be in Electronics, learn Microcontroller. With Microcontroller, you can create wonder in Electronics.

With thanks.


____________________________________________
IDEAS ARE MONEY IF THEY CAN BE USED ON GROUND.
বাস্তবে ব্যবহারযোগ্য চিন্তাধারাই মানুষের প্রকৃত সম্পদ।
 
well...thats no problem.....See what happens with ATmega8..

Can you give me the programs that you wrote for 12F683.

Can you tell me about the programmer that you used to program 12683? Can you give me the link/schematic or anything else about the programmer?



I agree with u বাস্তবে ব্যবহারযোগ্য চিন্তাধারাই মানুষের প্রকৃত সম্পদ।
 
No problem🙂 ......

But where to start?🙁 I'm too much confused:bigeyes: . I mean there are many highways,alleyes, doors and windows to learn about microcontroller.Can you give me suggestions where to start first?
Will I learn C programming first? Or will I learn the assembly language first? Or something else?
 
Hi Paswa,
I am also a school going kid like you.
I am learning microcontroller and am using the PIC 16F84A.
First I learnt Assembly and now I am learning C.
My advice to you is that you first learn assembly and then go for C. If you know assembly, you will know everything that is going on in your controller. But if you use C, you will be ignorant about many details regarding the controller and program. When you come to Bangladesh, you can use English, but to make most of the people understand you have to use Bangla. Microcontroller is also like that. You can use C but to understand most, you have to use assembly language.


_____________________________________________________________________________

The strongest man in the world is one, who stands alone for achieving something good.
পৃথিবীতে সেই সবচেয়ে শক্তিশালী ব্যক্তি, যে ভাল কিছু অর্জনের জন্য একাই নিরন্তর চেষ্টা চালিয়ে যায়।
 
I used this programmer:-

Sercon II

and the program (progpic) from the same site for several years, but serial ports are getting rarer, and the device library is limited.

The USB PicKit 2 is good value for money, does ICSP and integrates with MPLAB. This is less complicated than generating a hex file with MPASM and then shifting to another program to program(!) the chip, which can be a step too many for a beginner with no-one to demonstrate it.

If you can get a PicKit 2, or one of the clones from ebay, then you can avoid the complication of building the hardware. The circuits may be simple, but debugging one that doesn't work first time can be very difficult if you have never proved the software workflow (done the programming with one that works previously).

You can also get a board along with the PicKit with the ICSP pins on it. You can swap chips into and out of it to program them, or copy the connections for a new board. You can be sure you've got it right then, which again can be difficult for a person working from a circuit diagram for the first time. It also has a few LEDs, a pot and a switch so you can demo or test simple programs. The switch on mine went faulty tho'.

w
 
Hi,
Paswa,
Actually I did not learn from any specific book or the internet.
I learnt from my dad who is one of the best PIC microcontroller programmers in Bangladesh.
It is very difficult to learn by oneself, but if you stick to it, you will certainly be successful. I can help you on the way.
It is not possible to learn from only one source, but from many different sources.
Stick to it. Do not give up and in the long run, you will certainly be successful.

লেগে থাকলে তুমি নিশ্চয়ই সফলকাম হবে। যারা পরিশ্রম করে এবং ধৈর্য ধরে, সাফল্য তাদের নিশ্চিত। ধন্যবাদ।
_____________________________________________________________________________

The strongest man in the world is one, who stands alone for achieving something good.
পৃথিবীতে সেই সবচেয়ে শক্তিশালী ব্যক্তি, যে ভাল কিছু অর্জনের জন্য একাই নিরন্তর চেষ্টা চালিয়ে যায়।
 
Paswa,
Wakibaki has given you a sincere and good suggestion on one sense.
Tahmid is also correct in his perspective. If you want to learn to program Pic, you can purchase Pic kit2 and the board. But are you in a hurry? You are a school going kid and enough time is there in front of you. Instead of lighting some LED etc. with the help of ready made board and programming with pic kit2, you may try to build one by yourself and also can make your own Training Board and by doing so, you will be learning valuable lessons, which will be useful for you throughout. You may be unsuccessful for 1/2 times but ultimately you will be successful. I will provide you the design of my programmer, will provide the source of software, from where you can collect and if cannot, I will mail you the software. You can get these from internet also. If you are interested in Assembly Language, I can post you some of my programs written for 16F84A and these I can post through this Forum, so that others who are interested can see.

When I started Pic Programming, I also faced lot of problems with programmer as it was not available in my country and no office or agent of Microchip are here and hence I went to self making route. I made those with lot of hard work but that effort gave me lot of benefit. Afterwords, I earned lot of money by selling my programmers and Training Boards for different Pics. I furnished my Laboratory lavishly with those money.

Hardwork never goes in vain and shortcut may not help you in the long run.
I will take 3/4 days more and then I will start helping you.

Thanks.

____________________________________________
IDEAS ARE MONEY IF THEY CAN BE USED ON GROUND.
বাস্তবে ব্যবহারযোগ্য চিন্তাধারাই মানুষের প্রকৃত সম্পদ।
 
Of all conventional programming, assembly language programming is the most difficult place to start (has the steepest learning curve), and in some ways has the narrowest application.

A good introduction to programming nowadays is HTML or web page construction. It is the most accessable, and at the same time most exciting discipline for an all-round programmer. It extends through xml, ASP(.NET), php, javascript, Java, SQL, the whole range of high level languages and even assembly language, and encompasses operating systems, networking and web technology.

You can get an immediate result and build up your confidence and programming skill.

There is an outstanding series of tutorials at w3schools.

You should still try to learn assembly language too as this provides the ultimate level of machine control. After that you can learn VHDL.

w
 
Thanks everybody...S.G Mahbub,Wakibaki, Tahmid 🙂
And special thanks to Tahmid because I always get inspiration from him as he is just a school going boy like me.

I got my the electronic components of my dream. Like I got a PIC16F84A, a ATmega8, a 16x2 LCD module called "JHD 162A". who need more things to start microcontroller programming.

I have started assemblyt lang. learning from net....Hope I'll overcome it.

PIC Kit 2 ? I'll try to get this one...but I could make it out myself.

Now I need the simplest PIC16F84 programmer which only supports 16F84. After burning some programs to PIC16F84 I'll build a universal JDM programmer or the programmer that my friend, Mahbub built.

Along with PIC I've to build a Atmel AVR programmer later.

And projects with LCD module is always very interesting to mee......oh HElllo Worldd
🙄 🙄

The simplest 16F84 programmer of the world must be THIS I'll build this one fitst..

Thanks everybody..
Come again next day...
Theo(my name)
 
Hey friends....I failed everywhere... My PIC programmer didnt worked...my AVR Atmega8 programmer failed after reading twice,,I'm not sure if I have destroyed my microcontrollers.


PLEASE please share something good programmers for me please and please😕 😕 :bigeyes: 😕 :clown: :dead: :whazzat: :apathic
 
Paswa, don't give up.

It is very common to have difficulty programming a PIC first time especially with a home-made programmer.

I had experience programming a Z80 system with an EPROM, 80x86 assembler, 68000 and other systems. Still it took me hours to get it to work. One error in your program or setup or soldering fault can mean nothing will work, but you don't know where the fault is. If you knew that the program and setup were OK, then you could say the problem was in the soldering, but 3 unknown things is too many.

This is the same all over computing and electronics. One small thing is changed, and maybe your broadband stops working.

One small thing is changed, and your programmer starts working. But which thing?

This is why it is better for some beginners to buy a programmer and a demo board with some working example programs.

When you have a working setup, then you can modify it and start to really learn. You change one thing at a time. Now if you get a problem, you know where it is.

It is also very common to destroy processors by accident, but yours may still be OK. You have to accept this cost as part of the learning process. Perhaps you will be luckier or more careful than me, I always need to have spare processors.

What kind of serial port do you have? Is it on a card or motherboard in a desktop or is it on a laptop or is it a USB-serial adapter?

What are you going to test your programmed processor in?

The PicKit 2 low-pin-count demo board will run from the USB power. This is convenient. Any low-power board you build will also run the same way.

The circuit you referenced looks a bit simplistic, but it may well work. The SERCON 2 circuit I referenced earlier definitely works with a conventional serial port.

Keep trying.

w
 
Thanks everybody. Thanks

I've to forget the days of failure and have to start again with new hopes.

First I built the simplest PIC 16F84 programmer that I mentioned on a breadboard. And i'M SURE THAT THERE WAS NO ANY CONNECTION MISTAKES. I hooked up the serial port (which is in my motherboard D945GNT). I started the program that they suggested to use. But It didn't worked. While writing, after 28% done, it said write error.

There may be reasons behind it. I measured the voltage in Vdd (respect to GND) was 5.6Volt. PIC16F84A datasheet tells that the max. operating voltage should be <5.5V and maximum voltage should be 8.5V on Vdd pin. The MCLR voltage waw correct....It was 12.75V

I forget to shoot any pic of my setup. I dont know have I destroyed my MCU.

Now to the story of Atmega. I used a programmer called "Sercon II-mini". I arranged everything correctly on my breadboard and connected thr Atmega8. the program bundled successfully managed to detect the programmer and the chip. It managed to read from the flash memory twice and saved it. But I deleted the file accidently. But I remeber that the first line was 0000...second line was the same but the other lines was filled up with a jungle of binary (or hexadecimal number, I dont remeber clearly)100101010101111010 etc... And when I clicked on a option called "data window" then everything gone died. The software failed to detect the atmega8...and I tried in various way
but nothing seemed to work....DOnt know if I have destroyed my mega8.

BUT I gonna make the sercon II....But you have to confirm me, does it work? I'm thinking where to make on a veroboard or a perfboard or in a PCB..But no breadboard in this time

It's a Hard Rains A-gonna Fall.......

Thanks
Theo
 
Problem in C code

Hello Everybody,

I'm teenager DIYer. I'm a completely newcomer to the world of robotics. Can somebody please provide me a good PIC based scheamtic of a robot...which is not tooo much complex....preferably line following, wall following or anything else.

Please help🙂 😀 😉 😎 :angel:

I have a line following robot with source code. when i convert this code C to Hex this is show 4 error. i chack again and again but no error find. any one help me. it is emargency in my study. plllllllllllllllllllllllllllllllz.

I give this code
<><><><><><><><><>
#include <16F877A.H>; //declare a PIC header
#device adc=8; //set the bit for ADC
#fuses hs, nowdt, noprotect; //set the PIC protection
#use delay (clock=20000000); //set the clock frequency
#byte porta=5; //assign port a
#byte portd=8; //assign port d

int val1; //ADC value 1 left sensor
int val2; //ADC value 2 center sensor
int val3; //ADC value 3 right sensor
int vref; //voltage reference
void lmotor(int gear); //left motor function
void rmotor(int gear); //right motor function

void main() //main function
{
vref=0x7f; //set voltage reference value
set_tris_d(0); //declare port d as output
setup_port_a(all_analog); //enable port a as ADC port
setup_adc(adc_clock_internal); //set the clock for ADC
setup_ccp1(ccp_pwm); //set enable ccp1
setup_ccp2(ccp_pwm); //set enable ccp2
setup_timer_2(t2_div_by_4,100,1); //set post scaler timer

while(1) //inifinite loop
{
portd=0xaa; //set value for motor
set_adc_channel(0); //ADC at port A0 channel
val1=read_adc(); //read and store A0 value
set_adc_channel(2); //ADC at port A2 channel
val2=read_adc(); //read and store A2 value
set_adc_channel(4); //Adc at port A4
val3=read_adc(); //read and store A4 value

//start condition
//if sensor sense dark then value is greater than Vref
//if sensor sense bright then value is lower than Vref
if(val2>vref) //if sensor 2 is dark
{
if((val1<vref)&&(val3<vref)) //sensor 1&3 is bright
{ //send value to motor ccp
lmotor(70); //both motor moving at same rate
rmotor(70);
}
else if (val1>vref) //sensor 1 is dark
{
lmotor(0); //left motor stop
rmotor(70); //right motor move
}
else if (val3>vref) //sensor 3 is dark
{
lmotor(70); //left motor move
rmotor(0); //right motor stop
}
}
else if ((val1>vref)&&(val3<vref)) //if only sensor 1 is dark
{
lmotor(0); //left motor stop
rmotor(70); //right motor move
}

else if ((val3>vref)&&(val1<vref)) //if only sensor 3 is dark
{
lmotor(70); //left motor move
rmotor(0); //right motor stop
}
else //other than condition above
{
lmotor(60); //left motor move slow
rmotor(60); //right motor move slow
}
}
}
//end program
void lmotor(int gear) //left motor ccp control function
{
set_pwm1_duty(gear); //ccp1 duty cycle

}

void rmotor(int gear) //right motor ccp control function
{
set_pwm2_duty(gear); //ccp2 duty cycle
}

<><><><><><><><><><><>

If possible give me thie hex file.

MPlab show this problem

';' - missing problem in 2to 6 line.


Thank you

Mehedi
 
hello every body,
I need help on my line follower robot based on PIC 16f877A. i download C source code and try to compile this code in MPLAB. but it show missing error in first 6 line. but i can't find any problem those line. i give the code without header file. plz any body find the error or convert it HEX format.
<><><><><><><><><><><><><><><><><><><><><><><><><<>

#include <16F877A.H>; //declare a PIC header
#device adc=8; //set the bit for ADC
#fuses hs, nowdt, noprotect; //set the PIC protection
#use delay (clock=20000000); //set the clock frequency
int val1; //ADC value 1 left sensor
int val2; //ADC value 2 center sensor
int val3; //ADC value 3 right sensor
int vref; //voltage reference
void lmotor(int gear); //left motor function
void rmotor(int gear); //right motor function
#byte porta=5; //assign port a
#byte portd=8; //assign port d

void main() //main function
{
vref=0x7f; //set voltage reference value
set_tris_d(0); //declare port d as output
setup_port_a(all_analog); //enable port a as ADC port
setup_adc(adc_clock_internal); //set the clock for ADC
setup_ccp1(ccp_pwm); //set enable ccp1
setup_ccp2(ccp_pwm); //set enable ccp2
setup_timer_2(t2_div_by_4,100,1); //set post scaler timer

while(1) //inifinite loop
{
portd=0xaa; //set value for motor
set_adc_channel(0); //ADC at port A0 channel
val1=read_adc(); //read and store A0 value
set_adc_channel(2); //ADC at port A2 channel
val2=read_adc(); //read and store A2 value
set_adc_channel(4); //Adc at port A4
val3=read_adc(); //read and store A4 value

//start condition
//if sensor sense dark then value is greater than Vref
//if sensor sense bright then value is lower than Vref
if(val2>vref) //if sensor 2 is dark
{
if((val1<vref)&&(val3<vref)) //sensor 1&3 is bright
{ //send value to motor ccp
lmotor(70); //both motor moving at same rate
rmotor(70);
}
else if (val1>vref) //sensor 1 is dark
{
lmotor(0); //left motor stop
rmotor(70); //right motor move
}
else if (val3>vref) //sensor 3 is dark
{
lmotor(70); //left motor move
rmotor(0); //right motor stop
}
}
else if ((val1>vref)&&(val3<vref)) //if only sensor 1 is dark
{
lmotor(0); //left motor stop
rmotor(70); //right motor move
}





else if ((val3>vref)&&(val1<vref)) //if only sensor 3 is dark
{
lmotor(70); //left motor move
rmotor(0); //right motor stop
}
else //other than condition above
{
lmotor(60); //left motor move slow
rmotor(60); //right motor move slow
}


}
}
//end program
void lmotor(int gear) //left motor ccp control function
{
set_pwm1_duty(gear); //ccp1 duty cycle

}

void rmotor(int gear) //right motor ccp control function
{
set_pwm2_duty(gear); //ccp2 duty cycle
}

<><><><><><><><><><><><><><><><><><><><><><><>

It is very very emargency in my study.

Plz help me very queckly.

Thanks to all

Mehedi.
 
Status
Not open for further replies.