Coding a loop within Odrive

I am able to move the motor to different positions back and forth and also to position zero without a problem. All of this is accomplished by from my pc and the odrivetools with single instructions like:
odrv0.axis0.controller.set_point = 0, or
odrv0.axis0.controller.set_point = 8192, or
odrv0.axis0.controller.set_point = -8192
Is it possible to create a loop with odrivetools that rotates the motor back and forth and have the code residing on the odrive even if the power has been removed?

Thanks

Not sure about directly on the ODrive itself, but you more or less could do the exact same thing with an arduino of sorts connected to the ODrive.

I was thinking that modifying the firmware by adding the same arduino lines right after motor calibration process ends. The problem is that I am not that expert to get that done and I don’t even know what file is.
The reason of doing this is because I want to get rid of arduino for the following reason.:
If I type the position -32768 ,(just to say a number), from python motor is very quick.On the other hand if use arduino motor seems to be slower.

The lines are currently used by arduino are:
for (float ph = 0.0f; ph < 6.28318530718f; ph += 0.01f)
{
float pos_m0 = 20000.0f * cos(ph);
odrive.SetPosition(0, pos_m0);
}

I just want confirm that when using arduino the motor tends to be slower.

Thanks

Did you just test it using the sample code?

vs just doing odrive.SetPosition(0, -32768.0)

From arduino I run the full sketch
for (float ph = 0.0f; ph < 6.28318530718f; ph += 0.01f) {
float pos_m0 = 20000.0f * cos(ph);
odrive.SetPosition(0, pos_m0);}

I used arduino UNO and Teensy 3.6 boards. The first one very,very slow. Second one big improvement noticeable to a great extent.On the other hand by using, odrv0.axis0.controller.pos_setpoint = 32768 and then -32768 from python I can see a major major speed. Big difference. Like WOW. What makes me think, that the middle man-Arduino- is holding the motor up. Is either the USB and/or the trigonometric calculations., or both
For this reason I am eager to plug those lines on the firmware to see the motor’s behavior

Thanks

Gotcha, when testing with my arduino, I never ran the sin or cos function. My speeds when just sending a float without a calculation did not seem to slow the motor down. Float calculations on the arduino take a bit of time which is what I am thinking your issue might be. Also why the teensy performs much better with the additional processing power.

Try just sending a float without running the wave loop.

The thing is, and I could be wrong but, you are just using the arduino or teensy to do the communicating. After the command eg. odrive.SetPosition is received, the ODrive should react the same.

check the following arduino link comparing float calc speeds
https://forum.arduino.cc/index.php?topic=371813.0

How fast is that loop running?

Where I’m trying to accomplish is to run the motor from side to side within an specific amount of time.
For example I want to jump back and forth infinitely from position 0 to position 40960 in 0.042 secs. If I am able to place that loop as part of the firmware that would be what I am looking for.
After a deep analysis, I came to the conclusion I don’t need the trig functions to move the motor from side to side. A much more basic loop can do the job

Thanks

We don’t have a dedicated place to put user logic right now, but you could take over this idle loop, since it doesn’t do anything useful anyway.