Hi all , I am using the programming instruction analog write. When I use the number 255 I should be getting 5v at the pin. I am only getting 4.73v. I am using the nano board from duinotech. As this is wrong all the other voltages from lower numbers will be wrong also. I am using pin 3 and a 270 ohm resistor. Is 18ma too much from this pin?
I am getting an accurate 5v reading from the 5v pin for an input of 7v. Could this 7v input be somehow too low for pin3 ? Anybody know why I am only getting 4.73v on my multimeter?
You can't measure PWM on a meter.
No you never get that from PWM
This is how it works:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html
Anyway 4.73 V is well within the specifications for any pin, let alone a PWM one.
Please test the output voltage on pin3 in case of using digitalWrite() instruction:
digitalWrite(3, HIGH);
To be honest, there is no PWM on pin when the user uses 255 with analogWrite().
If you see to the source, the analogWrite() command invokes digitalWrite() with LOW and HIGH for extreme (0 and 255) cases.
The more current you draw from an I/O pin the more the voltage will drop. At 18mA a typical output voltage would be around 4.55V
Without the resistor you should see very close to 5V
Is 18ma too much from this pin?
You shouldn't go over 20mA
What is the actual Vcc that you measure on that board? It looks like we are assuming it is 5V, but is it?
@herbschwarz is correct, for a classic Nano (which is what I assume you have, even if it is a clone) 4.7~4.8V is normal, because of the diode built into the Nano board.
Connected how?
If the resistor connects the pin to ground, around 15~20mA will flow. That's not too much but it will probably cause a little more voltage drop.
===> analogWrite(3, 255);
===> digitalWrite(3, HIGH);  //post #4
When digitalWrite(3, HIGH); is executed, logic HIGH is asserted on DPin-3. In data sheets of ATmega328P MCU, the symbolic name for logic HIGH is VOH.
The data sheet says that the minimum vlaue of VOH will never go below 4.2V (with Vcc = 5V). You have got 4.7 V which is a very good value.
At this VOH = 4.2V, the DPin-3 is designed to source maximum 20 mA current.
So yeah... The PWM is working as you expect and 255 gives you a constant high.
High is 'nominally" 5V and low is "nominally" 0V.
This is the "magic" of digital! It can be imperfect, but it's still digitally-perfect!
...Above a certain voltage it's defined as a high, and below a certain voltage it's defined as low. In-between it's undefined/uncertain and may read high or low, but if your circuit is built right, it will be never be in-between and it's super-reliable and super-stable.
Also, outputs are more strict than inputs (the inputs have a narrower undefined range) so whenever you write a high you are sure to read a high, etc. ...Anything greater than 3.5V (0.7Vcc) on an input is read as high.
Different technologies & different voltages have different standards but the concepts are always the same.
I don't have that version of the data sheet.
I have the latest versiom dated 2020.
Can you show the entire section where that data appears?
https://store-usa.arduino.cc/products/arduino-nano?selectedStore=us
Input and Output
Each of the 14 digital pins on the Nano can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions:
EDIT: Not condoning or agreeing with this. Just showing one (very likely) place where people might get the incorrect idea that 40mA per pin is OK.
That makes it sound like it is OK to take 40mA from each of the 14 digital pins, which it certainly isn't
Please see details on page 322.  Then, please read notes 1-5 on page 323.  Think really hard about what the manufacturer is saying.
Yes, unfortunately, Arduino, among many, many others, have dropped the ball here.
Unfortunately that web-page is riddled with errors.
In one place they say the input voltage range is 7-12V, in another place it's 6-20V
In one place the max current is 40mA on the pinout diagram it's 20mA.
I can see why newbies often have troubles with the Arduino boards
From the data sheet
Note what is says at the side.
Now the test conditions for the recommended working voltages / currents
I'm not sure what datasheet sheet you have but the one I have, which I believe to be the latest revision, is completelt different.
You should download the latest revision from Microchips website.
Regardless, all of the information posted so far refers to "Absolute Maximum Ratings", and @GolamMostafa were to provide us a link to the document he's referencing online somewhere, I'm betting we'd see the same caveat notes I pointed to earlier.
Thanks Jim, That explains it. But what about other write values such as 127. Should I then get 2.5v? Hopefully you only get the error when you try for the full 5v.



