PyVESC icon indicating copy to clipboard operation
PyVESC copied to clipboard

Setup motor foc

Open Vincentvlb opened this issue 3 years ago • 3 comments

Hello, I would like to know if it is possible with your library to make a setup motor foc as in vesc tool. If possible, do you have an example? Thanks in advance, Vincent LAMBERT.

Vincentvlb avatar Jan 19 '22 15:01 Vincentvlb

Hello, I would like to know if it is possible with your library to make a setup motor foc as in vesc tool. If possible, do you have an example? Thanks in advance, Vincent LAMBERT.

Hello Vincent, I'm also search for setup motor foc only. didn't you find any code for that if yes means kindly help me out.

Thanks in advance.

RKajay2001 avatar May 15 '24 05:05 RKajay2001

Hello RKajay,

I'm an intern working with Vincent, and I've come back to the motor FOC setup with pyvesc as part of my internship project. Here's what I have so far:

class DetectApplyFOCMessage(metaclass=VESCMessage):
    id = COMM_DETECT_APPLY_ALL_FOC
    fields = [
        ('detect_can', 'i'),
        ('max_power_loss', 'd'),
        ('min_current_in', 'd'),
        ('max_current_in', 'd'),
        ('openloop_rpm', 'd'),
        ('sl_erpm', 'd')
    ]

serial_port = '/dev/ttyACM0'
serial = Serial(port=serial_port, baudrate=115200)
my_msg = DetectApplyFOCMessage(0, 60, -25, 60, 700, 4000)
serial.write(pyvesc.encode(my_msg))

With this setup, the motor makes some noises similar to those when using VESC Tool, but it doesn't really start spinning, and I don't know how to get feedback. The feedback I'm interested in is whether the hall sensors are detected or not.

I've also identified this frame that initiates the motor FOC setup, but again, I don't know how to get the feedback I need.

serial_port = '/dev/ttyACM0'
serial = Serial(port=serial_port, baudrate=115200)
frame = "02 16 3a 00 00 01 d4 c0 00 00 00 00 00 00 00 00 00 0a ae 60 00 3d 09 00 ac 46 03"
serial.write(bytearray.fromhex(frame))

If you have discovered anything new or have any additional insights, I would really appreciate your help!

MelvinWarnet avatar May 23 '24 10:05 MelvinWarnet

I didn't work with COMM_DETECT_APPLY_ALL_FOC I worked with COMM_DETECT_MOTOR_FLUX_LINKAGE and COMM_MCCONF commands only. I need solution in MCCONF command. As I'm worked with pyvesc we can either set or get with one command we can't do both with the same command

RKajay2001 avatar May 23 '24 10:05 RKajay2001