Wednesday, May 8, 2013

Embedded Front End - Interfacing the LED Matrix

The LED matrix

The LED matrix is used to display information about the bus which last arrived on a bus stop. It is connected to the arduino board on each bus stop. It is used in this prototype for display purposes. It uses SPI communication to send the data from the arduino to the LED matrix. It is a 8X8 matrix and we can set all the 64 bits individually for displaying the bus number.
It can be directly connected to the hardware SPI pins of the arduino but since we were having problems due to the MP3 shield connected on the SPI as well, we had to use software SPI by bit banging the pins to emulate SPI communication. The MP3 shield was sending trash values to the LED matrix due to which it was not functioning properly. But for normal purposes, it might not be necessary unless there are problems like the ones we faced.


Connections with Arduino:




Code: This will explain how we can modify each bit in the LED matrix using software SPI. Alternatively hardware SPI is very much straightforward.

#define DATAOUT 11//MOSI - DI
#define SPICLOCK  13//sck - SCK
#define SLAVESELECT 10//ss - CS

char data [64] =
{
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1,
  1,1,1,1,1,1,1,1
};

void setup()
{
  SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);//Activate SPI HW, Master Mode, diviser Clock par 16

  pinMode(DATAOUT, OUTPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(SLAVESELECT,OUTPUT);

  digitalWrite(SLAVESELECT,HIGH);

  Serial.begin(9600);
}

void loop()
{
  transfer(data);
}

char spi_transfer(volatile char data)
{
  SPDR = data;
  while (!(SPSR & (1<<SPIF)))
  {
  };
  return SPDR;
}

void transfer(char myData[64]) {
  digitalWrite(SLAVESELECT, LOW);
  for(int i=0; i<64; i++){
    spi_transfer(myData[i]);
  }
  digitalWrite(SLAVESELECT, HIGH);
  delayMicroseconds(500);

Tuesday, April 2, 2013

Communication using the Xbee Shield

In our project we have two buses and two bus stops, each having an arduino with a xbee shield.
The arduino at the bus communicates with the arduino at the bus stop. The bus sends the bus number and the stop number to the arduino at the bus stop. The bus stop receives the information which is retrieved by the psuedo server to update the database.


Transmitter code:

void setup()
{
  Serial.begin(9600); 
  Serial.flush();
}

void loop()
{

//transmitting a string that contains the information of the bus number and bus stop number

//receive an acknowledgement from the bus stop.

// transmit new string which is updated for the next bus stop

}

Receiver code:

void setup(){
  Serial.begin(9600);
}

void loop()
{

//receives a string from the bus.

//checks if the bus stop number in the string matches the number of that bus stop

// if matches then sends a string with the updated bus stop number
   else does not send anything.
}

Sunday, March 31, 2013

Project Description

Embedded Component:
The goal of the project is to develop a bus tracking system which will  provide users with the times that have elapsed since a last bus on each line has passed by, along with the time when the next bus on each line is expected (according to the SEPTA schedule). Each bus will have a unique identification number which will be communicated to a Zigbee module located at the approaching bus stop. The Arduino board which is connected to the Zigbee module at the bus stop will receive this identification number . At every bus stop the Arduino board will be connected to an Ethernet shield using which a database which is hosted on a server. This database will be updated as and when a bus arrives at a bus stop.


Android Component:
The project also involves design of an Android application using which the user can request the details at the bus stop and then he/she will be provided with the latest updated details of the last passed bus and the next expected bus at that bus stop on each line. This can be done by accessing a server containing a database where this data will be stored. The user can also select a particular bus number and the data about this bus (where it was present at which time) would be displayed.