Thursday 29 May 2014

MSP430G2553 Interfacing with DS1307

Here Iam interfacing DS1307 with msp430g2553 in Energia 0101E0011 , using "wire.h" .
The hour, minute ,and second is displayed on energia serial monitor.The remaining can be easily added.
The output can displayed on LCD if it is interfaced with this .

The common mistake everyone encounter with ds1307 and msp430 is that ds1307 is working in minimum 4.5 volt max 5v and msp430g2553 is low power max 3.5v. Here I changed the pullup voltage to 3.5 volt for ds1307 and vcc is 5v and also low power for msp430.
http://datasheets.maximintegrated.com/en/ds/DS1307.pdf this is the ds1307 datasheet.
The code is added below.
///////////////////////////////// 

#include "Wire.h"                 //for DS1307 I2C
#include <string.h>
#include <math.h>
#define DS1307_I2C_ADDRESS 0x68
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  /*
  //////here programmer set the current time ,from where the ds runs
  */
   second = 45;
   minute = 30;
   hour = 16;
   dayOfWeek = 5;
   dayOfMonth = 20;
   month = 3;
   year = 12;
   setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
void loop()
{
 getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);///to get current time from ds1307
 timedisplay();
}

void timedisplay()                 ///////////Function to display current time
{
  Serial.print(hour, DEC);
  Serial.print(":");
  Serial.print(minute, DEC);
  Serial.print(":");
  Serial.print(second, DEC);
  Serial.println("  ");
  delay(1000);
}

void getDateDs1307(byte *second,   // Gets the date and time from the ds1307
                   byte *minute,
                   byte *hour,
                   byte *dayOfWeek,
                   byte *dayOfMonth,
                   byte *month,
                   byte *year)
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.write(0);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

  // A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.read() & 0x7f);
  *minute     = bcdToDec(Wire.read());
  *hour       = bcdToDec(Wire.read() & 0x3f);  // Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month      = bcdToDec(Wire.read());
  *year       = bcdToDec(Wire.read());
}
void setDateDs1307(byte second,        // 0-59         ///to set time in ds1307
                   byte minute,        // 0-59
                   byte hour,          // 1-23
                   byte dayOfWeek,     // 1-7
                   byte dayOfMonth,    // 1-28/29/30/31
                   byte month,         // 1-12
                   byte year)          // 0-99
{
   Wire.beginTransmission(DS1307_I2C_ADDRESS);
   Wire.write(0);
   Wire.write(decToBcd(second));    // 0 to bit 7 starts the clock
   Wire.write(decToBcd(minute));
   Wire.write(decToBcd(hour));      // If you want 12 hour am/pm you need to set
                                   // bit 6 (also need to change readDateDs1307)
   Wire.write(decToBcd(dayOfWeek));
   Wire.write(decToBcd(dayOfMonth));
   Wire.write(decToBcd(month));
   Wire.write(decToBcd(year));
   Wire.endTransmission();
}
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return ( (val/10*16) + (val%10) );
}

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}



 The circuit is below


Sunday 18 May 2014

MSP430 LaunchPad: Adding Bluetooth to your MSP430 Project

MSP430 LaunchPad: Adding Bluetooth to your MSP430 Project: Most projects which I have seen input and output some sort of data: be it a multimedia stream, sensor data, or user inputs. In this post I w...

Wednesday 14 May 2014

How to Enable Touchpad Scrolling in Ubuntu 14.04 LTS

After Installing to Ubuntu latest version 'Ubuntu 14.04 LTS ' I found the side scroll in my touchpad was not working. My friends also faced this problems. So I think  this post will helpfull to all.

 I find  the Mouse & Touchpad settings to solve the problem .  You can see, Ubuntu 14.04 LTS  has enabled Two finger scroll by default. And for this reason edge scrolling has been disabled.

Follow the steps below to enable edge scrolling in Ubuntu 14.04 LTS


1) Go to Unity Dash ( top most  of the left tool bar) and search Mouse & Touchpad



2)In the Mouse & Touchpad settings, we can  see option of Two finger scroll checked. You have to uncheck this option.



The procedure is completed. Now you don't want to restart your computer.You can check the scroll is working or not by "Test Your settings"

You can see like below and test your touchpad..















When click on this circle you can see the colour change if the touchpad is ok.