It is currently 19 Apr 2018 16:24

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 07 Jan 2018 14:54 
Offline

Joined: 06 Jan 2018 09:45
Posts: 2
Hello,

I'm trying to get example of Air Quality 2 click to get compiled, but i receive errors. Example is taken from https://libstock.mikroe.com/projects/do ... ft90x.mpkg help file example air_quality_2_FT90x.c

I have mikroC PRO 2.2.1+visual TFT as software and HMI 5" FT900 Rev 1, hmi-bb and mikroprog for FT90X as hardware.

Compile errors:
0 122 Compilation Started stdint.h
61 324 Undeclared identifier 'co2_array' in expression AirQuality2_TEST.c
61 324 Undeclared identifier 'co2_array_ind' in expression AirQuality2_TEST.c
61 322 Pointer required AirQuality2_TEST.c
62 324 Undeclared identifier 'co2_array_ind' in expression AirQuality2_TEST.c
62 324 Undeclared identifier 'co2_array_ind' in expression AirQuality2_TEST.c
66 324 Undeclared identifier 'co2_array' in expression AirQuality2_TEST.c
66 322 Pointer required AirQuality2_TEST.c
66 317 Operator '' is not applicable to these operands '' AirQuality2_TEST.c
0 102 Finished (with errors): 07 tammi 2018, 14:59:02 AirQuality2_TEST.mcpf9


My code:
/***************************************************************************/
#include "air_quality_2_click.h"

/***************************************************************************/
#define POLLING_PERIOD 5000

#define SAMPLES 12
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
static iaq_info_t info;
static char str_buffer[16];

static iaq_status_t iaq_status;


/***************************************************************************/
static void system_init( void );

/***************************************************************************/
static void system_init( void )
{
    UART1_Init( 57600 );

    I2CM1_Init( _I2CM_SPEED_MODE_STANDARD, _I2CM_SWAP_DISABLE );
    air_quality_2_click_init();

    UART1_Write_Text("\x0C");   // Write new page.
    UART1_Write_Text("---------------------------------------------------\r\n");
    UART1_Write_Text("-|               System initialized.             |-\r\n");
    UART1_Write_Text("---------------------------------------------------\r\n");
}

static void status_to_str(iaq_status_t status, char* str)
{
    switch (status)
    {
    case IAQ_OK:
        strcpy(str, "OK");
        break;
    case IAQ_BUSY:
        strcpy(str, "BUSY");
        break;
    case IAQ_ERROR:
        strcpy(str, "ERROR");
        break;
    case IAQ_RUNIN:
        strcpy(str, "RUNIN");
        break;
    default:
        strcpy(str, "UNKNOWN");
        break;
    }
}

static float get_average(uint16_t sample)
{
    uint8_t i;
    float sum = 0;

    co2_array[co2_array_ind++] = sample;
    if(co2_array_ind == SAMPLES) co2_array_ind = 0;

    for(i = 0; i < SAMPLES; i++ )
    {
        sum += co2_array[i];
    }

    return sum / SAMPLES;
}

/***************************************************************************/
void main()
{
    system_init();

    while (1)
    {
        // Read measurements.
        iaq_status = air_quality_2_click_info(&info);

        // Write results to UART.
        UART1_Write_Text("Status:\x09\x09");
        status_to_str(iaq_status, str_buffer);
        UART1_Write_Text(str_buffer);
        UART1_Write_Text("\r\n");

        UART1_Write_Text("CO2:\x09\x09");
        LongToStr(info.co2_eq, str_buffer);
        UART1_Write_Text(Ltrim(str_buffer));
        UART1_Write_Text("\x09ppm\r\n");

        UART1_Write_Text("TVOC:\x09\x09");
        LongToStr(info.tvoc_eq, str_buffer);
        UART1_Write_Text(Ltrim(str_buffer));
        UART1_Write_Text("\x09ppb\r\n");

        UART1_Write_Text("Resistance:\x09");
        LongToStr(info.resistance, str_buffer);
        UART1_Write_Text(Ltrim(str_buffer));
        UART1_Write_Text("\x09ohm\r\n");

        UART1_Write_Text("---------------------------------------------------");
        UART1_Write_Text("\r\n");

        Delay_ms(POLLING_PERIOD);
    }
}

/*************** END OF FUNCTIONS *********************************************/


I tried this as workaround for errors:
float co2_array[12] = { 0 };
    int co2_array_ind = 0;

    //co2_array[*co2_array_ind++] = sample;
    //if(co2_array_ind == SAMPLES) co2_array_ind = 0;

    for(i = 0; i < SAMPLES; i++ )
    {
        co2_array[i] = sample;
    }


But then i get this:
0 122 Compilation Started stdint.h
116 123 Compiled Successfully AirQuality2_TEST.c
62 1164 Variable 'co2_array_ind' has been eliminated by optimizer AirQuality2_TEST.c
0 127 All files Compiled in 78 ms 
0 360 Unresolved extern 'TFT_16bit_RS' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_DataPort_Lo' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_WR' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_RS' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_DataPort_Lo' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_16bit_WR' __Lib_TFT_16bit_Defs.c
0 360 Unresolved extern 'TFT_CS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RD' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_CS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RD' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_RS' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_DataPort' __Lib_TFT_Defs.c
0 360 Unresolved extern 'TFT_WR' __Lib_TFT_Defs.c
0 102 Finished (with errors): 07 tammi 2018, 15:02:00 AirQuality2_TEST.mcpf9


After commenting this line and doing my workaround:
// iaq_status = air_quality_2_click_info(&info);

i get prog compiled but its not getting any readings

Terminal:
Status:      OK

CO2:      0   ppm

TVOC:      0   ppb

Resistance:   0   ohm

---------------------------------------------------


Any help is appreciated.


Top
 Profile  
 
PostPosted: 09 Jan 2018 10:13 
Offline
mikroElektronika team
User avatar

Joined: 18 Dec 2017 15:44
Posts: 94
Hi,

When you open example go to Project -> Edit Search Paths, then in section Header files and Source files
click on Add header path and Add search path icon and then in both cases choose Uses in Click_Air_quality_2, and at the end click on Apply.
I think this should solve the problem.

Best Regards,

_________________
Marko Stankovic.


Top
 Profile  
 
PostPosted: 16 Jan 2018 18:27 
Offline

Joined: 06 Jan 2018 09:45
Posts: 2
I have added search paths for it before trying those desperate measures :D

But i have purchased clicker 2 PIC32MX to make sensor readings to HMI via serial, since PIC32 seems to have better support on click boards at libstock. Hope it all will sort out better and easier with PIC32.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: