# PWM question

Discussion in 'General Electronics Chat' started by FastEddie, Jan 10, 2009.

1. ### FastEddie Thread Starter Active Member

Jul 14, 2007
35
0
Hi,
I'm trying to learn about PWM and at the same time possibly make a project that can create a 4-20 mA signal. I have basic knowledge but not too much into the specifics. I'm using a PIC 16F877A with mikroBasic on Easypic5 board using their example for PWM. When I tried this out I had the following results (with PWM set at all out).:

I connected my meter between RC2(PWM) and ground and read 5.02 volts. I thought this would be what I got so I was happy.

Then I connected a 220 Ohm resistor to RC2. Changed my meter setting to mA. I hooked my meter+ lead to the resistor and - lead to ground. I thought since 5V/220 Ohm is about 22mA that is what I would read. Instead I got about 17.1mA. I was curious, so I hooked another meter across the resistor to check the V drop. That read about 3.75V.

Any ideas? This has been driving me crazy all week.
I've attached my drawings, one for before resistor and one for after.

Thanks,
Ed

File size:
29.8 KB
Views:
18
File size:
31.5 KB
Views:
15
2. ### Audioguru Expert

Dec 20, 2007
10,808
1,221
The PIC has a resistance in its output Mosfets. The output voltage is 5V only if there is no output current. The output current causes the output voltage to be less and the wasted voltage heats up the output Mosfet.

3. ### FastEddie Thread Starter Active Member

Jul 14, 2007
35
0
Hi, thanks for answering so quick. So if I lower my resistor value untill I get in the range that I need I should be ok?

4. ### Alberto Active Member

Nov 7, 2008
169
36
Since you are using pwm then remember that you can adjust Vout using the DUTY CYCLE. Once you have a certain load (Your resistor) then duty cycle=255 will output the max V value. Duty cycle =0 will output 0 Volt.You will search for the correct setting, between (0 to 255) to output the Vout desired.

Alberto