[Solved] Wondering about quadrature encoder connection

General topics and discussions about the VESC and its development.
StevenCoral
Posts: 5
Joined: 16 Sep 2017, 13:23

[Solved] Wondering about quadrature encoder connection

Postby StevenCoral » 16 Sep 2017, 13:33

Hi all,
I want to start by saying that I have been looking for the answer for days now...
I have a VESC, and a brushed DC-motor. I want to connect to the vesc a regular, 2-channel (A/B), 700 CPR encoder (assuming quadrature counting).
I have seen the videos, I understand that I need to unsolder the filters (haven't done this yet), but nowhere it is stated how to actually connect the encoder. I've tried many forums, including this one, plus manuals and such. There are 3 hall sensor connections + 1 extra, and I only have 2 encoder channels (no index, and ill handle the encoder V+ and GND myself).
How do I connect it?
and if we're at it, assuming all my parameters are entered correctly to BLDC tools, will I be able to fetch the wheel position and velocity back from the VESC? what about speed control command? will it be doable assuming my PID is correct?

Thanks in advance,
Steve
Last edited by StevenCoral on 21 Sep 2017, 14:48, edited 1 time in total.

pf26
Posts: 296
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: Wondering about quadrature encoder connection

Postby pf26 » 16 Sep 2017, 18:01

The VESC requires encoders with A, B and I outputs. Anyway, how would you get an absolute position otherwise ? (absolute position is necessary for sensored FOC)
I think A, B and I connect to Hall 1, 2, 3 respectively.
As for the filter, the most important is to get rid of the 3 capacitors.

rew
Posts: 940
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Wondering about quadrature encoder connection

Postby rew » 16 Sep 2017, 20:13

Right! In another thread someone described having replaced the series resistors with 0 ohm ones. Moving from 4.7nF as in the BOM, to "about 10pF" of stray capacitance of the chip pin and PCB you're gaining a factor of 500 over the stock situation. That should be enough.

StevenCoral
Posts: 5
Joined: 16 Sep 2017, 13:23

Re: Wondering about quadrature encoder connection

Postby StevenCoral » 20 Sep 2017, 13:45

Thanks, basically position is calculated by the phase difference between channels A and B (quadrature), and the I is for correction in case of missed-out counts, which shouldnt happen on low-count low-speed encoders while using STM32 arm chips. even it does, i can handle a miss now and then. I'm also not using FOC but DC motors. Its for hobby robotics applications. I actually use an open-source code from MIT to pull the feedback from the vescs.
About the filters, ill just take them off completely. I dont want any back-current into my encoder from the pullup resistors when my A/B pins are low. the resistors in series can be left as they are actually (if ill see that 10k is too high ill replace them with lower ohms).
So you say A,B,I are hall 1,2,3? I'll try that.
I hope that the vesc is not depending on that I signal...

P.S.
Do I need to upload a special firmware for it as in the video? or is it enough for me to pick the right option in BLDC tools?

Thanks, Steve

pf26
Posts: 296
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: Wondering about quadrature encoder connection

Postby pf26 » 20 Sep 2017, 18:31

The index I signal gives the absolute 0 position of the encoder, there is just one such position where I is active on each turn. From there A/B simply count up/down depending on quadrature. Yes, the VESC needs the I signal, and will wait for it before it can actually use the encoder.
Could you please indicate how you would want to use the encoder count before you have zeroed it at a known position ? Otherwise, you will need to powerup the VESC with motor in the very same position and change the code or simulate an I index signal at startup. I can't see other way of doing.

rew
Posts: 940
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Wondering about quadrature encoder connection

Postby rew » 21 Sep 2017, 03:22

StevenCoral wrote:Thanks, basically position is calculated by the phase difference between channels A and B (quadrature), and the I is for correction in case of missed-out counts, which shouldnt happen on low-count low-speed encoders while using STM32 arm chips. even it does, i can handle a miss now and then. I'm also not using FOC but DC motors. Its for hobby robotics applications. I actually use an open-source code from MIT to pull the feedback from the vescs.
About the filters, ill just take them off completely. I dont want any back-current into my encoder from the pullup resistors when my A/B pins are low. the resistors in series can be left as they are actually (if ill see that 10k is too high ill replace them with lower ohms).
So you say A,B,I are hall 1,2,3? I'll try that.
I hope that the vesc is not depending on that I signal...

P.S.
Do I need to upload a special firmware for it as in the video? or is it enough for me to pick the right option in BLDC tools?

Thanks, Steve
no the phase difference betwee a and b does not come into play. Yesterday somehow the cpu switched hall 3 to output. The sensor did not suffer. I think the resistors are a good thing.

The special firmware was for encoder following. Stock firmware can use the encoder for driving the motor.

rew
Posts: 940
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Wondering about quadrature encoder connection

Postby rew » 21 Sep 2017, 03:23

rew wrote:
StevenCoral wrote:Thanks, basically position is calculated by the phase difference between channels A and B (quadrature), and the I is for correction in case of missed-out counts, which shouldnt happen on low-count low-speed encoders while using STM32 arm chips. even it does, i can handle a miss now and then. I'm also not using FOC but DC motors. Its for hobby robotics applications. I actually use an open-source code from MIT to pull the feedback from the vescs.
About the filters, ill just take them off completely. I dont want any back-current into my encoder from the pullup resistors when my A/B pins are low. the resistors in series can be left as they are actually (if ill see that 10k is too high ill replace them with lower ohms).
So you say A,B,I are hall 1,2,3? I'll try that.
I hope that the vesc is not depending on that I signal...

P.S.
Do I need to upload a special firmware for it as in the video? or is it enough for me to pick the right option in BLDC tools?

Thanks, Steve
no the phase difference betwee a and b does not come into play. Yesterday somehow on my test setup the cpu switched hall 3 to output. The sensor did not suffer. I think the resistors are a good thing.

The special firmware was for encoder following. Stock firmware can use the encoder for driving the motor.

StevenCoral
Posts: 5
Joined: 16 Sep 2017, 13:23

Re: Wondering about quadrature encoder connection

Postby StevenCoral » 21 Sep 2017, 08:21

Perhaps the word "phase" was out of context and wrong to use at this situation.
I have written encoder reading software several times, and from what I know is that when you have A and B channels, the fact that they are off by a quarter cycle enables you to get 4 times the resolution of your CPR, and also hands the perk of knowing the direction of rotation.
The index channel, for its own, does not provide any information about any of these, but can be used to modulo the count into the closest whole revolution, thus compensating for lost counts, if any.
I'm not writing this to show off or anything (see "from what I know"), but just to be a 100% sure I don't miss anything so that no damage is done. FOC is "out of my expertise" and may require the index in a manner I'm not familiar with. From your replies, I guess it has something to do with knowing the absolute angle of the wheel in regard with the magnetic field.
Remember, I do not use FOC but regular brushed DC motors, and I assume that in this mode the encoder would count anyway, even without an index channel. Is this correct? (gonna test it in the upcoming hour anyway :) ).
I apologize for prolonging this, just want to make sure with people with a bit (or a lot) more experience with the vescs.

Cheers,
Steve

pf26
Posts: 296
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: Wondering about quadrature encoder connection

Postby pf26 » 21 Sep 2017, 08:37

Yes, FOC requires to know precisely the absolute position of the rotor, so it can create in the stator the magnetic field corresponding to the highest possible torque. Therefore the I signal is required for absolute reference.
If you do not need absolute positions from the encoder, then the A/B signal will provide you a relative position, for instance to calculate RPM.

Prevas_erra
Posts: 24
Joined: 11 Apr 2016, 16:03
Location: Stockholm

Re: Wondering about quadrature encoder connection

Postby Prevas_erra » 21 Sep 2017, 14:11

Its difficult to see (in the SW) if encoder is supported with a DC motor. Set motor type DC, sensor port ABI and correct count.
Connect the encoder and see in Vesc-tool realtime data rotor position, erpm and tacho fields is something happens when you turn the encoder.
Make sure the electrical interface on the encoder is compatible first (3.3 or 5 volt single ended output), GND must be connected.
If it is not working you can write your own application to set-up and read the timer count. You could get speed from that.
Use a pushbutton (to GND) on the I input to mark the zero position.


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest