Skip to main content
added 115 characters in body
Source Link
Connor Wolf
  • 32.5k
  • 6
  • 81
  • 140

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

I'm making a lot of asusmptions here. First, I'm assuming a clock-instruction parity. Many MCUs require several clock-cycles to execute a single instruction, which would reduce the effective clock-rate. Second, I;m assuming your base counter is incrementing at the same rate as the system clock. This is generally only true for hardware counters. Third, the numbers I am using for things (the length of a year, etc...) are rounded versions of the real numbers. Lastly, this whole exercise is rather silly.

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200~\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microcontroller has at least 5 bytes of RAM, all of the listed devices will work.


For fun, let's look at how long a 64 bit long long would last:

\$2^{64} = 18,446,744,073,709,551,616 \$
\$ 18,446,744,073,709,551,616 / 20,000,000 =~ \approx922337203685.478 ~~ \$ Seconds
\$ \frac{922337203685}{60*60*24*365} = ~\approx29247.120~~\$ years

So with only 8 bytes of memory, it looks like you're good for at least the next 30 thousand years.

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

I'm making a lot of asusmptions here. First, I'm assuming a clock-instruction parity. Many MCUs require several clock-cycles to execute a single instruction, which would reduce the effective clock-rate. Second, I;m assuming your base counter is incrementing at the same rate as the system clock. This is generally only true for hardware counters. Third, this whole exercise is rather silly.

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200~\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microcontroller has at least 5 bytes of RAM, all of the listed devices will work.


For fun, let's look at how long a 64 bit long long would last:

\$2^{64} = 18,446,744,073,709,551,616 \$
\$ 18,446,744,073,709,551,616 / 20,000,000 =~ \approx922337203685.478 ~~ \$ Seconds
\$ \frac{922337203685}{60*60*24*365} = ~\approx29247.120~~\$ years

So with only 8 bytes of memory, it looks like you're good for at least the next 30 thousand years.

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

I'm making a lot of asusmptions here. First, I'm assuming a clock-instruction parity. Many MCUs require several clock-cycles to execute a single instruction, which would reduce the effective clock-rate. Second, I;m assuming your base counter is incrementing at the same rate as the system clock. This is generally only true for hardware counters. Third, the numbers I am using for things (the length of a year, etc...) are rounded versions of the real numbers. Lastly, this whole exercise is rather silly.

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200~\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microcontroller has at least 5 bytes of RAM, all of the listed devices will work.


For fun, let's look at how long a 64 bit long long would last:

\$2^{64} = 18,446,744,073,709,551,616 \$
\$ 18,446,744,073,709,551,616 / 20,000,000 =~ \approx922337203685.478 ~~ \$ Seconds
\$ \frac{922337203685}{60*60*24*365} = ~\approx29247.120~~\$ years

So with only 8 bytes of memory, it looks like you're good for at least the next 30 thousand years.

added 380 characters in body
Source Link
Connor Wolf
  • 32.5k
  • 6
  • 81
  • 140

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

I'm making a lot of asusmptions here. First, I'm assuming a clock-instruction parity. Many MCUs require several clock-cycles to execute a single instruction, which would reduce the effective clock-rate. Second, I;m assuming your base counter is incrementing at the same rate as the system clock. This is generally only true for hardware counters. Third, this whole exercise is rather silly.

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200\$\$2*60*60 = 7200~\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microntrollermicrocontroller has at least 5 bytes of RAM, all of the listed devices will work.


For fun, let's look at how long a 64 bit long long would last:

\$2^{64} = 18,446,744,073,709,551,616 \$
\$ 18,446,744,073,709,551,616 / 20,000,000 =~ \approx922337203685.478 ~~ \$ Seconds
\$ \frac{922337203685}{60*60*24*365} = ~\approx29247.120~~\$ years

So with only 8 bytes of memory, it looks like you're good for at least the next 30 thousand years.

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microntroller has at least 5 bytes of RAM, all of the listed devices will work.

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

I'm making a lot of asusmptions here. First, I'm assuming a clock-instruction parity. Many MCUs require several clock-cycles to execute a single instruction, which would reduce the effective clock-rate. Second, I;m assuming your base counter is incrementing at the same rate as the system clock. This is generally only true for hardware counters. Third, this whole exercise is rather silly.

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200~\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microcontroller has at least 5 bytes of RAM, all of the listed devices will work.


For fun, let's look at how long a 64 bit long long would last:

\$2^{64} = 18,446,744,073,709,551,616 \$
\$ 18,446,744,073,709,551,616 / 20,000,000 =~ \approx922337203685.478 ~~ \$ Seconds
\$ \frac{922337203685}{60*60*24*365} = ~\approx29247.120~~\$ years

So with only 8 bytes of memory, it looks like you're good for at least the next 30 thousand years.

added 186 characters in body
Source Link
Connor Wolf
  • 32.5k
  • 6
  • 81
  • 140

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microntroller has at least 5 bytes of RAM, all of the listed devices will work.

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments.


So, assuming a 20 Mhz clock, how large of a variable do you need?

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microntroller has at least 5 bytes of RAM, all of the listed devices will work.

The maximum attainable delay is based on a combination of the system clock, and available RAM.

Basically, you can create large variables (e.g. 32 bit ints, 64 bit ints) on an 8-bit MCU by spreading the int over multiple 8-bit ram segments. It takes multiple operations to perform addition or multiplication of such numbers (as you have to iterate over the individual bytes), but speed is not exactly critical here, so this is ok.


So, assuming a 20 Mhz clock, how large of a variable do you need?

\$20 Mhz = 20\times 10^{6} = 20,000,000\$
Well, \$ \frac{log(20,000,000)}{log(2)} = 24.2534966642115\$ , so you need ~24.25 bits to delay for one second.
2 Hours = \$2*60*60 = 7200\$ seconds, so you need \$ \frac{log(20,000,000*7,200)}{log(2)} = 37.0672778554286\$, so you need 37.06 (or basically 38 bits) bits of ram to represent a 2 hour delay.

So.... Assuming your microntroller has at least 5 bytes of RAM, all of the listed devices will work.

Source Link
Connor Wolf
  • 32.5k
  • 6
  • 81
  • 140
Loading