# BLDC motor control -

#### Enderke

##### New Member
I am currently using a 24V BLDC motor, with gearbox - ratio 1:139. The motor is controlled by a microcontroller(I think) which is included on the motor. The motor is turning without any code, simply by connecting it to 24V.
I want to find a way to control the controller so that the outgoing axle:

• Starts from one specific angle (say 0º)
• Make one complete rotation (either cw or ccw)
• Make one part of a rotation (say ¼, cw) and come back to the start angle (moving ccw).

I did connect the blue wire from the motor to an oscilloscope, which gave values differing from 0-5V with a 50% duty cycle. Speed of the motor is dependent on the voltage; 24V is full speed, anything less means less speed.

I tried some arduino codes to try to determine what kind of signal was coming from the blue wire, should I use digital or analog input, and how further..?

Does anybody have any experience with the readout / control of this kind of setup?

#### dknguyen

##### Well-Known Member
The hall sensors in that motor dont provide the absolute position data that you need for your goal. They provide pole positions for commutation and do not provide unique readings for rotor position and definitely not after passing through the gearbox. You will need external hardware like relays and limit switches (or an actual encoder on the gearbox shaft.)

Show us a photo of the blue wire on the scope.

How do you normally reverse rotation on the motor?

#### Enderke

##### New Member
Well that would be a shame.. The relative position can do as well I suppose, as long as I can have the outgoing shaft make one whole rotation and/or partial.. might this be possible?

reverse rotation would be archieved by connecting or disconnecting the yellow wire.

#### dknguyen

##### Well-Known Member
If the blue wire outputs some kind of signal throughout the rotation, you might be able to count up how many motor revolutions have passed (and accounting for the gearbox as well) to determine the rotation. Reversing sounds like the yellow has a pull-up or pull-down resistor so you can pull the opposite polarity via a transistor or directly with the mcu pin

Show us a scope of the blue wire while running. From the schematic, it looks like speed though which wont be helpful if it's analog, but if it's a ticking signal that is intended to have the pulses be counted that's what you want.

Do you have a way to halt rotation short of using a relay or FET to disconnect power via the MCU?

Last edited:

##### Well-Known Member
Even if the output pulse is just 1/rev of the motor it would mean that you have 139 pulses for each rev of the G.B. output shaft.
This would make it tricky to detect the 'home' position.
You say you want a move to come back to the start, can this be in the same dir or do you want to detect zero pos via reverse?
Max.

#### Enderke

##### New Member
We have been trying a few things - on a scope we get a 50% wave signal (img as example):

But trying to get a signal through arduino - using a digitalRead (on a digital pin) gives either 1 or 0, but values change, also when the motor is not powered..
Reading the wire on an analog pin, via analogRead gives values, which do differ when turned on or off, but not in a way you might expect (like the blockwave signal).

Don't have a scope I'm afraid - went to a tech school to use it there.

Do you have a way to halt rotation short of using a relay or FET to disconnect power via the MCU?
I can halt the rotation by disconnection the green wire, or by connecting the white wire. So I guess not..

You say you want a move to come back to the start, can this be in the same dir or do you want to detect zero pos via reverse?
We can use an external switch to determine the 'home position'. I do need to be able to rotate both ways, in the same direction, and in the reverse direction.

##### Well-Known Member
The scope trace appears to be a digital device, not analogue.
I have never used Arduino, just Picmicro at present, but that signal should enable a int-on-input type counter, or whatever Arduino uses.
If the Arduino is seeing a change when the motor is zero, what does the actual signal on a scope show when motor is non-powered?
Max.

Last edited:

#### dknguyen

##### Well-Known Member
We have been trying a few things - on a scope we get a 50% wave signal (img as example): View attachment 111403

But trying to get a signal through arduino - using a digitalRead (on a digital pin) gives either 1 or 0, but values change, also when the motor is not powered..
Reading the wire on an analog pin, via analogRead gives values, which do differ when turned on or off, but not in a way you might expect (like the blockwave signal).

Don't have a scope I'm afraid - went to a tech school to use it there.

I can halt the rotation by disconnection the green wire, or by connecting the white wire. So I guess not..

We can use an external switch to determine the 'home position'. I do need to be able to rotate both ways, in the same direction, and in the reverse direction.
That's good news. Those pulses are output for every angle of rotation and are intended to be counted up over a period of time and divided by that time interval to determine the speed. But you can count them to determine how far the motor has moved (but without any direction information kind of like how a car odometer counts up whether or not you are going forward or reverse).

Add on the external switch to determine your home position and use it to reset your count every time it's detected. This is especially important since you have no directional information when counting the pulses so it's vulnerable to cumulative errors errors from unintended changes in direction such as jerking back and forth when starting and stopping.

If the Arduino is seeing a change when the motor is zero, what does the actual signal on a scope show when motor is non-powered?
Max.
The schematic shows that the motor and hall sensor has a separate power supply so I assume what he means is that he still gets a signal when the motor is unpowered but when the hall sensor is powered, which makes sense.

Last edited:

##### Well-Known Member
We can use an external switch to determine the 'home position'. I do need to be able to rotate both ways, in the same direction, and in the reverse direction.
The type of encoder used to detect direction is a quadrature encoder and has two pulses, 90° apart. Like this $3.00 one on ebay 112030673020. Max. #### dknguyen ##### Well-Known Member Most Helpful Member The type of encoder used to detect direction is a quadrature encoder and has two pulses, 90° apart. Like this$3.00 one on ebay 112030673020.
Max.
Well, if he goes with that then he might as well just ignore the yellow wire on his motor. And he would have to stick it on the gearbox output shaft so he only gets one "home" or index pulse which also gives him a direct reading of the thing he is interested in. Getting on that goes on the motor would not be quite as useful since you get multiple index pulses per revolution of the gearbox though you could technically count those up too to figure out where the gearbox shaft is, but why bother?

He could also use a hall switch in SIP package with a small magnet on the shaft to just get the home position and use it with the yellow wire.