Newsgroups: comp.robotics
Path: brunix!uunet!timbuk.cray.com!hemlock.cray.com!kilian
From: kilian@cray.com (Alan Kilian)
Subject: Re: Beginner robot projects/ Ranging
Message-ID: <1992Aug4.133529.4126@hemlock.cray.com>
Lines: 333
Organization: Cray Research, Inc.
Date: 4 Aug 92 13:35:29 CDT

Well I am moving and getting my old house ready for renters to move in so 
the robot won't progress until this fall.

I thought I'd repost all 4 summaries since we are getting a lot of beginner
questions.

As always just Email me if you would like to chat about anything.

================================================================================

   Some folks have asked me to keep them up to date on my robot project
so here is the first update.

  Background:
    I built a robot in high school using a 1802 processor with 256 bytes of ram.
  The platform was crappy and I had to have a tether leading to the batteries
  so I never got very far with it.

  The new robot:
    The new robot has a nice platform. Aluminum "U" channel is the main
  construction component. There are two gear boxes for the main wheels.
  The gear boxes used to be driven with those funny brush less AC motors.
  I just removed the coil from around the armature and I drive the armature
  like a pully from two DC motors.
    The DC motors have an AC tachometer built into the motor. With the help
  of a LM3900 quad opamp I convert this into a 5Vdc pulse train.
    I drive the DC motors with one MOSFET transistor and two 5Vdc coil
  Single pole double throw relays. I tried using an H bridge with bipolar
  transistors but they had two problems: 1) Too large a voltage drop through
  two transistors and my motors ran slow. 2)The best driver circuit I came up
  with for insuring no smoke and having the capability to use pulse width
  modulation used two ICs per motor. (I have since seen a circuit that uses
  one IC per motor but it's too late now).
    The relays are setup to switch the motor from forward to reverse. The
  relays coils cost 90ma each so they are set up normally for the motors
  to go forward. It costs 180ma to reverse one motor and 360ma to reverse
  both motors. It's expensive to reverse the motors so I will do most of my
  turning by stopping one motor and driving the other.
    My motors use 140ma each when running forward. I don't know what they
  use in reverse but I wouldn't expect them to use much more than that.
    I use 8 "D" sized nicad batteries 4Amp-Hours so I should be able to get
  4000/300 = 13 Hours of forward movement out of them. (300 is 140ma * 2 :-))

    I am using a Motorola MC68HC16EVB to control the robot. This is a 16Bit
  16MHZ micro controller evaluation board with a Digital Signal Processor
  subsystem. It cost $168.16 and I will be getting a rebate of $68.16 since
  I completed their DSP project. So the controller will only cost me $100.00
    This controller has 8 lines of 10Bit A/D, 2 PWM outputs 4 timer outputs
  4 event capture lines, 7 interrupt inputs 1 pulse accumulator input
  and a bunch of Digital I/O lines. And when I get another chip I get 1 line
  of D/A output. It has a serial RS232 and a PC parallel port. I write
  software on a Compac, assemble it, down load it to the EVB and debug it with
  some free software from Motorola. When it's going I can switch a switch on
  the EVB and disconnect from the debugger in the PC and have the robot move
  around on it's own. This last feature requires a modification to the EVB 
  board that I invented. Of course I'll tell you what to change if you want to
  know. 

    Here are my plans for the project over the next 6 months.
  1) Add two ultrasonic range modules from Polaroid. I got these from someone
     on this news group and I connected them to my Commode-64 and they are great
  2) Add a 2 line by 16 character LCD display panel. Epson $26.19 from Mouser
  3) Add a speech synthesizer board. $150.00 From RC Systems
  4) Add a flux gate compass. Maybe from Radio Shack.

    Here's the current sate of the machine. The platform is done. The EVB is
  mounted. The 8 motor batteries and 4 CPU batteries are mounted. The EVB can
  control the speed of the motors with the 2 PWM outputs. The EVB can sense
  the motor speeds using 2 input capture lines.

    To do this week: Add buffers to get the direction outputs to the relays.
  Add a pair of analog inputs to measure the two battery voltages. Play around
  for a few days with fixed movement to run any bugs out of the platform.
    To do next week: Get the LCD panel running if I get the data sheet.
  Get one range module running. More software to avoid objects.

    I'll let you know how it goes. If you have any questions you can either
  email them to me or post them to this news group.

    I just got an MC68HC11EVB with an 8 Bit 2MHZ processor. The same processor
  that Fred and the boys at MIT use in the 6.270 robot building course so I
  will fool around with that one also. Maybe a smaller low power robot is in
  the works. We'll see.

                         -Alan Kilian

    Some folks have asked me to keep them up to date on my robot project
    here is the second update.

    Here are my plans for the project over the next 6 months.
	Add two ultrasonic range modules from Polaroid.
	Add a speech synthesizer board. $150.00 From RC Systems
	Add a flux gate compass. Maybe from Radio Shack.
	Tons of software.

    Things done this week:
	LCD display  module running.
	Motor feedback speed control running.

    This LCD module from EPSON is great. I had some trouble getting it running
	First I ALWAYS screw up if the module refers to power and ground as
	VSS/VDD Every damn time. If it's VCC/VDD I'm O.K. but VSS/VDD I
	always connect +5 to VSS and GND to VDD. Well the + is where the
	power comes out isn't it? so +5 is the Source and GND is the sink
  	right? Of course not that's only the way they teach it to kids in
	school. I just hate it when I learn that something that I understood
	in grade school was intentionally taught to me wrong. (You mean that
	even at absolute zero helium is a liquid? I thought absolute zero
	was the lack of ALL atomic motion. Well Noooooooooo we only told
	you that because we didn't think you could understand the REAL concept.
	What about billiard ball electrons? No? The earths orbital axis
	is parallel to the Moon's orbital axis. No? O.K. That's about enough
	whining about education). So I connected the power supply backwards
	and blew a fuse. Then I hooked up my ammeter and the module was
	drawing 2.2 Amps at 5 Volts. Yipes. I must have something hooked up
	wrong. Well Well Well I swapped VSS and VDD and it drew only 20 Ma
	but it didn't do anything. So I started interfacing it to the 68HC16
	and I couldn't get any display. You have to send this thing a few
	commands to get it running and the EPSON data sheet was shall we say
	"lacking in the most fundamental details" about how to go about this.
	so I started sending things like "Turn on the display and blink the
	cursor" commands. Nothing. I tried Set DAA (Data Address Address as far
	as I can tell) Nothing. Send some ASCII chars. Nothing. Well I guess
	it's blown up. One last thing. There's this Vo pin that says "Display
	contrast resistor" but that's it. I have a 51 page document talking
	about all the EPSON displays from 1X16 chars to 768X1024 arrays and
	it doesn't tell you what the Contrast resistor is. Oh here it is.
	On one of the application notes for a 256X192 array (Or something) 
	there is a 500KOhm variable resistor from Vo to GND. Cool. Well I
	don't have a 500KOhm Thats pretty large so I'll use a 10KOhm. Oh My GOD
	it works. I've got a blinking cursor!!! So I fiddle around with 500K
	fixed resistors and the display is blank. It turns out that 10KOhm
	is the correct value. You'd never get any display with a 500K Ohm 
	resistor. I lucked out again. Now the module is running but I can't
	boot the 68HC16 with the module plugged in. BooHoo. I turns out that
	one of the pins I am using for a digital output pin also functions
	as the external clock select pin when the processor is reset.
	If this pin is low at reset then the processor selects an external
	clock source. (Which I thoughtlessly didn't provide) Well a simple
	diode with it's cathode on the processor and it's anode on the LCD
	prevents the LCD from pulling this line low. It also interferes
	with me reading the DAA Least significant bit but that's just tough.
	If I can't keep track of where the cursor is in software then I'm
	out of a job anyway. So I wrote some routines to print values
	in HEX and It's just great.

    Motor speed control:
	This took some work also. There are 6.02 X 10^23 different sources
	for interrupts on the 68HC16 and I had to figure them out. I did
	get them running though. My speed controller simply checks the
	interval between two Tachometer pulses and compares them to the
	desired interval and increments or decrements the Pulse Width
	register appropriately. I wrote a second order feedback loop to
	control the motors and simulated it on my Sun workstation but I
	won't install it. The simple control works just fine. I'll soup
	it up a bit so that if the motor speed is way off from the desired
	speed I'll add a few to the PWM register instead of just one.

    Platform testing:
	I blow rubber bands like butter now. Crap. I'll install some bands
	that I got off some Broccoli they are perfect. about 1/4 Inch wide
	and 1 Inch diameter when not stretched. I also think I'll put the
	pulleys back on for a little more speed. I was running the drive right
	off the tiny motor shaft in the beginning. This will hopefully be
	the solution to my platform troubles.

    To do this week:
	Add buffers to get the direction outputs to the relays.
	Play around for a few days with fixed movement to run any more bugs out
	  of the platform.
	Get one range module running.

    To do next week: 
	I'm in Denver for a PEX meeting all week. Whine about PEX a lot.
	Take lots of photos.

    To do the third week:
  	More software to avoid objects.
	Build a scanning platform for the front range module.
	Build a position encoder for the front range module.
	Develop and print Denver photos.

                         -Alan Kilian



    Some folks have asked me to keep them up to date on my robot project
    here is the third update.

    Here are my plans for the project over the next 6 months.
	Add a speech synthesizer board. $150.00 From RC Systems
	Add a flux gate compass. Maybe from Radio Shack.
	Tons of software.

    Things done this week:
	One Polaroid range module is working.
	The new Broccoli rubber bands work great. Yipeee!!!
	Simple obstacle avoidance software running.

    This Polaroid module works fine. It is really easy to talk to. Just raise
	a line and it emits a chirp and when it hears an echo it will raise
	a different line. You just time the interval between the two lines
	being raised and that's the distance. Sound travels at .9 Ms per foot
	and you have to remember to divide the time by two because the sound
	traveled out and back.
    The module can't see the couch until it's about 6 Inches away.
    The module has a really narrow sensing cone so objects can sneak by and
	crash into the very edge of the platform. Scanning the module will cure
	this problem.

    To do this week:
	Re-solder the wheel stubs so that the wheels don't twist off if the
	  platform stalls against a wall.
	Add buffers to get the direction outputs to the relays.
	Play around for a few days with platform to run any more bugs out.

    To do next week: 
	I'm in Denver for a PEX meeting all week. Whine about PEX a lot.
	Take lots of photos.

    To do the third week:
	Add Infrared LED obstacle detectors for close range objects.
	Build a scanning platform for the front range module.
	Build a position encoder for the front range module.
  	More software to avoid objects.
	Develop and print Denver photos.

                         -Alan Kilian




    Some folks have asked me to keep them up to date on my robot project
    here is the fourth update.

    Here are my plans for the project over the next 6 months.
	Add a speech synthesizer board. $150.00 From RC Systems
	Add a flux gate compass. Maybe from Radio Shack.
	Tons of software.

    Things done this week:
	The controller can reverse the motors!!!
	    Man this was a pain. The amount of knowledge I lose every year is
	    spectacular. Everyone knows how to drive a 120 Milliamp 5Vdc relay
	    right? Well here's the path I took: I decided to be smart and add
	    a buffer chip between the CPU and the relays to protect the CPU
	    in case I did something wrong. O.K. I looked through my chips and
	    found a really long one. Something like 18 or 20 pins. This must
	    be a buss driver chip. I think it was a 74LS240 or 74LS640 Well it
	    was an octal inverting driver chip. Great! I'm all set. so I hook it
	    up to two of the CPUs outputs bits (I have two motors to control)
	    and twiddle with the select lines to get it enabled and now I have
	    two inverted outputs. I'm all set now. So I hook the outputs up to
	    the +5Vdc side of the relays and the other side is connected to
	    ground. Each motor has two relays controlling it and the coils of
	    these relays are connected in parallel. They draw about 
	    120 Milliamp each. Well I wrote a little software to control the
	    output bits and nothing happened. Boo Hoo. So I poked around for a
	    while and figured out that the 74LSWhatever was not putting out 5Vdc
	    SURPRISE! The data book says it can only source 10 Milliamps. Source
	    current is the amount of current the device can put out when it's
	    trying to output a logic 1 (or High or +5Vdc) Well I needed 240 Ma
	    and I could only get 10 Ma from this chip. I knew this years ago.
	    So I decided to use a MOSFET to drive the relays from the 
	    74LSWhatever and so I hooked one up. It didn't work. So I rearranged
	    its Source/Drain connections. It didn't work. At this point I
	    realized that I was a moron. I was using an N-channel MOSFET to try
	    and control the + voltage to a relay. This is wrong. I should have
	    had the relays connected to +5Vdc and the MOSFET controlling the
	    ground connection. This is also what I should have been doing with
	    the 74LSWhatever from the beginning. The 74LSWhatever can "Sink"
	    about 40 Ma (Sink is the amount of current the device can handle
	    when it's trying to produce a logic 0 (or Low or 0Vdc)) So anyway
	    I threw out the 74LSWhatever and everything and simply added a
	    MOSFET to the motor driver/relay boards and drove the MOSFETs gate
	    directly from the CPUs output pins.
	One Infrared LED obstacle detector is working.
	    This was a really fun project. I got one of those infrared detector
	    modules from Radio Shack. This thing detects a 40,000 Hz carrier
	    and outputs a 0Vdc signal when It detects the carrier. I built a
	    LM555 timer running at 40,000 Hz and connected it to an infrared
	    LED (From the Shack). The LED and the detector module are pointing
	    in the same direction and they cannot see each other. If there is
	    something in front of these guys that reflects infrared light then
	    the detector module sees the 40,000 Hz carrier and outputs a 0Vdc
	    signal. Another cool thing about this part is that I used surface
	    mount resistors for the LM555 timer. I got these resistors from
	    Radio Shack again in an assortment pack. I soldered them directly
	    to the pins of the LM555. It made a really small oscillator. It is
	    barely larger than the LM555 itself. Just a .001 microfarad cap.
	All support software is now running from a Zeos notebook 386 PC.
	    This means I am really portable now.
	The speech synthesizer can say "Firmware Version 1.4" but that's all.
	    This is only the test mode for the synthesizer. I can't send any
	    data from the PC yet because I don't know how to send data to the 
	    COMM1 port yet.

    To do this week:
	Re-solder the wheel stubs so that the wheels don't twist off if the
	  platform stalls against a wall.
	Play around for a few days with platform to run any more bugs out.
	Test battery lifetimes. Maybe get larger batteries for the CPU.

    To do next week: 
	Add motor current detectors (Ala Fred Martin @ MIT).
	Add battery voltage detectors.
	Build a trickle charger for both sets of batteries.

    To do third week:
	Build a scanning platform for the front range module.
	    I'll take apart one of my "Induction resolvers" and use it for a
	    platform for the transducer. It has nice bearings and four slip
	    connection to the rotor that I can send the signals through for
	    the transducer. Pretty cool.
	Build a position encoder for the front range module.
	    I took apart a full sized video game that had a wheel that spun all
	    the way around. It used an optical shaft encoder. I think I will
	    use this encoder to produce pulses for each little rotation
	    increment and use the HC16's pulse accumulator to add them up. If
	    I add something (Like a microswitch or another detector) to reset
	    the counter when the scanner is pointing straight backwards then
	    I will be able to use the counts as a position. This should be
	    almost free in terms of external circuitry.
  	More software to avoid objects.

                         -Alan Kilian



-- 
 -Alan Kilian           kilian@cray.com 612.683.5499 (Work) 612.729.1652 (Home)
  Cray Research, Inc.   655 F Lone Oak Drive, Eagan  MN, 55121 
                        "It's based on actual math". -Dilbert
