Friday 31 October 2014

week 7 semester 2 - testing the circuit

After a few times correcting the coding error and circuit, its finally work the way i desire. here is the picture of the running circuit without renewable source yet.






VA = to indicate voltage in from the first source
VB = to indicate voltage in from the second source
VC = to indicate voltage in from the third source
VD = the amount of the supply or storage
Total = to indicate the voltage amount left in the storage
% of VD = percentage of the total amount in the storage

Sunday 26 October 2014

week 6 semester 2 - The program

here is where we reach the part which coding or programming take place. since the circuit have be troubleshoot and work properly, it need a program to complete the system. so, the program for this project or circuit not very complex or complicated, because it just want to show the display of the voltage input and the total voltage collected in the storage.




 //variables
unsigned int batA,batB,batC,batD;
unsigned char arr_batA[4],arr_batB[4],arr_batC[4],arr_batD[5];

/*----------------------------- Initialization function -----------*/
void mcu_init()
{
//Lcd
Lcd_Config(&PORTB, 4, 5, 6, 3, 2, 1, 0); // Lcd_Init
Lcd_Cmd(Lcd_CLEAR);//Clear display
Lcd_Cmd(Lcd_CURSOR_OFF);//Turn cursor off

//relay
TRISD=0;
PORTD=1;
}
/*-------------------------- End of intialization --------------------*/

/*----------------------------- display values ----------------*/
void display_values()
{
 unsigned long temp,percent;
 unsigned int total;
//calculat battery A voltage
 temp=(unsigned long)(batA*20);
 temp=temp*100;
 batA = (unsigned int)(temp/1023);
  arr_batA[0]=batA/1000;
  arr_batA[1]=(batA%1000)/100;
  arr_batA[2]=((batA%1000)%100)/10;
  arr_batA[3]=((batA%1000)%100)%10;
  Lcd_Chr(1, 4, arr_batA[0]+'0');
  Lcd_Chr(1, 5, arr_batA[1]+'0');
  Lcd_Chr(1, 6, '.');
  Lcd_Chr(1, 7, arr_batA[2]+'0');
  Lcd_Chr(1, 8, arr_batA[3]+'0');


//calculate battery B  voltage
 temp=(unsigned long)(batB*20);
 temp=temp*100;
 batB = (unsigned int)(temp/1023);
  arr_batB[0]=batB/1000;
  arr_batB[1]=(batB%1000)/100;
  arr_batB[2]=((batB%1000)%100)/10;
  arr_batB[3]=((batB%1000)%100)%10;
  Lcd_Chr(1, 13, arr_batB[0]+'0');
  Lcd_Chr(1, 14, arr_batB[1]+'0');
  Lcd_Chr(1, 15, '.');
  Lcd_Chr(1, 16, arr_batB[2]+'0');
  Lcd_Chr(1, 17, arr_batB[3]+'0');
  
  //calculate battery C  voltage
 temp=(unsigned long)(batC*20);
 temp=temp*100;
 batC = (unsigned int)(temp/1023);
  arr_batC[0]=batC/1000;
  arr_batC[1]=(batC%1000)/100;
  arr_batC[2]=((batC%1000)%100)/10;
  arr_batC[3]=((batC%1000)%100)%10;
  Lcd_Chr(2, 4, arr_batC[0]+'0');
  Lcd_Chr(2, 5, arr_batC[1]+'0');
  Lcd_Chr(2, 6, '.');
  Lcd_Chr(2, 7, arr_batC[2]+'0');
  Lcd_Chr(2, 8, arr_batC[3]+'0');
  
  //calculate battery D voltage
 temp=(unsigned long)(batD*20);
 temp=temp*100;
 batD = (unsigned int)(temp/1023);
  arr_batD[0]=batD/1000;
  arr_batD[1]=(batD%1000)/100;
  arr_batD[2]=((batD%1000)%100)/10;
  arr_batD[3]=((batD%1000)%100)%10;
  Lcd_Chr(2, 13, arr_batD[0]+'0');
  Lcd_Chr(2, 14, arr_batD[1]+'0');
  Lcd_Chr(2, 15, '.');
  Lcd_Chr(2, 16, arr_batD[2]+'0');
  Lcd_Chr(2, 17, arr_batD[3]+'0');
  
total=batA+batB+batC;
  arr_batD[0]=total/1000;
  arr_batD[1]=(total%1000)/100;
  arr_batD[2]=((total%1000)%100)/10;
  arr_batD[3]=((total%1000)%100)%10;
  Lcd_Chr(3, 7, arr_batD[0]+'0');
  Lcd_Chr(3, 8, arr_batD[1]+'0');
  Lcd_Chr(3, 9, '.');
  Lcd_Chr(3, 10, arr_batD[2]+'0');
  Lcd_Chr(3, 11, arr_batD[3]+'0');
percent= ((unsigned long)batD*100)/12;
  arr_batD[0]=percent/10000;
  arr_batD[1]=(percent%10000)/1000;
  arr_batD[2]=((percent%10000)%1000)/100;
  arr_batD[3]=(((percent%10000)%1000)%100)/10;
  arr_batD[4]=(((percent%10000)%1000)%100)%10;
  Lcd_Chr(4, 9, arr_batD[0]+'0');
  Lcd_Chr(4, 10, arr_batD[1]+'0');
  Lcd_Chr(4, 11, arr_batD[2]+'0');
  Lcd_Chr(4, 12, '.');
  Lcd_Chr(4, 13, arr_batD[3]+'0');
  Lcd_Chr(4, 14, arr_batD[4]+'0');
 


}
/*--------------------------------------------------------------*/

/*----------------------------- main function -----------------*/
void main()
{
 mcu_init();
//static text
 Lcd_Out(1, 1, "VA:      VB:");
 Lcd_Out(2, 1, "VC:      VD:");
 Lcd_Out(3, 1, "Total:");
 Lcd_Out(4, 1, "% of VD:");
 while(1)
 {
batA=Adc_Read(0); //read batA
batB=Adc_Read(1);//read batB
batC=Adc_Read(2);//read batC
batD=Adc_Read(3);//read batD
 display_values();

 //compare values to control relay
 if(batD<1100)//need charging
 {
 PORTD.F0=1;//relay on
 }
  if (batD>=1200)//enough charging
 {
 PORTD.F0=0;//relay off
 }
 }

}
/*------------------------------ End of main-------------------*/

Saturday 18 October 2014

week 5 semester 2 - The circuits

this week i finished up the circuit based on the simulation that i did last week. i faced a few problem which are :

1) IC burn due to the over-voltage
2) short circuit between the cooper line on the board
3) soldering error at the voltage regulator circuit.


complete circuit of the project without input sources:

relay circuit to cutoff the voltage input when the storage is full


PIC circuit to control the system


input slot for the sources circuit


complete circuit including LCD



Friday 10 October 2014

week 4 semester 2 - schematics and simulations of the circuits

as the structure of the prototype is done, now i will be working on the circuit or the system of the project. this circuit will be a medium where the voltage will be collected and distribute from the sources and output (motor).

by using Proteus software here is the schematics of the circuit:

components:
1) LCD 16x4
2) Relay 
3) Push button
4) resistors 
5) transistor
6) PIC16f877a IC

Saturday 4 October 2014

week 3 semester 2 - finishing the structure

this week i worked on the surface of the structure based on the frame that i build. the surface is made by thin polystyrene which is harder than ordinary polystyrene. this type of polystyrene also can handle heat from hot glue. the hardest part of making the structure is the bending, because it must be bend slowly and gentle if there are too much pressure applied it will cause the polystyrene to break.


so here is the complete structure of my prototype:

view from the inside of the prototype

side view of the prototype

view form the back of the prototype