![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
BMS I/Fプログラム
Diff: main.cpp
- Revision:
- 4:c5b0a318c84d
- Parent:
- 3:8607d7ab7f25
- Child:
- 5:8076127d0690
--- a/main.cpp Fri Apr 29 09:00:40 2016 +0000 +++ b/main.cpp Fri Apr 29 09:59:16 2016 +0000 @@ -96,13 +96,18 @@ dat[3] = 0xff; dat[4] = 42; dat[5] = 255; - for(int loop_1 = 0; loop_1 < BMS_NUM; loop_1++){ - for(int loop = 0;loop < 6; loop++){ - spi.write(dat[loop]); - } - cmd = CalcCRCLTC6803(dat, 6); - spi.write(cmd); + + for(int loop = 0;loop < 6; loop++){ + spi.write(dat[loop]); } + cmd = CalcCRCLTC6803(dat, 6); + spi.write(cmd); + for(int loop = 0;loop < 6; loop++){ + spi.write(dat[loop]); + } + cmd = CalcCRCLTC6803(dat, 6); + spi.write(cmd); + cs = 1; wait(0.001); while(1) { @@ -110,12 +115,16 @@ cmd = RDCV; spi.write(cmd); spi.write(CalcCRCLTC6803(&cmd, 1)); - for(int bms = 0; bms < BMS_NUM; bms++){ - for(int cell = 0;cell < 18; cell++){ - getdat[cell][bms] = spi.write(0); - } - getpec = spi.write(0); + + for(int cell = 0;cell < 18; cell++){ + getdat[cell][0] = spi.write(0); } + getpec = spi.write(0); + for(int cell = 0;cell < 18; cell++){ + getdat[cell][1] = spi.write(0); + } + getpec = spi.write(0); + cs = 1; wait(0.001); cs = 0; @@ -137,13 +146,13 @@ cellvol[11][bms] = ((getdat[17][bms] << 4) | ((getdat[16][bms] & 0xf0) >> 4)); for(int loop = 0;loop < (12); loop++){ //表示する数値は(cellvol[loop] - 512)*1.5mV - pc.printf("Cell%2d = %5dmV\n", (loop*bms) + 1, ((cellvol[loop][bms] - 512)+((cellvol[loop][bms] - 512)/2))); + pc.printf("Cell%2d = %5dmV\n", (loop + (bms*12)) + 1, ((cellvol[loop][bms] - 512)+((cellvol[loop][bms] - 512)/2))); cellallvol += cellvol[loop][bms]; } } pc.printf("CellALL = %5dmV\n", ((cellallvol - 512*(12 * BMS_NUM))+((cellallvol - 512*(12 * BMS_NUM))/2))); - cmd = STCVADALL; + cmd = STCVADSELF1; spi.write(cmd); spi.write(CalcCRCLTC6803(&cmd, 1));