Library conflicts nRF52840 Sense

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

Hello PJ,

tried both BSPs. Compiler always says "class TimerOne " has no member named ‘initialize’

Rads
Wolfgang

Hi there,
Yes that’s not uncommon for older setups, and that’s for an AVR.
Try this one and you’ll see the Seeed board is called out and supported , BSP 1.0.X

HTH
GL :slight_smile: PJ

PS> DO NOT USE Timer (0) ZERO… or :bomb: :face_with_peeking_eye:

Hello PJ,

Coming nearer.
Modifying TimerInterruptLEDDemo, I could use one timer for a short blink, following by a second timer for a longer pause.
But this sketch is only in milliseconds, and I need the first timer in microseconds…
Suggestion?

Thanks for your patience,

Wolfgang

Hello PJ,

Is there a way to reset the Bluetooth system? It is only used at the beginning of the sketch, to start the main program.

Regards,

Wolfgang

Hi there,
Great to hear that, There is a learning curve but it’s not Too heavy a lift though.
Here are some ways to stop BLE on an nRF52840:

  • Start and stop advertising: Use sd_ble_gap_adv_start() and sd_ble_gap_adv_stop()
  • Disconnect from the central: Use sd_ble_gap_disconnect() while in a connection
  • Stop scanning with BLE.end(): While the peripheral is off, stop scanning with BLE.end()
  • Disable completely the 2.4Ghz radio: After the 52840 has full soft device enabled and ble stack has been run, disable completely the 2.4Ghz radio

HTH
GL :slight_smile: PJ

Hello PJ,

the sd commands were not accepted, but “BLE.end” worked!!! Golden Tip!!
Many thanks,

Wolfgang

Result:


Bye,
Wolfgang