457: Rubber Duck Phase Cancellation

Transcript from 457: Rubber Duck Phase Cancellation with Christopher White and Elecia White.

EW (00:00:01):

Hello and welcome to Embedded. I am Elecia White, alongside Christopher White. Today it is just us talking to each other, but we have a lot to talk about, including a lot of your questions.

CW (00:00:18):

Like?

EW (00:00:21):

Like...

CW (00:00:23):

If a duck quacks in a canyon, does it really not echo? Is that-

EW (00:00:28):

It actually does echo. But because of the frequency of the duck's quacks, it resonates at the same frequencies, which means the echo sounds just like the quack.

CW (00:00:39):

I think you just made that up.

EW (00:00:40):

I did not <laugh>. There is actually a paper about this.

CW (00:00:43):

Because echoes are time delayed. Right?

EW (00:00:45):

Right. But because of the way that the chasms usually...

CW (00:00:48):

Uh-huh?

EW (00:00:49):

Because of the chasms that get the echoes.

CW (00:00:51):

But- Do you think it is a phase cancellation thing?

EW (00:00:53):

It is definitely a phase cancellation-

CW (00:00:54):

Do you think it is a duck phase cancellation thing?

EW (00:00:56):

You are just trying for the title early, are you not?

CW (00:00:58):

If we get it out of the way early, then we can just stop.

EW (00:01:01):

Okay. Then yes, it is a "duck phase cancellation thingy."

CW (00:01:03):

Cool.

EW (00:01:06):

Okay. Well, that was all I had.

CW (00:01:09):

Cool. Well, we will see everybody in a couple of weeks. It is August, so they cannot really expect much from us.

EW (00:01:16):

Let us start with a question we had last time, from Guyrandy, in which he said, "I recall an episode where you talked about installing an antenna to your dad. How is that going?"

CW (00:01:33):

Did we not already cover this question?

EW (00:01:35):

We did, but a whole month has passed.

CW (00:01:39):

<laugh> "Duck phase cancellation thingy." Is that what you had? Okay. <laugh>

EW (00:01:45):

That is not going to be the title.

CW (00:01:46):

It is sure as hell is going to be the title. How is that going? Oh, it is interesting. My dad's hardware was delayed for a long time, because he ordered it assembled. He just got that, and he needs to get an antenna. I have not started assembling my radio, which is the same radio he got, but I chose to solder it. And since I am having slight amounts of trouble motivating myself to do things, I have not got started on that. But hopefully once I work up the energy, I can get that done in a couple days. So yeah, that project is taking a long time.

EW (00:02:21):

But you have been working on things.

CW (00:02:23):

Well, the longer problem is learning Morse code.

EW (00:02:26):

Okay. So you have learned almost all the letters at this point, except for like "X."

CW (00:02:31):

It is highly qualified. Yes. If you asked me-

EW (00:02:34):

But you told me X, Y, Y, Z?

CW (00:02:36):

No, Y Y Z.

EW (00:02:37):

Oh, I see. That does not have an X. Okay.

CW (00:02:40):

If you ask me a letter, I can probably tell you a letter.

EW (00:02:43):

But not if you ask for "X."

CW (00:02:45):

X I think is- Look, I will just look it up right now.

EW (00:02:47):

No, that does not count.

CW (00:02:49):

Anyway <laugh>, I have been using something called the Koch method, which a lot of people recommended. The idea is you learn them at kind of a high speed. So the letters- The letters can be transmitted at a speed, right?

EW (00:03:05):

Right.

CW (00:03:05):

The dots and the dits can come out at a certain speed. Per letter.

EW (00:03:11):

Di, di, dit. Di di dit. Yeah. Okay.

CW (00:03:13):

Yes, exactly. Right. And the number of- Obviously the faster the letters go, the more you can transmit in a given minute amount of time. So it tries to teach you a small amount of letters at a time, and builds them up. So the app I have starts out with two or three letters, like K and R and maybe-

EW (00:03:34):

Yeah, it was only a couple.

CW (00:03:35):

And you just do that for a while, at the full speed. It spits them out and you copy them down, and it says how many you got wrong.

EW (00:03:42):

But there are multiple speeds here. There is the letter, the di dah, speed.

CW (00:03:46):

Yes.

EW (00:03:46):

The inter-letter timing.

CW (00:03:50):

Those are the only two that are-

EW (00:03:51):

And the inter-word speed.

CW (00:03:52):

Inter-word timing is not controllable.

EW (00:03:54):

Not yet. Because you are not using words yet, because you are doing random things.

CW (00:03:57):

No, that is not a thing that is set anywhere, that I could find.

EW (00:03:59):

Oh, okay.

CW (00:04:01):

But the inter-letter spacing is controllable, and I made a mistake. So the first time I started learning it, I can turn that way down because it made everything easier. And I was learning the letters at full speed.

EW (00:04:11):

So you had something like, "Di di dit. Space. Space. Space. Di di dit."

CW (00:04:16):

Highly exaggerated.

EW (00:04:17):

Yes.

CW (00:04:19):

It was more 20% slower, than eight times slower. But yes, that is the idea. Mistake number one was doing that. I did not realize that was a mistake, until I turned that off and could not copy anything. It was just-

EW (00:04:34):

Because before you had, "Di di dit. Space. Space. Di di dit," and now you have "Di di dit. <pause> Di di dit."

CW (00:04:41):

No! If you turn off the spacing, the natural spacing that you are supposed to have between letters is so short that-

EW (00:04:48):

It is just "Di di dit. Di di dit." Not even that.

CW (00:04:51):

Say you had for the sake of argument, using the letters you have chosen, which are "S" and "S". Let us do-

EW (00:04:58):

It is only S so far. I was hoping to add an O at some point.

CW (00:05:00):

Let us do S and E.

EW (00:05:01):

Okay.

CW (00:05:01):

Sorry. S and I. I is di dit, and S is di di dit. So somebody might say "sit." Might be with the- It is called Farnsworth, the inter-letter spacing. So if you turn that up, it might be-

EW (00:05:15):

Farnsworth.

CW (00:05:15):

Di di dit, di dit, dah would be "sit."

EW (00:05:19):

Okay.

CW (00:05:20):

But if you turn the Farnsworth off and you start listening, it might be dididit didit dah. Actually, I am not even doing it fast enough. The way I have been hearing it in the app is dididitdidit dah. And so it almost sounds like those first two letters are squished together, which means it is ambiguous. Is that "S E"? Or is it "5"? "5" is five dits?

EW (00:05:40):

Or it could be two E's and an I.

CW (00:05:43):

Right. There is a little bit of inter-letter spacing. But if you have been making it expanded to learn, it is hard to train your brain to hear it, because it is a little fast. So I did that and collapsed. And then I asked some hams on Mastodon, and they said, "Oh yeah, do not use that."

(00:06:03):

Then turned down the speed, because the default speed I think a lot of people recommend is 20 words per minute letter speed, which is way too fast. So I turned down to 12. So now I am at 12, no quote Farnsworth spacing, no inter-letter exaggerated spacing. And started over from the beginning. I got to the point where that was okay. So I felt pretty good. But that was random letters. Random groups of letters. So the-

EW (00:06:28):

Which we thought was hard.

CW (00:06:30):

Naturally. Yes.

EW (00:06:31):

Because you are like, "Okay, these letters do not make sense. I am getting a T and then a Q and then a W. It just does not-

CW (00:06:37):

Right. There is no- You cannot predict the word that is coming, because it is not a word. So you figure, "Oh, when the words come, I will be able to get a sense for what is happening." But!

EW (00:06:47):

But.

CW (00:06:48):

Wrong. So the app I have was configurable to do random letters in groups of two to eight. So it would give you two letters, and then maybe three, and then maybe six, and then maybe four. And they would be spaced by word spacing. Fine. So I got through to the end with that, and was doing okay, like 90, 95% accuracy most of the time.

(00:07:07):

I switched to words. I went to a different app that just did the BBC news, and set the timings the same. Could not copy anything. The letters are coming out at the same speed. What went wrong? Do you have any idea what went wrong?

EW (00:07:26):

Well, I know it went wrong.

CW (00:07:27):

Oh, okay.

EW (00:07:27):

Because we have talked about it. What went wrong is as you suggested with "sit," that now you are using shorter letters all the time and it is easier to-

CW (00:07:37):

Exactly.

EW (00:07:39):

To get them confused. Because usually if you have less used letters, they are longer. But things like E are very short.

CW (00:07:47):

Longer or more complex. They may not be super longer, but they might be di di dah for U instead of di dit for E. And so common words are going to have E's next to I's, or A's next to E's. Short, short things like you are saying, with lots of maybe repeated small dits.

EW (00:08:10):

Well E is just a dit, right?

CW (00:08:11):

Yeah.

EW (00:08:11):

And T is just a dah.

CW (00:08:12):

Yeah.

EW (00:08:12):

And so if you think about SOS, the di di dit, dah dah dah, di di dit.

CW (00:08:16):

Yeah.

EW (00:08:18):

Is that SOS, or is that EEE TTT-

CW (00:08:21):

There is enough inter-letter spacing. That one is not hard.

EW (00:08:24):

But there should be.

CW (00:08:24):

That one is not hard.

EW (00:08:25):

Yes, that one is not too hard.

CW (00:08:26):

Because you are shifting between a big obvious group of dahs, and an obvious group of dits. But what about say, A which is di dah. "A" versus-

EW (00:08:36):

Oh, so that is just ET. <laugh>

CW (00:08:37):

Versus ET is a little bit ambiguous. So you got to- Yeah, it was really frustrating. Anyway, gone on about this for ten minutes <laugh>.

EW (00:08:46):

Welcome to Morse Today, to help you learn how to do your Morse encoding.

CW (00:08:51):

Anyway, I ran aground on that. It was very frustrating, realizing I was kind of back at square. So now I have changed the app. I found a way to have it give me common English words randomly. So I have been doing that. That has been a little bit better.

(00:09:03):

There are other things in the app, that give fake conversation stuff that you can transcribe. So I have been doing that a little bit, but it has been a long process. And you have to keep doing it, because it is not something you are going to remember forever. So if you take a few days off, you have to kind of crawl back up.

EW (00:09:23):

I do not think cognitive psychology things say that "crawl back up." It goes a lot faster, of course. And it is one of the best ways to learn. Is actually the intermittent learning is weirdly more effective than you would expect.

CW (00:09:36):

That is perfect for my attention span.

EW (00:09:37):

<laugh>

CW (00:09:40):

But yeah, <laugh> in my head, I can say any letter, I can very slowly copy. So I turn it way slow down, I can copy. So maybe I am trying to copy too fast at this point. I need to just accept that I am going to be at five or eight words per minute, or maybe ten if I am pushing it. So now I am trying bunch of different apps that give more actual words and things.

(00:10:07):

The other complication of Morse is a lot of stuff is abbreviated. This will not be an issue if I am just talking to my dad, because we are not going to use a lot of this stuff. But regular ham operators know all these Q codes and things, and these little two letter codes.

EW (00:10:22):

QC, QC.

CW (00:10:24):

Right. QC, QTH, whatever. DE. There are a whole bunch of them, because you do not want to be obviously hammering out long words if you do not have to. So there is a lot of shorthand stuff, and I do not know any of those right now, really. But it is just something learn.

EW (00:10:39):

That would mean talking to actual people. And I thought you would really just wanted to talk to your dad.

CW (00:10:43):

Well, I mean, you got to get practice somehow.

EW (00:10:44):

Fair.

CW (00:10:44):

And if I am transcribing stuff, either from radios for practice, without even talking to someone, just listening for practice, that stuff comes across a lot.

EW (00:10:57):

But you do understand that if I am ever trapped in space, or in a store with somebody talking to me, that I am not going to be able to remember Morse, and we are going to have to fall back to ASCII.

CW (00:11:06):

I do not know ASCII.

EW (00:11:08):

That is stunned silence, in case you were not sure.

CW (00:11:11):

Actually, 13 Hex is the dollar sign, I think. That is it. So you could send me dollar signs. Or maybe it is D.

EW (00:11:18):

40 is little A.

CW (00:11:20):

Yeah.

EW (00:11:21):

60 is big A.

CW (00:11:23):

Okay, so we can-

EW (00:11:23):

30 is all the number- 30 is zero.

CW (00:11:25):

Wait, that is Celsius. 40 is 96 degrees, and 60 is...

EW (00:11:30):

<laugh> Okay. But that is not the only thing you are learning.

CW (00:11:33):

It is not?

EW (00:11:34):

No. You have been taking this piano class that sounds terrifying to me.

CW (00:11:37):

Nobody wants to hear that.

EW (00:11:38):

It is like theory or something.

CW (00:11:40):

There is no theory in this class.

EW (00:11:42):

Oh, right. It was the last class was theory.

CW (00:11:44):

The last class was theory <laugh>.

EW (00:11:45):

This class is?

CW (00:11:46):

This is "Piano for songwriters."

EW (00:11:48):

Okay. And transposition.

CW (00:11:50):

Well, that is a part of the exercises. It is just a class.

EW (00:11:56):

Okay.

CW (00:11:56):

And I have to play live in front of people. That is the difficult part. So every week we have to learn a song, and perform it live in front of people, with singing.

EW (00:12:05):

And yet you never sing to me.

CW (00:12:06):

Somewhere on a hard drive. I am not going to sing with people. Somewhere on a hard drive-

EW (00:12:09):

Me!

CW (00:12:09):

In this house is about three hours of me practicing Taylor Swift's "Anti-hero."

EW (00:12:15):

And I still do not know where it is. I would share it with you if I did, I promise. Okay. Well, so you have not been entirely not doing anything.

CW (00:12:28):

<laugh>. Wow. High low praise? "Have not been entirely not doing"- Wait, I cannot even parse that. "Have not"- Wait, wait, wait. "Have not." That is one no, one negative. "Have not been entirely." "Entirely" is kind of a negative.

EW (00:12:41):

Have not, not been entirely.

CW (00:12:43):

"Have not, not been entirely." So that is two. So I have been doing things partially.

EW (00:12:47):

You have been doing things. You have been doing some things.

CW (00:12:48):

I have been doing partial things.

EW (00:12:50):

You- Okay. To be fair, you said to me very recently, "I have not done anything."

CW (00:12:54):

Well, that was true. I had not done anything that day.

EW (00:12:57):

That was like today and yesterday and the day before. You have said that.

CW (00:13:01):

No, no. Yesterday-

EW (00:13:02):

But that is not true.

CW (00:13:02):

No, no. Yesterday I did a bunch of stuff.

EW (00:13:04):

Okay, okay. But-

CW (00:13:05):

<laugh>

EW (00:13:05):

You are currently not fully employed.

CW (00:13:10):

I am very, very partially employed <laugh>. I am homeopathically employed at this point <laugh>.

EW (00:13:18):

But you did a good job on the newsletter this week. Not that anybody listening can find it now.

CW (00:13:24):

Although I apologize for not putting a link to the larger images, or the blog post. You can find those things on our site quite easily, by searching.

EW (00:13:33):

Anyway, he did a newsletter post that was all about the Kalman filter.

CW (00:13:36):

Uh-huh <affirmative>. Sensor fusion.

EW (00:13:38):

And where you can go to find various versions.

CW (00:13:41):

Ah, tutorials mostly. Different. Too many versions of the filter itself. A few implementations. Yes. I have been helping someone out, with their desire to have sensor fusion working on a device they are working on.

EW (00:13:59):

And because you are curious, you are spending some of your podcast time not charging them.

CW (00:14:05):

Yeah. Spending extra time reading about it, off the book, because it was interesting. So yeah, that has been interesting. Wow, how many times can I say "interesting"?

EW (00:14:15):

At least five more.

CW (00:14:17):

And then what happens <laugh>?

EW (00:14:18):

Who knows?

CW (00:14:19):

A guillotine falls on me? Yeah, no, it is a cool topic. Coming from a physics background, I tend to look at these things and go, "Oh, this should be easy." And then it is like, "Oh no, this is just like all that stuff I had to do." It is not that hard, but you do have to find the right introduction, I think. Because most of the easiest to find introductions, tend to be textbookish with lots of just, "Here is an equation, and here is a recurrence relation, and this does this." And it is like, "This does not make any sense."

(00:14:52):

I found some better tutorials that baby steps walk up the conceptual grounding of it, which still is hard to understand, because it is a little bit inside out backwards, the way things are expressed. I feel like I kind of understand the theory behind it, now. I could not implement one without a reference manual. Not that many people could.

(00:15:17):

The hard part with the whole sensor fusion thing with IMUs is the quaternion stuff. And that is just...

EW (00:15:25):

And that really is not part of the Kalman. Although, it is part of the IMU-

CW (00:15:30):

No, it is not. You do not need to use quaternions to have sensor fusion. But fixes a lot of stuff if you are doing a lot of rotation and full 360 rotations and things.

EW (00:15:40):

Well, and that is the problem. That is why you need to have them, is you have 360 to zero and it is a discontinuity. And if you want to talk about angular rate, which is the speed at which you are turning around, if you have the 360 to zero, you have a discontinuity. And then you cannot integrate over it, and it is all blah, blah, blah.

CW (00:15:56):

Yeah, but, I still do not fully get that stuff. Because you do have to translate it back to Euler angles afterward. Which is just-

EW (00:16:05):

After you integrate.

CW (00:16:06):

After you integrate.

EW (00:16:07):

After you do anything interesting. Anything that requires you to have a continuous function.

CW (00:16:13):

Okay. So...

EW (00:16:16):

So if you want to integrate for position-

CW (00:16:17):

What if I just want a wheel with a light on, to stay at the top. Just to pull an example out of my head. I want the light to stay on top of the wheel rotates. It is a bunch of LEDs around the rim of a wheel, and the one-

EW (00:16:30):

Okay, you are on a bike, and you want the light to always be at the top of where the bike is.

CW (00:16:36):

Yeah. So I do my Kalman filter, and it spits out the quaternions from the sensor fusion. And now I have got a four component vector that nobody understands.

EW (00:16:46):

The quaternions are just- Nobody looks at them and says, "Oh, I know what that is."

CW (00:16:50):

So naively I just take that, and convert it to Euler angles.

EW (00:16:54):

Cool.

CW (00:16:56):

Do I have any problems? Or is there some- You said there was an integration step?

EW (00:17:00):

Well, it depends on-

CW (00:17:01):

Sorry, listeners. We are just going to have a conversation now.

EW (00:17:04):

We actually meant to have this conversation before the show, and then we forgot.

CW (00:17:07):

<laugh>

EW (00:17:07):

So part of the Kalman involves figuring out- You estimate what your next position is going to be.

CW (00:17:17):

Yeah.

EW (00:17:17):

And in order to estimate what your next position is going to be, it often is an integration step.

CW (00:17:24):

Oh! Mmmmmm. Yes. You get the equations of motion and then you- Yes. Sure.

EW (00:17:29):

Right.

CW (00:17:29):

Because maybe you have acceleration or velocity, you do not have absolute- Gotcha. Mm-hmm. Okay. Agreed.

EW (00:17:38):

And so that step has to be done with the quaternions.

CW (00:17:40):

Oh, okay.

EW (00:17:42):

And that is why the quaternions end up in the Kalman filter, because the Kalman filter has to do the estimation.

CW (00:17:46):

Got it.

EW (00:17:47):

Which requires an integration step for the equations of motion.

CW (00:17:51):

So your sensor fusion- There are things you have to set up for the Kalman filter. You do not just buy a Kalman filter at a store in a box, and then glue it to your IMU. It is just math.

EW (00:18:01):

Right. So much math.

CW (00:18:03):

It has to be set up. And since it is predicting things, you have to write the equations of motion for the thing that is- Or whatever. The equations of prediction, let us say. What relates the measurements and the predictions in time? And usually for equations of motion, that is physics stuff like Newton's method or Runge–Kutta, whatever.

EW (00:18:26):

Those are ways of solving-

CW (00:18:28):

Differential equations.

EW (00:18:29):

Yes. But the equations of motion are just F equals m a, and one half v t...

CW (00:18:37):

No, you do not have F equals m a. You have- Well, okay, maybe you kind of do in one place, but this is- Even just as simple as-

EW (00:18:45):

But it is x equals-

CW (00:18:46):

Yeah, v t.

EW (00:18:47):

x naught plus v t.

CW (00:18:48):

Yeah, that exactly.

EW (00:18:50):

v t? One half v t?

CW (00:18:52):

No, just v t.

EW (00:18:52):

One half a t squared.

CW (00:18:54):

Yes. Because that is integrating v t.

EW (00:18:57):

Right.

CW (00:18:57):

Anyhow, so that stuff you have to build, and put into the Kalman filter as the prediction stuff. And there is another part. But yeah, that is the stuff you have to set up. And that can be complicated.

EW (00:19:10):

And that is the part that needs to be in the quaternion, because you do not want the discontinuity.

CW (00:19:15):

All right. Yeah. We are all on the same page here. But that means you do not have to mess with the quaternions, except in that setup part where you are writing the code that does the Kalman filter for your particular application. Once you have done that, it will spit out a quaternion, and then you just throw it at some trig that you can buy at the store. And then it will give you the regular axis of rotation.

EW (00:19:38):

Theoretically, as long as you are using one version of quaternions versus another, and you are consistent-

CW (00:19:43):

What! What? There is more than one version of quaternion?

EW (00:19:45):

Do not go down that-

CW (00:19:46):

Are there quinternions?

EW (00:19:48):

I assume so. I mean, you can have a four axis system with discontinuities. So in order to make it not have discontinuities, you put it into five, and then you would have a-

CW (00:19:58):

I have real mathematical problems with quaternions. Because it is i j- So it is this four part thing. It is i j and k. And i is your friendly i that everyone knows, that is i squared equals minus one. But apparently so is j and k. j squared equals minus one. k squared equals minus one. And i j times k equals minus one. So I mean, those are all the same thing.

EW (00:20:20):

Did I not give you a large book called "Rotations and Quaternions" and such things?

CW (00:20:26):

Yeah, I had to put it under a chair leg.

EW (00:20:28):

Yeah, that is what I have always used it for.

CW (00:20:31):

I do not want to learn that.

EW (00:20:33):

It is funny, because I thought it would be so much easier for you, because you have got the physics background.

CW (00:20:37):

No, I hate the projection stuff. That was so hard. I did that without quaternions. We did all that stuff in Euler angles and stuff. I do not think we ever touched on quaternions. And that was hard enough. Because you have got these transformations that- Anyway, let us get off this topic before I...

EW (00:20:53):

Okay. Self-promotion? I have the second edition of my O'Reilly "Making Embedded Systems" is coming out. Late fall is the prediction.

CW (00:21:04):

Of?

EW (00:21:05):

2023.

CW (00:21:05):

Yeah!

EW (00:21:05):

Thank you. It is currently on the O'Reilly Learning System, so you can get a preview. I think right now we have six, seven, eight chapters. I am not sure. One of them is the new chapter about interrupts. And one of the them is the greatly expanded chapter about how to set up your system, which used to be all state machines, and now talks about main loops, and all kinds of stuff.

(00:21:34):

And if I was not a slacker today, I would have finished the chapter either about debugging, or at least a major section of the chapter about the Internet of things. Man, I need a better title. It is "IoT and Network Sensors" is the title of that chapter. But I still hate that.

CW (00:21:55):

I think you should take this opportunity to destroy that acronym, and come up with one of your own.

EW (00:22:00):

Well, but then I cannot have the joke that the Ss is in IOT is for security, which I may put in the book. I have not quite decided.

CW (00:22:09):

Hang on. "Network of stuff."

EW (00:22:11):

"Network of things you do not need." How about "distributed sensors"? I have heard that was a term, in like 1968.

CW (00:22:19):

It sounds to me like you have greatly expanded the original book.

EW (00:22:23):

I have expanded the book more than O'Reilly expected <laugh>.

CW (00:22:27):

How many brand new chapters are there?

EW (00:22:30):

Well, it is a hard question, because interrupts actually had a small part in the state machines chapter. But it got massively expanded.

CW (00:22:39):

It is fair to call it a new chapter. So how many brand new chapters are in- It originally had eleven?

EW (00:22:44):

Originally had ten. Brand new chapters are interrupts. That came out of a couple other chapters. Updating code is becoming network of things.

CW (00:23:00):

Network of stuff.

EW (00:23:04):

<laugh> I put in a little section in the memory maps chapter, that I was not going to change much, the resource constraints chapter. I was just like, "Okay, talk about hard faults, because at this point they have seen the memory map and they are ready to talk about hard faults."

(00:23:17):

That became an entirely new chapter about debugging in which, hilariously to me, I do not know what the readers are going to think, but I talk about how to cause hard faults. It means that instead of trying to walk somebody through something when they are having a problem, I can talk about them as fun things you can do. And that has really made a lot of difference for the ease of writing.

(00:23:43):

Then I plan on adding a new chapter about motors at the very end. So after power consumption, it is not going to be very long, but I had a section about PID that did not fit, and I do not want to cut that. And I do want to talk more about FETs and actuators and power, and how not to blow your board up. It is mostly going to be how not to blow your board up.

CW (00:24:08):

So this is at least 30% larger?

EW (00:24:13):

Yeah, we are headed that way. Yeah. 30%.

CW (00:24:15):

It is pretty good. It is a solid second edition. It is not a fix errata, and add a new chapter about some hot topic.

EW (00:24:24):

Embedded Linux.

CW (00:24:25):

Yeah.

EW (00:24:27):

No, it is. Some of it came out of stuff I have talked about over the years. Some of it came out of Classpert, and things people had questions about. Every chapter still has an interview question, so you get three new interview questions. Although I think, yeah, one of them is not interview questions, it is what not to ask. Which I start out with a joke. The interrupting cow joke.

CW (00:24:53):

Wait. Do not give it away.

EW (00:24:54):

Okay. I mean, they have heard the interrupting cow joke. If you have not, go back to Svec's episode.

CW (00:25:00):

Make them work for it.

EW (00:25:04):

Yeah, it is more work than I expected <laugh>. I had a plan. I am not sticking to it. I had an editor that did not work with my style. And now I have an editor who works very well with my style, and we are having a good time. My pre-reader, my technical reviewers are fantastic.

(00:25:31):

Mostly I am having a good time, except for days like this, where I look at it and go, "I do not know words. Words? Words go here? Words, words." But some days they are like that. I did actually make a diagram today, which as you know, is worth at least a thousand words. Although in its current sketchy pencil version, it is probably worth more about four words.

CW (00:25:52):

Cool. And you said it will be done in fall-ish. Does that mean there will be paper published copies in fall?

EW (00:26:00):

Yeah, that is when the paper copies come out.

CW (00:26:02):

Wow. Okay. You know it is August 15th?

EW (00:26:05):

I am a little worried about that, but I actually do not mind if they push it out to January or February.

CW (00:26:10):

I mean, it is August 17th.

EW (00:26:13):

Let us see. Classpert is getting ready to have another cohort, but this one is going to be fully asynchronous. That means you are going through the class with other people, watching the videos, talking about homeworks. And there will be discussions on a Discord and mentors to help you. I will be around on Discord, but there will not be live classes. You do get to watch some of the old live classes. Only the best bits, so you do not have to sit through some of my worst jokes.

(00:26:44):

It will be cheaper. I think it is 599 now. Was on presale, but I think it is 599. Which is still pretty expensive. If you have a hardship case, I am such a sucker, so email me and we will figure that out. But if you can get your employer to pay for it, super duper. Ah, and I should know when that starts. Ooh. Oh, August, September 18th. It starts September 18th. It cannot start August 18th, because we are not ready <laugh>.

CW (00:27:15):

It is Friday.

EW (00:27:16):

Yeah. No, it is September.

CW (00:27:18):

Or tomorrow.

EW (00:27:19):

Depends on when we are recording this.

CW (00:27:21):

I do not know when we are recording this.

EW (00:27:24):

Okay, one more thing for me to blather about is I have a new origami class that I am taking. It is a YouTube class and it is online. It is by a guy named Boice who teaches you how to read crease patterns, which is the area that I am now looking into.

CW (00:27:46):

Crease patterns? Is this for like- No, this is not the crunchy crumbly.

EW (00:27:51):

No, this is not crumple. I know you like the crumples. No, this is when you have- Usually it is for more box folding, which is a style of folding that I do not really do. When you have complicated patterns that just come in black and white. Usually there is one set of dashed lines and one set of thick lines. You are supposed to fold all of the dash lines one way and all the thick lines the other way, and then you are just magically supposed to collapse it and it works.

(00:28:24):

I did not understand that there are actually methods to how you collapse it. It is not just hope and pray. It is like, "You start at this corner. You identify the important corner by these criteria. Here are some standard things you do, and how you identify them." It has been really interesting from a mathematical point of view. It is not super like, "Here is math," but it is more of a "Here are some functions you apply to paper and how to read them." I do not know. I went out looking for a new origami paper class, and ended up...

CW (00:29:01):

Just watching YouTube.

EW (00:29:02):

Watching YouTube.

CW (00:29:03):

Finding a YouTube thing.

EW (00:29:04):

Yeah.

CW (00:29:04):

Yeah. It says here that Supercon is November 3rd to 5th in Pasadena, California. I believe that a lot of tickets are going quickly or something, from people I see. We will not be there.

EW (00:29:20):

We will not be there, but it looks like fun. I think we will have a designee to give out Embedded stickers. So anybody who is going and wants a sticker, all you have to do is find the person who is giving them out.

CW (00:29:33):

<laugh>

EW (00:29:33):

I suggest walking around and saying, "Do you have the Embedded stickers?" to everyone you meet. And then forming some sort of mob, and then when you find the person, mobbing them.

CW (00:29:44):

Okay. All right <laugh>.

EW (00:29:46):

It is not a good plan.

CW (00:29:47):

Yeah.

EW (00:29:49):

Okay. I have a question that has been on my list for a long time. I asked it in our Patreon Slack, and I got some really interesting answers. I am going to start slow. Pseudocode. How do you define pseudocode? What is pseudocode to you?

CW (00:30:07):

I know we had this conversation, so I am going to probably lean back on things I have already talked about. Are you asking me to answer?

EW (00:30:13):

I am asking you to answer it now, as though you and I had only just met today.

CW (00:30:18):

Pseudocode, in my definition, is code for illustrative purposes, in say a tutorial or a book, that simplifies syntax so it is easily readable. And also is not for any real language or device.

EW (00:30:38):

So it is somewhere between text and code. It is not-

CW (00:30:42):

Ideally.

EW (00:30:42):

Syntactically interesting, but it attempts to tell the semantic definition of what you plan on doing.

CW (00:30:51):

Yes.

EW (00:30:52):

How often do you write pseudocode?

CW (00:30:56):

Nah. I cannot even remember any time I have. I might have done it in school for some things, for some papers.

EW (00:31:06):

You mean like 30 years ago?

CW (00:31:07):

Okay. That is it.

EW (00:31:12):

<laugh> Sorry.

CW (00:31:13):

Not quite 30 years ago yet!

EW (00:31:15):

Yet <laugh>.

CW (00:31:16):

Some parts of school. Yeah, something like that. I do not think I have done it professionally, except maybe in a document or two, or in a comment. Sometimes in a comment, you end up with something that is pseudocode-like. Because either you have written something too- Is a complex algorithm, or there is some optimization in there that makes it hard to read. So I think maybe I have done that a couple times, but it is not common that I have done that.

EW (00:31:44):

So the Kalman filter that you are looking at. You are going to go from- Ideally you are just going to grab a library. But let us say you are not going to grab a library for some reason. Let us just pretend.

CW (00:31:55):

All right. Yeah.

EW (00:31:58):

You would not take the Kalman steps that you need to do, and write them out in pseudocode, and then fill them in?

CW (00:32:07):

No. Because the math is close enough. It is all recurrence relations and things. I mean, that is already code. There are pieces of stuff you will need, like matrix multiplication and matrix inversion, and things that will have to be built to accomplish that. But all those operations are in the math. And if you do not understand the math well enough to implement straight from the math, not sure that rewriting it in a different way would help that much, for that particular application.

EW (00:32:32):

But you do not write, "Setting up the state estimation to use quaternions due to discontinuity"?

CW (00:32:43):

I might put that in a comment.

EW (00:32:45):

Right. But you do not write it before you write the code.

CW (00:32:48):

Not in pseudocode. If I was taking notes about the procedure, it would be math and prose, which I do not consider pseudocode.

EW (00:32:56):

What is the difference?

CW (00:32:57):

Pseudocode looks like code. If you look at it, you go, "What language is this? Because I do not know this language."

EW (00:33:03):

It does not just look like prose that is weirdly formatted?

CW (00:33:08):

I do not think so. And there are a lot of often "for loops." I have seen pseudocode-

EW (00:33:11):

Yeah, I would put "for loops" in my-

CW (00:33:13):

Yeah. See, so you are starting-

EW (00:33:14):

And "ifs."

CW (00:33:14):

To put code-ish things in there. And instead of "if," if you were doing it in prose, you would do, "check if-" You would have- What is the word I am looking for?

EW (00:33:29):

Conditionals?

CW (00:33:31):

Not conditionals. Like commands. Things to tell somebody to do.

EW (00:33:34):

Right.

CW (00:33:34):

You do not tell a computer, "Check if this equals this." You just say "if." You do not write sentences. I think pseudocode is- It is compact like code, but I am not sure it is- Pseudocode seems mostly useful in cases where you are trying to convey a computer programming topic, but you are not sure what language somebody might be using.

EW (00:33:56):

So the reason this came up, and the reason I am talking about it, is because I use pseudocode all the time. Like all the time. I use it in my book, which is here nor there. That is what you are saying about it, is you use it when you do not really care what the person is actually writing in.

CW (00:34:16):

But I am working on a simulator for the robotic system I am working on. The simulator basically is the pseudocode. And then I take that and I made all of those printf's and then I made them call functions, because a simulator does not do anything. It just tells you what it would do, if only it could do something. As we go on, the simulator will gain functionality, but those printf's will stay there. But those printf's all started out with a list of what I wanted to have happen.

(00:34:47):

Sure. I think we are just quibbling over what the definition of "pseudocode" is.

EW (00:34:52):

For me, that was totally pseudocode. It was a list of things I wanted to have happen. A lot of times there were not spaces between words. Sometimes there were open parens, closed parens-

CW (00:35:04):

Okay. That is fine. I am not the pseudocode police, if you want to call that pseudocode. It is just not what I consider pseudocode.

EW (00:35:10):

Okay. It sounds like what you said, though.

CW (00:35:14):

Yeah, it is probably is. I would have to look at it to say if I- But who cares?

EW (00:35:18):

Okay.

CW (00:35:20):

Yeah. I get you get what you are saying. It is instead of writing out a long paragraph about how something works, you have kind of broken into a series of steps and things. I guess that is pseudocode. Sure. The only thing is I feel like pseudocode looks like a computer language, more than a list of just steps.

EW (00:35:43):

My steps had, like I said, they were camel case and not English. This came about because I had a really good experience when someone brought me a problem, and instead of actually figuring out what the problem was- I kind of knew. But instead of figuring out what the problem was, I knew they had enough time to debug it.

(00:36:03):

So I said, "Why do you not write down comments for what it is you want this piece of code to do?" Basically I wanted them to write pseudocode for what they wanted this piece of code to do. And I knew, and as happened, when they wrote that out, they could see the bug themselves. And so I use pseudocode both for design and for debugging.

CW (00:36:28):

Yeah. Maybe I use it more. I would have to look through my notebooks. Yeah, I think certainly I have written out little procedures and things.

EW (00:36:36):

I write out stuff before coding it a lot, unless I really know it well.

CW (00:36:40):

Oh, yeah. I am just not sure if I ever considered it pseudocode before.

EW (00:36:45):

Do you have another name for it?

CW (00:36:46):

No.

EW (00:36:46):

Other than just "notes"?

CW (00:36:47):

<laugh>

EW (00:36:47):

I mean "notes" is fine.

CW (00:36:51):

"Algorithm." Write the algorithm out, something like that. Yeah. I do not know that the language matters that much.

EW (00:37:00):

Okay. So you are saying we agree, we just have different terms for our-

CW (00:37:04):

Well, I do not know. I would have to look at what I do. I have not broken something down like that in a while. Is there somebody who is saying that pseudocode is something else?

EW (00:37:16):

I was just really surprised when I asked folks about using pseudocode, and everybody said, "No, I never do."

CW (00:37:22):

Oh, okay.

EW (00:37:23):

And I was like, "But I use it all the time. One of us is wrong. And I am pretty sure-" Wait, no. I just did not understand how people were not using what I consider this amazing...

CW (00:37:36):

Certainly I think jumping straight into code, and trying to do things is often a mistake."

EW (00:37:41):

Design by typing?

CW (00:37:43):

Yeah. Mistake. Whether you want to call it "pseudocode" or "planning" or- There is probably a continuum between stuff that looks like pseudocode, and stuff that looks like an essay, but that is all the same stuff. And doing that ahead of time is, like you said, "Very instructive."

(00:37:59):

It was like, "Hey, well it is kind of like rubber duck debugging." Debugging? Debucking? Rubber duck phase cancellation.

EW (00:38:06):

<laugh>

CW (00:38:06):

"Rubber duck debugging" where you explain something to someone else, even if the someone else is not real. Because the process of getting into the explain mode of your brain, often forces you to notice things you would not otherwise notice. And I think that is the same thing. Writing out how does the code work, not in C, not in Python, not in whatever people use, is the same kind of mechanism.

EW (00:38:33):

And it is useful for both planning and debugging. Because there are so many times the bug is really- The code does exactly what you told it to. It just was not what you wanted it to.

CW (00:38:43):

I told the code to smash the stack.

EW (00:38:46):

<laugh> Smash! Ah, okay. So now we have some more listener questions. Oh wait, no, no, no. I have other questions for you. We are never going to get to these listener questions. I am so sorry.

CW (00:38:57):

That is fine.

EW (00:39:00):

You had-

CW (00:39:02):

What did I do?

EW (00:39:03):

Last week-

CW (00:39:04):

Oh no.

EW (00:39:05):

You needed to write what was going to be a very standard, boring email. You were not quite sure how to phrase some of the things. And I said, "Well, why do not you just use ChatGPT to write-"

CW (00:39:16):

Why are you doing this?

EW (00:39:18):

And that is the response. Tell me about that response.

CW (00:39:22):

Do you really want to talk about ChatGPT? Because I have feelings.

EW (00:39:25):

I know you have feelings, but it is funny because they are not the same feelings we had three or four or five episodes of just us talking.

CW (00:39:32):

Are you sure? Because I remember an entire episode where I spent most of the episode making fun of it and thinking it was stupid.

EW (00:39:39):

But you also did spend part of the episode being ChatGPT's interface talking to me.

CW (00:39:46):

Yes. That was my way of mocking it.

EW (00:39:48):

Right. But that was fun. Now you are beyond fun and into-

CW (00:39:54):

I- Hmm.

EW (00:39:55):

Yes, into Grover hmmms.

CW (00:39:57):

I think it is overhyped. At the same time, I think it is being misused. I think it does not work as well as people have thought it has, because of some psychological things where it convinces people it is talking like a human. And it is very hard to get your brain to not be sympathetic to the imaginary computer.

EW (00:40:25):

And it apologizes all the time. How can you keep kicking it?

CW (00:40:28):

I think despite the fact that I used it to write some code, I have further thought about it, and realized it probably did not save me any time. Because the extra time that I did not include where I had to edit what it did, and tell it it had done it wrong, and think about how it had done it wrong. So even though it was maybe a slightly more pleasant procedure interacting with an imaginary rubber duck, I probably could have done it myself with looking stuff up and figuring it out. So that is one aspect.

(00:40:58):

People are going to disagree a lot with me, but that is fine. I also do not like the people who are behind it. I do not like how it was generated. There are a lot of questions I have about how things are being trained, including where it is coming from, what kind of bias it has in it.

(00:41:14):

The more I have used it and learned about it, the more I realize it is extremely- It feels limited. The more I have used it, the less novel things come out of it, because it cannot make novel things. It can only synthesize what it has been trained on, and repeat what it thinks is going to come next.

(00:41:37):

What bothers me the most is the people behind it are a little bit icky. And the people using it and jamming into things are not doing any thinking ahead about what it means and what it is actually doing. Like Google has started putting the top result- The top result is usually a summary generated by their large language model, of a common result.

EW (00:42:09):

Like the age of the universe? Is that one of them?

CW (00:42:11):

Yes. There have been several now, where you can ask at the age of the universe, and it will give you a totally bogus answer from a crackpot physicist, because that was the top search result and it just summarized it. And it gives it authoritatively. It says, "The age of the universe is" whatever it was, 60 billion years, which is not correct.

(00:42:26):

Another funny example was- What was it? Something about a goose?

EW (00:42:35):

Gooses kill people?

CW (00:42:36):

How dangerous is a goose? The top result was, "Goose can kill hundreds of people at a time, incinerating them" or something. It was summarizing a popular forum post on a news article that was somebody's joke. But it truncated it and left out the part where the guy made it clear it was a joke. And it just took as the authoritative answer, that geese are actually weapons of mass destruction. There was another one the other day too.

(00:43:03):

But anyway, this is the kind of thing that- Everything is getting slowly ruined, but in a fun way. And that bugs the hell out of me.

EW (00:43:15):

I do not know how I feel about it. I admit that there are times that I will look around the internet and not find what I want, but know that it is there. Usually it involves VSCode in some JSON format <laugh>. It does okay on those, but I have never been super amused by it. You were amused by it for a little while.

CW (00:43:38):

Yeah, and I think that people are amused by it. There was another article too that came out recently where somebody- I do not know if it was a formal study or something, but it was an investigation of how accurate its code work was. It was basically wrong 60%, 50% of the time in some significant way.

(00:43:59):

Which, like we said in the past, if you know what you are doing, that is correctable, but how long does that persist? How long until that poisons education in such a way that people do not know that things are wrong. Or maybe it makes a subtle mistake you did not catch and you are just taking it.

EW (00:44:19):

That is my fear.

CW (00:44:22):

With the things you are talking about, I think there are great uses for large language models, that are trained on focused data sets. So the stuff you are talking about, "How do I format this JSON for this particular configuration?" That is great. You know, find a training set that is freely available, where you can train on a whole corpus of configuration files for difficult things, or something like that.

(00:44:44):

But do not include copyrighted novels, and things you scraped from Twitter, and Reddit posts in scary forums about stuff, that is going to- The idea of just throwing the entire body of texts that is on the internet into a model, and seeing what happens. Then having some stuff appear to be useful, and some stuff appear to be maybe not useful. And we are not sure what this does. That is just weird.

(00:45:14):

And there is a whole other aspect of, "Oh, this is an intelligence." Those people drive me nuts. It is a statistical machines, and it is going to spit out what you put into it. So far we put the internet into it, and I do not know a lot of people who think the entirety of the internet is all that great.

EW (00:45:34):

I hope that we do get some more limited data sets, that can direct the knowledge in a way that is trustworthy. The lack of it being trustworthy is-

CW (00:45:49):

I do not think that is fixable. There are several large language model researchers who said, "This is just how they work."

EW (00:45:56):

No, but like my VSCode thing.

CW (00:45:59):

Oh, yeah.

EW (00:45:59):

If you trained one on a lot of embedded systems, like all of embedded.com, and my book if it was copyright free, and all of the forums for the Nordic and ST.

CW (00:46:15):

But, yeah.

EW (00:46:17):

You probably could get to something that was reasonably correct for most microcontrollers.

CW (00:46:24):

That is the thing, is "reasonably correct." My understanding, and I am not an expert in these things, I have read researchers on this who said "The hallucination problem is baked into the architecture."

EW (00:46:36):

Yeah. We talked to a professor a while back about how the hallucination problem-Because it does not have any way to tell if it is-

CW (00:46:44):

It does not know right or wrong.

EW (00:46:46):

Yeah. It knows it does not know truth or fiction.

CW (00:46:49):

Yeah. It knows this is common.

EW (00:46:51):

Yeah. And even then, when you have edges...

CW (00:46:57):

And there is a stochastic aspect of these, right? If you run the same input, it is not going to give you the same output every time, by design. Because there is that random element in DNNs. So some period of time it is going to give good answers, but some period they will not, just because it has got to explore that whole space. Anyhow.

(00:47:23):

Those are my feelings. I have not been using it at all recently. Although I did hear that OpenAI is losing a ton of money every time somebody uses it. So I have considered using it a lot now.

EW (00:47:34):

Just to punish them.

CW (00:47:36):

It is like 30 cents a query.

EW (00:47:38):

Yes, I saw something like that. Okay. I have one more question for you that probably will take all of our available time.

CW (00:47:48):

God, is this just Christopher Rants Day?

EW (00:47:51):

Oh yeah.

CW (00:47:52):

What have I done?

EW (00:47:54):

Now I know that the solution to this problem involves a small demon, who sits inside of a box.

CW (00:48:04):

Oh, I am not explaining heat pumps.

EW (00:48:06):

It says right here, "How do heat pumps work?" You agreed to this.

CW (00:48:10):

No, I did not prepare for this. I cannot explain it.

EW (00:48:13):

You explained it to me.

CW (00:48:15):

Ah, <laugh> I cannot explain- It is too hard. The thermodynamics escape me. I still do not really understand it. Heat pumps take heat from one place and move it to another place. And by doing so, they can be much more efficient than generating heat in the destination location.

(00:48:31):

So my stupid explanation for how heat pump works, and how it can move many kilowatt hours of heat from one place to another by using a fraction of a kilowatt hour, is imagine you had a glowing molten nickel ball the size of a bowling ball in a box, and you picked up that box and you moved it somewhere else, and opened it up in the box in the new room. It did not take you number of kilowatt hours of the glowing hot ball to heat up that room. All it took was the energy for you to pick it up and move it, presumably incinerating your arms in the process. That is my concept of how they work.

(00:49:12):

How they actually work involves the box being refrigerant that is compressed and expanded, and lots of complicated thermodynamics things that-

EW (00:49:22):

Maxwell's demon.

CW (00:49:23):

No, Maxwell's demon had a little- Had like tweezers.

EW (00:49:26):

Right.

CW (00:49:26):

And he was tweezing. This does not tweeze.

EW (00:49:29):

Pretty sure it does.

CW (00:49:30):

Anyway, this came up because we have installed some heat pump based things in our house. It is still fascinating, because they are extremely efficient. The heat is being generated by the environment or the sun. It is not cheating. Something is generating the energy. It is just it is already there for the taking.

EW (00:49:51):

And you are just moving it. You are not generating it. And that is why they are more efficient.

CW (00:49:54):

Yeah.

EW (00:49:54):

Well that did not take nearly as long as I expected.

CW (00:49:58):

That is probably because I did a very bad job.

EW (00:50:00):

Well, you did not go into the detail I have previously heard.

CW (00:50:02):

If you want me to talk about the Carnot cycle and adiabatic expansion and heating, and words that I used to know what they meant. I cannot speak to those things.

EW (00:50:14):

Cool.

CW (00:50:16):

But most people have at least one heat pump in their house. That is how refrigerators work.

EW (00:50:21):

Okay. Do you want to talk about portable code or compilers and linkers?

CW (00:50:27):

I feel like portable code might set me off into a pointless rant, because, yeah. What was the other one? Compilers and linkers. I do not think we should talk about compilers and linkers right now. Yeah, no, that will take another hour.

EW (00:50:41):

Okay. So what is portable code? William asks.

CW (00:50:46):

Portable code is code that can be...

EW (00:50:49):

Drunk?

CW (00:50:51):

That is potable code.

EW (00:50:52):

Potable code. You can drink it. It is okay.

CW (00:50:55):

<laugh> Portable code. Portable code is code that- Well there is not a strict definition. Some people think portable code is code that can be recompiled for a different architecture than it was originally written on or for, and it will run there on the new architecture.

(00:51:16):

Some people might say portable code is an executable that can be taken from one platform to a different platform, and it will still run. Some people might say it is interpretable code that can be taken from. So which- Those are all fine definitions.

EW (00:51:34):

The first one. The first one, where you have to recompile it.

CW (00:51:37):

Okay. Because a lot of portable code exists that does not have to be recompiled. That is the entirety of Java, and a lot of things like Electron, and-

EW (00:51:47):

Electron?

CW (00:51:47):

Python. Electron. A lot of apps you use is built on Electron. The Slack app is built on Electron. VSCode is built on Electron. Electron is, as I understand it, a JavaScript engine combined with something else.

EW (00:52:03):

Okay. Sorry. Particle.io had different...

CW (00:52:08):

No, not that one.

EW (00:52:09):

Particles. And I thought maybe there might be an electron board and I was very confused.

CW (00:52:13):

<laugh> Yes. VSCode runs on particle.io.

EW (00:52:15):

No, it does not.

CW (00:52:17):

Yeah, Electron is a free and open source framework from the Open JavaScript Foundation. It came out of the Chromium, so it uses Node.js which is a way to run JavaScript as an application on your computer.

EW (00:52:30):

So, okay. I want to go back to you recompile, because-

CW (00:52:33):

Yeah, so we are picking recompile. So, okay, that is portable code. What is the next question?

EW (00:52:40):

Does it really exist? Yes.

CW (00:52:43):

Sure. I have written it.

EW (00:52:45):

Yes. Is all code portable with enough effort? No.

CW (00:52:51):

I think yes, with enough effort. Because with enough effort, you just rewrite the entire thing.

EW (00:52:55):

And have an if statement.

CW (00:52:56):

And you leave some of the comments in. Because those are probably fine.

EW (00:52:59):

I am not sure.

CW (00:53:01):

Yes, in the degenerate case, all code is portable with enough effort.

EW (00:53:06):

So if you want to think about portable code, go to a big code base like Zephyr or MicroPython, or even like STM32's CMSIS build.

CW (00:53:26):

Okay. Yeah, finish this thought, but I will come back.

EW (00:53:29):

All of those things can be compiled for different processors, and a lot of times it is with #defs, which we will have to discuss whether that makes stuff more portable or less. But in the end, one of the things that I would encourage folks to look at, is the structure of the code. Because you have these layers.

(00:53:53):

You have a very top layer, you have a middle layer, you get down to a hardware abstraction layer, that goes down into a processor abstraction layer, and it just layers and layers and layers. And so portability is about layers. Because you want to be able to replace the lower layers.

CW (00:54:15):

The platform specific stuff.

EW (00:54:16):

The processor specific, the platform specific, the vendor specific, whatever SDK may change, you want that to be off to the side in its own little playground, so you can swap it out.

CW (00:54:32):

The thing about portable code in some situations, not all situations, but in some situations, is like with all things in programming, there are trade-offs.

EW (00:54:41):

Ooh, yeah.

CW (00:54:41):

The more portable we make something-

EW (00:54:43):

<laugh> The longer it will take to develop.

CW (00:54:45):

Well, the longer it takes to develop, sometimes.

EW (00:54:47):

The more complex.

CW (00:54:47):

But sometimes you lose some of the platform-specific benefits. It depends on the kind of thing you are working on, but-

EW (00:54:54):

Like flexibility and speed.

CW (00:54:55):

Flexibility and speed, or maybe a feature that your portable thing cannot do.

EW (00:55:02):

Right. Like some microprocessors have RSA keys. They can store fairly large ones, that a small 8-bit processor could not really handle.

CW (00:55:14):

Yeah. Or on the application side, you might have an application framework that is cross-platform, let us say, Qt. I have lots of experience writing cross-platform applications in Qt. And the great thing about it is actually works. I have done this.

(00:55:28):

I have taken for prototyping purposes, a shipping medical device that was written on Windows. It took me one day to port it to Linux. And it worked. It looked the same and worked the same. There were quirks, things that needed to be worked around, but it mostly worked. I also took that application and I took the core of it, and ported it to iOS, so the viewing part of the medical device could be run on an iPad. That took a couple of days. So it can be done, and that is great.

(00:55:59):

The downside is for application-like things, there are certain affordances, there are certain look and feel things, there are certain interface things, that the native frameworks on macOS, iOS, Android, whatever, people are familiar with how that works and what it looks like and how it performs.

(00:56:18):

When you abstract that away to a cross-platform framework, that necessarily is next to or sits on top that, sometimes they do a good job of copying those things or importing them in, but sometimes stuff gets messed up. So now you have got a cross-platform of- Yeah, but it does not look like a Windows app. It does not really look like a Mac app. It looks like cross-platform framework app. Which is why VSCode looks a little weird. Looks the same on every platform, but does not look like a Mac app. It does not look like a Windows app. It is just one of the things.

(00:56:54):

But like what you are saying on the low level, that happens too, where maybe you have got to have a software implementation of something, that is hardware accelerated. Because to take advantage of the 15 hardware accelerated different things, would be a big effort and would break your...

EW (00:57:11):

Portability.

CW (00:57:11):

Port layering modularity story. And so you take a performance hit.

EW (00:57:17):

Talking about Qt is a good way to think about this, because-

CW (00:57:23):

And I will say they did a good job with making things look native.

EW (00:57:26):

When you think about portability, sometimes we think about my application, which runs bare metal on this platform, now needs to go to a different processor, possibly because of the chip shortage. So now I have to rip out all of the STM32 guts, and try to replace them with SAM D from Microchip. There is a lot of swearing, and the peripherals work differently, and the documentation is not consistent from one processor to another. So you are looking all different kinds of places.

(00:58:04):

Could you have made that portable? Absolutely. You could have put it on MicroPython and never written a line of C. But you had to make that decision in the beginning.

CW (00:58:19):

And it had to be something that did not have another trade-off, like performance. Right?

EW (00:58:23):

Like performance. MicroPython aside, it is the idea that if you decide in the beginning you need a lot of portability, then you can start structuring things for them. But if you decide later, then trying to fit those layers in, it is really hard to slip the lasagna noodles in between the spaghetti noodles. Okay. It may be snack time. I am sorry.

CW (00:58:51):

I am not following that analogy. Why...

EW (00:58:55):

If you were planning on doing a portable system, you would make lots of layers like lasagna. But if you were not and you made a pile of spaghetti, but you tried to fit in the lasagna noodles between the spaghetti.

CW (00:59:08):

Okay. I was wondering if there was an actual cooking thing, where lasagna and spaghetti were together.

EW (00:59:14):

No, but we did see that one about spaghetti and pizza. That was not good.

CW (00:59:18):

It was not spaghetti and pizza. It was spaghetti pizza.

EW (00:59:20):

Right. Not good. Late night YouTubing.

CW (00:59:25):

So this is one of these things like "modularity" and-

EW (00:59:28):

"Encapsulation."

CW (00:59:29):

Blah, blah, blah, and "encapsulation"-

EW (00:59:31):

"Object-oriented."

CW (00:59:33):

And "doing testing" and "planning" and "design."

EW (00:59:38):

So many air quotes <laugh>.

CW (00:59:40):

"Thinking." All things that- Okay, a lot of those were jokes, but a lot of these things are things you have to decide you want as a feature of what you are doing upfront, because they have costs. They have development costs, they have sometimes performance costs, sometimes feature costs. And you need to know if it is important. For a lot of people, portability is not important. Like I know I am staying with this STM32F whatever for this product line. I have already acquired all of them. This is not changing.

EW (01:00:14):

But you look at Zephyr and they are like, "This is portable." It has no point unless it is portable.

CW (01:00:19):

Right.

EW (01:00:22):

So I assume, William, you fall between those two?

CW (01:00:25):

I did not look at the-

EW (01:00:27):

There is not much more. "How many different ways can developers argue about what is the right way to make a call portable or code portable?"

CW (01:00:37):

A lot, because like we said already, the definition is not- I would not say it is not well-defined, but it encompasses a lot of things.

EW (01:00:46):

And it affects a lot of things. If you have classes and you are doing C++, your portability layers are somewhat different.

CW (01:00:53):

Yeah. I think if you write well-designed, well-structured code, it tends to be more portable as in a consequence of good design. And so you can get 80% of the way there, by just doing good design practices, without saying, "Oh, I am making this portable." I found that to be true. It is like, "Oh, this is well designed code. It is easy to-"

(01:01:20):

If it is modular, not in the- People make fun of modularity these days, I do not know why. But if you take some steps toward modularity and keeping things separated, keeping areas of responsibility localized in code, those are easier things to move to different places. The whole thing about having your business logic separated from your user interface logic, things like that.

(01:01:46):

Even for embedded device that matters, right? If those things are not tightly, tightly, tightly coupled, you can disconnect one from another. So maybe you are not quote, "porting the code." But if you can take the UI code, for example, and not have to change it a whole ton, when you do move to a different microcontroller. Let us say you did have to write all the low levels, that is not really portable code, but it was code that you were set up for success to port.

(01:02:16):

I guess coming back to the original question, "Is all code portable with enough effort?" No, because all code is not portable, but all code can be ported. I would say that portable code is code that is already ready to be moved with minimal effort.

EW (01:02:36):

I am sort of changing the subject, but not entirely. Did I ever talk to you about semantic webs?

CW (01:02:41):

I think that rings a bell, but go ahead.

EW (01:02:47):

Maybe I do not even have the right word for it. Maybe it is not "webs," maybe- Semantic something. "Semantic meaning." "Semantic words."

CW (01:02:53):

"Semantic satiation," where I say the word "toast" until it sounds funny?

EW (01:02:58):

No <laugh>. "Semantic mapping."

CW (01:02:59):

Okay.

EW (01:02:59):

Okay. So there is this idea that in languages, the translation programs do not work to translate "mother" into "madre" in Spanish. Instead, they take this idea of a semantic map, where you- We have all of these words that have relationships. If you talk about a ruler and a woman, then you may have a queen or an empress, right?

CW (01:03:36):

Mm-hmm.

EW (01:03:36):

And those words will occur in other languages, in those same relations, and they will be next to each other.

CW (01:03:44):

Okay.

EW (01:03:44):

And so there is all this idea of there is a whole map of words, and how they sit close to each other and far from each other. You do not get the word "queen" and "cyanobacteria" together very often.

CW (01:04:00):

You do not.

EW (01:04:03):

<laugh> It was hard to find those two, "No, that happens in bee colonies. No, that happens-" Okay. And so linguists or people who research this sort of thing, identify these key words and create these maps of how languages map to each other. So when you are translating, you are translating from the maps to each other.

CW (01:04:30):

On the edge of my seat to see where the hell this is going.

EW (01:04:32):

Porting!

CW (01:04:35):

<laugh> Here we are.

EW (01:04:36):

Is like making a semantic map. The first time you learn a language, you are baby, and you only really get one or two shots at learning a good language, and getting a semantic map of how the world works. When you learn a second language, it is really hard because you have to figure out how to map all of their stuff onto your languages, and those maps may not match.

CW (01:04:56):

Yeah.

EW (01:04:56):

I mean, there are words in some languages that do not match in others. When you start learning more and more languages, you start working more with the map and less with the language. And you know all of the languages have a word for mother. All of the languages have a word for-

CW (01:05:14):

Cyanobacteria.

EW (01:05:15):

Ruler, woman, highly powered. So porting is like that, where you start out and you have to port from let us say one microprocessor to another, with a different underlying CMSIS HAL layer, but you are still on a Cortex-M. Now you have to port from the Cortex-M family over to an ESP.

(01:05:40):

Each time you are going to find more things that do not agree, and more things that belong in a layer together. All of the timers go here. And even though the timers do not work the same, they do not have the same interrupts, they do not behave all alike, they all need to have these five things that go with them.

(01:06:02):

I do not really know where I was going, but this whole semantic mapping translation has been totally fascinating.

CW (01:06:10):

I find that true of operating systems. Oftentimes people will ask, "Oh, which operating system should I use?" Or, "How do you learn a new RTOS?" You know, topic of RTOSs. And I have never cared, because they all have the same stuff.

(01:06:23):

They have a scheduler, they have a messaging system, they have synchronization primitives. Mostly they are all similar. They have better features and worse features, and some have more features and less features, but they all have the same kind of primitives. There are a few that are off the wall, and do different stuff, but-

EW (01:06:41):

And some are cheaper than others, and some are better supported than others.

CW (01:06:44):

But I do not feel like I am learning a new operating system, when somebody says, "Oh, we are using Cheetos." Okay, Cheetos looks like Fritos, or whatever, right?

EW (01:06:54):

<laugh> The new snack-based RTOS systems.

CW (01:07:00):

No, I think you are right. I think the semantic map is a good thing. I think that happens in a lot of areas, where you stop caring about the specifics of the thing you are using, or the new thing you are using, and you start analogizing it to a class of things. And you just need to find-

EW (01:07:18):

You start working with the meta information.

CW (01:07:20):

How it does the particular class of thing in its specific way. To wrap up the portable code thing, I think it is important to distinguish between code that can be ported and portable code. I think almost all code can be ported, but portable code says to me, "This is ready to be ported in a not too difficult way."

EW (01:07:44):

Right. This already has a layer-

CW (01:07:46):

This is designed to be ported.

EW (01:07:48):

To be ported. Okay. Well, I think we are about out of time.

CW (01:07:53):

I feel out of time.

EW (01:07:55):

Okay. Well, this might be my favorite chapter and we need to Pooh, so we have to give it plenty of time. Oh, right. Thank you?

CW (01:08:02):

Thank you for listening to this show, which I believe is called Embedded. Thank you to our Patreon supporters for supporting us.

EW (01:08:15):

And for their questions.

CW (01:08:15):

We may have a new support thing up on the website.

EW (01:08:20):

I already announced we were doing the Ko-fi thing.

CW (01:08:23):

Today?

EW (01:08:24):

No, like months ago.

CW (01:08:25):

Well, we are actually doing it as soon as I remember, for people who do not like Patreon. I understand why you might not. Not that we need your support, but we appreciate it.

EW (01:08:35):

We do appreciate it.

CW (01:08:36):

That will still get you into Slack. We will figure out how to do that. Okay, so thank you to our listeners for listening. Thank you to Elecia for hosting. Thank you to me for something?

EW (01:08:52):

Co-hosting and producing.

CW (01:08:53):

What else goes in this?

EW (01:08:54):

And editing and all the things.

CW (01:08:55):

What else goes in this? Oh, if you want to contact us, you can hit us up at show@embedded.fm. Or there is a contact form on the website, which is embedded.fm We have a newsletter every week. I personally write the newsletter. It is not very long. We usually try to have something about the show. And then some extra little things that ourselves and maybe our helpers find throughout the web that might interest you.

EW (01:09:26):

Thanks Rene.

(01:09:26):

Yes, thanks Rene. And on the off weeks, when we do not have a show, I try to find some interesting little topic. Sometimes a blog post from the website or something else, and expand upon that.

(01:09:42):

This week it was Kalman filters.

CW (01:09:44):

Kalman filters.

EW (01:09:45):

Which you titled?

CW (01:09:46):

They sign up for the newsletter. I do not know if you get past newsletters, if you sign.

EW (01:09:50):

I think you can find them if you work at it.

CW (01:09:53):

Anyway, you can sign up for that on the website. That website again is embedded.fm.

EW (01:09:59):

Okay. Chapter six. Oh, this is "Winnie-the-Pooh" by A. A. Milne. If this is the first time you are joining us, I am surprised you made it this far. But welcome.

(01:10:09):

[Winnie-the-Pooh excerpt]