RPM Control Mood Using PyUAVCAN vs Serial CLI

Dear Zubax Team,
I hope this finds you well,
Thanks a lot for the support over here.

I have a question about initiating RPM Command using pyuavcan_v0 library. To my knowledge the only way to do it using node.periodic(0.1, setpoint1). I would like to send the throttle RPM command instantly using pyuavcan_v0 in the similar way that the serial doing it rpm 1000, because I noticed that the performance differs (Serial is better since it is not periodic). In the documentation of pyuavcan says node.periodic is for one-shot also…

I want to disable the periodic thing and just send the command.

I am also having a max limit of 10700 Mechanical RPM using RPM governor mood. I would love to increase it, I tried increasing mot_pwm_hz to 75000 and this is the limit.

Thanks in advance,
Regards.


To publish a message once, just say node.broadcast(message). No need to use the periodic handler here. In your case it would be like node.broadcast(pyuavcan_v0.equipment.esc.RPMCommand(rpm=1000)).

Re max RPM, you may have reached the hard implementation limit as shown in the reference manual.

FYI:

electrical rate = mechanical rate * pole count / 2

1 Like

Thanks a lot for you reply, it is really helpful.

For my case it was:

setpoint = [int(2000)]
node.broadcast(pyuavcan_v0.equipment.esc.RPMCommand(rpm=setpoint))

I used node.broadcast(message) and it worked perfectly, however it works only for 1 second and stops after that. How to specify the period in seconds.
I tried node.spin() but this only specify the period of feedback.

I actually managed to do it using this code

import pyuavcan_v0
import time

end_time = time.time() + 3 #Time interval in Seconds
print(time.time(), end_time)

if __name__ == '__main__':
     node = pyuavcan_v0.make_node('COM14', node_id=125, bitrate=1000000)
     node_monitor = pyuavcan_v0.app.node_monitor.NodeMonitor(node)
     dynamic_node_id_allocator = pyuavcan_v0.app.dynamic_node_id.CentralizedServer(node, node_monitor)
     node.add_handler(pyuavcan_v0.equipment.esc.Status, lambda msg: print(pyuavcan_v0.to_yaml(msg)))
     RPM_Setpoint = [int(1000)]
     while time.time() < end_time:
         node.broadcast(pyuavcan_v0.equipment.esc.RPMCommand(rpm=RPM_Setpoint))
         node.spin(0)

I guess it might work but you are flooding the bus with your message and not using spin() properly. The recommended solution is to use node.periodic