DPRG
DPRG List  



[DPRG] AT90C2313-10PI for a line follower?

Subject: [DPRG] AT90C2313-10PI for a line follower?
From: Kenneth Maxon kmaxon at qwest.net
Date: Sat Jul 15 16:52:07 CDT 2006


Hello Walter,

The switch statement has 8 possible conditions, however only 7 of them are
accounted for.  Assuming the bits in order represent left, middle and right,
then when only the middle sensor is activated no output is defined.  Is
there really no operation / output defined for the case when only the middle
sensor is activated?  Also, the compiler *MAY* create garbage (less likely
with modern compilers) or a program that does not function correctly when a
case is switched that does not exist.  If it really is undefined, the
default context should be used.  At the end of the list of cases (inside the
brace), just add a line as follows:

default: break;

The last note is one on style (read=feel free to ignore it).  Although
while(0<1); will work often this is just shortened to while(1);

-Kenneth

-----Original Message-----
From: dprglist-bounces at dprg.org [mailto:dprglist-bounces at dprg.org]On
Behalf Of Balter Wiggin
Sent: Saturday, July 15, 2006 3:54 PM
To: dprglist at dprg.org
Subject: [DPRG] AT90C2313-10PI for a line follower?


As my next intended project, the bicycle computer was scrubbed because of
funding issues, i thought i would refine my line follower design while still
retaining my objective of using a microcontroller to increase precision.
I've snapped up a little bit of code that i think should work, but im not
quite sure. Trisb would be an input of three line sensors: left, middle, and
right respectively. Porta would be connected to two motors, the left half to
the left, and the right half to the right. This approach at motor control
would allow two settings on the pager motors that i salvaged. Note that I'm
still learning to program.

#include <system.h>

void main()
{
trisa = 0000b;
trisb = 111b;
porta = 0000b;
do{
switch(portb)
{
case 101b: porta = 1111b;break;
case 110b: porta = 1110b;break;
case 011b: porta = 0111b;break;
case 001b: porta = 0110b;break;
case 100b: porta = 0110b;break;
case 000b: porta = 0000b;break;
case 111b: porta = 0000b;break;
}
while (0 < 1);
}
}


Thanks,
Walter

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

_______________________________________________
DPRGlist mailing list
DPRGlist at dprg.org
http://list.dprg.org/mailman/listinfo/dprglist




More information about the DPRG mailing list