Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Timer runs not proberly, Accelerometer measures not correctly, ... ?

    DerPreuße
    Established Member

    Timer runs not proberly, Accelerometer measures not correctly, ... ?

    Hello everybody,

    i had a working code on my xdk but due to a change of ip-address of a mqtt-broker, i had to flash the code again and since then there a some oddities.

    I coded a timer wich read the accelerationvalues every 5ms and write it to a buffer. If that procedure is passes 50 times the buffer is written in a txt-file on sdcard, published to a mqtt-broker and is cleared. With my modest mathematic-skills i figured out that there should be a message after every 250ms but as the code still worked, they appeared after approx. 500ms.

    I also had build a python-script wich shows me the published data, and if i knock on the sensor three times, the sensor only recognize sporadically.

    Any ideas?

    Best Regards

    Olli

    4 REPLIES 4
    DerPreuße
    Established Member

    Re: Timer runs not proberly, Accelerometer measures not correctly, ... ?

    It seems like the sensor is busy doing something. The following picture should show a sinus-like wave but the signal is interrupted somehow..

    Error_Pic.png

    LlobetAtWork
    Senior Member

    Re: Timer runs not proberly, Accelerometer measures not correctly, ... ?

    Hello Olli,

    the gaps could be there because the XDK is prioritizing sending data over acquiring data. Is it a C-Program or something in Mita?

    If it was a C-Program, a good design would have a data acquisition task triggered by a timer or interrupt which acquires the data and pushes it into a buffer and a second task that is triggered by a certain amount of data present in this buffer. 

    Depending on the priority selection this enables the scheduler to avoid dead time where a task is waiting for some external interaction to happen.

    Best regards,

    Francisco LL.

    DerPreuße
    Established Member

    Re: Timer runs not proberly, Accelerometer measures not correctly, ... ?

    Hello Fransisco LL,

    it is C, i just wonder why this behavior occurs with exactly same code as it has, before i changed ip-adress...

    I initialize a timer-Task via xTaskCreate, wich calls method "ReadAccelerometer" every 5ms, this method fills a buffer and increase a counter by one, when the counter reaches the value of 50, it calls methods "WriteDataToSdCard" and "PublishDataToBroker", then the buffer is cleared.

    I could share the whole code, if you may take a look.

    This is also typically again, i use the xdk to get machine data and at monday i have first tests.. and now it just don't work anymore.

    Edit: i am really not a professional with microcontroller and there is no error code yet, and it still not work properly. I had also suggested a defect in hardware but it worked like a clockwork just one flash before.

    Best Regards

    Olli
    DerPreuße
    Established Member

    Re: Timer runs not proberly, Accelerometer measures not correctly, ... ?

    Hello again,

    i figured out that the controller is busy writing to sd-card. I think maybe the card is broken but didn´t had the chance yet to test another card. I removed wich would touch sd-card and controller is working fine.

    I have still some Questions, that maybe do not directly correspond to the topic above:

    1. How could i wait on a method like mqtt_connect() until connection is established and proceed after checked a return value?

    I tried:

    while( ! Mqtt_isConnected(session_ptr) ) {
    
    }

    The Problem is that, if i doesn´t add a delay after Mqtt_connect() like 5000ms, my controller cant connect to broker and the following publications are running into  a big bright void.

    2. I received the following error-message but controller is working fine, any Ideas why it is raised?

     INFO | XDK DEVICE 1: Error in ServalPAL package.
     INFO | XDK DEVICE 1: 	Package ID: 30
     INFO | XDK DEVICE 1: 	Module ID: 7
     INFO | XDK DEVICE 1: 	Severity code: 2
     INFO | XDK DEVICE 1: 	Error code: 72

    It has something to do with ADC-Channel, like it is not ready yet. Maybe you have some general information aboiut proper initialization.

    Best Regards

    Olli

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist