You are here

Position control of brushed dc motor with Vesc and REV through bore encoder

15 posts / 0 new
Last post
Greasy_D
Offline
Last seen: 1 year 6 months ago
Joined: 2022-11-30 02:56
Posts: 3
Position control of brushed dc motor with Vesc and REV through bore encoder

I am working with an autonomous gokart team through my college and we are trying to use a REV encoder and RC controller connected to a VESC to control the position of a brushed DC motor. 

The encoder position shows up great in the realtime tab of the VESC tool with the exception of being 180 degrees out of phase. When I send it to 20 degrees it tries to go to 200. 

Position control through the VESC tool is somewhat working, but it won't settle on a given degree. It always oscillates 180degrees out of phase with the specified value. 

When hooking up the RC controller and using PPM control the movement is very sporadic and gives only a few degrees of movement. 

So my main question is how can I set up the PPM to create an RC controller with the VESC, REV encoder and brushed DC motor?
 

frank
Offline
Last seen: 11 hours 6 min ago
VESC BronzeVESC FreeVESC GoldVESC OriginalVESC PlatinumVESC Silver
Joined: 2016-12-27 20:19
Posts: 847

Are you sure that you avoided ground loops? Is everything powered form the VESC controllers 5V rail? Did you consider to swap out the DC with a BLDC motor?

https://www.youtube.com/watch?v=H-6qzmeCNtw&t=896s

Greasy_D
Offline
Last seen: 1 year 6 months ago
Joined: 2022-11-30 02:56
Posts: 3

Hey Frank,

Thanks for the reply. 

Everything is powered through the VESC and there are no ground loops. Unfortunately swapping the motor isn't an option due to the application. Jack S., the sponsor for the project at UCSD, mentioned how well the VESC works with BLDC but we have to keep the DC.

At one point we had position control working smoothly through the VESC-tool UART control, but after disconnecting and reconnecting the VESC the same PID setting were not working. As stated the main goal is to have RC position control. It seems like it should be possible as we are getting a clean encoder reading in the realtime data.

That would be awesome if we could get that precision control in the video.

frank
Offline
Last seen: 11 hours 6 min ago
VESC BronzeVESC FreeVESC GoldVESC OriginalVESC PlatinumVESC Silver
Joined: 2016-12-27 20:19
Posts: 847

Probably Vedder has a tip for you... I'll ask him.

benjamin
Offline
Last seen: 6 days 7 hours ago
VESC FreeVESC OriginalVESC Platinum
Joined: 2016-12-26 15:20
Posts: 490

I haven't used the DC motor position control code in many years and it is quite possible that something is broken and/or that all features, such as position division angle, do not work. The only thing I can do is to set something up with a DC motor and see if I can get it running, which will take some time.

Can you start with a default configuration, make your setup and show me exactly what you have changed in the configuration and how it is not working? That would help a lot in getting an idea on where to start debugging this.

JackSilb
Offline
Last seen: 1 year 8 months ago
VESC Free
Joined: 2020-03-25 06:33
Posts: 8

Hi Benjamin, 

Thanks to you and Frank to replying.

It is early for the students to get to the lab, they usually have long nights we will reply soon.

To keep this simple, lets focus on a bench top easy setup before we go to our evGoKart steering.

We are planning to  use a VESC to control an Electric Power Steering (EPAS) that has a DC motor. No option to change that at the moment, it is from a Toyota car. In a near future we have more plans for similar setup in a larger vehicle.

Let's just assume we have to use a DC brushed motor:

  • VESC 6.0 HW with the latest firmware version from a VESC tools 6.02
  • OK - Reset VESC to default settings, started fresh
  • OK - DC brushed motor with encoder, added the ticks per revolution 8192 Counts per revolution
  • OK - can see the 0->360->0 encoder position at the VESC
  • OK - The ABI encoder is very clean when we plot the position. Actually, impressively clean position plotting. Good job on that code. We can see 0 to 360 and jumps back to 0. I am guessing the I of the ABI works just fine.  https://www.revrobotics.com/rev-11-1271/

As you can imagine, we can't do the motor detection wizard as we successfully do with BLDC motors in several of our robots at UC San Diego

  • OK - Current control, duty cycle control works just fine with the VESC tools and PPM input

When we try to use position control it does not move, move erratic, or gets out of control.

I am not sure the problem we are seeing has to do BLDC vs. BDC. It seems the issue in on the position control PID or other things we are not setting correctly, or firmware. It seems that basically we need to move the motor to the position using PID. the type of motor would not matter for the PID control loop. Right?

If you give us a recipe that we should try to start on the PID we can cooperate. 
I imagine this will help many other people that will need position control with brushed DC motors using external encoders. 

Wish list:

Add end of travel to the firmware. e.g., limit switches into the I/Os similar to the EMO that you already have.

 

JackSilb
Offline
Last seen: 1 year 8 months ago
VESC Free
Joined: 2020-03-25 06:33
Posts: 8

@benjamin

PPM vs. CAN.

Not that would matter at this point, once we have position control using the VESC Tools we would like to use PPM with the two VESCs Steering and Thorrtle (throttle works just fine) to have a "big RC car" to shake-up the HW while the software comes along. Then it will be CAN comm. We have done CAN to 2 VESCs already.

The urgency to our request is because we have a critical decision point this week. Either we will use the VESC to do the position control for the steering (we prefer that), or we will bring the encoder into our main real time controller (STM32 with MBED) and make the VESC be just a DC motor ESC.

We are planning for a long weekend on software integration. We would like to have the VESC DC motor ABI encoder position control working before the weekend so we can focus on the software on the top of that and don't spend time on the low level control if we can .

Therefore, any help you can give us today and during the next days will be greatly apreciated.
It seems simple. We are missing something on the PID settings or there is something on the firmware that we don't have control over.

How can we help you help us?
Should we start with some PID values you want us to try for a DC motor with ABI encoder?  No realy load on the output shaft at this point.

Thank you!,

Jack

benjamin
Offline
Last seen: 6 days 7 hours ago
VESC FreeVESC OriginalVESC Platinum
Joined: 2016-12-26 15:20
Posts: 490

The FOC position controller is very different from the one in the BLDC code. In BLDC it uses duty cycle control and not current control and it does not have support for the position angle division setting.

Is the encoder on the motor or on the output shaft? If it is on the output shaft you probably don't need the position angle division setting as you operate within one encoder turn.

Did you try swapping the motor cables, so that the feedback has the correct sign?

JackSilb
Offline
Last seen: 1 year 8 months ago
VESC Free
Joined: 2020-03-25 06:33
Posts: 8

Benjamin, here are the settings at the VESC. I started fresh, the not touch the PID, for a quick test for you. The ABI encoder info really clean and linear.

https://drive.google.com/file/d/1RtwtY3nCEnkfRl0OHCWsih8wEofFh2zU/view?usp=sharing

 

 

JackSilb
Offline
Last seen: 1 year 8 months ago
VESC Free
Joined: 2020-03-25 06:33
Posts: 8

>Is the encoder on the motor or on the output shaft? If it is on the output shaft you probably don't need the position angle division setting as you operate within one encoder turn.

 

The encoder is on the output shaft. We wanted that way too. We want to know really what we are steering, (nor not).

 

JackSilb
Offline
Last seen: 1 year 8 months ago
VESC Free
Joined: 2020-03-25 06:33
Posts: 8

Hi Benjamin, we have two  ECE students that started this Friday working on the VESC position control with the brushed DC motor and ABI encoder.
How can they help?
ex:
do some testing such as PID seetings and come post the results back here
Modify the coder as you see the neeed. It will take 1.5 until they get to know they way around where to look at the VESC software base
In summary we have 2 resources to help with ~ 10 hours per week each.
Count on us to help.

Thank you,
Jack 

gokulswami
Offline
Last seen: 1 year 8 months ago
Joined: 2023-04-10 21:44
Posts: 3

Hi Benjamin, I'm one of the new ECE students working on the issue with our brushed DC motor + ABI encoder with VESC. I just wanted to catch up with you and double check if you can determine anything from the tests done by @JackSilb and @Greasy_D, and if we need to do anything else.

As of now, we will be taking a look at the current setup and doing our own testing.

AlicLuna
Offline
Last seen: 1 year 8 months ago
Joined: 2023-04-08 05:32
Posts: 1

Hello Benjamin,

I would like to introduce myself as well, I am the other student working on the issues with @GokulSwami. Again, we would like to touch base to see if there are any paths of direction that you would suggest we should take. We are open to communicating here on the VESC Forums, through email, or possibly scheduling a call some time.

Thank you for your time,

Alic

gokulswami
Offline
Last seen: 1 year 8 months ago
Joined: 2023-04-10 21:44
Posts: 3

We went through the testing process again today with @JackSilb and were able to get position control working by just swapping the cables. Can't believe something as simple as that solved our issues. Thanks for your help!

EnDeR_WiGiN
Offline
Last seen: 11 months 3 weeks ago
Joined: 2023-03-01 17:28
Posts: 1

I also used the REV through bore encoder for FOC and ran into this exact issue. When trying to fix the encoder feedback none of my changes would stick. I got stuck at 5 mechanical rotations and would make 1 rotation in the Rotor Position feedback. I then re-ran the "Detect encoder", foc_encoder_detect [current], and changed the values manually and none of my changes would apply. I restarted my the vesc tool and got stuck at 2 Mechanical rotations made 1 rotation in the rotor position feedback. At this point, I knew the Encoder Counts setting was wrong but any change would not be represented.

I restarted the VESC tool and was able to do a clean setup of the ABI encoder and it worked. First set encoder counts, then run the "Detect encoder" and apply those settings, after set the encoder as a feedback device in FOC->General. If you have to change any setting after doing it once it seems you need to restart VESC tool. It could be possible that removing the Encoder from the Sensor mode in FOC would also work but did not experiment with it any longer.

There defiantly appears to be something wrong with the setting not applying when using ABI Encoder as a FOC feedback sensor. It would be great if this could be fixed. I would like to clarify I ran into this problem with a brushless motor, not a brushed motor.  I have not run into any other issues other than the rare crash.