You are here

Current Sensing in VESC

18 posts / 0 new
Last post
Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17
Current Sensing in VESC

Hello,

I am quite new to the VESC and understanding the oepn source firmware.

Can anyone please explain me how is the negative current being sensed in the VESC tool?

In the firmware I see "GET_CURRENT()" for to read the input at the ADC pins mapped to current sensing.

"

// Current ADC macros. Override them for custom current measurement functions.
#ifndef GET_CURRENT1
#ifdef INVERTED_SHUNT_POLARITY
#define GET_CURRENT1()      4095 - ADC_Value[ADC_IND_CURR1]
#else
#define GET_CURRENT1()      ADC_Value[ADC_IND_CURR1]
#endif
#endif

"

I understand, how the ADC_Value[<ADC-Index>] reads the positive current which corresponds to values between 0 - 4095. But for negative current 4095 - ADC_Value[<ADC-Index>] is used. However, I am not very sure how it is reading the negative value of the current.

I have a custom application and for that I am using bidirectional ACS current sensors that reads +/-10As.
I have to update the firmware corresponding to the current sensors. So I have to make mimic current sensors as Shunt Resistors for VESC.

It will be great if anyone can help explaining the current sensing principle in VESC Firmware.

Or, if anyone has done this before (which I am sure would have been implemented) and can help me in resolving my problem. It will be great help. Its been more than 4-5 days I am investigating this, andhave no right leads.

 

 

skyline1970
Offline
Last seen: 12 months 1 day ago
VESC Free
Joined: 2017-09-07 22:28
Posts: 232

simply, assume vref=3.3v

mid voltage (I=0) 1.65v = vref/2

+Imax =3.3v

-Imax =0v

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

So, it applies that

at I = 0A, ADC ADC value is 2048

at I = - I_max A, ADC ADC value is 0

at I = I_max A, ADC ADC value is 4096

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

If I replace, the shunts by three current sensors (ACS). Do I need to make changes in firmware corresponding to same?

skyline1970
Offline
Last seen: 12 months 1 day ago
VESC Free
Joined: 2017-09-07 22:28
Posts: 232

sw mod. may not be needed. so many hw types of vesc. some use phase shunts, some 2 shunts placed sources of mosfets, some 3 shunts placed sources of mosfets.

be sure your hw is compatible with any type of vesc.

 I had used acs709, and no problem had been faced.

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

I am using ACS7124. Every time I connect my motor to the control board and power board and do the parameter set up the VESC desktop tool shows an error of "detection failed: -11". If you print the fault in the terminal it says undervoltage fault. The current values seems quite high and voltage is very low about 4-5 volts.

According to VESC firmware, for 0 current STM pin has 0 and for Imax current 4096. For the reverse current i.e. inverted shunt polarity for -Imax 4096-4096 = 0 and for zero current 4096-0 = 4096. So the max value becomes the min value and min value is the max value.

However, in case of bidirectional ACS current sensors:

at I = 0A, ADC ADC value is 2048

at I = - I_max A, ADC ADC value is 0

at I = I_max A, ADC ADC value is 4096

(correct me if I am wrong)

I guess same is the case with you! Can you help me how you manage to read the correct current value with these values.

skyline1970
Offline
Last seen: 12 months 1 day ago
VESC Free
Joined: 2017-09-07 22:28
Posts: 232

just change the pins sensing current of   Acs

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

Hello, I am again seeking help as I am unable to resolve the issues with the current sensors.

skyline1970 mentioned that no need to make any changes in the software.
However, I am still not able to sense the right current values.
As I do the motor set up, my controller goes into under voltage fault and when printing faults in terminal, it displays very less value of voltage and not so high values of current.

When I operate the motor with duty cycle control in the left most corner of VESC desktop tool (keeping it very low of range 1-7% when having 42 volts battery) the motor spins. But as the duty ratio is set above 7%, the motor stops spinning and controller goes into under voltage fault. This seems weird to me that as I am increasing the duty ratio, the voltage is going down.

 

skyline1970
Offline
Last seen: 12 months 1 day ago
VESC Free
Joined: 2017-09-07 22:28
Posts: 232

is the battery good, it should not give "under voltage fault".

could you measure ~ +1.65v at current sense outputs, when the throttle at stop pos. ?

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

Yes, the battery is fine and is fully charged.
I am operating the standard VESC with the same battery.

And yes current sensor IC output 1.65 V at 0 Amp.

 

Today, I was just observing the PWM pulses over the oscilloscope and I realized that the pulses for high and low switch overlaps each other.

As I increase the duty ratio the overlapping increases,.

In the custom hardware, I am using the UCC27712 620-V, 1.8-A, 2.8-A High-Side Low-Side Gate Driver with Interlock driver IC. However VESC uses DRV8301.

I did not make any changes in the firmware for deadtime generation or pwm generation.

Do you think I need to do make corresponding changes in the code as well?

 

skyline1970
Offline
Last seen: 12 months 1 day ago
VESC Free
Joined: 2017-09-07 22:28
Posts: 232

under vesc-tool, define deadtime as 480uS, and try,

or as an hw solution, a pld/fpga could be used betveen vesc uc and driver to eliminate  overlaping of hi/lo signals

sw mod maybe aeasier.

kanebend
Offline
Last seen: 2 years 3 months ago
Joined: 2021-12-13 04:14
Posts: 1

If I substitute three current sensors for the shunts (ACS). Do I need to make any changes to the firmware as a result of this? smash karts

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

I am looking answer for the similar question. If you do a lil math with the ADC values and the equations used in the firmware to sense the current. You will find out, that there is no need to make any change in the firmware.

However, I am still struggling with current sensing issues. Let me know if you are able to solve it!

 

cuaxr
Offline
Last seen: 1 year 2 months ago
Joined: 2021-10-19 14:34
Posts: 2

Hello! When I operate the motor with duty cycle control and as the duty ratio is set above 0.6, the motor stops spinning. I want to know how you solved it?  

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

What happens with the motor voltage when the duty ratio is above 0.6?
Is it going down?

What type of fault if being shown?

In my case I am using custom hardware with some changed components in the Control Board. Also I observed that the generated PWM pulses are overlapping each other and as the duty ratio is increased the overlap increases.

It leads to drop in battery voltage and thus controller goes into under voltage fault.

It is still a issue and I am still working on it.

Elwin
Offline
Last seen: 1 month 1 week ago
VESC Free
Joined: 2021-09-30 16:41
Posts: 76

What is overlapping with what? Can you show traces of it?

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17

The upper and lower switch of the same leg should be complementary to each other with some deadtime in between.

However, in my case they are overlapping.

 

Toshi Sharma
Offline
Last seen: 2 years 1 week ago
Joined: 2021-08-30 11:15
Posts: 17