# My microbit car motors has non-negative output driving emf, are there easy ways to measure the operating p.d.

#### lichiyan

Joined May 27, 2022
4
I want to measure the p.d. of the motor when it operate, the motor has two input A and B. Both of them can be 0 or positive. If I connect either of them to ground,and other to an input pin, the input might be grounded. What is the easy circuit to measure the p.d. with signs?

#### MisterBill2

Joined Jan 23, 2018
12,399
Really the statement makes no sense. First, no abbreviation, because the meaning of "PD"is not clear. You will need to tell us what it is you want to measure. Then there is the "input pin" Input to what?? I am not able to read what is in other people's minds and so the TS must provide a lot more information to avoid getting only guesses.
You can connect the motor to a volt meter and measure voltage. I am guessing that a "microbit car" is some sort of battery operated remote controlled vehicle, but that is only a guess. Most small battery operated motors have two terminals, the direction of rotation depends on which terminal is positive.

#### KeithWalker

Joined Jul 10, 2017
2,403
Really the statement makes no sense. First, no abbreviation, because the meaning of "PD"is not clear. You will need to tell us what it is you want to measure. Then there is the "input pin" Input to what?? I am not able to read what is in other people's minds and so the TS must provide a lot more information to avoid getting only guesses.
I agree that the question was not very clear, but there is enough information to give a helpful answer.
Micro:bit is a micrcontroller which comes with an adapter board and various other add-ons. The url in my answer (#2) is for a tutorial on using a motor with it.

#### lichiyan

Joined May 27, 2022
4
Sorry for that, my case is, the motor is driven by an power IC, that gives either +V or ground(~+0.2V) to terminals A and B when operates.

When the output of the IC is reversed, the motor is reversed.
In both cases, either A or B is grounded (~+0.2V).
I want to measure the overall voltage V_{AB} of the motor when it operates with the microbit analog input onboard.
Suppose I connect one of the motor terminal B to microbit analog input X, and
another terminal A to common ground,
I doubt it is not working as
A may be V+ and
B is low (~+0.2V)
the output of power IC (A) is shorted to the ground and the overall circuit may burn. (I did not try it)
I do not want to use two analog inputs of microbit, are there any method that can measure V_{AB} and feeds the result to single analog input?

#### MisterBill2

Joined Jan 23, 2018
12,399
The solution is to use a measuring device that has neither terminal referenced to any external voltage. An instrument amplifier would be a good example, as would a portable battery powered multimeter.

#### lichiyan

Joined May 27, 2022
4
The solution is to use a measuring device that has neither terminal referenced to any external voltage. An instrument amplifier would be a good example, as would a portable battery powered multimeter.
Thanks for your reply, I have reference some ic like TI INA 317, thanks a lot

#### KeithWalker

Joined Jul 10, 2017
2,403
As I stated in answer #2 - DON'T connect either terminal of your motor to an input pin on the Micro:bit. Voltage spikes generated by the motor will damage the input.
You will need to design a complex op-amp circuit to measure the absolute voltage across the motor in both directions using only one analog input. What exactly are you trying to do? Maybe there is a simpler way of achieving the results that you want.

#### shortbus

Joined Sep 30, 2009
9,441
as would a portable battery powered multimeter.
Can you give the make and model of one that isn't portable or battery powered?

#### KeithWalker

Joined Jul 10, 2017
2,403
Can you give the make and model of one that isn't portable or battery powered?
Keysight 34450A Digital Multimeter,5.5 Digit
BK Precision 2831E 4 1/2 Digit True RMS Bench Multimeter
Keithley 2110-120 5.5 Digit Digital Multimeter (USB only) 120V Version
Sigilent TRMS 5.5 Digit Bench DMM TFT LCD Display
Fluke 6.5 Digit Precision Multimeter 35ppm
etc.

#### BobTPH

Joined Jun 5, 2013
5,227
Which does not help at all if the intent is to have the microcontroller know the voltage across the motor.

My question. Is why he wants to measure the voltage. If it is being driven by a PWM controller , which is likely since he mentioned an IC, the voltage is not of interest, the duty cycle is more likely what he wants.

So, what are you trying to do by measuring the voltage?

Bob

#### MisterBill2

Joined Jan 23, 2018
12,399
Can you give the make and model of one that isn't portable or battery powered?
At one business they did have an "all-in-one electronic lab". It had a signal generator, counter-timer, power supply, and digital multimeter all in one mains operated enclosure.EXCEPT that the multimeter was powered by a nine-volt battery, and because nobody realized that the battery was usually dead. No, I do not recall the brand name, but certainly it was made in China. I added a separate internal transformer power supply for the multi-meter.
So indeed, there are non-portable battery powered digital multi-meters.

#### lichiyan

Joined May 27, 2022
4
As I stated in answer #2 - DON'T connect either terminal of your motor to an input pin on the Micro:bit. Voltage spikes generated by the motor will damage the input.
You will need to design a complex op-amp circuit to measure the absolute voltage across the motor in both directions using only one analog input. What exactly are you trying to do? Maybe there is a simpler way of achieving the results that you want.
I would like to calibrate the applied potential from power IC, the working potential of the motor and the running speed of the car, such that I do not need an encoder for motor. I hope I might also integrate the speed and get the displacement.

#### MisterBill2

Joined Jan 23, 2018
12,399
OK, sort of lost track of the TS wanting the motor voltage to also be a computer analog input. The common means to measure the voltage of something not directly tied to common is to use two analog inputs, giving two voltage readings, and then subtract those values in the software. This method is well developed and a lot has been published about it.
To avoid damage and errors from motor spikes and noise there will need to be some series filtering in both of the connections, and it the maximum anticipated motor voltage is greater than the input voltage range of the analog inputs, also a voltage divider will be required, which may be part of he filter circuit.
Since we are given no information about the motor voltage range, the motor voltage source supply, or the analog input allowable voltage range I can make no comment about any voltage dividers or series resistor values.
But the TS will have that information, I hope.
And the good news is that this input scheme does not require any active devices or any external power, nor is it very complex. It does require access to the analog input portion common connection and the motor supply common connection.

#### BobTPH

Joined Jun 5, 2013
5,227
I would like to calibrate the applied potential from power IC, the working potential of the motor and the running speed of the car, such that I do not need an encoder for motor. I hope I might also integrate the speed and get the displacement.
That is exactly what I guessed. But motor speed is not usually controlled by voltage, it is controlled by PWM. What motor controller are you using?

Bob

#### KeithWalker

Joined Jul 10, 2017
2,403
I would like to calibrate the applied potential from power IC, the working potential of the motor and the running speed of the car, such that I do not need an encoder for motor. I hope I might also integrate the speed and get the displacement.
The speed of the motor is proportional yo the back EMF of the motor, not the voltage across its terminals. If the voltage across the motor is constant, the speed will change with the load. That means that if your car is going up a gradient. it will slow down and it will speed up down a gradient. If you can control the speed of the motor, you also have the added problem that the motor is being driven by a pulse width modulated supply, which is a series of pulses with the amplitude of the supply voltage and with variable pulse lengths. The average voltage is difficult to measure with a DVM. That is why I stated that " You will need to design a complex op-amp circuit to measure the absolute voltage across the motor in both directions using only one analog input.".
It is possible to calculate the back EMF of the motor because it is proportional to the voltage across the motor minus the voltage dropped across the internal resistance of the motor but it would need a complex circuit to do it, and even more complex if you have speed control.
An optical encoder would be a much simpler solution.

Last edited:

#### MisterBill2

Joined Jan 23, 2018
12,399
Now we have guesses that the motor speed is controlled by pulse width modulation, which, given that the direction is stated as being reversed as an option tells me that the driver is an "H Bridge" circuit, and that the control signal may, or not, be available.
But we have never been told what sort of motor, except that it has two terminals.
So a good guess is that it is a permanent magnet field brush type DC motor, and it will tend to have a counter EMF, as well as a fair amount of brush noise.
But now a possible scheme exists for measuring the back EMF of the motor, If the "Microbit" is fast enough and if it is generating the PWM control signal and if the analog inputs can be used in a differential manner. and if the analog response time is fast enough, then the scheme can work quite well.
The process will be to measure and save the voltage reading across the otor, by means of subtracting the two voltages, during the off time of the PWM drive cycle. A fair amount of code would be required, but physically that is all that is required.
This is based on the guess that the PWM drive is directly controlled by that "Microbit"

#### KeithWalker

Joined Jul 10, 2017
2,403
Now we have guesses that the motor speed is controlled by pulse width modulation, which, given that the direction is stated as being reversed as an option tells me that the driver is an "H Bridge" circuit, and that the control signal may, or not, be available.
But we have never been told what sort of motor, except that it has two terminals.
So a good guess is that it is a permanent magnet field brush type DC motor, and it will tend to have a counter EMF, as well as a fair amount of brush noise.
But now a possible scheme exists for measuring the back EMF of the motor, If the "Microbit" is fast enough and if it is generating the PWM control signal and if the analog inputs can be used in a differential manner. and if the analog response time is fast enough, then the scheme can work quite well.
The process will be to measure and save the voltage reading across the otor, by means of subtracting the two voltages, during the off time of the PWM drive cycle. A fair amount of code would be required, but physically that is all that is required.
This is based on the guess that the PWM drive is directly controlled by that "Microbit"
It is not that simple. How would you measure the voltage dropped across the internal resistance of the motor using a Micro;bit A/D while you are measuring the voltage across the motor with another A/D input?. Both values are needed.
The voltage dropped across the internal resistance of the motor is equal to the motor current times the internal resistance. You would need to use a shunt to get the current, but then you have different reference points for the two measurements and two A/Ds that have a common reference point. An op-amp level shifter/amplifier circuit would be needed to get the reference point of both measured voltages to be the same and the shunt measurement large enough to subtract from the motor voltage. It's beginning to get complicated!

#### MisterBill2

Joined Jan 23, 2018
12,399
In response to post#18: During that interval when the drive voltage is switched off the only current flowing in the motor resistance is the current drawn by the two analog input circuits. And note that the common side of those two inputs must be tied to the common side of the drive power source feeding the "H Bridge" circuit. With this scheme timing is everything. The drive switches off, the back EMF is measured, and then the drive switches back on for the next PWM pulse. Also note that not one bit of this sequence is measuring the motor current draw while the drive circuit is ON. That will require a third analog input as well as a shunt resistance and an amplifier to read the shunt voltage. So getting the current measurement desired is by no means simple.
It is possible that the timing and performance required are beyond the capabilities of the MicroBit system, though. And it is certain that my explanation of the sequence to measure the counter EMF was not understood by KW.

But if the TS really is only seeking to read the motor RPM, then an entirely different system may be a better choice. That will be to NOT USE PWM as a speed control, but rather a variable DC voltage, and monitor the frequency of the motor commutation signal (brush noise). THAT will provide an accurate means of reading the exact RPM with a small amount of calculation.

Last edited: