problem with reading voltage from bybass rezistor on H-bridge

Hi, I have problem with reading voltage from bypass rezostor on H-bridge used for reverzation and PWM controling DC motor.
Here’s my code:

#define MOST1 12
#define MOST2 11
void setup() {
  pinMode(MOST1, OUTPUT);
  pinMode(MOST2, OUTPUT);

int stav = 48;
long cas = 0;
int hodnota, pohyb1 = 0, pohyb2 = 0;

void loop() {
  if (millis() >= cas)

    cas += 1000;

  if (Serial.available() > 0)
    stav =;
  if (analogRead(A4) <= 1000 && (pohyb1 == 1 || pohyb2 == 1){
      analogWrite(MOST1, 0);
      analogWrite(MOST2, 0);
if (stav == 48)
    pohyb1 = 1;
    pohyb2 = 0;
    analogWrite(MOST1, 255);
    analogWrite(MOST2, 0);
  if (stav == 49)
    pohyb1 = 0;
    pohyb2 = 1;
    analogWrite(MOST2, 255);
    analogWrite(MOST1, 0);
  hodnota = analogRead(A4);

VCC is 5V
from this point i’m reading voltage and when current in my circuit raises up, voltage on this point fall down for some mV i want to stop the motor putting 0V on H-bridge input
this is the teory but in practise arduino always think theres lover voltage on this point but it isnt. theres always 5V
that bypass resistor is good i measured voltage decrease before thats good but i cant understand why arduino think that voltage is lover. when i am measuring voltage and sending that to serial monitor theres always 1023
i need big accuracy
so anyone can help me fix this?

I think what you are doing is measuring voltage across a current sense resistor?

Its not clear what you have going on with your circuit. We can understand schematics and pictures better than descriptions!

Otherwise it also sounds like your current sense resistor is before your bridge? Normally it is between bridge low side sources / emmiters and ground.

thats right
but i use this bridge to reverse rotation so i cant add that resistor there.
but it doesnt matter i fonud where was the problem

The current sense resistor should be to ground, not the positive supply. The motor supply is noisier than
just about any part of a circuit I can think of, the worst place to try and measure current.

I'm glad you got your problem figured out but..

The direction of current flow through the sense resistor does not change with motor direction. We are talking about bidirectional motors. Current sense after the whole bridge.

So, that's the best place for that resistor (resistor R10 is motor) i cant add resistor on one pole of motor that will do bad things in circuit
I measure full current in circuit on that resistor and it doesnt matter if motor is turning to one or to the other side

If those are questions then yes ( the LOW side of the bridge )yes .. and yes. Please use question marks.

no that's only evaluation

Sorry then, Sounds like you have it sorted.. You are measuring current the same way with the resistor top or bottom but the measurement will be much cleaner from the low side measured as a voltage (across the resistor) referenced to ground .

i don't really understand you could you draw it?

I just did a quick sketch.

Say… for example the sense resistor was 0.1 Ohm

When 2 amps is conducted through it


2*0.1 = 0.2 Volts will be measured at the top of the sense resistor.

The analog in pins of the arduino should read 1024/5 * 0.2 = 41

The resistor would be using P = IV = 0.4 watts

thx but i dont need that calculates :smiley: i know them

okay that sketch helped me to understand i check that