2023-05-29 09:09:16 https://www.electronicdesign.com/technologies/analog/whitepaper/21133206/back-to-basics-impedance-matching 2023-05-29 09:20:33 Almost the first thing they mention is transmission lines, which were at the heart of the Vertasium video discussion yesterday. They just turn out to be pretty important. 2023-05-29 09:21:02 The good old "current is like water flowing in a pipe" analogy only gets you so far. 2023-05-29 09:21:34 It's pretty remarkable how "distant" lumped parameter circuit analysis turns out to be from "the full story." 2023-05-29 09:22:10 great chance for some xkcd://356 2023-05-29 09:22:39 :-) 2023-05-29 09:24:49 Last night I noodled around some Tesla coil videos. Small ones look pretty simple to whip up. 2023-05-29 09:29:42 It was also pretty clear that several of those guys didn't really have a clue what they were doing. :-) 2023-05-29 09:29:51 Just tinker toyed it. 2023-05-29 09:30:21 That's definitely a circuit that can hurt you if you aren't careful. 2023-05-29 09:31:51 The original design used a spark gap as a switching element; newer designs use transistors or vacuum tubes. 2023-05-29 09:32:40 BTW, vacuum tube tech is a lot of fun - it's easy enough to understand how tubes work with just some basic high school physics. Much more straightforward than transistors. 2023-05-29 09:34:14 I saw the other day that prior to the advent of tube amplification, telephone calls were limited to somewhere around 800 miles. 2023-05-29 09:34:54 And suddenly scenes in old movies where people yelled through the phone line make a lot more sense - it actually helped when you were out near that limit. 2023-05-29 09:34:57 they had to reboot some vacuum tube teaching when an EE student learned it to make guitar amps 2023-05-29 09:35:34 Yeah; they put the particular non-linearities of tubes to deliberate use in those. 2023-05-29 09:35:57 Then later looked for transistor circuits that "emulated" that behavior, deliberately. 2023-05-29 09:36:54 They didn't really teach me about tubes at all in college. I think that's probably a mistake - it's a worthwhile "stepping stone," precisely because it *is* so easy to explain with basic physics. 2023-05-29 09:37:10 Then the things you learn about transistors just make more sense. 2023-05-29 09:37:49 But my curriculum didn't touch on them even a little. 2023-05-29 09:38:13 hence rebooting it when a student is like ima make guitar amps! and profs are like uh hang on 2023-05-29 09:38:49 There was a used book store near my condo the year I was between marriages. I'd often go in and just explore. One day I found a book on tube tech, and took it up to buy. The owner was chatting with some buddy of his. He took the book from me and looked at it, then looked at his friend and said "I think I'll wait for the movie." 2023-05-29 09:39:47 Old books are the best ticket for learning tubes - there are some good ones floating around for free online. 2023-05-29 09:42:13 That guy - the bookstore owner - was a classic sort of long-hair hippie type guy who you could picture sitting around reading poetry and philosophy. 2023-05-29 09:42:26 With his joint beside him. :-) 2023-05-29 09:48:10 It's a little sobering when you study something like impedance matching and realize that when the job at hand is to deliver power to a load, you right away can only get half of it to your load. 2023-05-29 09:48:37 At best. 2023-05-29 09:49:41 and combustion cars are heat engines that also move on the side 2023-05-29 09:50:00 Yeah, the thermo efficiency limit is also sobering. 2023-05-29 09:50:16 You see immediately why you want your car engine to be hot. 2023-05-29 09:52:33 Also explains why warm-blooded animals can be so much more active that cold blooded ones. 2023-05-29 09:53:33 than 2023-05-29 09:54:18 I constantly see people on YouTube and Quora fantasizing over "free energy machines." That's a mind set that's hard for me to understand. 2023-05-29 09:54:45 But they're just completely convinced that "miracles are being hidden from us." 2023-05-29 09:54:52 Tesla is one of their poster boys. 2023-05-29 09:55:16 And trying to educate them usually just gets you attacked. 2023-05-29 09:55:28 "In the pocket of Big Oil," or whatever. 2023-05-29 09:56:05 "Closed-minded." 2023-05-29 09:56:27 "Learned physics in a box." 2023-05-29 09:59:26 It's really pretty funny - most people never expect to see a rock roll uphill, or to see water that just fell through a hydroelectric dam crawl bacup up behind the dam on its on. But put a magnet in the situation, and suddenly they expect magic. 2023-05-29 09:59:44 All common sense just flies out the window. 2023-05-29 10:00:59 s/on/own/ 2023-05-29 13:40:13 I'm still a little annoyed that it's on us to keep up with how big malloc regions are. It means I have to save that somewhere if I want to be able to do a proper cleanup later. 2023-05-29 13:40:49 or you end up with paperclips hung from all the rack doors 2023-05-29 13:40:58 I'm opting to do it by returning the address mmap returns + 16, and using those two cells to store the size and a link to most recent prior malloc result. 2023-05-29 13:41:16 So as long as I have the most recent address I got, I can step back through that list and free them all when the time comes. 2023-05-29 13:41:46 that sounds like a forth dictionary 2023-05-29 13:41:56 A little bit, doesn't it? :-) 2023-05-29 13:42:39 Of course it opens a category of possible bugs - if I corrupt any of those cells, I lose access to prior allocations. 2023-05-29 13:45:38 paperclip... 2023-05-29 13:46:33 But oh well - that's what return to the os and full restart is for. 2023-05-29 13:47:07 I'm having the boot code allocate regions for bodies, headers, cfa table, pfa table, and the heap. 2023-05-29 13:47:42 Then I'm carving the root task block and the disk buffers out of that heap, before anything else is taken. Basically it just pushes the base of the heap up past those. 2023-05-29 13:49:33 And after it was all said and done I wound up with 15 "system variables" to track all the regions and their sizes. Which works perfectly - the very first cell of the body region has a jump instruction; the next 15 cells are for those variables. So the main code stars at 0x80, so those variables fill out a cache line just right. 2023-05-29 13:51:31 Not that the cache line thing really matters - none of those variables typically will be written anyway. I don't plan to use malloc reguarly; for the most part Forth will manage its own heap. 2023-05-29 13:55:52 On first start up, no previous malloc results will exist. The code copies a default config table to the stack and then "builds it," allocating the buffers and so on. The idea is that later I can put an altered system config on the stack and go to another entry point that will free the existing buffers and then enter that same "build" code. So I could, for example, restart with a bigger heap, or a larger 2023-05-29 13:55:54 user variable space, or whatever. 2023-05-29 13:56:19 Without actually having to re-compile. 2023-05-29 13:56:52 None of this code actually has to be in "the system" after it's running, so I'll put it at the tail end and it won't be included in the body copy. 2023-05-29 14:00:43 First goal will just be to get all this built, have the initial Forth code just say "exit" and then fight with it until that runs and returns smoothly to the system I launched from. 2023-05-29 14:01:58 The idea would be that something like " block run" would run it. 2023-05-29 14:02:49 And that actually already works, if the first byte of block is a return instruction. 2023-05-29 14:03:46 Obviously when I grow beyond one block I'd have to block in all of them first. 2023-05-29 15:10:04 I think for early validation of this I'll arrange for the return value from a system run to be the address returned by the last malloc. And I won't free anything. So that will send me back an address that's the start of that linked list of regions - I'll be able to inspect them. 2023-05-29 17:53:31 You know, they make all these wonderful little integrated circuits to do things like automatic antenna tuning and so on, so you'd think it would be a wonderful time to be a ham. 2023-05-29 17:53:34 But... 2023-05-29 17:53:50 They're all primarily designed to operate in the multi-hundred megahertz range. 2023-05-29 17:53:55 I.e., for cellphones. 2023-05-29 17:54:07 Generally practically useless for HF work. 2023-05-29 17:54:47 That's just one example - it's a general issue. 2023-05-29 17:55:32 What I ought to do is make a PCB with footprints I can solder any capacitors on i want, and rig it with solid state switches and a microcontroller. 2023-05-29 18:05:56 So, I like {> ... >} and {< ... <} for forward and backward assembly jump syntax. No one here will have any trouble imagining what they'd do. 2023-05-29 18:06:23 Maybe that syntax for jumps with one-byte displacement and {-> etc. for jumps with longer displacement. 2023-05-29 18:06:34 Or {>> 2023-05-29 18:07:07 Nice thing about those is that I can prefix them with conditionals much the way I do my existing conditional stuff. 2023-05-29 18:32:53 those looked like these shifty eyed emoticons one has seen on various jp fora 2023-05-29 18:34:57 : ಠ_ಠ ." this code is no good" 2023-05-29 18:43:48 Oh, the python package "terminalplot" is pretty neat. Just does exactly the sort of console graphs you'd expect a console to do. 2023-05-29 20:13:30 : SLICE ( addr len idx — a1 l1 a2 l2 ) 2DUP > IF DROP 2DUP + 0 EXIT THEN 2DUP - >R SWAP DROP 2DUP + R> ; \ correct? 2023-05-29 20:28:34 that definition of SLICE doesn't seem to work for me in gforth 2023-05-29 20:29:38 but if locals are acceptable then this works ... : SLICE { addr len idx } addr len addr idx + len idx - ; 2023-05-29 20:32:26 assuming slice leaves the original addr and len entact as ( a1 l1 ) and the slice as ( a2 l2 )? 2023-05-29 20:33:44 nope you should get two ‘strings’ a1 l1 is the one in front of the slice while a2 l2 is after 2023-05-29 20:38:57 : SLICE { addr len idx -- a1 l1 a2 l2 } addr idx addr idx + len idx - ; 2023-05-29 20:40:45 how do these locals work? underneath that is? 2023-05-29 20:44:48 according to the gforth documentation, there is an extra stack dedicated to local variable storage and a special area in the dictionary that is dedicated to local variable name storage which is cleared at the beginning of each word definition 2023-05-29 20:45:48 sounds a bit too complicated for me to implement 2023-05-29 20:45:48 without looking at gforth code itself, i would guess there is a precursor to the usual dictionary word lookup devoted to local variable search 2023-05-29 20:47:26 in my forth implementation, i have a call frame stack and one of the variables in the frame object is responsible for storing locals 2023-05-29 20:48:31 maybe i'm doing it wrong, but less stack juggling seems to make programming a lot easier to do and read later 2023-05-29 20:50:49 so… VARIABLE addr VARIABLE len VARIABLE idx : SLICE ( addr len idx — a1 l1 a2 l2 ) idx ! len ! addr ! addr @ idx @ addr @ idx @ + len @ idx @ - ; \ works but does not have the clamping I had 2023-05-29 20:58:08 your original implementation works if i use 2DUP < IF instead of 2DUP > IF 2023-05-29 21:08:40 : SLICE ( addr len idx — a1 l1 a2 l2 ) 2DUP < IF DROP 2DUP + 0 EXIT THEN 2DUP - >R SWAP DROP 2DUP + R> ; ok 2023-05-29 21:08:52 S' abcd' 2 SLICE .S ok 2023-05-29 21:09:10 <4> 94793896943696 2 94793896943698 2 ok 2023-05-29 21:09:22 S' abcd' 5 SLICE ok 2023-05-29 21:09:31 .S <4> 94793896943632 4 94793896943636 0 ok 2023-05-29 21:10:48 i am trying to eat my own dogfood and using what's barely an irc client via forth -> javascript -> websocket -> websocketd -> socat -> libera. and i haven't given myself the ability to escape double quotes yet - so i replaced what were double quotes above with single quotes instead 2023-05-29 21:14:36 So, I see this going something like this. Once I've got my dictionary pointers set up, I might say something like 2023-05-29 21:15:03 HANDLER docol ...assembly instructions... NEXT 2023-05-29 21:15:32 HANDLER creates a word docol in the HOST dictionary, but it's basically a constant that captures the then-current offset in the TARGET dictionary as its value. 2023-05-29 21:16:58 Then VARIABLE is a word that also goes in the host dictionary, but which will be able to create a header, and in the creation of that header it users the word dovar (which would have been created similar to docol earlier) to get the value to set the CFA too. 2023-05-29 21:17:37 So HANDLER doesn't create any target dictionary entry - it just registers where the next code to be added to that dictionary will go. 2023-05-29 21:18:39 As I metacompile, every word I encounter will be either in the host's meta vocabulary or in the target dictionary. If the first, it gets executed right now. If the latter, it gets compiled. 2023-05-29 21:20:32 The kind of thing that might become a rub is that sooner or later I'm going to want to define VARIABLE, for example, in the target dictionary. That may mean that I want to use different names in the host's meta vocabulary. 2023-05-29 21:21:03 So .VARIABLE might mean create a variable in the target dictionary, whereas VARIABLE would mean compile target VARIABLE. 2023-05-29 21:21:40 I'm not sure yet how prickly that general issue is going to get. 2023-05-29 21:22:15 Take + for example. I might want to use host + for something, or I might want to compile target host. I guess this is where mode words like TARGET and HOST come into play. 2023-05-29 21:23:51 Maybe that's as simple as having HOST drop the target vocabulary from the search order and TARGET put it back.