Monday, April 16, 2012

Antenna switches are built. 
  • Orange to 5V
  • Brown to Ground
  • Orange and White Right Switch
  • Brown and White Left Switch
Full details at

Sunday, April 8, 2012

[ROBOMAG2012] Motor Control Code Usage

The motor control has been rewritten to make it easier to use across multiple files. The public member functions are as follows:

set_attr( arr_attributes ):
This function allows us to set the pwm center and PWM half range for the Maestro ports.
Parameters: arr_attributes is an array of ordered pairs [c,r], where the order is determined by the ports to which each servo or motor is connected. The array index corresponds to each port. c is the pwm center, r is the half range, which is the difference between the max and pwm center.
self.pwm_attr[n][0] + self.pwm_attr[n][1] = pwm max for port n
self.pwm_attr[n][0] - self.pwm_attr[n][1] = pwm min for port n

turn( amount = 0 ):
The turn function takes a percentage and convert to appropriate turning angle
-100. to < 0. turns left, > 0. to +100. turns right
Any values outside of this range will place the servos back to neutral position

drive( speed = 0 ):
The move command takes a power percentage and converts to appropriate power
-100. to < 0. moves backward, > 0. to +100. moves forward
Any values outside of this range will turn the motors off

honk( on ):
if on = 1, Turns horn on HIGH pwmout = 3000
else turns horn on LOW pwmout = 100

reset( ):
brings all the pwm to default settings. Centers steering servos and turns off motor control

To use these functions, an object must first be constructed. By default, the only parameter required is the COM Port number. On this particular machine, the servo controller is on port 7. The code would look like:

motors = control( 7 )
motors.set_attr( [[1500, 406], [1500, 406], [1496, 504]] ) 50 )
time.sleep( 3 )
motors.honk( 1 )
motors.turn( 68 )
time.sleep( 2 )
motors.honk( 0 )
motors.turn( ) 100 )
time.sleep( 5 ) )

This creates the control object named motors and sets the pwm centers and half ranges for the front servo, the rear servo, and the speed controller on ports 0, 1, 2, respectively. It then starts moving at 50% speed, turns 68% to the right and honks its horn while moving, straightens out while moving, and speeds up to 100% speed for 5 more seconds before slowing down to a stop.

Tuesday, April 3, 2012

Distance Sensing Claw

The claw is complete and spits out comma delimited serial values corresponding to distance (up to ~3m) at 8N1 57600 over the included usb adapter.  For more info and code see:

Tuesday, March 20, 2012

[ROBOMAG2012] Compass Module

We've decided to use a tilt-compensated compass module that consists of an accelerometer and a magnetometer. This particular module is a Pololu LSM303DLH #1250. It's no longer available for sale, but details are still on their website. It needed calibration based on its maximum and minimum values which were obtained by spinning the module in all directions. After the values were obtained, the heading can be accurately determined by some sample code in their Arduino library. A few modifications were made and the Arduino interfaces with the serial port. Any UART sending it the appropriate commands will receive the desired response. As of now, the only valid command is getting the heading direction. The code looks like this:

#include <Wire.h>
#include <LSM303.h>

LSM303 compass;
char iscommand;
char command;
char a;
int count = 0;
void setup() {
  // Calibration values. Use the Calibrate example program to get the values for
  // your compass.

  compass.m_min.x = -705; compass.m_min.y = -539; compass.m_min.z = -337;
  compass.m_max.x = +325; compass.m_max.y = +546; compass.m_max.z = 605;

void loop() {
  //compass must be read constantly to get updated position
  //so regardless of a need for data stream, this line is needed;
  int heading = compass.heading((LSM303::vector){0,-1,0});
  //& signifies the beginning of the command
  if( Serial.peek( ) == '&' )
    //this just gets rid of the & char );
    //command is the next char in buffer
    command = );
    if ( command == '1' )
      Serial.print( "Heading: " );
      Serial.println( "Invalid command" );
  //get rid of anything that's not part a command
  else if( Serial.peek( ) != -1 )
  { );
  //delay needed because processing speed > transfer speed
  delay( 25 );