| Electronic Components Datasheet Search |
|
AN2512 Datasheet(PDF) 31 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2512 Datasheet(HTML) 31 Page - STMicroelectronics |
|
31 / 38 page ![]() AN2512 Example of source code 31/38 if (ReadSTPM01Falg == 0){ for (i = 0; i < 3; i ++){ NewTemp = * new; e->old[i] = NewTemp;// save the value for the first time reading new ++; //next data } e->quot[0] = 0; e->quot[1] = 0; e->quot[2] = 0; } else{ e->quant[3] = 0; for (i = 0; i <3; i++ ){ NewTemp = *new; // Rollover high to low occurs when MSB goes from F to 0 if (NewTemp >= e->old[i]){ if ((NewTemp - e->old[i]) >= 0x80000){ //roll over, negative energy e->quant[i] = 0x100000 + e->old[i] -NewTemp; e->quant[3] -= e->quant[i];//total ernergy minus the negative energy } else{ e->quant[i] = NewTemp - e->old[i]; //positive energy e->quant[3] += e->quant[i]; //add the positive energy to the total energy } } else{ if ((e->old[i] - NewTemp) >= 0x80000) { //roll over, positive energy e->quant[i] = 0x100000 + NewTemp - e->old[i]; e->quant[3] += e->quant[i]; //total ernergy plus the positive energy } else{ e->quant[i] = e->old[i] - NewTemp; //negative energy e->quant[3] -= e->quant[i]; //total energy minus the negative energy } } e->old[i] = NewTemp;// save the value for next time new ++; //next data } } |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |