Post Go back to editing

Missing The Mark for Ending of a Measurement Loop

Category: Hardware
Product Number: emStat pico

Hello

I try to control emstat pico module with stm32 processor. When I check the capturing data, I recognized that there is no '*\n" command in the recording data. Do you what it can be reason for that?

Here is the recorded data, "e\nM0007\nPda8061B74u;ba8030F9Dn,12,28\n", '\0' <repeats 62 times>

Parents Reply Children
  • Hello  

    Thank you for your response! Here is my script. I basically update certain values in the script because of that I use snprintf.

    snprintf(Chrono_Amp, 200, "e\n"
    							"var p\n"
    							"var c\n"
    							"set_pgstat_chan 0\n"
    							"set_pgstat_mode 2\n"
    							"set_range ba %d%c\n" // Added current range control
    							"wait %d\n" // Added tequilibrium
    						    "cell_on\n"
    							"meas_loop_ca p c %d\m %d %d\n"
    							"pck_start\n"
    							"pck_add p\n"
    							"pck_add c\n"
    							"pck_end\n"
    							"endloop\n"
    							"cell_off\n"
    							"\n\0",
    							Current_range,
    							Current_unit,
    							tequil16,
    							EdcChro,
    							tintervalChro,
    							trunChro);

  • Hi,

    The script looks ok to me, You may try a shorter runtime or increase the interval-time so that there only a few packages send by the Pico back to the host. Maybe the last part of the data is lost having the loop termination part "*\n"

    Regards,

    Walter

  • Hello  

    I agree with you about losing data because when I check the raw data before parsing, it looks like that "e\nM0007\nPda8061B74u;ba8030F9Dn,12,28\n" I recognized that there should be one more digit as well after the last 8. Based on the document, it would be like that "...,288\n*\n\n". Is that correct? Other thing is that when I increase the interval time to 5 s and keep total run time in 10s, I got same problem.

  • Hi,

    If a 10s runtime and a 5s interval time still caused the same issue, I would suggest looking at the communication implementation.

    Are you using interrupt or polling ? Do you have a circular buffer? How big is the receiving buffer? Are you able to grab a complete output of the latest script , I expect only 2 packets followed by the "*\n"

    Cheers,

    Walter

  • Like this:

    M0007
    Pda807A1CAu;ba635FE86p,10,20A
    Pda807A1CAu;ba635FE86p,10,20A
    *

  • I set it in interrupt mode. The circular buffer is in DMA mode, so in my case there is no circular buffer. Receiving buffer size is 100 bytes. 

  • So I understood that you are using DMA in circular mode, am I correct?

    And the DMA generates an interrupt if some threshold is exceeded? 

    So when the data comes in how fast are you parsing the data so the buffer can be overwritten in the buffer?

    Which STM32 do you use? 

    Sorry for al these questions but I have to get a complete picture of this.

  • No worries, thank you for your quick response!

    I use UART in interrupt mode, not DMA mode.

    Actually, I didn't know answer of the question,"when the data comes in how fast are you parsing the data so the buffer can be overwritten in the buffer?". How can I measure the how fast parsing of data?

    STM32F407IEH6

  • Ah okay so you get an interrupt every time you receive a character?

  • Exactly, for example here is my receive call back function,

    UART3 is for emstatpico and STM32 communication; UART2 is for STM32 to PC communication.

    uint8_t RXData[100];

    uint8_t temp_counter = 0;

    uint8_t buffer[100];

    uint8_t RXBuff[100];

    uint16_t mCounter = 0;

    void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)

    {

    int i = 0;

    int j = 0;

    int start = -1;

    int end = -1;

    if (huart == &huart3) {

    HAL_UART_Transmit(&huart2, RXData, 1, 1000);

    RXBuff[mCounter++] = RXData[0];

    }

    // Find the start and end indices of the data

    for (i = 0; i < strlen(RXBuff); i++) {

    if (RXBuff[i] == 'P') {

    start = i;

    break;

    }

    }

    for(i = start; i < strlen(RXBuff); i++) {

    if (RXBuff[i] == '\n') {

    end = i;

    break;

    }

    }

    // Copy the data to the buffer

    if (start != -1 && end != -1) {

    for (i = start; i <= end; i++) {

    buffer[j++] = RXBuff[i];

    }

    for(int temp = 0; temp < 100 ; temp++) RXBuff[temp] = 0;

    mCounter = 0;

    buffer[j] = '\0';

    }

    HAL_UART_Receive_IT(&huart3, RXData, 1);

    }