address = 0;
break;
case 2:
address = 0x40;
break;
case 3:
address = 0x14;
break;
case 4:
address = 0x54;
break;
default:
address = 0;
}
address += (y-1);
lcd_send_byte(0,0x80|address);
}
The LCD cursor placement math is based on LCD
display address mapping. For a 2x8 LCD module, line 1 is
addressed as 0 through 7 decimal and line 2 is addressed
40 through 47 decimal. Once the cursor is placed and the 9
is displayed at the cursor position, we can execute the 0-9
display code:
do{
rotorbyte = POSCNTL + 0x30;
if(rotorbyte != oldbyte)
{
lcd_gotoxy(1,1);
lcd_send_byte(1,rotorbyte);
oldbyte=rotorbyte;
}
}while(1);
The rotorbyte will cycle from 0x39 to 0x30 with the
first turn of the optical encoder shaft in a clockwise
direction. The displayed count continues to increment as
the shaft rotates in a clockwise direction. Rotating the shaft
in a counter-clockwise direction will decrement the
displayed count.
Rotating Your Encoder
at Both Ends
You now have everything you need to add an optical
encoder to the input end of your robotic projects. Process
the optical encoder’s pushbutton just as you would any
other pushbutton attached to a PIC I/O port. The idea is to
select your value with the rotation of the optical encoder
shaft and lock in or save the value with a push of the knob
that is set-screwed onto the optical encoder’s shaft. I did
just that with the optical encoder hardware you see in
Photo 2 and you can too. SV
Fred Eady may be reached via email at fred@edtp.com
STEER WINNING ROBOTS
WITHOUT SERVOS!
Perform proportional speed, direction, and steering with only two Radio/Control channels for vehicles using two
separate brush-type electric motors mounted right and left
with our mixing RDFR dual speed control. Used in many
successful competitive robots. Single joystick operation: up
goes straight ahead, down is reverse. Pure right or left twirls
vehicle as motors turn opposite directions. In between stick
positions completely proportional. Plugs in like a servo to
your Futaba, JR, Hitec, or similar radio. Compatible with gyro
steering stabilization. Various volt and amp sizes available.
The RDFR47E 55V 75A per motor unit pictured above.
www.vantec.com
Order at
(888) 929-5055
SERVO 07.2010 49