-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improving latency of set_channel_
#10
Comments
Hi, // ensure the device is sleeping as it may have been left enabled if you run this multiple times without a reset
pwm.disable().unwrap();
pwm.set_prescale(3).unwrap();
pwm.enable().unwrap(); A few questions:
You can also tweak the release profile further for increased performance with stuff like |
Thanks for the quick response! I did more research into this, and here's what I came up with. The interesting part to me is the interface for i2c.write() which states:
This means it is sending 1 byte at a time, and then waiting for the device to send back an acknowledge. I'm assuming here that the device can only send an ack once per cycle, meaning this method would limit how quickly I can send new state information to the device. This would also explain why I've looked at the In case that's not the lead answering your questions:
Raspberry Pi model 4 (1.5 Ghz). I doubt this is the limiting factor
Included in the original post last paragraph; "with isolcpus and taskset, built in release mode"
No
No, pretty naive stuff here just wrapping it in rust timing logic with Instant::now() and diffing over a large sample of steps. I experimented with how many calls to Question for youWould it be feasible to add the |
I see. I agree the running speed should not be the limiting factor. The The difference between the methods is how much they transfer:
So if you are calling It seems from your code that the Have you tried increasing the baud rate like I said above? |
Hi! First all I love this library and I'm new to embedded programming, so hopefully the questions I'm asking are relevant.
I'm trying to control a stepper motor with this driver over i2c from my rasbperry pi. I'm setting the driver to 1526hz. Very roughly, this is my setup:
My stepper motor code does calculations for the step and microstepping (not important now), and then calls:
The important part here is that I am setting
set_channel_on_off
6 times per step. When I time my application it takes approximately 600 micoseconds per call toset_channel_on_off
. If I just useset_channel_off
it takes 400 microseconds (improvement). I looked atset_all_on_off
hoping batching would work, but that takes longer than each call sequentially.I'm trying to run my motor at faster speeds, and I'm currently blocked because each of these calls is (relatively) slow. I'm trying to figure out what to do. Do you have any idea what the latency would be here? I suspect this is either in how quicly I2C reads the value or perhaps because I'm using dev fs implementation of I2C, but researching these topics is coming up pretty empty. I'm not sure if setting the i2c baud rate would improve this or not, so wanted to ask here for ideas
Additional information: I'm running on raspberry pi with
isolcpus
andtaskset
, built in release mode so I shouldn't be having any problems with OS scheduling or code performance. I'm calculating the timing as the average of several thousand invocations of my step code, so the latency isn't from the timing.The text was updated successfully, but these errors were encountered: