Discuss this article in the SERVO Magazine forums at http://forum.servomagazine.com
Our resident expert on all things
robotic is merely an email away.
roboto@servomagazine.com
Tap into the sum of allhumanknowledge and get your questions answered here!
From software algorithms to material selection, Mr. Roboto strives to meet you
where you are — and what more would you expect from a complex service droid?
by
Dennis Clark
As you read this, it is August, the summer is ending,
and it is time to get back to the design boards for next
year’s summer robot season. You will have been to some
big expos and competitions, and will have long lists of
ambitious activities to make your robot even better,
stronger, and faster. I want to get my RoboBuilder robot
back up and running with his new hip servos installed so
that he can moon-walk when he dances (okay, so that he
can WALK period!). Some of my non-Windows buddies and
I are looking at a different controller backpack with a bit
more speed, power, and capability than the stock one. The
Rasberry PI is on that list, but in my case, a Digilent
Cerebot controller seems to be a good option. For Robo
One competitions, dynamic stabilization is the golden
solution, but just motion will make me happy for now! At
the other end of the expense continuum, I am building a
Mech Warrior style robot from Lynxmotion system parts
that will fire LEGO darts at intruders (like my cat), which
will be fun. How many of you out there are trying your
hand at walkers? Rolling robots are great for many things,
but nothing beats a walking robot for crowd appeal!
This month, I’m going to wrap up my series on the
Digilent MAX32 board and MPLAB development. I’ll add a
serial port communication back to the PC so we can see
what is happening, while showing a fast way to send
numbers — not just static text — over an ASCII
communications link. We’ll see what else we can do
before I run out of time!
The Last Installment on
Programming the Digilent MAX32
Last month, we ended by implementing an Input
Capture module to measure the pulse given by the HC-SR04
sonar module. There was no really good way to blink an
LED to approximate the distance measurement, so I simply
left a spot where you could stop the debugger to get a
value. That was a bit clumsy, so this month we’ll implement
a virtual COM port using the USB connection to the
MAX32 board. When I set up the Peripheral Bus Clock on
the PIC32 way back when, I set it to 10 MHz to make my
math dealing with timers easy. This is the clock that will be
used with the USART on the PIC32. Just to pick a number, I
chose a bit rate of 38400. Also — just to pick a formula — I
chose to use the BRGH (High speed
Baud Rate Generator) = 1. In Section
21: UART, document number
DS61107F, Section 21. 3, we see that
the baud rate calculator formula for
BRGH = 1 is:
Listing 1: Set up the UART1 to talk to a COM port.
void SerialInit(int baud)
{
/*
* 38400 baud is good for a 10MHz PBUS.
* using BRGH = 1, baud, 8N1
* Directly set bits, too many to use "OR'd" bit fields!
*/
int n;UxBRG =
FPB - 1
4 BaudRate •
U1MODE = 0x00008008;
U1STA = 0x00005400;
U1BRG = (PBUSFREQ/(4*baud)) -1;
// Clear the screen
for (n=0;n<80;n++) {
putsUART1("\r");}
}
14 SERVO 08.2012
where FPB is the peripheral bus clock
( 10 MHz) and UxBRG is U1BRG (the
baud rate generator register for
UART1). Doing the math, we see
that U1BRG would be 64.104. We
can’t use fractions in the BRG