Saturday, February 18, 2017

LiteSerialLogger: Zero SRAM Serial Logging

Last week, I talked about Arduino library memory use - and pointed out that the Serial library, in particular, is entirely wasteful for the purpose of simply writing log messages out to the serial port.

What's one to do about this?  Well, one can do many things, but what I chose to do is to write my own serial logging library - that uses zero SRAM except when actually writing messages to the serial port!

This isn't the first time I've written something along these lines.  Every few years, I seem to find myself writing yet another serial output library for some reason or other, and serial UARTs are pretty boring to bang bits into at this point.  They're slightly more exciting if they have a FIFO bolted on and a high speed clock, but not by much.

In any case - take a look at this!  A basic Arduino sketch uses 9 bytes of dynamic memory or SRAM (for the millisecond timer), and with an awful lot of serial logging, I also use a mere 9 bytes!

What's this library?  How did I write it?  And how can you use it?  Read on!

Saturday, February 11, 2017

Common Arduino Library SRAM Use

I've been playing with Arduino for a few months now, and one of the things I've found incredibly frustrating is just how much dynamic/global memory (SRAM) most of the common libraries use - the standard Serial library uses nearly 200 bytes of precious RAM, always and forever, just to print a single log message, and a lot of others aren't that much better.

Further, advice about Arduino memory pressure tends towards the handwavy "Well... don't use globals, and use the F() macro..." side of things - which, while accurate, is missing some very important information for understanding what is happening and how you can resolve the issues.

Here's a particularly bad example of what I'm talking about.  With literally nothing done but some libraries initialized, this code is using 1101/2048 bytes of RAM - 53%, and I haven't done a single useful thing yet!

I'm going to dive into library memory use in some depth, look at a few examples, and profile some commonly used libraries!  Read on if you're interested!

Saturday, February 4, 2017

Building a Button Box: Technical Discussion

My daughter (23 months old) likes pressing buttons and anything involving lights ("yight!").  I had some time off this winter - and some parts to build something I call a "Button Box."  And what, realistically, is both a toy that can grow with her, and a subtle way to teach low level programming when she's older (if she's at all interested).  Because nobody is learning C in schools anymore, and C still matters.

This box contains an Arduino Uno, a 20x4 LCD, a few NeoPixel strips, a bunch of buttons, some LEDs, a battery and power supply, and the supporting wiring mess to make it all work - entirely hand soldered, and certainly one of a kind!

I'm doing two posts on this.  You've found the "highly technical discussion" post - this will be useful if you happen to want to build something similar, or find out what I did, in rather substantial detail.  This post also includes lessons learned - places I wasted time, had to rework things, or would just do things differently if I were to do it again.

If you're simply interested in what the build process looked like, you may be more interested in my other post, which is a (somewhat) shorter description of the build process.  This post includes that content as well, so there's no real point in reading both unless you want to.

In any case, if you want the gory technical details, read on!

Saturday, January 28, 2017

Building a Button Box: Overview

I have a daughter (not Cindy Lou Who, but she is slightly less than 2) who loves buttons and lights ("yight!").

If something looks like a button, or looks like it could be a button, she'll press it.  Repeatedly - especially if it clicks!  Clicking buttons are the best, and I'm glad things like dishwashers come with button locks now.

She's also learning colors and letters.  I had some time off over the winter, so I built her a button box that's useful for all of these things!

This is the non-absurdly-technical description of my build.  If you're looking for the gory technical details with an awful lot of advice about how not to do things, you'll want to check back next week for a radically longer post.

Otherwise, read on for how I built her button box!

Saturday, January 21, 2017

Progress vs Decline: What to expect going forward

What on earth just happened?  Donald Trump is now our president.

For quite a few months now (since early in the primaries), I've been saying that, while I don't support Trump, I saw a viable path for him to be elected President.  I caught a huge amount of flak for that.  Even the week before the election, pointing to the closing 538 probabilities and extrapolating out, I got accused of being ignorant of math, clueless about polling, and generally a complete moron for saying, "Folks?  Don't be so sure of a Hillary victory just yet."

Why?  And what does this mean?  I'll try to explain.

Something happened that wasn't supposed to happen.  Donald Trump is the new President of the United States of America.  This wasn't how the story goes.  Following eight years of Obama's Presidency, Hillary Clinton, who is, by the way, a woman, was supposed to Fight the Good Fight against the Evilly Evil Forces of Mordor (represented by none so vile as Donald Trump), triumph in a landslide, and rule over America, representing the fluttering flag of Progress.

That didn't happen - and the howling was incredible.  Trump wasn't supposed to win.  Trump was most assuredly not supposed to win with 304 electoral college votes (which would have been more, except for the faithless electors - of which there were only 2 from Trump, but 5 from Clinton).

Why wasn't Trump supposed to win?  What happened?  And what can we expect going forward based on this?

Saturday, January 14, 2017

Charging a Tesla S/X at 350kW: Plausible!

In late December, Elon Musk tweeted something interesting about 350kW or faster supercharging - and there has been a lot of talk and speculation since then.

Some people think he's talking about trucks - which would make plenty of sense.  Trucks need large battery packs which will require a rapid charge rate to be useful - there's definitely a good fit there.

But... what about a current Model S or Model X?  Could you actually charge one at 350kW with the current hardware?

I didn't know, and I couldn't find anyone who'd actually done the math - so, working with some basic back of the envelope calculations, I decided to find out!

Read on to join me and see what happens if you try to charge at this high rate - but I'll tell you up front - it seems entirely plausible to me!

Saturday, January 7, 2017

No Actual Post Today, Sorry.

I have plenty of posts nearly ready to go - but none fully ready this weekend.

Unfortunately, my wireless ISP and I have been having... conversations since about Thursday, over the extreme lack of internet they've been providing.  This poses a problem for my normal schedule of polishing a post on Friday and Saturday - and going elsewhere isn't worth it with all the snow and ice.

I've learned many things with a packet sniffer (including my radio's IP address), and learned that their level 1 techs are utterly full of shit about a wide variety of issues.  One particularly annoying one is the claim that a 5Ghz AP will interfere with their radios - which are operating in the licensed 5.4/5.7Ghz band - not the unlicensed 5.2/5.8Ghz spectrum 802.11 APs operate in.

Along with almost everything else they've said.  Yes, restarting my AP did temporarily resolve issues, but this is only because the normal IP lease is 60 seconds, and the "We can't talk to the real server, here's a 10. IP address" lease is 40,000 seconds or so.

Not entertained...

Hopefully, back to your regularly scheduled posts next weekend.