You are here

How to read COMM_ROTOR_POSITION through uart

5 posts / 0 new
Last post
Graham Bowen-Davies
Offline
Last seen: 3 years 5 months ago
Joined: 2021-04-13 19:58
Posts: 3
How to read COMM_ROTOR_POSITION through uart

Hi,

I'm setting to up communication to teh VESC through an Arduino. Using SolidGeek's libraries, I have been able to send position control commands. What I need, is to read in the current position of the motor.

In order to set position, I modified the existing "setRPM" to make a "setPOS" command.

To set position, I naively tired to convert "getVescValues" to a "getVescPos", with the command value of "COMM_ROTOR_POSITION". But this does not seem to be recognized (payload size is zero).

Any pointers on how I should be going this are appreciated. I'm very new to arduino, and I have very little comfort with "C" language.

 

Thanks

 

Graham Bowen-Davies
Offline
Last seen: 3 years 5 months ago
Joined: 2021-04-13 19:58
Posts: 3

Nothing doing here? The following is the bit code that I attempted, but lenPayload returns zero

bool VescUart::getVescPos(void) {

	uint8_t command[1] = { COMM_ROTOR_POSITION };
	uint8_t payload[256];

	int lenSent = packSendPayload(command, 1);

	int lenPayload = receiveUartMessage(payload);
	
	Serial.println(lenPayload);

}

 

Graham

Gloobox
Offline
Last seen: 1 year 1 month ago
Joined: 2019-09-22 14:42
Posts: 1

Hi Graham, 

I have the same question than you ;), but do not have done some tests for now.

do you have solved your problem?

do you have tried to insert a delay between PackSend and UART reception?

 

Have a good day

Bruno

J_THAKKAR
Offline
Last seen: 1 month 2 weeks ago
VESC Free
Joined: 2024-07-18 03:26
Posts: 1

Hi Graham,

I have same doubt when i send get_values it give me 79 bytes data but by sending comm_get_rotor pos vesc is not responding can youo please tell me what is the isuue or i can also find the rotor position from get values command.

 

mansi712
Offline
Last seen: 2 days 20 hours ago
VESC Free
Joined: 2024-08-08 11:50
Posts: 9

Anyone able to get this working? 

I can get the live position of my motor out using PidPos with VescUart library, but dont know how to use it to run other vesc as this library doesnot support SetPosition().

mansi