Go Down

### Topic: Read a 12V pwm with Arduino (Read 3716 times)previous topic - next topic

#### bvli

##### Sep 21, 2011, 08:07 am
Hi there!

Quite new to electronics, so please be gentle!

I need to read a 12V pwm signal in my project. How do I convert it to a 5V pwm for me to read it using the pulseIn(...) function.

I found this: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232444802, but in fact I do not understand what to do with the resistor, transistor. (how to connect them) Wouldn't a normal voltage divider circuit suffer?

Could any of you guys point me in the right direction?

#### retrolefty

#1
##### Sep 21, 2011, 08:21 am
Yes, I see no reason a simple two resistor voltage divider wouldn't do the job just fine.

Lefty

#### bvli

#2
##### Sep 21, 2011, 08:30 am

Yes, I see no reason a simple two resistor voltage divider wouldn't do the job just fine.

Thank you very much.

#### retrolefty

#3
##### Sep 21, 2011, 08:33 am
Your welcome. Just remember to connect the grounds together from the 12vdc system/voltage divider and  arduino ground pin.

#4
##### Sep 22, 2011, 12:49 am
would a zener diode also work to protect the input on the arduino ?

what would happen if the 12v signal went to say 100v by accident

#### retrolefty

#5
##### Sep 22, 2011, 01:16 am

would a zener diode also work to protect the input on the arduino ?

Yes that is another method, one say 4.7vdc zener diode and one current limiting resistor would 'chop' the +12vdc signal to a 0 - 4.7vdc signal.

what would happen if the 12v signal went to say 100v by accident

If using a voltage divider a 100vdc could cause destruction of the arduino chip. If using the zener maybe nothing or destruction of the series current limiting resistor.

I like the zener + resistor solution over the two resistor divider solution.

#### bvli

#6
##### Sep 22, 2011, 12:08 pm
Quote

I like the zener + resistor solution over the two resistor divider solution.

Ok, if it will protect my arduinos input it is maybe the way to go. So here's another newbie question:

I should connect the Zener in parallel with the input and ground. But where should I place the resister? And how will I calculate the value of the resistor?

#### retrolefty

#7
##### Sep 22, 2011, 03:27 pm
I should connect the Zener in parallel with the input and ground.

But where should I place the resister?

Between input pin and source of 12vdc PWM signal.

And how will I calculate the value of the resistor?

Not critical in this application, 1k ohms should work fine.

Lefty

#### bvli

#8
##### Sep 22, 2011, 07:49 pm
Thanks again Lefty!