2009年8月21日 星期五

電流

標準, 1 OZ 40 MIL 的線, 能走 1A ....
如此換算 假如我要 走 5 A , 那就是 加大線粗到 200 MIL , 或者 加大 到 2 OZ, 線粗到 100 MIL ..................
加大 OZ 會多收錢, 所以最好加大線粗..................

PCB電路板銅皮寬度和所流過電流量大小的計算方法

PCB電路板銅皮寬度和所流過電流量大小的計算方法

一般PCB板的銅箔厚度為35um,線條寬度為1mm時,那末線條的橫切面的面積為0.035平方毫米,通常取電流密度30A/平方毫米,所以,每毫米線寬可以流過1A電流。

IPC275-A的標准上有計算公式.同溫升,銅箔厚度,A有關.

I = 0.0150(DT 0.5453)(A 0.7349) for IPC-D-275 Internal Traces

I = 0.0647(DT 0.4281)(A 0.6732) for IPC-D-275 External Traces

2009年8月9日 星期日

dePIC24F I2C Master 程式

#include "../hfiles/p24fj64ga006.h"
#include "../hfiles/pin.h"

/**********************************************************

**********************************************************/
void main(void)
{
ConfigIntI2C();
OpenI2C();

unsigned char temp1,temp2;
//WP=0; /*write protection*/

temp1=write_I2C(0X1F0,0X35); //(unsigned int I2C_addr, unsigned char I2C_data);

temp2=read_I2C(0X1F0); //(unsigned int I2C_addr);
//WP=1;
}
/**********************************************************

**********************************************************/
unsigned char write_I2C(unsigned int I2C_addr, unsigned char I2C_data)
{
StartI2C();
while(I2C1CONbits.SEN==1);

MasterWriteI2C(0xa2); /*device address*/
while(I2C1STATbits.TRSTAT);
if(I2C1STATbits.ACKSTAT==1) return 0;

MasterWriteI2C((I2C_addr>>8)&0XFF); /*high 8 bit data address*/
while(I2C1STATbits.TRSTAT);
if(I2C1STATbits.ACKSTAT) return 0;

MasterWriteI2C((I2C_addr)&0XFF); /*low 8 bit data address*/
while(I2C1STATbits.TRSTAT);
if(I2C1STATbits.ACKSTAT) return 0;

MasterWriteI2C(I2C_data); /*low 8 bit data*/
while(I2C1STATbits.TRSTAT);
if(I2C1STATbits.ACKSTAT) return 0;

StopI2C();
while(I2C1CONbits.PEN);
return 1;
}
/**********************************************************

**********************************************************/
unsigned char read_I2C(unsigned int I2C_addr)
{
unsigned char temp;

StartI2C();
while(I2C1CONbits.SEN);

MasterWriteI2C(0xa2); /*DEVICE address,write*/
while(I2C1STATbits.TRSTAT);

MasterWriteI2C((I2C_addr>>8)&0XFF); /*device high 8 bit data address*/
while(I2C1STATbits.TRSTAT);

MasterWriteI2C(I2C_addr& 0XFF); /*device low 8 bit data address*/
while(I2C1STATbits.TRSTAT);

RestartI2C();
while(I2C1CONbits.RSEN);

MasterWriteI2C(0xa3); /*device address,read*/
while(I2C1STATbits.TRSTAT);

temp=MasterReadI2C();

NotAckI2C();

StopI2C();
while(I2C1CONbits.PEN);

return temp;
}
/**********************************************************

**********************************************************/
unsigned char MasterReadI2C(void)
{
I2C1CONbits.RCEN = 1;
while(I2C1CONbits.RCEN);

I2C1STATbits.I2COV = 0;

return(I2C1RCV);
}
/**********************************************************

**********************************************************/
char MasterWriteI2C(unsigned char data_out)
{
I2C1TRN = data_out;

if(I2C1STATbits.IWCOL) /* If write collision occurs,return -1 */
{
I2C1STATbits.IWCOL=0;return -1;
}
else
{
return 0;
}
}
/**********************************************************

**********************************************************/
void AckI2C(void)
{
I2C1CONbits.ACKDT = 0;
I2C1CONbits.ACKEN = 1;
}
/**********************************************************

**********************************************************/
void ConfigIntI2C(void)
{
/*
SI2CIF = 0; // clear the MI2C & SI2C Interrupts
MI2CIF = 0;

SI2CIP0 = 0; // set the SI2C priority
SI2CIP1 = 0; // set the SI2C priority
SI2CIP2 = 0; // set the SI2C priority
MI2CIP0 = 0; // set the MI2C priority
MI2CIP1 = 0; // set the MI2C priority
MI2CIP2 = 0; // set the MI2C priority
SI2CIE = 0; // enable/disable the SI2C Interrupt
MI2CIE = 0; // enable/disable the MI2C Interrupt
*/
}
/**********************************************************

**********************************************************/
void NotAckI2C(void)
{
I2C1CONbits.ACKDT = 1;
I2C1CONbits.ACKEN = 1;
}
/**********************************************************

**********************************************************/
void OpenI2C(void)
{
I2C1BRG = 27; /*BAUD= 100khz,at 11.0592mhz fcy*/
I2C1CONbits.I2CEN=1;
}
/**********************************************************

**********************************************************/
void RestartI2C(void)
{
I2C1CONbits.RSEN = 1; /* initiate restart on SDA and SCL pins */
}
/**********************************************************

**********************************************************/
void StartI2C(void)
{
I2C1CONbits.SEN = 1; /* initiate Start on SDA and SCL pins */
}
/**********************************************************

**********************************************************/
void StopI2C(void)
{
I2C1CONbits.PEN = 1; /* initiate Stop on SDA and SCL pins */
}
/**********************************************************

**********************************************************/