cancel
Showing results for 
Search instead for 
Did you mean: 

robot car STM32F3 DISCOVERY AND HC-SR04 PROBLEMS

Posted on December 16, 2014 at 11:03

I try to create a robot car, using a MCU stm32f3 Discovery, an ultrasonic sensor HC-SR04, two motors and H-Bridge L298N  to control the DC motors a , and a conversor RS232 to USB, for to see the distance in my pc.

The problem is:

When i supply the MCU STM32 Discovery by USB, i can see without problems the distance.The HC-SR04 and conversor works fine.But when i supply the MCU (5V) through the L928N H-Bridge, the ultrasonic sensor don´t works correctly and , just can see some characters.To supply the L298N i use a mobile phone charger, and they debit a 12V DC .

In send in annex the hardware Diagram.

Thanks for any help.

Greetins

9 REPLIES 9
AvaTar
Lead
Posted on December 16, 2014 at 11:44

But when i supply the MCU (5V) through the L928N H-Bridge, ...

 

Citing from the L298 datasheet:

An additional supply input is provided so that the logic works at a lower voltage.

 

You can't supply your MCU/sensor, etc., from the L298 (as I understood you are trying). The other way around, you need to provide a stable 5V to the VSS pins (9 or 12, depending on package).

Posted on December 17, 2014 at 15:04

Thaks for answer.

But i also tried with a 9V battery, for supplie the L298N and the sensor dont works.So, how i can supplie the L298N (and motors ) and the HC-SR04 correctly?.What is the best away?

AvaTar
Lead
Posted on December 17, 2014 at 17:35

But i also tried with a 9V battery, for supplie the L298N and the sensor dont works.

 

Not sure what you mean by that.

You need two supply voltages for the L298N, one +5V (digital logic) and one for the motor (e.g. 12V in your case).

Your sensor needs +5V, the discovery board too (the 5V input).

To interface the sensor, make sure you use 5 volt - tolerant GPIOs, and that output to the sensor achieves a sufficient level. The datasheet only specifies ''TTL''.

Only the L298N needs/accepts a higher voltage, e.g. 9V or 12V in your case.

If you had the sensor and the discovery board hooked up to that, they might already be dead.

I would be wary of EMI issues. A motor's back-EMF can kill you sensor + discovery board.

Posted on December 18, 2014 at 00:00

Thanks.

The problem of the L298N is resolved.Had to disconnect the jumper.

Now, i supply 12V for motors and 5V for discovery by another supply.

The Discovery have two pins 5V input/output voltage.When i use the usb port for supply the discovery , the 5v pins give me 5V(input), when i dont use the usb port i apply 5V in the first 5V pin, and the second 5V pin for the HC-SR04.

But the problem dont desappears. 

When supply the discovery by USB , the HC-SR04 works well, but when i use another source supply, only see some characters by Hiperterminal

Need to configure something  in Discovery...

AvaTar
Lead
Posted on December 18, 2014 at 11:51

Sounds like you have a problem with logic levels.

When supplied by USB, the discovery board actually sees about 4.7V, and about 3.1V for the MCU. Both thanks to Shottky diodes in the supply lines.

The trigger output (from the MCU to the sensor) might have sufficient level when the sensor is supplied with 4.7V, but not when supplied with 5.0V, as threshold levels move with supply voltage.

You can try to configure the output as open drain and add a pull-up resistor, or use an external transistor.

 

Posted on December 18, 2014 at 12:17

OK.So, i have to configure the output as open drain and add a pull-up resistor.

The answer is:

So, i have to use the another 5v from MCU and install a resistor (by hardware)?

Or , i have to use a PIN output, for example PD2 and configure by software as a

open drain and add a pull-up resistor?. See the picture in annex please.

Thanks for help

Have a nice day.

________________

Attachments :

Supply_Problems.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Ro&d=%2Fa%2F0X0000000bh3%2FOjnFixTj.1eazr2ImZNU3ROi.qXhRXfyshKSc1x3Uhw&asPdf=false
AvaTar
Lead
Posted on December 18, 2014 at 18:14

So, i have to use the another 5v from MCU and install a resistor (by hardware)?

 

Not sure what you mean with that, but no.

 Or , i have to use a PIN output, for example PD2  and configure by software as a open drain and add a pull-up resistor?

 

 

If PD2 is the output to drive the sensor trigger signal, yes.

The internal pull-ups are tied to 3.3V (3.1V, actually) and are obviously not sufficient. So you need an external pull-up resistor to 5V.

Since the sensor datasheet is rather unspecific about driving requirements for the trigger input, I would start with 5 ... 10kOhm.

BTW, if you have a scope, you could try to analyze the situation.

I can only guess.

Posted on December 19, 2014 at 11:56

OK, but, when i measure the voltage (multimeter) from MCU to Sensor, i have 5V. Oscilloscope, i don't have .

But i gone tray with a resistor into the line of 5V from MCU to Sensor, and see what happen.

Thanks again  for help.

AvaTar
Lead
Posted on December 19, 2014 at 14:35

But i gone tray with a resistor into the line of 5V from MCU to Sensor, and see what happen.

 

Again, I'm not sure what you mean by that.

The pull-up resistor needs to be from PD2 (the trigger output) to +5V.

You presumably need a higher trigger pulse level, as 3V seem not to work, when you properly support the sensor with 5V.

If unsure, look up ''pull-up resistor'' in your favourite search engine.