Go Down

Topic: simple simulation of pins on arduino? (Read 447 times) previous topic - next topic


Hey all, I'm getting start with using LTSpice to simulate some simple circuits hooked up with my Arduino Uno.

I have a question as to how to simulate digital pins in INPUT, OUTPUT or INPUT_PULLUP modes. I don't want to simulate the entire arduino, but is there a way to easily simulate individual digital pins in something like LTSpice in one of the above states? I don't  know enough about what's going on inside the Arduino or Atmega chips to know whether or not I can just simulate it with a resistor and diode, or how to include a pull-up resistor into the diagram. If anyone has any advice for how to easily simulate the input pins on the arduino or can point me towards some schematics I'd be really grateful.



Look in the "I/O ports" section of the ATmega328 datasheet.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)


The output drivers are about 30 to 40 ohms when on, infinite when off, and the pullup
is about 30k.

You can model the protection diodes too if you want.
[ I won't respond to messages, use the forum please ]


So, essentially no current will flow into an output pin when it is turned off (low)? But when it is turned on (high) there is maybe a 30 or 40 ohm resistance?

Is there any resistance on the input pins? The Arduino docs suggest that there is, but the Atmega datasheets makes me think there is no resistance when configured as input.

Input pins make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 megohm in front of the pin.

If the Arduino docs is right then where would that 100 megaohm resistor be in terms of the pull-up resistor?

I think that going back and forth between the atmega docs and the arduino docs is confusing me..


Normally inputs can be modelled as 10^10 ohms for CMOS.  At room temperature.
The 100M value is at max operating temperature as leakage currents rise exponentially
with temperature.

Unless you are running a very strange circuit you don't have to worry about these details,
its three ideal MOSFETs and a resistor (and two protection diodes if that matters).
[ I won't respond to messages, use the forum please ]


So, essentially no current will flow into an output pin when it is turned off (low)

No when an output pin is low there is the same impedance to ground as there was to 5V when it was high.


For some  simulations you need to take into account the input capacitance of the pins.
For digital I/O pins it is max 10pF.
For the analog ADC inputs it can be modelled as a 1...100kohm (datasheet is not clear about this) resistor in series with a 14pF (S/H) capacitor which is connected to Vcc/2 (see figure 24-8 in the atmel datasheet for ATmega 48/88/168/328)
Maybe this is helpfull to you.
You do not need a new P.C., you need a new O.S.  Linux is free, safe, easy, fast and reliable.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131