Library conflicts nRF52840 Sense

Sketch with libraries LSM6DS3. and Wire.h works. Some calculations are used,
Sketch With ArduinoBLE.h also works, using LightBlue.

But when I add the ArduinoBLE application to the program that works with LSM6DS3+Wire, the same calculations are erratic.

My goal is to start an acceleration based timer with my iPhone. Any suggestions?

Regards,

Wolfgang

Hi there,
Which BSP are you using?
Have a Look at the IMU Park demo , see if you gain any Higher understanding :smile: :v:

HTH
GL :slight_smile: PJ

Is BSP the printed circuit? I ade one with a pushbutton connected to a pull-up input. Output Is a pulse of 1 10 2 ms, every 8 ms.

It seems that calculations where only integers are involved, are O.K.
But to read the acceleration sensors I have to convert and scale floating values:

sval =int (50.0*(2.0-myIMU.readFloatAccelX())*0.5);

That seems to conflict with the Bluetooth software.

Is there a method of reading the acceleration values directly as an integer?
Regards,
Wolfgang.

Hi there,
No it’s the board support Package you pick when you select the Board in the arduino IDE
There are two, Depending on which one is Selected and used in the first line of the compiler output after the Fully Qualified Board Name…FQBN
here is the Xiao ESP32C3 , using BSP @ 2.0.8

FQBN: esp32:esp32:XIAO_ESP32C3
Using board 'XIAO_ESP32C3' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.8

Bellow is the Xiao Nrf52840 series.see two choices, the first one is this, mbed 2.9.2

FQBN: Seeeduino:mbed:xiaonRF52840Sense
Using board 'xiaonRF52840Sense' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\2.9.2

the second one is the non-mbed 1.1.8

FQBN: Seeeduino:nrf52:xiaonRF52840Sense
Using board 'xiaonRF52840Sense' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.8

Choose wisely,
HTH
GL :slight_smile: PJ

Thanks for your quick response.

On my Mac mini, the only BSP I can find for my nRF52840 Sense. is the
Seed nRF52 mbed enabled Boards. Deinstalled all others, but it did not help.
The float values can be between. -4,000 g and +4,000 g. No documentation available on how the I2c measurements are made.
But maybe you have another idea.

Regards,
Wolfgang

Hi there,
I take that you have tried the High level examples ?
GL :smiley: PJ

Yes, they looked simpler.

Regards
Wolfgang

Hello PJ,

Tried the low level example, but still no improvement.
Could you have a look t the program? I do not know how to upload the sketch, please advise.

Regards,

Wolfgang

Hi there,
So you could read the raw values and convert them have you looked here,

also give a look at the data sheet , you can round the readings also to help conversion.
you can use a Kalman Filter also to give pitch and Yaw from the raw readings.
HTH
GL :slight_smile: PJ

Hello PJ,

in IMU Capture the same float readings are used as in the high level examples.

I like the Low level approach, because with one call I get integer values for x and y

One g is 4000. In my application, the max value expected is 3 g, so 12000, OK as integer.

But the problem remains, time issues are corrupted when the acceleration calls have been made.
I will try to isolate the sensor call in a separate function. But that will have to wait until next week, I have to take care of my grandson…

Regards,

Wolfgang

Maybe there is another issue: I use pins D4 and D5 as output and input. But D4 and D5 are also marked SDA and SCL (whatever it means).

Next week I will change them to D2 and D3. Some soldering involved…

Rs.
Wolfgang

Hi there,
Yes Good to know the Low level gets it done, You have any other devices connected? Those pins are for I2C communication with those devices. You can also enable a time stamp that is in the IMU presented with the readings. So maybe look there if high precision for timing is needed.
Read over the Data Sheet for the LSM6DS3 during the down time and check out all the things it does as well.
Look at this thread, by Msfujino. There’s a lot in there but well documented.
HTH
GL :slight_smile: PJ

ps. I’m having fun with my Nephews, 12,10, 7… :sweat_smile: :family_man_boy_boy: I showed them the 3D printer and we printed some darth vaders, storm trooper and spiderman head,etc. I think 1 of the three is destin to be an engineer. :smile: :pray:

Hello PJ,

Stil no progress.
Changed the output pin from 4 to 0. Pin 5 not used any more.

Measured acceleration values are perfect, but delays and mills() vary wildly, as soon as the Bluetooth software is used.
The bluetooth communication works very nice, but it messes up all time issues.
Am I really the first person to use BT and IMU at the same time?
I hope I do not have to throw away the Xiao Senses…:frowning:
Rads,

Wolfgang

Hi there,
Without seeing the actual Code in Question, Perhaps you need an additional LIB installed for RTC or interrupts.?
are you using the builtin TimeStamp function?
HTH
GL :slight_smile: PJ

Hello PJ,

is there anything to control the timers? In the past, in Assembler you had complete control of the 2 Microchip timers…

There is no difference between using multiple delayMicroseconds and using millis(). (unsigned long).

Just to clarify: I have to generate a servo pulse with a frequency of 125 Hz (8 ms for one complete pulse). The HIGH duration is calculated when the servo signal is LOW. During this LOW time, I measure the x and y values two times (3 ms separated), calculate the averages, and calculate the duration of the next HIGH duration.
So, I cannot use the Arduino servo library.

The problem is, that the calculations are OK, but on the scope I see that the HIGH and LOW durations now and then are exceeded for one to two ms, but not constantly…

Regards,

Wolfgang

Hi there,
Without Seeing the code, I can’t offer much help.
Yes, There is an Interrupts Library and a Timer Library both for Nrf52840 , I don’t have links but you can search here for the examples folks have posted. Sounds like that is what you need.
HTH
GL :slight_smile: PJ

Hello PJ.

Yes, the example blink_print in the timer library is interesting. But I do not understand the toggle principle.
My timer needs pulse of 1 to 2 ms. Then, in the LOW time, the duration of the next pulse is calculated.
Then, after 8 ms since the beginning of the first pulse, everything happens again.
Could you lease look at that sketch, and give me an indication for the solution?
Kind regards,

Wolfgang
P.S Started 50 years ago with FORTRAN. :slight_smile:

Hi there,
LOL, man I vaguely remember some Fortran77 back in the 80"s ? Punch cards too. WOW
The Nrf52840 has Several timers and the PWM’s You can use either.
to achieve the outcome, Check out how Arduino generates Pulses link

Basically set the pulse length, attach an Interrupt, In the ISR reset the timer value start the duty cycle timer with interrupt and rinse and repeat.
like this one, it’s also applicable to Xiao.

HTH
GL :slight_smile: PJ
I’ll look at the blink_print time permitting :wink:and make some comments. :v:

Thanks for the suggestions,
The TimerOne library looked perfect, but it seems not to work with my Xiao Sense, The examples will not compile…
Tried also to change the frequency of the Servo library. Was not able to change the Refresh Interval to 8000 instead of 20000… Still stuck…

Rgards,

Wolfgang

Hi there,
Have you tried the other BSP? In the board selection Pick the second one. What is the BSP that is NOT compiling? Look at compiler output and see which it is.?
HTH
GL :slight_smile: PJ