Hi Mehedi,
are you sure you need the leading '#' in the following lines?
I give the code. this code i use to compile. but show error.
I have 16f877A PIC and JDM programar with win800 program, i use maplab to compile the code.
Thanks
Thanks
i give this code. i don't know how can use this code.
Hi Mehedi,
are you sure you need the leading '#' in the following lines?
i give this code. i don't know how can use this code.
Hello thamid
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.
লেগে থাকলে তুমি নিশ্চয়ই সফলকাম হবে। যারা পরিশ্রম করে এবং ধৈর্য ধরে, সাফল্য তাদের নিশ্চিত। ধন্যবাদ।
Thamid i hope you help me. plz go this link and help me
http://www.diyaudio.com/forums/everything-else/125270-need-pic-based-line-following-robot-5.html
_____________________________________________________________________________
The strongest man in the world is one, who stands alone for achieving something good.
পৃথিবীতে সেই সবচেয়ে শক্তিশালী ব্যক্তি, যে ভাল কিছু অর্জনের জন্য একাই নিরন্তর চেষ্টা চালিয়ে যায়।
Need help to convert a c code
I hope you help me see my problem in 5 page and plz help me.
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.
বাস্তবে ব্যবহারযোগ্য চিন্তাধারাই মানুষের প্রকৃত সম্পদ।
I hope you help me see my problem in 5 page and plz help me.
@Mehedi
I'm not sure at all, but for the code of your first post, try modifying the first six lines removing ";" :
#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
I'm not sure at all, but for the code of your first post, try modifying the first six lines removing ";" :
#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
Hello Friend
Same result.
@Mehedi
I'm not sure at all, but for the code of your first post, try modifying the first six lines removing ";" :
#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
Same result.
Need help
Hello, Mahbub
I have everything for a making a line following robot. it make using by pic 16f877a.
but i have a problem to convert the c source code. are you help me. i provide the source code. if you able to convert it hex format plz send it. this project is a key point in my study. plz help me...
#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
}
Thanks
Mehedi
Hi Paswa,
Where are you? What is your progress regarding Robot?
Thanks.
Hello, Mahbub
I have everything for a making a line following robot. it make using by pic 16f877a.
but i have a problem to convert the c source code. are you help me. i provide the source code. if you able to convert it hex format plz send it. this project is a key point in my study. plz help me...
#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
}
Thanks
Mehedi
Hello Switters
Yes. error still now.
In this case could be useful to read my reply to your first post 😉
What do you think the leading '#' on the first six statement means?
Code is changed in your second post, are you sure compiler errors are still the same?
Yes. error still now.
Yes. error still now.
I think it's a tool/compiler problem. I believe that on the latest versions of MPLAB the source code you posted should be complied with the CCS compiler.
- Status
- Not open for further replies.
- Home
- General Interest
- Everything Else
- Need a PIC based Line Following Robot