Berkeley Electronic Interfaces Course – Robot Module 3.1 – Comparator

by Fuyang

PowerBlocking_WsBrPower Blocking

Instead of powering the Wheatstone bridge with sensor all the time, one should use an output pin from MSP430G2 so that only a period of time the Wheatstone bridge is powered. It’s like taking measurement discontinuously, so to save lots of power consumption.

The way to do is as shown below, using the P1.1 on MSP430G2 as power output and connect it to the front rail, where all sensors are connected.

PowerBlocking_WsBr2

Now the Wheatstone bridge has been power blocked 🙂

Comparator

Then we can attach the Wheatstone bridge sensor to the amplifier OPA2344. At the moment the amp work as a comparator, so that the small voltage different on the two Wheatstone output pin will be compared and the signal will be output after the comparator as +3.3V or 0V.OPA2344PA

As shown below that:

  • Firstly connect the amplifier power supply on the grade;
  • Then connect the Vout of Wheatstone bridge to the input pins of OPA2344;
  • Then connect the output of the amp to the pin P1.2 or P1.7 to control, as an example here, the on board red or green light to on and off.

Module3_Sketch_Comparator

PowerBlocking_WsBr4

There we go. Now if we boot the chip up then it is easy to test that when light up in front of the photocell, the LED on board will lights, and vise versa.

IMG_20150905_215254

IMG_20150905_215238










//***************************************************************************************
// EE40LX
// Sketch 3.2
//
// Description; Power-block a 3.3V rail at P1.1 and subsequently read inputs from
// Wheatstone bridges, connected to P1.2 and P1.7
//
// Tom Zajdel
// University of California, Berkeley
// July 27, 2015
//
// Version 1.2 July 27, 2015 - Added curly brackets to conditional statements
//
// Version 1.1 January 26, 2015 - Fixed a timing bug by using delayMicroseconds()
// and also corrected errors in pin assignment
//
//***************************************************************************************
//see pins_energia.h for more LED definitions


int PBRAIL = P1_1; // set PBRAIL as P1.1 alias
int LPHOTO = P1_2; // set LPHOTO as P1.2 alias
int RPHOTO = P1_7; // set RPHOTO as P1.7 alias

int REDLED = P1_0; // set REDLED as P1_0 alias
int GRNLED = P1_6; // set GRNLED as P1_6 alias

void setup()
{ 
 
 // set power block pin and led pins as outputs
 pinMode(PBRAIL, OUTPUT);
 pinMode(REDLED, OUTPUT);
 pinMode(GRNLED, OUTPUT);
 
 // set photocell input pins
 pinMode(LPHOTO, INPUT);
 pinMode(RPHOTO, INPUT);

}

void loop()
{
 digitalWrite(PBRAIL, HIGH); // supply 3.3V to the power rail
 delayMicroseconds(1000); // delay briefly to allow comparator outputs to settle

 if (digitalRead(LPHOTO) == HIGH) // if LPHOTO is on, turn REDLED on
 {
 digitalWrite(REDLED, HIGH); // otherwise, turn REDLED off
 }
 else
 {
 digitalWrite(REDLED, LOW); 
 } 
 
 if (digitalRead(RPHOTO) == HIGH) // if RPHOTO is on, turn GRNLED on
 {
 digitalWrite(GRNLED, HIGH); // otherwise, turn GRNLED off
 }
 else
 {
 digitalWrite(GRNLED, LOW); 
 }
 
 digitalWrite(PBRAIL, LOW); // turn the power rail off again
 sleep(19); // wait 19 ms (can do other tasks in this time,
 // but we are simply demonstrating that you can cut power
 // to the circuits for 95% of the time and not notice!

}