Lab 5: Gamotochip

Yan Tran
joseph Giardina
May 03, 2004

The purpose of this lab was to build a device that used a motor
with an encoder attached and experiment with the device through the
motor’s registers. We had the choice of communicating with te motor/encoder
combination through either the serial port or through the Cricket. We opted for
the cricket since the libraries for communicating to the motor in Cricket Logo were
already available. The setup we used to communicate to the motor/encoder was as follows:

In the setup, the UML devboard was used solely to make the 12 volt serial
connection into a 5 volt connection that the GamotoBoard could use. Also,
the two separate power supplies, one for the logic, one for the motor were
connected together so that only one power supply had to be connected to
the entire board. Our device was a simple catapault. The catapault lowered
first to hold an object, then fired the object. The diagram of the catapault is as
follows:

In the lab, we experimented with several of the registers, to yield varying results. The registers we
experimented with are as follows:

SetVelocity: We left this as the default number. When we experimented with this number, we ended up
getting a constant velocity from the moment it was set. Had we made a device that was constantly moving, we would
have used this register, but since our device only moved for short, fixed periods of time, we set the register at zero.

PwrLimit: We set this register to 255 (full motor power)

Kp: This register seemed to give the catapault a greater acceleration. The greater the number we used when
using the catapault, the farther the object traveled. This register was set to 4500

Ki: This register is used for steady-state error in the system. For a deeper understanding of this register,
consider our initial trials with the catapault. In our initial trials, Kp and Kd were set with low values while Ki was set
with a high value. This led to a .pendulum. action in the catapault system, or as we called it, "the angry catapault"
The catapault would swing back and forth continuously. The solution to this was either to set this register to a lower value
or to set both the Kp and Kd registers to higher values. This register was set to 50.

Kd: This register is used to compensate for overshoot in the system. This register, when it was set high
and the other registers were set high, made the catapault more rigid. When any force was put on the motor to try to change
its position, the motor would draw more amps and resist this force.

SetPosition: We used this register to lower the catapault, then to raise the catapault to fire an object.

The main Cricket Logo code that we used to communicate with and set registers was as follows:

to gxSetPosition :val :adr
gxSetReg24 47 :val :adr
End

to gxSetReg24 :reg :val :adr
;Writes a 16-bit value to a 24-bit register
bsend 256 + 17
bsend :adr
bsend :reg
> bsend low-byte :val
bsend high-byte :val
if (:val < 0) [bsend 255] ;sign-extend to 24 bits
if (:val > -1) [bsend 0] ;sign-extend to 24 bits
End

This code allowed us to write to a 24-bit register such as the position
register. The other code can be found at http://www.cs.uml.edu/~fredm/courses/91.548-spr04/student/jgiardin/lab5/lab5.lgo The remainder of the code
allows a person a write to any size register and read from any register.

We also tracked data when we programmed our catapault to move in increments of 100 motor points until it launched
its projectile. A data point represented the catapault at a unit of time
Aftrer gaining spped and getting to each of its intermediate positions and its final position,
the motor pulls back to compensate for its overshoot