Line following robot start code

Status
Not open for further replies.

PA3040

Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Visit site
Activity points
6,936
Dare All

Can you please give me some idea to convert following C code to Assembly code

I need convert red color code only


Code:
#define s_left		RB0
#define s_mleft		RB1
#define s_mright	RB2
#define s_right		RB3
[COLOR="#FF0000"]if ((s_left==1)&&(s_mleft==0)&&(s_mright==0)&&(s_right==0))[/COLOR]

This is related to PIC 16f887a line following robot

Thanks
 

Hi,

As you know I don't do C but think thats saying IF rb0 - rb3 are set to 1000 then do whatever follows.

So in assembly you just read that Port /Bits and compare it to 1000 using whatever methods you choose; a bit at a time or the whole nibble/byte .
If equal then do that function, if not skip/goto
 
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating


Code:
line_follow	btfss	PORTB,s_left
			goto	s_mleft
			btfsc	PORTB,s_mleft
			goto	s_mleft
			btfsc	PORTB,s_mright
			goto	s_mleft
			btfsc	PORTB,s_right
			goto	s_mleft

Am I correct?
 

Code:
line_follow	btfss	PORTB,s_left
			goto	s_mleft
			btfsc	PORTB,s_mleft
			goto	s_mleft
			btfsc	PORTB,s_mright
			goto	s_mleft
			btfsc	PORTB,s_right
			goto	s_mleft

Am I correct?


Hi,

nearly,

Code:
line_follow	btfss	PORTB,s_left
			goto	not_equal
			btfsc	PORTB,s_mleft
			goto	not_equal
			btfsc	PORTB,s_mright
			goto	not_equal
			btfsc	PORTB,s_right
			goto	not_equal
is_equal             ; code 

not_equal          ; code
 
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear WP100

Let's assume, if we use four sensors for line follow. Black line cover two sensors and sensor state off

Then possible step as per two to the power four

0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111

in between possible combinations

0000
0001
0011
0111
1000
1001
1100
1110
1111

Am I correct
Please advice
 

Hi PA,

Have never done robots so cannot help you directly.

Not sure what your logic for those two lists are ? It all depend on the thickness of the line and how far the sensors are apart and how the robot approaches the line.

Perhaps have a search of the the forum including the Robotics section.

Have a look at his thread where I assisted with a bit of assembler code, its only a simple device but good practical experience.
https://www.edaboard.com/threads/276222/
 

Hi

As per my robot Ir LED panel, the Line width is equal to gap between two LED's Please see attached image

1.In my upper part of 5th post was showing possible number of steps for four sensor in mathematically

2. In lower part of my 5th post was showing possible number of steps in real world

Should you please advice in this regard



Thanks in advance
 

Hi PA,

Not something I have done, but if you search around there seems plenty of info on basic line following robots...
or perhaps so other members can help.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…