2018-11-08 12:44 AM
Hi All;
I would like to measure active power.
DataTx[0] = 0xFF;
DataTx[1] = 0x00;
DataTx[2] = 0xA0;
DataTx[3] = 0x00;
DataTx[4] = Metro_HAL_CalcCRC8(DataTx);
HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)DataTx, (uint8_t *)DataRx, sizeof(DataTx),100);
DataTx[0] = 0xFF;
DataTx[1] = 0x01;
DataTx[2] = 0x1E;
DataTx[3] = 0x04;
DataTx[4] = Metro_HAL_CalcCRC8(DataTx);
HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)DataTx, (uint8_t *)DataRx, sizeof(DataTx),100);
DataTx[0] = 0xFF;
DataTx[1] = 0x05;
DataTx[2] = 0x80;
DataTx[3] = 0x00;
DataTx[4] = Metro_HAL_CalcCRC8(DataTx);
HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)DataTx, (uint8_t *)DataRx, sizeof(DataTx),100);
DataTx[0] = 0x04;
DataTx[1] = 0xFF;
DataTx[2] = 0xFF;
DataTx[3] = 0xFF;
DataTx[4] = Metro_HAL_CalcCRC8(DataTx);
HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)DataTx, (uint8_t *)DataRx, sizeof(DataTx),100);
DataTx[0] = 0x5C; // Active power
DataTx[1] = 0xFF;
DataTx[2] = 0xFF;
DataTx[3] = 0xFF;
DataTx[4] = Metro_HAL_CalcCRC8(DataTx);
HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)DataTx, (uint8_t *)DataRx, sizeof(DataTx),100);
Tx[0] = DataRx[0];
Tx[1] = DataRx[1];
Tx[2] = DataRx[2];
Tx[3] = DataRx[3];
convertBufferContent();
HAL_Delay(1000);
// DataTx[0] = 0x28;
//DataTx[1] = 0x29;
//DataTx[2] = 0x00;
//DataTx[3] = 0x49;
//HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)DataTx, (uint8_t *)DataRx, sizeof(DataTx),100);
//HAL_Delay(1000);
I received data in DataRx variable. How should I do when I would like to watch real value? ( Such as V1 : 230V )