Hi,
after searching for voltage divider info I came up with this I have in my picture. Is this method correct? If I make R1 = 15Kohm and R2 = 10kohm I get 5v on the digital pin?
Are these resistors ok, or could they be 150kohm and 100kohm? Could I make a voltage divider for the NH5019 VDD in the same way?
The divider sounds ok
12*[10/(10+15)]=4.8
The description "Proximity switch NPN" suggests it is an open-collector output, in which case you need a different arrangement, probably direct connection to the Arduino input and using INPUT_PULLUP or even an additional pullup resistor to Vcc on the Arduino.
You have omitted to provide the all-important datasheet for the proximity sensor. Without that your question cannot be answered. ![]()
And some research on the LJ12A3 indicates that it is in fact, an open-collector output.
A prox sensor with an NPN output does not generate a voltage. These are referred to as an open collector output because the output sinks current, it does not source current. A PNP output does source current which would work for the way you have the resistors shown.
https://www.dataq.com/blog/data-acquisition/whats-all-this-sink-and-source-current-stuff/
The easiest way to make the NPN work in our case is to connect the prox output pin to the Arduino input pin and declare the input pin with INPUT_PULLUP which connects an internal resistor inside the Arduino chip to the +5V supply. When the prox sensor detects whatever it is supposed to detect, the Arduino input pin will be LOW. When the prox is not active, the input pin will be HIGH.
The VDD pin of the VHN5019 is a +5 volt logic supply pin. That pin should be connected to the +5V pin of the Arduino. Are you using a complete motor driver board here or just the IC? Just an IC needs many additional parts not shown on your diagram. You need to research that one if so.
Ok, so I can safely connect the proximity sensor output pin to the Arduino input pin, even if the proximity sensor is connected to 12v?
VNH5019 is a complete motor controller, the controller is not very near the Arduino board so I was tempted to use the 12v line to power it(of course I would need some way to make 12v to 5v). But maybe I take the +5 volt from Arduino anyway.
for VNH5019 use 5V voltage regulator.

This should work with an NPN open collector output, diode blocks any voltage from switch, but switch can pull input LOW.

Should not actually be necessary, but certainly a safe approach.
Diagram is wrong for this sensor, but certainly you should not be using "Vin" or the "barrel jack" to power the Arduino - you need a proper switchmode "buck" regulator to provide 5 V for the Arduino and the motor module.
Thanks for the help, i can confirm that with this sensor there is no need for a voltage divider. I connected the sensor as Paul_B and WattsThat suggested and it works great.
Paul_B, do you suggest I connect to the 5v input with switchmode "buck" regulator? What is a proper switchmode regulator?
Pololu is commonly recommended here as a reliable manufacturer.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
