Wishful Coding

Didn't you ever wish your
computer understood you?

The Science of Logic and the Science of Experiment

When discussing ideas about our universe that are in some way controversial, the scientific argument is often brought up. In the words of everyones favorite astrophysicist:

The good thing about Science is that it’s true whether or not you believe in it.

This notion has been on my mind quite a bit lately. As an engineer and somewhat rational being, I depend on a lot of science, but as a human being, I also find some of its explanations somewhat lacking.

It occurs to me that there are two kinds of science. The science of logic, which provides undeniable formal proofs based on a set of axioms (from the Greek ἀξίωμα, “that which commends itself as evident”). The evidence for these axioms is provided by the Science of Experiment, where it is key to note that experiments and the humans conducting them are fallible.

So to have an alternative view of the universe does not mean to reject science and logic, it means to reject the outcome of an experiment that lead to an axiom that lead to a proof. The question then becomes, which experiments do you trust?

The easy ones are the ones you experience on a daily basis or can easily verify yourself. I’m pretty sure Newtonian physics work pretty well on the human scale, but I’ve not personally seen an atom, traveled near the speed of light, or even seen the earth from space, so how can I know about those things for certain?

One step down are experiments that others have done and verified, that make a lot of sense. I did not personally verify the experiment, but as a personal hypothesis (ὑπόθεσις, “to suppose”) they explain the things I see pretty well. Suppose electrons exist and move towards the lowest potential, my electric circuits make a lot of sense. Suppose the earth is round, it makes a lot of sense I can’t see the Eiffel tower from my window. (and a lot of other things make sense that way, too)

Then there are things that I have no idea about, one way or another. In these cases it just comes down to who I trust. Ideally, peer-reviewed journals should provide a high degree of trust, but in the face of the current reproducibility crisis, prestige-driven research, and questionable industry ties, one might start to wonder how trustworthy some research really is.

I have absolutely no clue about quarks, quantum entanglement, black matter, the big bang, and many other things. When you start telling me the world is really 12 dimensions but they’re rolled up in a ball, that’s very, very far removed from anything I can see and touch. I have no reason to doubt these things, so I trust them to be more or less true until a better story comes around.

A more problematic case is the Healthcare industry, which makes money as long as you’re not healthy. There is a lot of questionable and contradictory information out there form all sides. So it’s not surprising there is an antivacc movement that trusts anecdotal evidence above published research.

And finally, there are things where the scientific community kind of misses the point. It might be that homeopathy is just placebo effect, but it glosses over some remarkable detail: The way you think about a medicine apparently influences how well you feel.

This seems to me like a profound concept, indicating that body and mind influence each other. This is what I would call the holistic axiom, that everything influences everything. It underpins many alternative concepts such as homeopathy and astrology, that have elevated the study of these connections to an art form.

Published on

Introduction To Game Boy Hacking at SHA2017

At SHA2017 I gave a workshop about Game Boy assembly programming. Despite the projector not working, it was fun to do, and I got some nice feedback. We looked at some code from Pokemon Red, made some small changes, and more. Unfortunately there was not enough time to dive into Super Mario Land and write code from scratch.

For those that want to continue, or were not there, the PDF can be downloaded here.

As a bonus, someone asked how you could disassemble Super Mario Land and extract images from it. In theory this should be easy by using pokemontools, but I could not get it to work right away.

What I did do is search the code for the location of the sprites. The VRAM tile data is located at 0x8000, so searching for that adress in the debugger gives a few places that copy data from ROM to VRAM. Using pokemontools, I was able to at least decode a block of tiles at 0x4032, shown below. Other blocks should be possible to find as well, but that’s for another time.

Super Mario Land tiles

USBTinyISP debug oscilloscope

When I’m using a normal Arduino board I usually just do printf debugging. But when I design a PCB with an AVR chip on it, I don’t always want to use serial.

Now if you have an expensive official AVR debugger, you can use debugwire with Atmel Studio, but that is a proprietary protocol that is not supported by avrdude and the USBTinyISP I have.

For my guitar tuner project I really needed a way to debug the program I’m writing. So I looked around if anyone had figured out something to do at least basic printf debugging via SPI.

The best thing I found is people using another Arduino to forward SPI commands to the Arduino serial console. That seemed a bit clumsy when I already have a perfectly fine SPI chip in my ISP.

So I took a break from my guitar tuner to write an SPI debugging tool. I configured the AVR as an SPI slave, and then used PyUSB to send SPI commands with the USBTinyISP. In this particular case it was more insightful to plot numerical values than to print text, so I used matplotlib to make a very basic “SPI oscilloscope” to probe some variables on the AVR.

oscilloscope

I put the code on Github. It’s pretty basic right now, but if people besides me actually need this kind of thing, it may eventually grow into a nice Arduino library and command line tool.