-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tuning the frequencies #142
base: main
Are you sure you want to change the base?
Tuning the frequencies #142
Conversation
sfy-buoy/sfy-artemis/src/main.rs
Outdated
@@ -303,7 +303,7 @@ fn main() -> ! { | |||
|
|||
// XXX: This needs to be adapted to frequency, and queue length. Maybe just remove when we | |||
// have the remaining space check? Check after Hjeltefjorden deployment. | |||
const LOOP_DELAY: u32 = 14 * 40_000; | |||
const LOOP_DELAY: u32 = 10 * 40_000; /////////////////////// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The queue length is a little more than 14. While the time it takes to fill up a 1024 elements long buffer with 26 Hz is about 40 seconds (40_000 ms). This is the output frequency from the FIR filter, which is still 26 Hz (or 52 Hz if so configured) even if you run the IMU faster. So this should stay the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you can reduce it to get more debug output of course :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I will keep it at 14 for now, then. Thanks
2da10f8
to
d4eb288
Compare
We are using the IMU in FIFO mode. The ODR sets the general output rate if you sample the IMU manually (i.e. read the value at the sample rate). In FIFO mode, an internal buffer is filled up on the IMU. The RTC (real time clock) interrupt in sfy-artemis/src/main.rs runs the routine at a specified interval configured in the setup code in main.rs. It calls code in lib.rs and then in waves.rs that drains the FIFO. If the buffer on the artemis is full, it makes a package and queues it for transmission home and resets the artemis-buffer. The FIFO rate is configured with the BDR (probably in addition to the ODR), but both of those should be set correctly if you change the frequency constant. But if any of those are missing from the driver you need to make sure they are available both places. |
417Hz is okay. I am still working on how to increase it further. Your comment above is helpful (I locate the problem), but I still have not figured out how to make it work. |
I thought that if I enabled compression in FIFO (increase buffer size) i'd be able to do 833Hz, but it seems like it didn't do any difference. I'll leave it here, as it might have something to it, and i am not sure if I did it correctly :) |
sfy-buoy/sfy-artemis/src/main.rs
Outdated
@@ -107,7 +107,7 @@ fn main() -> ! { | |||
info!("Setting up IOM and RTC."); | |||
delay.delay_ms(1_000u32); | |||
|
|||
let i2c4 = i2c::I2c::new(dp.IOM4, pins.d10, pins.d9, i2c::Freq::F400kHz); | |||
let i2c4 = i2c::I2c::new(dp.IOM4, pins.d10, pins.d9, i2c::Freq::F100kHz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This decreases the communication frequency with the SD-card, should probably not be done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. i2c4 is the notecarrier, and it was at 100kHz originally, so i figured i would change it back since it did not make a difference
Nice :) I did not enable it since we don't react to FIFO-full events, but drain it at regular intervals. So we would risk that it works sometimes (in the lab), but not on real data with higher entropy. It should be easier to get high sample-rate to work without storage enabled, worth trying that first! Are you getting any errors? Or how do you recognize that it is failing? |
Maybe you need to decrease the loop-delay in the main loop. But if it turns out that the RTC interrupt is too infrequent, you may have to do FIFO draining (current RTC interrupt handler) in the main loop. |
Just curious: what frequency are you running the I2C port at? If I remember correctly the default frequencies of 100 or 400kHz are too low to sustain data transfer at 833Hz. But both the Artemis and the ISM support 1MHz I2C frequency (which is what I use om the OMB). Can this come into play, or are you already using 1MHz I2C frequency? |
Yep, I'm pretty sure it is at 1 MHz now for the IMU. I think the modem can't do more than 100 kHz or 400 kHz, the SD-card can do many MHz (12 after initialization?). I think I was wrong, the port you have configured here in this PR is for the notecard, but it should still probably not be modified. |
Okay, good to know! I am currently not having storage enabled. The error that keeps appearing is the TooFewSamples:
It is originating from the check_retrieve function in lib.rs, because fifo_full = true |
Correct, it is at 1mHz for the imu. The notecard was originally at 100kHz, so I just switched it back from 400, after trying. |
That explains it 😁 |
I think I've figured out that the problem is the interrupt handler. It can interrupt at a frequency of CentiSecond but not faster, and that is not sufficient for sampling rate faster than 417Hz. |
Ok, then we can try to drain the FIFO in the main loop? That is a big
change though.
tir. 18. jul. 2023, 11:32 skrev stianvikanes ***@***.***>:
… Maybe you need to decrease the loop-delay in the main loop. But if it
turns out that the RTC interrupt is too infrequent, you may have to do FIFO
draining (current RTC interrupt handler) in the main loop.
I think I've figured out that the problem is the interrupt handler. It can
interrupt at a frequency of CentiSecond but not faster, and that is not
sufficient for sampling rate faster than 417Hz.
—
Reply to this email directly, view it on GitHub
<#142 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAN36Z4GLIMGAN2PX7LMNLXQZJ4RANCNFSM6AAAAAAZWYWMYQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Yes, Let us try! |
The You essentially have to call the contents of the RTC function in the main loop, and remove the So you have to move most of the contents of the RTC function to the main loop, probably before the existing if-block. You could in theory simplify stuff with the queuing since it is now not on a different interrupt (which you can think of as a separate thread), but lets keep it so that we can later use the IMU interrupt. |
Thanks! |
No description provided.