The Pentametric has arrived

The Bogart Pentametric arrived in the mail yesterday and I connected it to a 12V power supply in my study. Connecting it was straight forward following the wiring diagram printed on the cover of the input unit. The connectors are of high quality. After applying power I hooked it to the serial port of my PC using a standard serial cable. Using the PMComm software from the Bogart Engineering web site configuring the unit was very easy. Below is a picture of the setup. In the middle in the bottom is the Pentametric input unit and serial interface connected to the Atmel Xplain board. The Xplain board is connected to an nRF24LE1 evaluation board (left) through SPI and this board sends a radio packet with the measured data every second. To the right is the nRF24LE1 receiver board showing the battery voltage, 13.8V. The battery in this setup is a laboratory type power supply.

Pentametric input unit and computer interface (lower middle)

Pentametric input unit and computer interface (lower middle)

Instructions for communicating with Pentametric via the serial interface can be found in this document: How to access data via the RS232 port from the PentaMetric battery monitor.

I will post the full source code here after it is finished but here is a preview of the “short read” command:

bool pentametric_short_read(unsigned char a, unsigned char n, unsigned char *msg)
{
unsigned char crc, i;
putchar(usart_data_, 0×81);
putchar(usart_data_, a);
putchar(usart_data_, n);
crc = 0×81 + a + n;
putchar(usart_data_, ~crc);
crc = 0;
for(i=0;i<n;i++)
{
msg[i] = getchar(usart_data_);
crc += msg[i];
}
crc += getchar(usart_data_);
if (crc != 0xff)
return false;
return true;
}
bool pentametric_short_read(uint8_t a, uint8_t n, uint8_t *msg)
{
    uint8_t crc, i;

    putchar(usart_data_, 0x81);
    putchar(usart_data_, a);
    putchar(usart_data_, n);
    crc = 0x81 + a + n;
    putchar(usart_data_, ~crc);
    crc = 0;
    for(i=0;i<n;i++)
    {
        msg[i] = getchar(usart_data_);
        crc += msg[i];
    }
    crc += getchar(usart_data_);
    if (crc != 0xff)
        return false;
    return true;
}
Advertisement

3 Responses to The Pentametric has arrived

  1. Have you had any luck getting the right values for FORMAT2 on the short reads? It seems the values coming back are some sort of float conversion that’s not being covered 100% correctly in the documentation.

    • Hi Wyatt,

      You are right! There is an error in the documentation. The multiplication with -1 should be done only inside the if. Corrected code below. Thanks for the thumbs up!

  2. Yes I have. Here is the function I use to calculate the shunt current (msg[] contains the bytes read using the function desribed in my blog above):


    double calculate_i32(uint8_t *msg)
    {
    double fres;
    uint32_t tmp32;
    tmp32 = (uint32_t)msg[2];
    tmp32 <<= 8;
    tmp32 |= (uint32_t)msg[1];
    tmp32 <<= 8;
    tmp32 |= (uint32_t)msg[0];
    if (tmp32 & 0x800000)
    {
    tmp32 = ~tmp32;
    tmp32 &= 0x7FFFFF;
    fres = -1.0 * (double)tmp32;
    }
    else
    {
    fres = (double)tmp32;
    }
    return fres/100.0;
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s