Drexel University

Mechanical Engineering and Mechanics
Special Topic: Autonomous Vehicle Control
Dr. Harry Kwatny

Friday, February 19, 2010

Velocity Test Data

On Thursday I re-soldered the EB500 header strip to the PS/2 connector wire.  Abuse/overuse had led to the failure of Chiu Yen's original solder job.

After completing that task and verifying the motor system, we conducted our first test of the truck's performance.  With a stopwatch we measured the time for the truck to travel a pre-determined distance as a function of our input to the speed controller.  I was in charge of recording data; Allen drove the truck via the netbook, ensuring that it accelerated to the target speed before entering the test zone and keeping it on a straight course;  Chiu Yen was the truck retriever and called out when it entered the test zone; and Venkat manned the stopwatch at the end of the test zone.  In this arrangement we conducted fifteen test runs; three each at five input speeds.  The test zone was the carpeted area beside the computers in the MEM UG computer laboratory and measured 2.45 meters in length.  The plot below shows a summary of our data; the average velocity for each control input is plotted along with the standard deviation.

Tuesday, February 16, 2010

Bluetooth - PS/2 Connection

We connected our EmbeddedBlue EB500 Bluetooth Transceiver via one of the Parallax Propeller's built-in PS/2 ports.  The male connector was re-purposed from an old keyboard; the wire ends of the cord are soldered to a 2 x 10 male x female header (0.1" spacing).  The wiring diagram is below:
 
We elected to connect to the green PS/2 port labeled "Keyboard," communicating on the Propeller's digital pins 24 and 25.  The actual signal connections are shown in the table below:

      PS/2 Pin  Signal  EB500 Pin
      ---------------------------
         1      TX           3
         2      N/C          -
         3      GND      1 & 2
         4      VCC         20
         5      RX           4
         6      N/C          -

The TX connection is data transmitted from the EB500; RX is the data line incoming from the Propeller.  N/C = no connection.  Note that the EB500 data sheet specifies that both pins 1 and 2 be connected to ground; we have accomplished that by soldering them together on the header.  That way we weren't risking any damage to our (now out of production) Bluetooth board.

Thursday, February 4, 2010

Basic working code!

We finally got some code to work and interface with the blue tooth through hyper-terminal. Check out the code below!
{{Truckbasic.spin}}
{{
11-25-08
Control E-MAXX truck equiped with 5 Ping))) sensors and a CMUcam2+
}}
Con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Th_Channel = 12 'servo control settings
St_Channel = 7
Rate = 1
MaxDist = 100 'ping range settings
NeutralDist = 40
MinDist = 1
MaxForward = 135 'speed controller settings
MinForward = 131
Neutral = 125
MinReverse = 122
MaxReverse = 115
ExtLeft = 190 'steering settings
ExtRight = 40
MaxSteer = 50
Center = (ExtLeft + ExtRight) / 2
SensLim = 100
SteeringProportionalGain = 1
ConfidenceThreshold = 75

OBJ
Servo : "PWM"
Serial_PC : "FullDuplexSerial"
Num : "Numbers"
Distance : "Ping"
VAR
Byte Throttle 'display values
Byte Steering
Byte Cam_angle
Word D0
Word D1
Word D2
Word D3
Word D4
Byte mx 'camera values
Byte my
Byte x1
Byte y1
Byte x2
Byte y2
Byte pixels
Byte confidence
Byte r1
Byte r2
Byte TargetAquired
Byte CrMean
Byte YMean
Byte CbMean
Byte CrDeviation
Byte YDeviation
Byte CbDeviation
PUB Main
BTSetup 'setup bluetooth connection
Throttle := Neutral
Steering := 115
Cam_angle := 125
r1 := 0
r2 := 0
repeat 'main loop
UserIn
UserOut
Servo.Send(Th_Channel, Rate, Throttle)
Servo.Send(St_Channel, Rate, Steering)
PUB BTSetup
Serial_PC.start(24, 25, 0, 9600) 'if bluetooth card is in 9600 mode change it to 115200
Serial_PC.str(string("set baud 115200 *", 13))
waitcnt(clkfreq/10 + cnt)
PUB UserIn | input
input := serial_PC.rx
Sample
if input == "w" 'forward
Throttle := Throttle + 3
elseif input == "s" 'reverse
Throttle := Throttle - 3
elseif input == "a" 'turn wheels left
Steering := Steering + 10
elseif input == "d" 'turn wheels right
Steering := Steering - 10
elseif input == " " 'all stop
Throttle := Neutral
Steering := 115
Cam_angle := 125
repeat
if serial_PC.rxcheck <> -1
quit
UserOut 'temp added for loop
Servo.Send(Th_Channel, Rate, Throttle)
Servo.Send(St_Channel, Rate, Steering)
if D4 < 5
quit
throttle := Neutral
Steering := 115
else
serial_PC.tx(13)
serial_PC.str(string("unknown"))
PUB UserOut
serial_PC.tx(13)
if Throttle
serial_PC.str(string("Throttle:"))
serial_PC.str(Num.ToStr(Throttle, Num#DDEC))
if Steering
serial_PC.str(string(" Steering:"))
serial_PC.str(Num.ToStr(Steering, Num#DDEC))
if D0
serial_PC.str(string(" D0"))
serial_PC.str(Num.ToStr(D0,Num#DDEC))
if D2
serial_PC.str(string(" D2"))
serial_PC.str(Num.ToStr(D2,Num#DDEC))
PUB Sample
D0 := Distance.Centimeters(0) 'only enable pins with a ping attached or code will hang
waitcnt(clkfreq/1000 + cnt)
D2 := Distance.Centimeters(2) 'only enable pins with a ping attached or code will hang
waitcnt(clkfreq/1000 + cnt)

Thursday, January 28, 2010

Bluetooth Transceiver Testing

Alan and Venkat suspect some problems with our Parallax EB500 "Embedded Blue 500" Bluetooth transceiver, so I removed it from the truck for testing independent of the Propeller microcontroller.

The board itself is shown on the left.  Apparently, it has been discontinued by Parallax (Parallax store), but what we have is what we have.  The EB500 is part of a line of Bluetooth transceivers designed by  A7 Engineering.  Luckily, the user manual containing the technical specifications, circuit board layout, and pinouts is still available (EB500 User Manual).

I have an Arduino Nano 3.0 (Atmel ATmega 328, manufactured by Gravitech) that I'll use to test the EB500.  According to the user manual, we need to connect a total of seven pins for communications without flow control:  two grounds, transmit, receive, status, mode, and power.  The status and mode pins aren't crucial, but I'll connect them for debugging purposes.  Two grounds are specified, pins 1 and 2, and should both be connected.  The data sheet says the EB500 draws 35 mA at maximum speed and can accept 5 to 12 volts - within the specifications of the Arduino.  The connections I made are as follows:

     EB500 Pin (Signal)  Arduino Pin
     -------------------------------
       1 (GND)    <------->  GND
       2 (GND)    <------->  GND
       3 (TX)     <------->   12
       4 (RX)     <------->   11
       8 (STATUS) <------->   10
       9 (MODE)   <------->    9
       20(VCC)    <------->   5V



Note that pin 1 on the EB500 is the lower-right most pin, marked with a white dot, and has a white box around it.  Pin 20 is the upper-right most pin; be sure to check this connection before powering up the Arduino.  The Arduino will be powered directly from the PC via the USB connection.  After verifying all the connections, I connect the USB to the computer.  The blue LED power indicator lights up and within half a second the green connection indicator on the EB500 briefly flashes once.

I open the Arduino development environment (download here) and load up the program I've written.  The sketch depends on one external library, NewSoftSerial.




The complete code listing is at the bottom of this post.  I compile and upload the software to the Arduino, and open the built in Serial Monitor, setting the transmission rate to 9600 baud.  On the Bluetooth-enabled netbook, I start up HyperTerminal, connecting to the COM port the to the associated EB500 serial port.  (The EB500 serial port was created when the device was previously added in My Bluetooth Places.  The default password for the EB500 is 0000 (four zeroes).)


The port settings are 9600 bits per second, 8 data bits, no parity, 1 stop bit, and no flow control.  After accepting the port settings, HyperTerminal automatically connects to the EB500.  The indicator light turns on solid green, and "Bluetooth:  Connected" is displayed on the Arduino serial monitor.  This lets us know that the EB500 has set its status pin (8) high and confirms that it is connected.  Everything looks good so far!  On the netbook, I type some characters into the HyperTerminal window.  If everything's working right, they'll appear in the Arduino serial monitor window...okay!  Also, the red LED blinks with every character sent.  The characters don't appear in the HyperTerminal window because we haven't set the terminal up to echo the characters locally.  That's not really necessary.  Lastly, I'll send a message back to the netbook.  In the field at the top of the serial monitor I type my message and press enter to send it.  


And presto, there they are!  Lastly, I'll click the "hang up" button in HyperTerminal to disconnect the Bluetooth connection.  The green LED switches off and the Arduino sees that pin 8 has gone low, resulting in a "Bluetooth:  Disconnected" message.



It looks like the EB500 Bluetooth module is functioning well - maybe the problems are stemming from our PS/2 connector...?


-Ted


The test code follows.



//eb500_test.pde - EB500 Test Program
//Theodore A. Bieniosek
//January 27, 2010
//MEM380-003, Autonomous Vehicle Control
//This sketch was developed to test the Embedded Blue EB500 Bluetooth Module,
//demonstrating simple serial communications.
//Serial settings should be 9600 bps, 8 data bits, no parity, 1 stop bit, and no flow control.
//Utilizes the interrupt-based NewSoftSerial library instead of the built in software serial.
//http://arduiniana.org/libraries/NewSoftSerial/

#include

#define MO 9              //Mode, EB500 Pin No. 9
#define ST 10             //Status, EB500 Pin No. 8
#define TX 11             //Transmit, EB500 Pin No. 4 (EB500's RX)
#define RX 12             //Receive, EB500 Pin No. 3 (EB500's TX)
#define IOLED 13          //Use Arduino's built-in LED to flash when transmitting/receiving

boolean LEDstate = 0;
boolean STATUS;
char data_in;
char data_out;

NewSoftSerial eb500( RX, TX );

void setup()
{
  //Initialize data pins
  pinMode( MO, OUTPUT );
  pinMode( ST, INPUT );
  pinMode( RX, INPUT );
  pinMode( TX, OUTPUT );
  digitalWrite( MO, LOW );
  //Start serial connections
  Serial.begin( 9600 );
  eb500.begin( 9600 );
}

void loop()
{
  //Check Bluetooth for incoming data
  if( eb500.available() > 0 )
  {
    data_in = eb500.read();
    Serial.print( data_in );
    flash();
  }

  //Check serial buffer for outgoing data
  if( Serial.available() > 0 )
  {
    data_out = Serial.read();
    eb500.print( data_out );
    flash();
  }

  //Check for change in status of Bluetooth connection
  checkStatus();
}

//Function to check Bluetooth connection status
void checkStatus()
{
  boolean previous_status = STATUS;
  STATUS = digitalRead(ST);
  if( STATUS != previous_status )
  {
    if( STATUS )
    {
      Serial.println( "Bluetooth: Connected" );
    }
    else
    {
      Serial.println( "Bluetooth: Disconnected" );
    }
  }
}

//Function to flash the onboard LED
void flash()
{
  LEDstate = !LEDstate;
  digitalWrite( IOLED, LEDstate );
}


Monday, January 25, 2010

January 21, 2010

Issues with the bluetooth connection today, takes up majority of time.
  1. Connection keeps "dropping".
  2. Inconsistent signal connection while trying to parse codes to vehicle.
This may be due to hardware problems in the vehicle setup.

Other notes:
At one point, vehicle throttles suddenly, this may be due to energy residue left in the system. Venkat tested voltages of components to determine if there are any energy leak. Wire connections are tighten.

When bluetooth connection was available, vehicle was able to take inputs to steer left and right, increase speed in forward motion and reverse.

Vehicle crashed into wall when tested on the ground caused by delay in the feedback to steer. Fortunately, not much damage was done except the battery pack fell out from inside the vehicle. Front bumper did its job.

January 18, 2010

We further tested the vehicle today and outline what we want to achieve with this vehicle.

Previous groups working on this project have been able to achieve the following:
  1. Vehicle able to recognize and follow a particular color
  2. Vehicle avoids wall and back out from corners
Additional goals outlined for our vehicle:
  1. Start and Stop according to traffic light colors
  2. Collision avoidance when traveling in the presence of other trucks/moving objects
  3. Flees when in pursuit by another vehicle or chase another vehicle
Ted to build LED traffic light for his Robotics class which we can utilize for our new goal; outcome to be determined.