Puzzled over PWM with NPN transistor

I bought a sparkfun 5V panel meter, one of the ones with needles.

I hooked it up directly to pin 3 and at duty cycle 255 it says 5V as expected.

Then I thought I better use a transistor (even though the coil is 7kOhms) so I hooked up some PN100 NPN transistor. The meter still read 5V.

At 128 duty cycle it shows a little less than 2.5V, with the NPN transistor. Curiously, if I drive it straight off pin 3, however, the meter shows like 4V.

How could that be? Why would the needle show a substantially higher (and apparently less correct) reading with no NPN transistor?

It's worth noting that PWM outputs don't show up well (or as expected) on voltage meters unless you first smooth the square wave signal into a steady(ish) voltage.

I was hoping the needle itself would act as a mass/spring Low-pass filter.

The meter also 'sings' at middle PWM values so I tried making a low pass filter with a 75ohm resistor and 220uF cap. This should give a time constant of 16ms which I would think would filter the 500Hz PWM well. However, there is no change in the sound with or without the filter.

I don't understand why the filter didn't work, and I don't understand why the meter reads higher with no NPN transistor than it does with the transistor.

If you just have the panel meter hooked up to that output I would try a much higher ohm resistor, it may well be that the 75ohm resistor flows enough energy to leave you with most of a square wave.
That is what I'd try at least. Fair warning: I'm far from an EE.

I don't understand why the filter didn't work, and I don't understand why the meter reads higher with no NPN transistor than it does with the transistor.

You need to put up a diagram of exactly how you used a transistor. I suspect you have wired it up wrong or used the wrong sort of circuit.
The mass of the needle won't act as a filter. As mentioned before make that resistor 1000 times bigger.

If I make the resistor 1000 times bigger it will compete with the 7000 ohm meter coil and my meter won't go full-scale any more. Even the 75ohm resistor causes the meter to drop about a needle-width.

I have it hooked up like this:

5V>Meter + terminal> meter - terminal>NPN transistor collector; transistor emitter to ground, gate to pin 3. : gives 2.3V at 128 duty cycle

5V>Meter + terminal> meter - terminal>pin 3 : gives 4V at 128 duty cycle.

Even if the transistor is not working correctly and that's why it gives a lower reading when I use the transistor, why would the meter give a 4V reading at a duty cycle of 128 anyway?

I figured it out. Still testing at 128 duty cycle.

If I hook it up to ground, and the + side to pin 3, it reads perfectly fine (same as transistor).

If I hook the meter up to 5V, and the ground side to pin 3, then the meter reads 4V for some reason.

I thought that a PWM pin would sink the same amount of current as it would source, but apparently that is not the case. If the meter reads a higher voltage when the pin is set up to sink current than when it's set up to source it, then I guess that means the pin doesn't sink as much current as it will source. I think.

I thought that a PWM pin would sink the same amount of current as it would source, but apparently that is not the case.

Well from an output pin electrical point of view that is not a true statement. The output are fully symmetrical push/pull and have the same drive specifications when sinking or sourcing current. Look external to the output pin for a valid explanation.

I know that's what it says in the datasheet, but if I switch the wire from 5V input to GND, with the PWM pin running, I get two different meter readings, and it's only correct when I hook it up to GND. At a duty cycle of 128 it should be a symmetrical square wave so it should give the same reading both ways if the pin really was symmetrical.

I know that's what it says in the datasheet

Do you not believe the datasheet? I've found arguing with either compiler error messages or hardware datasheets a useless activity, I always lose the argument. XD

Not sure what to say about your observations. Possible if I could see a real schematic and the electrical internals for your meters ( meters are current meters using internal series resistor to scale a given voltage to a given current), some explanation might present itself. And there are plenty of people around here smarter them me, so be patient if you want a root reason for your observations.

Lefty

I get two different meter readings, and it's only correct when I hook it up to GND.

Is that with or without the filter. If it is without it is surprising, if it is with then it is no surprise.