Does code increase battery life?

There has been discussion on Chief Delphi about the weight of code. One person pointed out that the binary 0 is stored on flash as ‘on’. My concern is about battery life. If zero is stored as on, than if I write a lot of code, it should increase the battery life of our robot, right?

2 Likes

Of course, but all those extra trapped electrons may mean you exceed the weight limit.

11 Likes

I find that robots without code usually get a longer battery life than robots with code, but they’re not as much fun.

37 Likes

12 Likes

Here’s some likely flawed math.

190’s build folder for our robot code is 69 MB (nice). This is 552000000 bits.

Based on this paper, one bit requires roughly 3.5 * 10^-16 Joules to store. So, our code will take 1.932e-7 Joules to store.

AndyMark says that our standard FRC battery has 18 Amp hours of energy and has 12 Volts.

18 aH = 64800 Coulombs, and 64800 C * 12 V = 777600 Joules in a robot battery.

Finally, this means that (1.932e-7) / 777600 = .000000000024845679% of our totally energy in our battery is used to store the bits in our robot code.

15 Likes

Actually with TTL logic 0 states draw more power than 1 states. Probably not relevant to microprocessors since they don’t use TTL. Anyway limiting the use of drivetrain motors will help with battery life.

exactly, so if our robot draws too much current, I just need to write more code!

nice maths. I wouldn’t want our robot to be set back by .000000000024845679% of what it could be! of course a battery is no longer truly usable before all 18ah are used.

2 Likes

One way you can reduce the weight of your code (and thus improve battery life) is to take out all the comments.

6 Likes

that would be great, but unfortunately the compiler pretends that comments don’t exist so they don’t exist to the rio.

1 Like

Only one letter off…

https://commons.marymount.edu/locjowett/coke-adds-life/

1 Like

Since the code is stored in flash memory on the rio, I think there’s an argument to be made that code, in a way, IS a battery.

2 Likes

hmmmmm :thinking:

Came here to say this. Whether a stored logical 1 or 0 takes up more electrons or “batteries” is dependent on the underlying storage technology - some flash/eeprom implementations need more to store a 1, some need more to store a 0.

Even still, it doesn’t matter. Who says 1 has to be “high voltage”, and 0 has to be “low voltage”? As long as all the chips on the board “agree” on the standard… There doesn’t have to be a universal mapping from electrical state to logical 1/0 states. For the sake of this discussion, just pick the mapping that makes your code’s storage more efficient.

^^

1 Like

These threads are the reason why I can’t get off of Chief

1 Like

The moment when you realize the thread isn’t about current limiting.

8 Likes

For TTL the low state is considered “0” by most people. Specifically for TTL the low state will conduct more current than the high state which is a high impedance state. So you use the low state for turning on lights and relays. The low state is a more energy consumptive state For programming you use nands and nors verses “or” and “and”. You are correct other technologies use other standards. (TTL probably doesn’t apply to anything on the Rio) While completely arbitrarily “0” is used as “false” and 1 is used as “True” in most programing languages . My comment specifically applies to TTL. Admittedly a red herring for this thread, but then I don’t think the OP intended this thread to be serious. :thinking:
image
Source XKCD

5 Likes

That’s my assumption as well :slight_smile: In case anyone was wondering, it is almost always a very silly idea to change your hardware implementation to match some particular software assumption.

That being said: Yes, I have industry stores about it happening.

Which is why I moved it to Chit-Chat. But nothing non-serious on CD stays non-serious.

1 Like