issues with external pl pcdu conversion
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-02-22 15:27:47 +01:00
parent 9e3d7bccd9
commit 3f318afe2c
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 21 additions and 17 deletions

View File

@ -320,8 +320,8 @@ void SpiTestClass::performOneShotMax1227Test() {
}
}
adcCfg.plPcduAdcExtConv = false;
adcCfg.plPcduAdcIntConv = true;
adcCfg.plPcduAdcExtConv = true;
adcCfg.plPcduAdcIntConv = false;
performMax1227Test();
}
@ -343,8 +343,8 @@ void SpiTestClass::performMax1227Test() {
<< std::endl;
return;
}
uint32_t spiSpeed = 1'000'000;
spi::SpiModes spiMode = spi::SpiModes::MODE_3;
uint32_t spiSpeed = 976'000;
spi::SpiModes spiMode = spi::SpiModes::MODE_0;
setSpiSpeedAndMode(fd, spiMode, spiSpeed);
max1227RadSensorTest(fd);
@ -535,11 +535,12 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
adcCfg.vbatSwitch = false;
// Takes a bit of time until the ADC is usable
TaskFactory::delayTask(50);
}
if (adcCfg.plPcduAdcExtConv) {
sendBuffer[0] = max1227::buildResetByte(false);
spiTransferStruct[0].len = 1;
transfer(fd, gpioIds::PLPCDU_ADC_CS);
}
if (adcCfg.plPcduAdcExtConv) {
sendBuffer[0] = max1227::buildSetupByte(ClkSel::EXT_CONV_EXT_TIMED, RefSel::INT_REF_NO_WAKEUP,
DiffSel::NONE_0);
spiTransferStruct[0].len = 1;
@ -551,16 +552,20 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
for (uint8_t idx = 0; idx < n + 1; idx++) {
adcRaw[idx] = (recvBuffer[idx * 2 + 1] << 8) | recvBuffer[idx * 2 + 2];
}
arrayprinter::print(recvBuffer.data(), spiTransferStruct[0].len, OutputType::HEX);
sif::info << "PL PCDU ADC values:" << std::endl;
for (int idx = 0; idx < n + 1; idx++) {
sif::info << "Raw Value " << idx << ": " << adcRaw[idx] << std::endl;
}
usleep(10);
spiTransferStruct[0].len = 0;
max1227::prepareExternallyClockedTemperatureRead(sendBuffer.data(), spiTransferStruct[0].len);
transfer(fd, gpioIds::PLPCDU_ADC_CS);
int16_t tempRaw = ((recvBuffer[23] & 0x0f) << 8) | recvBuffer[24];
float temp = max1227::getTemperature(tempRaw);
sif::info << "Temperature: " << temp << std::endl;
sif::info << "PL PCDU ADC ext conv [" << std::hex << std::setfill('0');
for (int idx = 0; idx < n + 1; idx++) {
sif::info << std::setw(3) << adcRaw[idx];
if(idx < n) {
sif::info << ",";
}
}
sif::info << "]" << std::endl;
sif::info << "Temperature: " << max1227::getTemperature(tempRaw) << " C" << std::endl;
}
if (adcCfg.plPcduAdcIntConv) {
sendBuffer[0] = max1227::buildResetByte(true);
@ -583,7 +588,6 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
shiftOutZeros();
transfer(fd, gpioIds::PLPCDU_ADC_CS);
setSendBuffer();
//arrayprinter::print(recvBuffer.data(), 26, OutputType::HEX);
uint16_t adcRaw[n + 1] = {};
int16_t tempRaw = ((recvBuffer[0] & 0x0f) << 8) | recvBuffer[1];
sif::info << "PL PCDU ADC int conv [" << std::hex << std::setfill('0');
@ -595,7 +599,7 @@ void SpiTestClass::max1227PlPcduTest(int fd) {
}
}
sif::info << "]" << std::endl;
sif::info << "Temperature: " << tempRaw * 0.125 << " C" << std::endl;
sif::info << "Temperature: " << max1227::getTemperature(tempRaw) << " C" << std::endl;
}
}

View File

@ -65,7 +65,7 @@ void prepareExternallyClockedSingleChannelRead(uint8_t* spiBuf, uint8_t channel,
* the first byte (first conversion byte) the the rest of the SPI buffer.
* @param spiBuf
* @param n Channel number. Example: If the ADC has 6 channels, n will be 5
* @param sz
* @param sz Will be incremented by amount which should be sent
*/
void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
@ -73,7 +73,7 @@ void prepareExternallyClockedRead0ToN(uint8_t* spiBuf, uint8_t n, size_t& sz);
* Prepare an externally clocked temperature read. 25 bytes have to be sent
* and the raw temperature value will appear on the last 2 bytes of the reply.
* @param spiBuf
* @param sz
* @param sz Will be incremented by amount which should be sent
*/
void prepareExternallyClockedTemperatureRead(uint8_t* spiBuf, size_t& sz);