Friday, July 19, 2013

Alfred 1.0 Construction Continues

Alfred 1.0 showing breadboard area.

The construction of ALFRED 1.0 continues with the addition of a rear holder for the main MCU and Pololu motor shield.   Additionally, there is a breadboard area for prototyping and testing additional circuitry.  There is plenty of room for an LCD display and the ultrasonic range sensor.  

Compartments open to allow access to battery and extra space for future expansion and modules.

The Freedom KL25Z CPU board and the Pololu motor shield mount in the rear.   Velcro holds MCU boards and bread board area in place.


Battery compartment area







Rear view showing vertically mounted MCU and motor shield.

Modular design allows access to battery and electronics

Saturday, July 13, 2013

Freescale Freedom KL25Z with HC-SR04 Ultrasonic Range Finder

I recently began working on the robot again. Today's post shows the Ultrasonic Range Finder using the Freescale KL25Z experimenter's board and the HC-SR04 Ultrasonic range finder.  This experiment uses a post found on http://mcuoneclipse.com.   You can find all about this here.  The LCD display shows the range in both US and Centimeters.   We will be using what is learned here to provide distance sensors for the ALFRED 1 robot.  
 

Alfred 1 Robot Chassis Design

A few months ago I finished the chassis prototype for the Alfred 1 robot.   The chassis is made from a cheap cutting board from Walmart, some spare erector set parts and an old back up tape plastic case.  

The only purchased components are two plastic gear motors and some wheels from Pololu electronics.
The robot will be using a Freescale Freedom KL25Z development board for CPU power, a Pololu Arduino Motor shield for controlling motion, HC-SR04 sonic range finder for distance sensing.   Wireless communication remains to be determined.



Friday, January 27, 2012

123 UART Test for Launchpad and EZ430 RF2500T


The challenge was to connect a Launchpad and an EZ430 RF2500T board via UART interface. I had a Launchpad populated with an MSP430G2553 microcontroller that had the UART working to the PC with the USB cable. The plan was to connect the EZ430 as a daughter board on J4. An earlier blog post had shown that the configuration at least somewhat works. Today's post shows a 123 test to validate the UART between the RF430 and the Launchpad. The EZ430 RF device sends a 0,1,2 3 pattern to the Lauchpad which sets displays the number on the leds and echos back the sequence to the EZ430 RF which in turn receives the number and its leds display the echoed number. It is an easy visual way to verify that the UART communication link between the two devices is working.

Lessons Learned about the Launchpad daughter board connection for the EZ430 RF device

There are a couple different versions of the lauchpad developer board. Revision 1.4 and under require a jumper configuration change on J3 when using a device such as the MSPG2553 with a hardware UART. This is because these boards are wired for earlier 14 pin devices using a software UART. Here it is necessary to criss cross the RX and TX pins at J3 in order to use the hardware UART over the USB interface. Revision 1.5 and later have moved the RX and TX configuration on the board. This solves the issue of using the 20 pin devices with the hardware UART.

It should be noted also that the screen print on my rev 1.4 boards label pin 3 (P1.1) as TXD and pin 4 (P1.2) as RXD. This is fine for 14 pin devices when using software UART solutions, however, the g2553 UART uses pin 3 (P1.1) as RXD and pin 4 (P1.2) as TXD. As a result the J4 connector is wired backwards for using the hardware UART on the 20 pin G2553 devices. Therefore, it is necessary to connect the EZ430 RF device using jumper wires and the J4 connector is useless when hardware UART is used.

Code for the Lauchpad 123 UART test
Load the Launchpad 123 Test software onto a Launchpad that is populated with an g2553 device. Remove jumpers from J3 after programming the Launchpad.
//******************************************************************************
// UART TESTING CODE FOR Launchpad
//
// By M. Tellitocci
// Tellitronics Inc.
// January 2012
//
// Description: Perform a 123 test on the Launchpad and EZ430 RF2500T boards to verify UART operation.
// On the EZ430 RF board timer A triggers a transmission of test sequence
// 0x030, 0x031, 0x032, 0x033 which repeats and is transmitted
// by the EZ430 UART. The launchpad with a MSPG2553 Hardware UART
// receives the test sequence and toggles its leds in binary sequence.
// The launchpad echos back the test pattern and the LED's on the
// EZ430 RF2500T repeat the pattern.
// Built with CCS Version 4.2.0
//
// Companion code for the launchpad board is called echotest.
//
// This software sample code is provided for educational purposes only and
// the user assumes all risk of its use there is no warranty or support.
// It is provided as is for education and hobbyist experimentation.
//******************************************************************************
#include "msp430g2553.h"
char str[31];
unsigned int i;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;

P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1DIR = BIT6 + BIT0; // P1.6 and P1.0 outputs
P1OUT = BIT6+BIT0; // LEDs off
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}


// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{

if(UCA0RXBUF==0x030)
{
P1OUT=0;
UCA0TXBUF = 0x030;
}
else if (UCA0RXBUF==0x031)
{
P1OUT= BIT0;
UCA0TXBUF = 0x031;
}
else if (UCA0RXBUF==0x032)
{
P1OUT=BIT6;
UCA0TXBUF = 0x032;
}
else if (UCA0RXBUF==0x033)
{
P1OUT=BIT0+BIT6;
UCA0TXBUF = 0x033;
}

}

// USCI A0/B0 Transmit ISR
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
UCA0TXBUF = str[i++]; // TX next character
}

Code for the EZ430 RF2500T dongle
Load an EZ430 RF2500T board with the test software using Code Composer. Remove the
EZ430 board and install on its battery board.
//******************************************************************************
// UART TESTING CODE FOR EZ430 RF2500T
//
// By M. Tellitocci
// Tellitronics Inc.
// January 2012
//
// Description: Timer A triggers a transmission of test sequence
// 0x030, 0x031, 0x032, 0x033 which repeats and is transmitted
// by the EZ430 UART. A launchpad with a MSPG2553 Hardware UART
// receives the test sequence and toggles its leds in binary sequence.
// The launchpad echos back the test pattern and the LED's on the
// EZ430 RF2500T repeat the pattern.
//
//
// Built with CCS Version 4.2.0
//
// Companion code for the launchpad board is called echotest.
//
// This software sample code is provided for educational purposes only and
// the user assumes all risk of its use there is no warranty or support.
// It is provided as is for education and hobbyist experimentation.
//******************************************************************************
#include "msp430.h"
#include "in430.h"
#include "msp430F2274.h"
unsigned int i=0;
unsigned int j=0;
int main ( void )
{
//- timer example code
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x03; // initialize led pins

// basic clock system control register 3
BCSCTL3 |= LFXT1S_2; // VLOCLK
TACCTL0 = CCIE; // Capture compare interupt enable
TACCR0 = 2000; // Timer A capture register value
TACTL = MC_1+TASSEL_1; // Up mode: the timer counts up to TACCR0. Clock srce ACLK.

BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register (GIE+LPM3_bits ) ;
}

#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
if (i==0)
{
UCA0TXBUF=0x030;
i++;
}
else if (i==1)
{
UCA0TXBUF=0x031;
i++;
}
else if (i==2)
{
UCA0TXBUF=0x032;
i++;
}
else if (i==3)
{
UCA0TXBUF=0x033;
i=0;
}
}

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
if(UCA0RXBUF==0x030)
{ P1OUT=0x00;
}
else if (UCA0RXBUF==0x031)
{ P1OUT= 0x01;
}
else if (UCA0RXBUF==0x032)
{ P1OUT=0x02;
}
else if (UCA0RXBUF==0x033)
{ P1OUT=0x03;
}
//UCA0TXBUF=UCA0RXBUF;
}

// USCI A0/B0 Transmit ISR
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
}

Hardware Setup

A male header was soldered on to the EZ430 battery board in order to easily access the RX, TX, VCC and GND connections.

The EZ430 battery pack is used to power both the launchpad and the EZ430.

Jumpers were connected between VCC on the Launchpad and EZ430 battery board, GND on the Launchpad and GND on the EZ430 battery board.

The UART is connected as follows:

Pin 3 (P1.1) on launchpad to pin 3.4 (TXD) on the EZ430.
Pin 4 (P1.2) on the launchpad to Pin 3.5 on the EZ430.

Remove all jumpers on J3 of the launchpad.

Once all the hardware connections are made and the battery jumper on the EZ430 in place the 123 UART test begins. The EZ430 transmits 0,1, 2 and 3. The Launchpad receives the byte and its leds display the binary number and the byte is echoed back to the EZ430. The EZ430 receives the byte and its leds display the received byte.

Coming soon is the code to enable the Launchpad to operate wirelessly.

Saturday, May 14, 2011

The WII Motion Plus Gyro







Now we return to the Quad Copter project picking up with the WII Motion Plus Gyro that will be used as a sensor. I picked one of these up from Amazon.Com for about 10.00 dollars and free shipping. It makes for an inexpensive 3-axis gyro that can be hacked for use in home-brewed electronics experiments. I have been researching the specifics of how to utilize this device. Most of the information I found indicated that the device can be easily polled by a microprocessor with an an I2C interface. The board inside the WII Motion Plus contains an I2C interface, 14 bit ADC and a 3-axis gyro. A lot in a cheap package. I will be getting into the technical aspects of the interface in a later post. This time I am simply going to describe the process of dismantling the Motion Plus to obtain the gyro. It was definitely designed so that it could not be easily unassembled. Two Y-bit screws on the back could not be removed with any of the tools that I have. I tried phillips and hex and square bits and then tried to drill the screws out. Even then the back would not come apart. I then tried to pry the shell apart, but found it was put together tightly and securely. As a result the outside shell was rendered useless by the time I got to the gyro. I feared that the circuitry would be damaged even though I was careful. In the end I managed to remove the gyro from the plastic case. Then I unsoldered the female pass-through port connector. This will allow me to make a cable with a female plug so that I can use the male connector that is attached to the gyro board. Later will begin experimenting with the hardware interface and making use of the data that the gyro provides.

The Capicitive Touch Booster Pack for the Launchpad



I took some time to play with the Capacitive Touch Booster Pack on the Launchpad. This kit from TI cost $ 4.30 during the initial 430 hours of release. I purchaed one because it looked cool. The booster pack is a shield-like board for the Launchpad that plugs into the headers. You must solder the male headers that came with the LP in order to connect a booster pack. The kit also comes with an 20 pin MSP430G2452 micro chip that is preloaded with the demo software. It was easy to hook up, although I could not find any where in the documentation that specified the orientation for the board. The demo provides a capacitive touch wheel surrounded by led's with a touch button in the middle. Very similar to the IPOD wheel interface. It also has a proximity sensor that wakes the board up when a hand is waved in front of it. The demo was impressive and worked right out of the box with no need to flash the microprocessor. TI provides an extensive library of sample code and a library of functions for the capacitive touch applications. Some day I may play with this some more and use the wheel in a hand held wireless remote for the quad.

Wireless Launchpad with the EZ430 RF2500T

Recently, I experimented with the LaunchPad and the EZ430 RF2500T. I plugged an EZ430 RF2500T configured as an access point to the USB port on my laptop. I plugged another EZ430 RF on the J4 connector of the Launchpad. This device was configured as an End Device. On the Launchpad I used the 2231 micro controller and loaded a demo application from TI that reports status of tempature readings (LO, IN or HI).

The purpose of this experiment was to validate that the EZ430 RF2500T can be used for wireless communication with the LaunchPad.

With this setup I was able to wirelessly transmit the tempature status from the LaunchPad to the laptop. Using Hyperterminal I was able to view the data transmitted by the EZ430 RF2500T.

You can find the code for the EZ430 RF2500T access point and end device by downloading TI's EKG-Based Heart-Rate Monitor Implementation on the LaunchPad Value Line Development Kit Using the
MSP430G2452 MCU application demo source
. The code for the wireless devices will work right out of the box without modification. I used IAR Kickstart to load the access point and end-device projects on a pair of the EZ430 RF2500T's. Since I did not have the hardware setup for the Heart Rate monitor I loaded the TI demo code shown here on the LaunchPad just so that I could get some data to transmit for the test.

//***********************************************************
// Lab7.c Software UART
//
// SFB 10/2010
//***********************************************************

#include

#define TXD BIT1 // TXD on P1.1
#define RXD BIT2 // RXD on P1.2
#define Bitime 13*1 // 0x0D

unsigned int TXByte;
unsigned char BitCnt;

unsigned int TxHI[]={0x48,0x49,0x0A,0x08,0x08};
unsigned int TxLO[]={0x4C,0x4F,0x0A,0x08,0x08};
unsigned int TxIN[]={0x49,0x4E,0x0A,0x08,0x08};

volatile long tempRaw;
volatile long tempSet = 0;
volatile int i;

void FaultRoutine(void);
void ConfigWDT(void);
void ConfigClocks(void);
void ConfigPins(void);
void ConfigADC10(void);
void ConfigTimerA2(void);
void Transmit(void);

void main(void)
{
ConfigWDT();
ConfigClocks();
ConfigPins();
ConfigADC10();
ConfigTimerA2();

while(1)
{
_bis_SR_register(LPM3_bits + GIE); // turn on interrupts and LPM3

if (tempSet == 0)
{
tempSet = tempRaw; // Set reference temp
}
if (tempSet > tempRaw + 5) // test for lo
{
P1OUT = BIT6; // green LED on
P1OUT &= ~BIT0; // red LED off
for (i=0;i<5;i++)
{
TXByte = TxLO[i];
Transmit();
}
}
if (tempSet < tempRaw - 5) // test for hi
{
P1OUT = BIT0; // red LED on
P1OUT &= ~BIT6; // green LED off
for (i=0;i<5;i++)
{
TXByte = TxHI[i];
Transmit();
}
}
if (tempSet <= tempRaw + 2 & tempSet >= tempRaw - 2)
{ // test for in range
P1OUT &= ~(BIT0 + BIT6); // both LEDs off
for (i=0;i<5;i++)
{
TXByte = TxIN[i];
Transmit();
}
}
}
}

void ConfigWDT(void)
{
WDTCTL = WDT_ADLY_250; // <1 sec WDT interval
IE1 |= WDTIE; // Enable WDT interrupt
}

void ConfigClocks(void)
{
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
FaultRoutine(); // If calibration data is erased
// run FaultRoutine()
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO
IFG1 &= ~OFIFG; // Clear OSCFault flag
BCSCTL2 = 0; // MCLK = DCO = SMCLK
}

void FaultRoutine(void)
{
P1OUT = BIT0; // P1.0 on (red LED)
while(1); // TRAP
}

void ConfigPins(void)
{
P1SEL |= TXD + RXD; // P1.1 & 2 TA0, rest GPIO
P1DIR = ~(BIT3 + RXD); // P1.3 input, other outputs
P1OUT = 0; // clear output pins
P2SEL = ~(BIT6 + BIT7); // P2.6 and 7 GPIO
P2DIR |= BIT6 + BIT7; // P1.6 and 7 outputs
P2OUT = 0; // clear output pins

}

void ConfigADC10(void)
{
ADC10CTL1 = INCH_10 + ADC10DIV_0; // Temp Sensor ADC10CLK
}

void ConfigTimerA2(void)
{
CCTL0 = OUT; // TXD Idle as Mark
TACTL = TASSEL_2 + MC_2 + ID_3; // SMCLK/8, continuos mode
}

// WDT interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void WDT(void)
{
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON;
_delay_cycles(500); // Wait for ADC Ref to settle
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
_delay_cycles(100);
ADC10CTL0 &= ~ENC; // Disable ADC conversion
ADC10CTL0 &= ~(REFON + ADC10ON); // Ref and ADC10 off
tempRaw = ADC10MEM; // Read conversion value
_bic_SR_register_on_exit(LPM3_bits); // Clr LPM3 bits from SR on exit
}

// Function Transmits Character from TXByte
void Transmit()
{
BitCnt = 0xA; // Load Bit counter, 8data + ST/SP
while (CCR0 != TAR) // Prevent async capture
CCR0 = TAR; // Current state of TA counter
CCR0 += Bitime; // Some time till first bit
TXByte |= 0x100; // Add mark stop bit to TXByte
TXByte = TXByte << 1; // Add space start bit
CCTL0 = CCIS0 + OUTMOD0 + CCIE; // TXD = mark = idle
while ( CCTL0 & CCIE ); // Wait for TX completion
}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
CCR0 += Bitime; // Add Offset to CCR0
if (CCTL0 & CCIS0) // TX on CCI0B?
{
if ( BitCnt == 0)
{
CCTL0 &= ~ CCIE ; // All bits TXed, disable interrupt
}

else
{
CCTL0 |= OUTMOD2; // TX Space
if (TXByte & 0x01)
CCTL0 &= ~ OUTMOD2; // TX Mark
TXByte = TXByte >> 1;
BitCnt --;
}
}
}

This experiment was a success. Some day I will try the EKG Heart rate demo if I can put together the hardware or obtain the demo board at a reasonable price.