Hi all
I am trying to control the position of a valve, using a BLDC motor with hall and encoder(A/B) feedback.
The Motor needs to turn 26 revolutions from Closed to Open valve. There is no absolute sensor on the motor, only relative A/B encoder and end-stop, in each outer position of the valve.
I can spin the motor without any problems, but I cannot get position to work, I feel that the documentation is lacking some information about this subject. I see that multiple people got it to work on Youtube, but they are using different sensors.
Is it possible to get absolute position control using 3xHall effect(digital) and A/B encoder. Driving the motor to an end-stop and declaring this: absolute 0 position?
VESC 4 FW 3.63
here is the sensor signals from the motor:
The motor is a geared motor 5:1
1 revolution of the motor gives 3 encoder pulses/revolution (15 encoder pulses pr. shaft rotation)
Valve from Closed to Open
- 26 shaft revolutions * 15 encoder pulses = 390 encoder pulses from Closed to Open
Hall A |
Hall B |
Hall C |
Encoder A |
Encoder B |
|
1 |
1 |
0 |
1 |
0 |
|
1 |
1 |
0 |
0 |
0 |
|
1 |
0 |
0 |
0 |
1 |
|
1 |
0 |
0 |
0 |
1 |
|
1 |
0 |
0 |
1 |
1 |
|
1 |
0 |
0 |
1 |
0 |
|
1 |
0 |
1 |
1 |
0 |
|
1 |
0 |
1 |
0 |
0 |
|
1 |
0 |
1 |
0 |
1 |
|
0 |
0 |
1 |
0 |
1 |
|
0 |
0 |
1 |
1 |
1 |
|
0 |
1 |
1 |
1 |
0 |
|
0 |
1 |
1 |
1 |
0 |
|
0 |
1 |
1 |
0 |
0 |
|
0 |
1 |
0 |
0 |
1 |
|
0 |
1 |
0 |
0 |
1 |
|
0 |
1 |
0 |
1 |
1 |
|
0 |
1 |
0 |
1 |
0 |
Kind regards
Johan
This might make more sense then the 1 and 0's in the table
To get around the problem, I have attached a Teensy 4.0 there reads the encoder signal and outputs the Index signal for every 48 encoder ticks (To simulate the ABI encoder)
When I try to detect the encoder, the motor spins very slowly, back and forward onn time, and the continues to spin forward forever, I cannot stop it. The position just jumps back and forward for every tick, and jumps 30 deg when it sees the index signal.
Please see the picture below for reference.
Any thought of why it does not work??
(Don't mind the low voltage fault, that happened when I cut power to the VESC)
Can anyone see why my VESC can't recognize my engine position/angle ?EDIT (It turned out I was an idiot The cable I used for Hall inputs, had H2 and H3 swapped )
It runs great now, with the virtual Index signal from Teensy 4.0
Here is a better picture of my position signals:
Electrical Rpm = 1000
Shaft Rpm = 200
Ch1 Encoder A (Connected to Hall 1)
Ch2 Encoder B (Connected to Hall 2)
Ch3 Encoder I (Connected to Hall3) (This signal is created from an external Teensy 4.0, One pulse for every shaft rotation, at the picture. Can be changed to )
Ch4 Current clamp on motor-wire A
Ch6 Motor Hall signal (Not connected to VESC, just here for reference)
Arduino/Teensy Code for creating virtual index from regular AB encoder:
(The code is not optimized in any way, the code was only intended for bench testing)
----------------
#include <Encoder.h>
Encoder Encoder1(20, 18);
int Pin_Index = 10;
int Pin_Index_status = 1;
void setup()
{
pinMode(Pin_Index, OUTPUT);
}
long Encoder_pos = -999;
void loop() {
long Encoder_posNew;
Encoder_posNew = Encoder1.read();
if (Encoder_posNew != Encoder_pos)
{
if (Encoder_posNew > 119 || Encoder_posNew < -119) // Write the amout of encoderpulses you want. when it reach 0 an index pulse is created
{
Encoder1.write(0);
Encoder_posNew = 0;
}
Encoder_pos = Encoder_posNew;
if (Encoder_posNew == 0 && Pin_Index_status == 0)
{
digitalWrite(Pin_Index, HIGH);
Pin_Index_status = 2;
Serial.println("Index ON");
}
if (Encoder_posNew != 0 && Pin_Index_status == 1)
{
digitalWrite(Pin_Index, LOW);
Pin_Index_status = 0;
Serial.println("Index OFF");
}
if (Encoder_posNew != 0 && Pin_Index_status == 2)
{
Pin_Index_status = 1;
}
}
}
THX for documenting how you solved your issues! This will help others with a similar problem.