Hello Community!

I am new to XDK and encountered several problems over the past few days;

1.Problem with basics: Hello World Code Example

I read the XDK110: Guide Workbench First Steps instructions and followed the steps for creating a new project and the Hello World Code Example (creating new project, application template). I used the code from the manual for the main.c file and application.h file but failed to get the intended outcome (refer to first image).

 

2. Modifying demo codes.

I have been playing around with the demo templates like the LedsAndButtons. 

There demos are working fine but when I altered parts of it eg:

/* Process the Button1 Data in side the Application context */
static void processButton1Data(void * param1, uint32_t buttonstatus)
{
    BCDS_UNUSED(param1);
    Retcode_T retVal = RETCODE_OK;
    switch (buttonstatus)
    {
    case BSP_XDK_BUTTON_PRESS:
        {
        retVal = BSP_LED_Switch((uint32_t) BSP_XDK_LED_R, (uint32_t) BSP_LED_COMMAND_ON);
        if (RETCODE_OK == retVal)
        {
            retVal = BSP_LED_Switch((uint32_t) BSP_XDK_LED_O, (uint32_t) BSP_LED_COMMAND_ON);
        }
        if (RETCODE_OK == retVal)
        {
            retVal = BSP_LED_Switch((uint32_t) BSP_XDK_LED_Y, (uint32_t) BSP_LED_COMMAND_ON);
        }
        if (RETCODE_OK == retVal)
        {
            printf("PB1 Pressed \n\r");

 

for this case, I changed all the responses to ON. 

However, after buidling and flashing or just flashing it directly, the response from the XDK is still the same as the demo template with no changes at all. 

 

3.  No binary file for DataLogger

I have read other threads on similar cases and followed the recommended steps (Eg. Re-starting software, Re-Installing software, Building) but I am unable to overcome it.

I have attached screenshots on the steps I have taken when opening the datalogger file (image 2-5).

 

My overall objective is to able to program it in such a way that I can record data onto my SD card remotely and select the required sensors accordingly.

 

Hoping that I can get some guidance from you guys and thank you in advance! 

 

Regards,

Ronald Tan

 

 

 

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 10. 18 오후 3:33 as a reply to Ronald Tan.

Hello Ronald,

first, I would like to welcome you to the XDK community.

Regarding your first issue, the code-snippet from the first steps guide has a linebreak in the middle of the string. Additionally, the last quotation mark has the wrong character, as it should actually be the same style as the first quotation mark of the string. You can copy the following function call, instead of the current one in that line:

  xTaskCreate(applicationInit, (const char * const) "Test Application to print Hello World", 256,NULL,1,&applicationTask);

This should fix that error. I also noticed that you did not save the implementation files. Make sure that you save them before attempting to flash the application to the XDK. The Workbench will ignore pending changes during flashing, and only take the last saved content.

Additionally, I recommend to not change the content of the Main.c file. I admit that this is a flaw in the current First Steps guide. It would be the best if you revert the changes, or create a new XdkApplicationTemplate after deleting the old one (make sure to check the option to delete the project from the disk).

Regarding the LedsAndButtons example and your modifications, perhaps you did not save the changes, either? If you did, did the code actually rebuild before it got flashed to the XDK? Just in case, build the project manually by right-clicking it in the project explorer and selecting Build Project.

Finally, your last issue, I would like to recommend a different method of importing the project. In the Import Window, select General > Existing Projects into Workspace instead of General > Projects from Folder or Archive. But before you do that, make sure to delete the other projects from the workspace (and if they have been copied into the workspace at C:\XDK-Workbench\workspace, delete the project content from the disk, as well). Importing a project is additionally covered in the Workbench Installation Guide

Also, just to cover all bases, did you install your workbench at C:\XDK-Workbench\ or did you use spaces in the installation path?

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 10. 19 오전 10:36 as a reply to Franjo Stjepandic.

Hi Franjo,

 

Thank you so much for your help! I have been able to solve the first two issues.

My work bench is installed in C:\XDK-Workbench\. 

 

However for the data logging, the Console showed "bad filename in logger.ini" (image1). May I know what does this mean?

And also, how can I log all these data into my SD card directly?

 

Regards,

Ronald Tan

 

 

 

 

 

 

 

 

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 10. 19 오후 2:46 as a reply to Ronald Tan.

Hello Ronald,

I am glad that the first issues are solved now.


As for the new issue now, you have to save the files logger.ini and custlog.ini on the microSD card, which you insert into the XDK's microSD card slot. The console log basically shows that the XDK cannot find the file.

The SD card has to be formatted to a FAT32 file system, and when you copy the files onto the SD card, make sure that their names are not altered. Windows has a bad habit of adding the file ending .txt to certain files. The XDK will find logger.ini, but not logger.ini.txt.

The Data Logger Demo will basically store all sensor data onto the microSD Card, if it does run correctly.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 10. 20 오전 7:29 as a reply to Franjo Stjepandic.

Hi Franjo,

Yes I am able to record the data in my SD card now. Thank you so much! :)

The data is collected at every 12ms interval. How will I be able to alter this frequency from the file?

Thank you in advance!

Regards,

Ronald

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 10. 20 오후 2:09 as a reply to Ronald Tan.

Hello Ronald,

I am glad to hear that you were able to make it work!

The data collection and write intervals are directly coded into the application. You can change them inside the source-file XDK_Datalogger_cc.c

Inside that file you can set the intervals on lines 62 and 64:

62: #define SAMPLE_TASK_INTERVAL_IN_MS                1
64: #define SD_TASK_INTERVAL_IN_MS                    60


In the file logger.ini, you can set the frequencies and sample rates and other settings for the individual sensors.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 10. 22 오전 12:43 as a reply to Franjo Stjepandic.

Hello Franjo,

I have tried mofidying both line 62 and 64 but the unit time stamp is still at every 12ms interval (image 1),  may I know what to change if I would like to have the data collected at eg. 50ms interval? 

Also, for the altering of info for individual sensors, do I directly modify the file in the SD card?

Additionally, if there are sensors which I do not wan to utilize, will removing them the logger.ini file do this? 

Thank you in advance!

Regards,

Ronald Tan

 

 

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 10. 23 오후 4:25 as a reply to Ronald Tan.

Hello Ronald,

12ms seems like a minimum time required when all sensors are activated and their sensor values retrieved. There is also a minimum delay between the decision to write and the write being done. Additionally, the variables I mentioned in my last post are not the exact interval between the sensor values being updated or between writes to the SD card. They are the time between making two attempts, while the attempts themselves may take longer.

In short, the variables do not reflect the exact time interval between two rows in the csv file.

As such, I can only recommend to try out different settings yourself, and make sure to always build and flash the new version after saving the source files. Sometimes when clicking the flash button, the project doesn't get rebuilt. If that is the case, right-click the project in your project explorer and select "Build Project" before you flash it.

For altering the settings of individual servers you have to directly modify the file logger.ini on your SD card, as you correctly assumed. Each of the sensor's sections is marked with the sensor's name in brackets, such as [bme280]. Each of them has the option enabled. Set this to 0 for sensors you do not require. The csv file produced during logging will automatically have the columns for unused sensors omitted.

Please tell me if this wa shelpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 11. 10 오전 3:02 as a reply to Franjo Stjepandic.

Hi Franjo,
 

I have tried a few combination for line 62 and 64 and managed to get the recording interval at 12ms,360ms and 12000ms. However, I still could not fully understand the correlation with it. May I request for a brief explanation regarding this?

And also, I will be placing the sensor for recording remotely and I am concerned with the battery life. I have let the XDK run the logging of data and the battery seems to run out after ~6hours. Do you have any advice on extending its battery lifespan?

Thank you so much!

Regards,

Ronald

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 11. 10 오후 3:17 as a reply to Ronald Tan.

Hello Ronald,

I have inspected the codes of the Data Logger demo for updating sensor values and for writing those values to the SD card.

The sensor values are actually always appended to the buffer that will get written to the SD card. With a setting of 10ms for the SAMPLE_TAS_INTERVAL_IN_MS, and a setting of 200ms for SD_TASK_INTERVAL_IN_MS, it is expected that four lines of sensor values are written each 200ms. I was previously confused myself, since the function for the task, which is responsible for writing sensor values into the buffer (not the SD card) is called UpdateSensorValues(). This made me expect that the buffer will only hold one line (i.e. the most recent values).

As I have written, that is expected that four lines of sensor values are written each 200ms with the above example, that is not the case. The issue lies in the function sampleSensors(), which is called with every iteration of the function UpdateSensorValues(). This function takes a sample of the sensors only if a preconfigured number of ticks has elapsed since the last sample.

Currently, the elapsed number of ticks is decremented by exactly 1 with each call of sampleSensors(). Depending on the configuration, this can be 10. You can see which value it will be if you create a log with SAMPLE_TASK_INTERVAL_IN_MS set to 1. The resulting time difference between two lines is the factor you have to keep in mind when setting the sample interval.

So, if the time difference between two lines is 10, you can only set your sample rate to multiples of 10. The real sample rate will be SAMPLE_TASK_INTERVAL_IN_MS * 10 in that case.

This issue will be forwarded to the responsible developers, since this is definitely not intended.

I hope that this information is useful to you. Unfortunately, some intervals will not be possible with the current state of the program. I can only ask for your patience in that regard, until the issue is solved.

Regarding how to extend the battery's lifetime, sleep modes of the XDK are currently not supported, unfortunately. But what you can do to preserve energy, is to choose wisely which sensors you need and leave all others, which you do not require, disabled.

Alternatively, you can also attach a power bank to the XDK, to expand the battery lifetime. But note, that you would have to choose a power bank without an internal charging current logic.

This is necessary because power banks with that logic will only fully charge the XDK once. Afterwards, they will turn off and only turn on, when the XDK is re-attached to them.

Furthermore, if you have an electrical socket near the XDK in your remote environment, then you can use a USB to power socket adapter, which provides 500 mA, to supply the XDK.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 10 오전 12:29 as a reply to Franjo Stjepandic.

Hi Franjo,

Thank you for the information!

To add on the question on not using a particular sensor, will deleting a sensor from the logger file in the SD card turn off a sensor, or will the sensor continue to run but not record the data? If so, how may I completely shut off a sensor from the code in order to maximize my battery life? 

In addition, for my upcoming project, I may require to collect multiple sets of data in on sitting and is it possible for the excel files created to have an actual time or creation? 

Thank you in advance!

Best Regards,

Ronald

 

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 11 오후 5:00 as a reply to Ronald Tan.

Hello Ronald,

I am always glad to help.

Disabling a sensor in the logger.ini will actually not initialize the sensor which implicates powering it on to preserve energy. You do not need to take additional action to turn the sensor off manually. Of course, you can't simply delete the sensor's section from the logger.ini file, just set enabled=0 on the sensors you do not need.

Regarding your other questions, the XDK does not have a real-time clock. You can count the system ticks after the XDK applicatio booted and calculate the current timestamps in milli seconds over them.

A calculation could be implemented as follows:

uint32_t CurrentTime = xTaskGetTickCount() / portTICK_RATE_MS;

Please note that this requires an adaption of the function get_fattime() in the implementation file ff.c that use these timestamps to write the corresponding entries in the log file.

Furthermore, that recommendation would work for the creation of the log files and the timestamps within the file.

Please note that this will only work if the XDK is at continuously supplied so it does not turn off, because then the actual tickcount will get lost.

As another alternative to that, if WiFi is available (at least temporarily when the application starts), you can request the current real time from an SNTP server. An SNTP server's main purpose is to provide real time to clients. You can see an example on this in the BoschXDKCloudConnectivity example from Workbench 3.1, in the files Sntptime.c and Sntptime.h.

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 12 오전 3:15 as a reply to Franjo Stjepandic.

Hi Franjo,

Thank you so much for the information!

I noticed that the acoustic sensor is not used and there is not data recorded on that. I would like to find out on how I can activate the acoustic sensor and record the information together with the rest of the data.

In addition, is it possible for me to on the bluetooth and use the VirtualXdkDemo to view on my mobile device while running the data logging?

Thank you in advance!

Regards,

Ronald

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 13 오후 5:25 as a reply to Ronald Tan.

Hello Ronald,

I am glad that I could help you.

You are correct, the acoustic sensor is currently not used and not implemented in the Data Logger demo. To use it, you would have to implement it by yourself into the Data Logger demo in the same manner as the other sensors are implemented.

For more information about how to implement the acoustic sensor, I would ask you taking a look at this thread here. There I explained in detail about how to use the API of the acoustic sensor. In addition to that, you would have to implement the acoustic sensor similar to how the other sensors are implemented into the demo, so I would also recommend to take a look at those implementations.

Regarding your other question, yes it is possible to log data on an SD card and send data via bluetooth at the same time.

Unfortunately, the VirtualXdkDemo does not offer the possibility to log data on an SD card, but you can combine the project of the VirtualXdkDemo with the Demo Data Logger. You would mainly have to beware of the fact that both projects initialize (nearly) every sensor. Modules and Sensors should only be initialized once.

Also, keep in mind that the performance of either functionality (bluetooth and datalogger) will most likely have decreased performance, since both functionalities are running at the same time.

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 13 오전 6:10 as a reply to Franjo Stjepandic.

Hi Franjo,

 

Thank you for the information!

I have followed editing the file according to some of the other posts I have found regarding the acoustic sensor. I seem to have turned the sensor on but it does not record in the excel file. Do i have to modify the logger.ini file?

And also, can I have the link reccomended by you again? As there may have been some error and the link provided by u in the reply above links me back to this post.

 

In response to the timestamping,

may i know which file/line i should add it in?

uint32_t CurrentTime = xTaskGetTickCount() / portTICK_RATE_MS;
 

Thank you in advance!

 

Regards,

Ronald

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 13 오후 5:23 as a reply to Ronald Tan.

Hello Ronald,

my bad, I gave you the wrong link. The correct thread is here.

Adding the acoustic sensor to the Data Logger demo is not a simple task, if you want it to have the same capabilities of being enabled or disabled as the other sensors have.

But if you don't need those capabilities, you can simply force it into the Data Logger demo. For this, you would have to initialize the acoustic sensor first. You can do that anywhere in the initialization phase of the code, by calling the functions BSP_Mic_AKU340_Connect() and BSP_Mic_AKU340_Enable().

In the XDK_Datalogger_cc.c in the function writeSensorDataCsvHeader(), you have to add a header entry for the acoustic sensor (the column's name).

In the function writeSensorDataCsv() you have to write the sensor data, which can be retrieved by calling BSP_Mic_AKU340_Sense().


This should be enough to integrate the acoustic sensor by brute force into the Data Logger Demo, but there might still be some missing modifications.

Regarding the timestamp, you can use the code anywhere where you need to use the current time of the XDK. To give more specific advice, I would have to know what you want to do with it. Keep in mind that the current time of the XDK is only the time since the XDK booted the application, not the real time. As mentioned before, you would have to use an NTP Server to get the real time.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo

 

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 17 오후 1:49 as a reply to Franjo Stjepandic.

Hi Franjo,

Thank you for the answer!

I have followed the steps in the link given to enable the acoustic sensor (image 1).

However, after enabling the acoustic sensor in the datalogging demo, how can I record the acoustic sensor data in the excel file along with all the other sensors? Do I have to make modifications to the logger file found in my SD card (image 2)? If so, what are the changes I should make?

 

As for the timing in the SD card, each button press would create a new excel file in the SD card. What I hope to achienve (if possible), is for each excel file created in the SD card to have a real time recorded.

 

Thank you in advance!

 

 

Best Regards,

Ronald Tan

 

 

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 18 오후 5:24 as a reply to Ronald Tan.

Hello Ronald,

regarding your first point, to integrate the acoustic sensor into the Data Logger demo, I have written down a concise and (hopefully) understandable description as follows:

First, create a new folder called AKU_340 containing the source file AKU_340.c and the header file AKU_340.h.

The source-file should have the (minimal) content:

#include "BCDS_BSP_Mic_AKU340.h"

int32_t getAkuData;

void aku_340_getData(void){
	getAkuData = BSP_Mic_AKU340_Sense();
}

void aku_340_init(void){
	BSP_Mic_AKU340_Connect();
	BSP_Mic_AKU340_Enable();
}


void aku_340_deInit(void){
	BSP_Mic_AKU340_Disable();
	BSP_Mic_AKU340_Disconnect();
}

Of course, this code can be modified with error handling and such, but this is the bare neccessity for the interaction between the Data Logger and the AKU340 API.

The header-file should make the implementation known, by using the following content for he header-file AKU_340.h:

#ifndef AKU_340_AKU_340_H_
#define AKU_340_AKU_340_H_

void aku_340_getData(void);
void aku_340_init(void);
void aku_340_deInit(void);
extern int32_t getAkuData;

#endif /* AKU_340_AKU_340_H_ */

To build the source-file, the following line must be added in the project's Makefile below line 21:

$(BCDS_APP_DIR)/AKU_340/AKU_340.c \

Make sure that the previous line ends with a backslash (\), otherwise this will fail.

Additionally, include the header-file in XDK_Datalogger_cc.c as follows:

#include "AKU_340/AKU_340.h"

Now, the preliminaries are done. In the following, I will explain to you how to write the sensor data to the csv-file, without controlling the sensor AKU340 via logger.ini. All of the following modifications take place in the source-file XDK-Datalogger_cc.c

In the function Sensor_init(), at the following lines:

aku_340_init();
bytesPerSample += 32;
enabledSensorCounter++;

This will initialize the acoustic sensor, regardless of any settings done in the logger.ini.

In the function writeSensorDataCsvHeader(), add the code line ActiveBuffer->length += sprintf(ActiveBuffer->data + ActiveBuffer->length, ";aku340_level[raw]"); near the end as follows:

ActiveBuffer->length += sprintf(ActiveBuffer->data + ActiveBuffer->length,
        ";aku340_level[raw]"); // add this before the original last line
ActiveBuffer->length += sprintf(ActiveBuffer->data + ActiveBuffer->length,
        ";\n"); // this is the last line in the function

This will add a column for the acoustic sensor. It will always be the last column.

Writing the acoustic sensor data to every row can be done in writeSensorDataCsv() by adding the code line ActiveBuffer->length += sprintf(ActiveBuffer->data + ActiveBuffer->length, ";%ld", getAkuData); near the end. As with the CSV Header in the previously modified function, this should be the second-last line.

Finally, the variable getAkuData has to be updated regularly. This should be done in the function sampleSensors(). For this, add the line aku_340_getData() near the end (before the return).

With this, the last column of your csv file should now always be the acoustic sensor, printing out the corresponding values. If you actually want to control the behaviour of the AKU340 using the logger.ini file, there are more modifications to be made. I have only shown you the minimal implementation to include the acoustic sensor.


Regarding your second issue, I am not quite sure how you want the real time recorded. Do you want to have the files named according to the time they have been created at? Such as year-month-day-hour-minute-second. If you do, I would first like to know if you already implemented receiving the real time from an NTP server.

As mentioned before, the XDK doesn't know the current real time and can only track the amount of time the XDK has been active since booting the application.

Please tell me if this was helpful so far, and feel free to ask further questions.

Kind regards,
Franjo

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 25 오전 6:16 as a reply to Franjo Stjepandic.

Hello Franjo,

First of all, I would like to wish you a merry christmas! And also, thank you for the detailed description.

I have tried to follow the steps accordingly and tried several times but have faced some problems. 

I have screenshots the steps i have taken and the error. 

May I find out which part of the steps have I made any error?

Thank you in advance!

 

Regards,

Ronald 

 

 

0 (0 투표)
RE: Guidance on Basics (Creating new project and data logging)
응답
17. 12. 28 오후 5:22 as a reply to Ronald Tan.

Hello Ronald,

I am always glad to help.

As far as I can tell, the steps you performed and described in your screenshots should definitely produce the results you expect, besides one mistake.

On the screenshot four, which shows the makefile's conents, you inserted the line $(BCDS_APP_DIR/AKU_340/AKU_340.c \. There is a closing bracket ) missing. The line should be inserted as follows:

$(BCDS_APP_DIR)/AKU_340/AKU_340.c \

Furthermore, I am not able to see what kind of error you receive in your console, in regards to the undefined reference (which is marked red in the console). Could you please show me the complete error message, if it still appears after fixing the makefile error?

Kind regards,
Franjo

0 (0 투표)