cancel
Showing results for 
Search instead for 
Did you mean: 

display in stm cube ide for project of nanoedge studio ia

IsmailYangui
Associate III

Hello everyone, I am working on a project using nanoedge studio ia in rating N, I want to check my project with cube ide, I can make a view with tera term or other tool, which shows the result corresponding to my database. I used stm32L475vgt6; The problem is that there is also no display with a simple code that says printf(hello World)

1 ACCEPTED SOLUTION

Accepted Solutions
Julian E.
ST Employee

You need to split your dataset in two files:

  • Diabetes
  • Non-diabetes

Then you need to remove the results columns in both files.

 

After that import both file in the step "Signal" in NanoEdge and you should have your 2 files with 8 columns each.

Then launch a benchmark and select both files to create a model.

 

Later in your implementation in C, to make the classification, you will need to send data containing the 8 kinds of values you used.

 

Julian

 

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

8 REPLIES 8
Julian E.
ST Employee

Hello Ismail,

 

I didn't understand your question.

Can you explain me what is the "println(hello World")" you are talking about?

You can use screenshot if you need to.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

after i finished all steps of nanoedge . now i want to do this project in stm cube ide . i want the result displays in tera term . but there is no result appear in tera term so i make a simple code to testing . but no result also . now i  want to make a led to light up when the result is diabetes and light off when non_diabetes .. to undrsatnd me . the dataset i used in nanoedge is a dataset for daibetes . so it's 1 if daibetes else 0

IsmailYangui
Associate III
/* Includes */
#include "main.h"
#include "NanoEdgeAI.h"
#include "knowledge.h"
#include "stm32l4xx_hal.h"
#include <stdlib.h> // Include standard library for rand()



/* Private variables */
NEAI_StateTypeDef neai_state;
UART_HandleTypeDef huart4;

/* Private function prototypes */
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_UART4_Init(void);
float knowledge_buffer[50];

NEAI_StateTypeDef neai_state;
/* Main function */
int main(void) {
    HAL_Init();                     // Initialize HAL
    SystemClock_Config();           // Configure the system clock

    MX_GPIO_Init();                 // Initialize GPIOs
    MX_UART4_Init();                // Initialize UART if used

    // Initialize NanoEdge AI
    neai_state = neai_classification_init(knowledge_buffer);
    if (neai_state != NEAI_OK) {
        // Handle initialization error
        while(1);  // Halt here or handle as per your project's error handling strategy
    }

    // Main loop
    while (1) {
        float input_data[AXIS_NUMBER * DATA_INPUT_USER];  // Replace with actual sensor data acquisition

        // Example: simulate sensor data acquisition
        for (int i = 0; i < AXIS_NUMBER * DATA_INPUT_USER; i++) {
            input_data[i] = (float)(rand() % 100);  // Example data generation
        }

        float output_buffer[CLASS_NUMBER];
        uint16_t id_class;

        // Perform classification
        neai_state = neai_classification(input_data, output_buffer, &id_class);
        if (neai_state != NEAI_OK) {
            // Handle classification error
            continue;  // Or handle as per your project's error handling strategy
        }

        // Determine LED status based on classification result
        if (id_class == 1) {
            // Diabetes detected, turn on LED
            HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);  // Adjust GPIO pin as per your setup
        } else {
            // No diabetes detected, turn off LED
            HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);  // Adjust GPIO pin as per your setup
        }

        HAL_Delay(1000);  // Adjust delay as necessary for your application
    }
}

/* System Clock Configuration */
void SystemClock_Config(void) {
    RCC_OscInitTypeDef RCC_OscInitStruct = {0};
    RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

    // Configure the main internal regulator output voltage
    if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK) {
        Error_Handler();
    }

    // Initialize the RCC Oscillators according to the specified parameters
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
    RCC_OscInitStruct.MSIState = RCC_MSI_ON;
    RCC_OscInitStruct.MSICalibrationValue = 0;
    RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
    if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
        Error_Handler();
    }

    // Initialize the CPU, AHB and APB buses clocks
    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
    if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
        Error_Handler();
    }
}

/* GPIO Initialization */
void MX_GPIO_Init(void) {
    GPIO_InitTypeDef GPIO_InitStruct = {0};

    // GPIO Ports Clock Enable
    __HAL_RCC_GPIOA_CLK_ENABLE();  // Adjust as per your GPIO port

    // Configure GPIO pin : PA5 (example pin)
    GPIO_InitStruct.Pin = GPIO_PIN_5;  // Adjust GPIO pin as per your setup
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}

/* UART4 Initialization */
void MX_UART4_Init(void) {
    huart4.Instance = UART4;
    huart4.Init.BaudRate = 115200;
    huart4.Init.WordLength = UART_WORDLENGTH_8B;
    huart4.Init.StopBits = UART_STOPBITS_1;
    huart4.Init.Parity = UART_PARITY_NONE;
    huart4.Init.Mode = UART_MODE_TX_RX;
    huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
    huart4.Init.OverSampling = UART_OVERSAMPLING_16;
    huart4.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
    huart4.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
    if (HAL_UART_Init(&huart4) != HAL_OK) {
        Error_Handler();
    }
}

/* Error Handler */
void Error_Handler(void) {
    while (1) {
        // Handle error
    }
}

/* assert_failed function */
void assert_failed(uint8_t *file, uint32_t line) {
    // Handle assertion failed
}

 

IsmailYangui
Associate III

this is my errors

13:37:05 **** Incremental Build of configuration Debug for project emchi_jed_bouk ****

make -j4 all

arm-none-eabi-gcc "../Core/Src/main.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32L475xx -c -I../Core/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/main.o"

../Core/Src/main.c:24:16: error: expected identifier or '(' before '=' token

24 | enum neai_state=neai_classification_init();

| ^

../Core/Src/main.c:35:1: error: unknown type name 'NEAI_StateTypeDef'; did you mean 'HAL_StatusTypeDef'?

35 | NEAI_StateTypeDef neai_state;

| ^~~~~~~~~~~~~~~~~

| HAL_StatusTypeDef

../Core/Src/main.c:35:19: error: conflicting types for 'neai_state'; have 'int'

35 | NEAI_StateTypeDef neai_state;

| ^~~~~~~~~~

../Core/Src/main.c:26:19: note: previous declaration of 'neai_state' with type 'HAL_StatusTypeDef'

26 | HAL_StatusTypeDef neai_state;

| ^~~~~~~~~~

make: *** [Core/Src/subdir.mk:34: Core/Src/main.o] Error 1

"make -j4 all" terminated with exit code 2. Build might be incomplete.

 

13:37:06 Build Failed. 4 errors, 0 warnings. (took 1s.101ms)

 

 

Hello Ismail,

 

First, this doesn't exist: 

 

 

NEAI_StateTypeDef

 

 

Then, you need to add this function to redirect the uart to the printf:

 

 

/**
  * @brief  Redirecting stdout to USART1 which is connected on the STLINK port
  * @retval
  * 
  */
int __io_putchar(int ch)
{
uint8_t c[1];
c[0] = ch & 0x00FF;
HAL_UART_Transmit(&huart1, &*c, 1, 10);
return ch;
}

 

 

(in this example, it if the huart1, but it depends on the one you are using, I believe you are using the huart4)

 

You can look at this repository containing the source code of the data logger in NanoEdge AI Studio. You will find everything related to NanoEdge and you should be able to replicate it for your project:

https://github.com/stm32-hotspot/stm32ai-nanoedge-datalogger/blob/main/Projects/NUCLEO-L476RG/NUCLEO-L476RG_LIS2MDL/Core/Src/main.c

 

You can also to take a look at this tutorial that explain how to use NanoEdge AI Studio to create a N class classification model to detect a classify multiple states of a fan. All the files are provided and the code should be very similar to what you are trying to do:

https://wiki.st.com/stm32mcu/wiki/AI:How_to_create_a_multi-state_vibrations_classifier_using_NanoEdge_AI_studio

 

After that, If you have any question regarding NanoEdge, feel free to ask them in this community.

 

Have a good day,

Julian

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Thank you for your reply.. I have a simple question.. When I add a dataset in nanoedge studio..Should the dataset contain the result of parameter ? . For example.. my data set contains 8 inputs such as blood and glucose and one output for diabetes (1) or non-diabetes (0). Should the output be present or should it not exist?

Julian E.
ST Employee

You need to split your dataset in two files:

  • Diabetes
  • Non-diabetes

Then you need to remove the results columns in both files.

 

After that import both file in the step "Signal" in NanoEdge and you should have your 2 files with 8 columns each.

Then launch a benchmark and select both files to create a model.

 

Later in your implementation in C, to make the classification, you will need to send data containing the 8 kinds of values you used.

 

Julian

 

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Thanks..  this my big problem is  the steps of implementation. There's no display for the result. So i be confused.. Also i create an other simple project stm32 just to display a sentence but nothing to display