MC40SE with PIC16F887 controller programming problem

Programmer, In-Circuit Debugger, PIC Start-Up Kit, Memory Interface...

MC40SE with PIC16F887 controller programming problem

Postby cyclonz » Wed Feb 01, 2012 9:05 pm

Hi all,

Anybody can help me to do programming in line crossing when want tu turn at junction especially for robocon. Here i already done the line tracing program. I cannot do the line crossing program because not familiar with MC40SE board. The program that i want is when robot cross 5 lane then the robot turn left. Please help me. Below is the program that i have done.

while(1)
{
if((SEN1==1)&& (SEN2==0)&&(SEN3==1))
{
brushless(PORT1, RUN, CW, 800);
brushless(PORT2, RUN, CCW, 800);
}

if((SEN1==0)&& (SEN2==0)&&(SEN3==1))
{
brushless(PORT1, RUN, CW, 500);
}

if((SEN1==1)&& (SEN2==0)&&(SEN3==0))
{
brushless(PORT2, RUN, CCW, 500);
}
else if((SEN1==1)&& (SEN2==1)&&(SEN3==1))
{
brushless(PORT1, BRAKE, CW, 0);
brushless(PORT2, BRAKE, CCW, 0);
}
}


while(1); //infinite loop
cyclonz
Freshie
 
Posts: 5
Joined: Wed Feb 01, 2012 8:39 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby robosang » Wed Feb 01, 2012 9:23 pm

Kind of curious to know, how is the code look like if this is not MC40Se? I am not familiar with MC40SE, but is some robot controller? How is the code look like on other board?
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby cyclonz » Wed Feb 01, 2012 9:30 pm

Hi robosang. This is the latest board from cytron replacing the AR40B launcing around october 2011. I'm familiar with AR40B. But when i use this new board so i'm having problem to do the program. Really headache. I'm really need help form cytron guys or anybody. I really need for our robocon competition. Please heeeeelllp...
cyclonz
Freshie
 
Posts: 5
Joined: Wed Feb 01, 2012 8:39 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby robosang » Wed Feb 01, 2012 11:13 pm

cyclonz WROTE:Hi robosang. This is the latest board from cytron replacing the AR40B launcing around october 2011. I'm familiar with AR40B. But when i use this new board so i'm having problem to do the program. Really headache. I'm really need help form cytron guys or anybody. I really need for our robocon competition. Please heeeeelllp...


So where is the code for AR40B? How is the code look? Is impossible for us to write a code base on a hardware that we do not know. If you are familiar with AR40B, I think should not be problem with this new product from Cytron, I don know how they design it, but should have the similar functions right? BTW, I am not Cytron guy, just some busy body 8-)
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby shahrul » Thu Feb 02, 2012 11:40 am

I'm not MC40SE user. The code look like controlling brushless motor to do a line following.
As I understand your question, you want do cross 5 line. Then you need add extra line sensor to count that. You can do increment or decrement. Ex use decrement, set initial value to 5 and decrement that variable every time detect crossing/line.
I have use brushless motor, see here, enjoy it. :)
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: MC40SE with PIC16F887 controller programming problem

Postby cyclonz » Fri Feb 03, 2012 7:50 am

thanks shahrul

ur page really good n it really help. but now i wanna do a subroutine for line counting. but still cannot. i understand what do u suggested. but the problem for me is i cannot compile my program. anybody have sample programming code for line tracing and junction. please help.
cyclonz
Freshie
 
Posts: 5
Joined: Wed Feb 01, 2012 8:39 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby kl84 » Fri Feb 03, 2012 6:34 pm

Why cannot compile your program? What's the error you get? The line following and counting program for both AR40B and MC40SE should be the same. You must have made some mistake there...
User avatar
kl84
Amateur
 
Posts: 166
Joined: Thu Jul 08, 2010 12:14 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby robosang » Sat Feb 04, 2012 7:26 pm

Yup, agree with kl84.... should have some problem with the code if compile have error.

Just curious to see the code in the older board AR40B as you mentioned you are familiar with it and should have the line following with cross counting code, I like to learn too :) , from there I can help to modify.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby cyclonz » Wed Feb 08, 2012 3:40 pm

here i have done some programming and the error is - undefined identifier "cross". Can anybody help me what is the problem for this statement. here i attached the program that i have done for linecross. Hopefully can anybody help me. thanks

/***********************************************************************************
* PRIVATE FUNCTION: LINE CROSS
************************************************************************************/

void linecross(unsigned char simpang)//subroutine utk kira simpang
{
cross=0; //panggil variable "cross"=0
brushless(PORT1, RUN, CCW, 600);
brushless(PORT2, RUN, CW, 600);

while(cross<simpang); //bila nilai "cross" kecil dari "simpang" baca line bwh
{
linetracer();

if((SEN1==0)&&(SEN2==0)&&(SEN3==0))
{
brushless(PORT1, RUN, CCW, 100);
brushless(PORT2, RUN, CCW, 100);

while((SEN1==0)&&(SEN3==0));
{
cross++;
}
}

}

}



This program i directly transfer from AR40B to MC40SE.
cyclonz
Freshie
 
Posts: 5
Joined: Wed Feb 01, 2012 8:39 pm

Re: MC40SE with PIC16F887 controller programming problem

Postby robosang » Wed Feb 08, 2012 7:41 pm

You din declare the cross.

cross need to be declare, either global variable or local variable.

replace
cross=0; //panggil variable "cross"=0


with this
unsigned char cross=0; //panggil variable "cross"=0


You need to study the code, not just copy it. Declaring variable is very basic concept in C code. This has nothing to do with hardware. Even computer base programming will require it.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Next

Return to PIC Development Tool

Who is online

Users browsing this forum: No registered users and 24 guests