Sat on the kit for a few years, spent the last 2 weeks finally following through the series, I finally finished 30 minutes ago. How delightful to come back to the playlist and find a new episode! Thanks for waiting for me :) This is such a great series. I showed my 6yo the final build, had him plug it in and reset it, his response: "Wow! How did you make it do that!?" Me: *starts explaining* Him (interrupting): "Can you make it say Hello, Arlo!?". I walked him through the whole process of modifying the program, building, looking at his name in HEX, pulling out the EEPROM, programming it and getting it back on the breadboard. When it printed "Hello, Arlo!" I think a new hobbyist was born. Then, as I'm typing this, he's in People Playground and calls me over to show me he's put "Hello, Arlo!" on a terminal looking screen you drop into the world. Yeah, he's hooked :)
That’s so cool. Today I was doing the project where you hook up the video card to a monitor and I showed my daughter, and told her about the hex codes of the 64 color palette and the 100x75 pixel resolution. (She’s in a class learning html, css, and JavaScript so she’s aware of RGB codes in hex, and she makes a lot of digital art as a hobby).So she designed a 100x75 png file for me of a frog eating a fly (LOL) and I modified the python program to convert it since she didn’t index the colors, I had the convert program do it for me. Burned it onto the EEPROM and it shows the frog now :) I think this is helping encourage her too. (She’s 13 not 6 though, big difference.)
I wonder if people remember those old Radio Shack kid's electronics kits? They were absolutely brilliant. This is kinda like that, but usually for bigger kids. :)
Ben... You do an excellent job of explaining both the electronic and software side of this. Not that everyone needs to be a bare-metal programmer, but we need more developers that understand what's going on "under the covers" in hardware. It's been a long time since I did 6502 assembler (back in the computer wars (C=64, Apple ][, Atari .. before the IBM PC!).
I've met programmers, good ones too, that have never even had a clue what their computers looked like inside. They'd probably be able to name some components, but that's it.
"Be conservative in what you do, be liberal in what you accept from others" - Jon Poster Man, this is turning into a philosophy channel... and I'm here for it!
It's Postel's Law, probably auto-correct got you. It's the principle of robustness that all application developers and architects should strive for. TCP is a very robust protocol and has stood the test of time indeed. Application layer protocols are a different thing entirely - HTTP I'm looking at you askance.
I'm certain you can handle this series. I have no previous experience with breadboard builds. I've only soldered 2 pre-made PCB kits which, like Ben says at the beginning of this series, only really taught me how to solder. I sat on the kit for years because, every time I started, I felt the same way as you. But then lately I've been binging the LOOK MUM NO COMPUTER channel (curse the algorithm for not suggest the channel to me years ago), who's tag line is "Don't be afraid to try it". He knowledgeably, yet haphazardly, throws extremely cool stuff together without a single fear of making a mistake. It's incredibly inspiring. He happened to mention Ben's kit in one of the videos and I decided to embrace that mindset and just dive in to completing the kit, ignoring the voice telling me I'm not ready for it. After 2 weeks working on the clock module and this series, I finished today. You can do it!
Literally just yesterday I was trying to hook up a COM port on my headless server to a cheap USB UART adapter. Of course it didn't work and I bet it's because I was trying to interface RS-232 level port with 5V level adapter. Great video and great timing.
Software person here: I love the order in which you write the code for demonstration. The loop, the if-then-else-logic, and then the body for each case. I vow to steal that when I try to explain stuff.
That was one of the most important things I learned early on. Don't write code like an essay. Write it "from the outside in". First the overall structure (with comments explaining what goes here), then the interior.
I’m finishing up the last kit now (I did the 6502, the 8-bit breadboard computer, and almost done with the video card) and a new kit just came out. Awesome!
I've learned: Pay attention to your breadboard power rails. I got one that had split rails (The lines tell you! The lines maaan!) which I think meant I somehow created a short loop. The VRMs silently and smokelessly died and were passing 12v straight through into the circuit ("ooh that's a bit warm..."). Fortunately nothing else died, but that genie of the magic smoke is always there, trying to escape!
@@scottlarson1548 It had some cache memory on it, IIRC. So if the processor was busy, you could "ride through" and not miss any data. There were several UART type devices out around the same time, all i know is the 16550 ended up being what pretty much every body used. Your experience, however, might be different.
@@scottlarson1548 You have exceeded my rather limit knowledge on the subject! ^-^ Only did a very little bit of breadboarding serial comms, and it was always a 16550. So my experience is extremely limited. But i know pretty much every laptop and desktop i owned from the mid 80's on were all 16550's for the serial ports. Don't know why, it's just all i ever saw.
I wish those chips had been around in 1979 when I faced the task of of interfacing a Commodore Pet to an ICL 2960 (I think it was) mainframe in order to download the 1861 census data for a district of Dudley which the mainframe held on magnetic tape. The Pet had no serial interface, so I had to create one using discrete logic and level shifters, and I ended up making one that ran at 300 baud. The database was 'only' about 600K in size, but that took about a day, if I recall correctly, to successfully download onto two double-sided 8-inch floppy disks, in a dual disk drive which was a custom addon for the Pet because the Commodore disks (on the IEEE interface) didn't have enough capacity.
It's almost like Ben heard i don't know how that i'm on my way to build his 6502 computer using his videos.. One again, great job Ben! I'll definitely used that in a while!
@@shaunclarke94 I'm not sure exactly, but there's a lot of room inside that plastic that's not the silicon die, especially on DIP packages. Most of the space is just for the pins. The caps are probably just potted in there.
The MAX233 is around $11. The MAX232 is around $7, and clones (including high quality ones, such as TI's version) are under $2. Capacitors are a few cents. So unless you are really tight on space, it's significantly cheaper to use the TI clone of the MAX232 with external capacitors.
I found your channel two days ago and have been glued to the screen ever since! I actually had the book you based your breadboard computer on, and built the mk 2 when I was 15-16 :) I just wanted to mention that that you can run timer 1 on VIA in continuous mode to generate a square wave with an arbitrary frequency. Setting it to generate an irq when it restarts lets you run your interrupt handler on every leading edge of that wave. It makes it a lot simpler to handle the read/write timings.
It's worth pointing out that Postel's Law didn't work out so well for the Internet. With every implementation being liberal in what it accepts, it wasn't so easy to spot if your implementation had mistakes in what it sent to others, until certain combinations just didn't work at all. Nowadays, we want to have a clear specification and hold all implementations strictly to the specification.
I believe you can implement send and receive at the same time by using one of the timer interrupts of the VIA chip and handling receive in the Interrupt routine. Sending is done synchronously in the main routine. You can also use the second timer of the VIA for better timing.
Doing that would cause a fair amount of jitter in the send routine. Namely because it's unaware of any timing issues caused by interrupts for the receive. Additionally, send and receive are not necessarily synchronized as to the start of each byte. But since he's gonna use a UART in the next video, there's no need to go extreme low level bit-banging with microsecond level timing and frankly, both send and receive would be well served via interrupts at that point.
@@johncochran8497 If you want full duplex with no jitter, use one timer interrupt running at more than twice the speed (from sampling theorem) you need to keep up with 10 x 104uS (single byte time). It's not exactly high speed even for a 6502 (about 2kHz). Poll receive, and transmit when a byte to send is required, using two buffers. As far as I know, old 8 bit 6502 home computers were only half duplex, and used interrupts for send and receive (at least my Atari 800 worked like that).
@@threeMetreJim Since the hardware is doing pure bit banging, you need that interrupt at twice the bit frequency, not the byte frequency. So call it 52 uS. The Apple // had a clock speed of 1.023MHz, so we're talking an interrupt every 53 clock cycles. There is a 13 clock cycles overhead for taking the interrupt and the rti to return. So you've got only 40 clocks to handle the send/receive plus what ever else you're doing that isn't directly involved with handling the data communications. Not very practical. The next video will use an UART so right there the need to handle individual bits goes away and the interrupts happen on xmit empty or recv full. This means that on average interrupts only happen 1920 times per second, or 520 uS which is 533 clock cycles on an Apple // or 520 clocks after excluding mandatory interrupt overhead. Much more reasonable for processing data outside of direct I/O support.
@@johncochran8497 Not bit banging, using the UART. Nowhere near fast enough to bit bang. My mistake of getting ahead as soon as Ben mentioned UART. Apologies for that.
@@threeMetreJim No problem. I assumed that you had read and knew that the context of this subthread was bit banging. And the interrupt frequency of the UART may actually be even lower, depending upon whether or not the UART has any FIFO queues for send and receive. Assuming no FIFO and Apple // clock speeds, I'd estimate the fastest practical RS232 speed would be 38400 baud giving an average of 133 clocks to handle each byte and other processing.
I have no idea why UA-cam stuck this in my feed but I've now watched pretty much every one of these videos and have been fascinated. I have also understood not a thing, but I eagerly await the next video.
Your videos have so much charm and it's hard to explain why. But the fact that I had the following interaction is a good example; "The computer only has this five volt supply, but we need to generate this +-10v or so..." "Didn't he just put out a video about a really simple way to do that? I think it was even his most recent-" "Well in my last video I talked about how a charge pump is..."
How many people are out there now who can do this? I deal with Electrical Engineers and Software Developers a lot at my work. The former cannot design a circuit without a CAD simulator, and the latter cannot write an application without C#... Ben, you are a gem! Hope you have a good employer.
That’s wild, my electrical engineering class in school did cover CAD but only after we’d gotten good at laying out circuits by pencil and bresdboard. Like the CAD lessons started by translating a breadboard design into CAD. But that was 13 years ago now. Maybe they’re not bothering anymore
I hope in future u talk about 8086,8259 PIC,8254 PIT Because you are the only person on UA-cam who explains things in a detailed and organized way, you deserve a medal
@@bayareapianist I think it was because that explanation isn't fully relevant to this lesson. But to satisfy your enquiry, the RS-232 standard was intended to operate reliably in electrically "noisy" environments. In such an environment, making the voltage "swing" across a larger voltage range makes the connection more likely to reject any interference. Or to put it another way, a "pulse" of voltage induced into the communication wiring by electro-magnetism from nearby electrical equipment is less likely to be misinterpreted as being part of the data transmission if you use positive and negative voltages which are widely separated from each other. That is also why the standard allows the voltage swing to go all the way from positive 25 volts to negative 25 volts (a swing of 50 volts). TL;DR: It makes the data connection more reliable.
The 6502 is in my opinion the best teaching CPU ever built. People who owned Commodore computers could get into machine language in a few months thank to the kernel built routines. The memory addressing scheme by page memory and offset is simple compared to i386 base address and segment/offset scheme. This is the CPU to experiment and have fun with.
I didn't know about the page memory system in the Commodore. I had an Atari 8-bit that just addressed everything by address directly. Was the Commodore harder to program in 6502 than the Atari ?
@@mikecimerian6913 I think we're talking about different addressing schemes. I think you're talking about index addressing like (address),y . I'm talking about direct addressing like lda #5 sta address. my bad.
i'm being motivated by all of your videos and i think i'll create my own 6502 computer. thanks for all the expalations and help you give :D (maybe i'll get the kit as a birthday gift)
I have been hesitant to embark on a relatively simple learning project for work where I need to communicate via Modbus over RS485 using a simple microcontroller. I haven't started it due to really having a hard time understanding a lot of this stuff and finding anything on youtube that is straight and to the point was very hard. And now, you come out with this video. While its not exactly the same, it does give me enough to go on to feel a bit more comfortable with my project. I really an looking forward to your next video as it will likely also be very helpful. Thank you, Ben!!!
There's also an intermediate level you can go at for serial communications aside from that sort of "raw bit banging", using interrupts and a generic timer peripheral. The CPU never actually runs a delay loop, it just sets a virtual alarm clock for whenever it needs to next send a bit, and sets an interrupt for any transitions on the recieve line to record splits with a virtual stopwatch. This style of programming is one that a lot of people aren't really aware is possible, and it can get you out of a lot of sticky situations when you need to deal with multiple tasks with tight timing and/or less-conventional protocols.
@@harveyxing2329 Not quite, though that style of event-loop control is also useful. I'm talking about just a more advanced way of using interrupts and timer peripherals.
Problem with interrupts with slow processors like 6502 here, is that in a high speed communication the actual interrupt takes tens of cycles already. Interrupt, saving/restoring registers and returning from there all take their time. So in a worst situation, cpu is 'stuck' at re-firing the same interrupt all the time. It gets even worse if both send/receive are firing their own interrupts. (Have to remember there are only 2 interrupt lines in 6502 chip, IRQ and NMI, and they have priorities.)
Ben, sometimes I think your in-video mistakes work out to being great teaching tools. I don't think anyone here will ever forget that 9600 baud works out to 104 microseconds per bit for the rest of our lives 😁
@@vurpo7080 That's a great catch, actually. It's not just that the symbol could be more than one bit, a quick search showed a way in which an entire nibble (one digit of hexadecimal) can be jammed into the space of one pulse using a complex signal. I doubt that's the limit, either.
@@sirnukesalot24 I believe modern fast Ethernet and Wi-Fi can go as far as one of 2048 options jammed in a single baud (11 bits per baud, though probably 3 of them are error correction)
Funny story -- I encountered the same microsecond/millisecond issue recently. -- I found a bit of old Amiga keyboard interface code that worked with Microcontrollers (i.e. to make a bluetooth keyboard out of an [un]dead computer); and something just didn't seem right... like it seemed like it was missing keystrokes at regular intervals... -- I think most people just assumed that's how those keyboards are? -- But it turns out, there was a bit of protocol code that was calling a delay_milliseconds, but it should have been microseconds (according to the data sheet even) -- I changed that bit of code and everything started working great, no more dropped keys! :D
I remember from back in the day, that RS-232 had rise and fall time restrictions. With some cables and some devices you needed to add a tiny bit of capacitance (330 pF would usually do it) between the transmitter output and ground, or you'd be able to hear computer hash on every AM radio on the block. I don't know if Maxim loads the outputs of the MAX232 with an internal cap, and frankly I'm too lazy to pull up the data sheet right now. But it might be something to be aware of. Then again, there's probably enough stray capacitance around the breadboard that you don't need to worry.
I write programs for a living and the projects are all complicated and deep. They are also existing on several layers of abstraction at the same time, from very high level libraries to very low level numeric type implementations (think 128 bit floating point). Even this video (awesome, as always), which feels like bare metal tinkering compared to my daily work, is actually already several steps up the ladder of abstraction. You aren't making logic circuits from discrete components, each chip represents hundreds or thousands of such components. In actual fact, the abstraction goes all the way down, as levels of reality are based on the abstraction of realized properties in emergent realms arising from the generalized increase in complexity at each layer. As far as I know, this doesn't stop until you get to the "spacetime foam", which might itself be some from of reality arising from still more detailed underlayment, and itself is just an effect. Whoa.
Upon reflection, I wonder if it goes up forever as well - once the complexity arises, the new level of abstraction emerges from the chaos. Humans aren't the limit, not even on earth. None of this abstraction would be possible if the complex human interactions among billions of us didn't exist first. The abstract layer of the group undoubtedly leads to interactions between groups of humans, and then that complexity leads to further abstraction as long as it keeps being complicated.
Upon furhter reflection, it is the groupings of items throuout the universe, then groupings of universes??? then more groupings of shit, then some fat guy sitting in his mothers basement.
I imagine it'll be the WDC version of the 65c51 UART chip. I used it for a bit with my SBC but I've gone with the MAX3100 SPI UART and just bitbanged the SPI which was a great learning experience on it's own, but now I just can't go back to the older chips.. :)
Great video, great explanation of RS232 serial. Thankfully I have been able to use "TTL serial" for most of my projects, which is far simpler to imp!cement.
wow.... the "conservative in what you do, liberal in what you accept from others" hit a nerve with me! This reminds me of the ancient Stoic principle and quote from Marcus Aurelius... "Be tolerant with others and strict with yourself." Very cool. Thanks for including nuggets of learning like that!
for the TI-83 and related calculators (expect the newer TI-84s) have a Link port, and the serial protocol across it works no matter how fast either calculator is
An easier way is to buy an RS232 interface board with built in level converters, they are kind of targeted at the Arduino fraternity, however that does not matter, they talk 5V for direct connection to your VIA
I'm currently watching this video on my TV and I'm some distance away from the TV. When Ben brought the paper in at 4:34, I thought he showed us some APL code, until I realised that it were words some moments later XD
One of the frustrating things in my job is to match a RS-232 to USB serial interface to the equipment I'm trying to interface. My job has many devices, both operational and test equipment, with craft terminals and other old data ports that require it. As Ben stated in the video, manufacturers of the interfaces very often cut corners, both in the adapter and in the equipment.
Great videos. Glad to see a new one. Do you have any information or links describing your camera and lighting setup? I tried to make similar videos but I can’t come near the quality and sharpness of your setup.
Ah...the good old days of programming the 6502 for all kinds of embedded applications. Even more enjoyable was developing a Real-Time Executive for the 68HC11 microcontroller. I miss those days.
Third try, apparently YT blocks any mention on 6502 forum. Ordered some of those chips, then started reading the forum, and ended up using different UART chips, out of which PC16552 was the better one. Hope this time the comment goes through :)
@@banedon8087 Yes, as far as I remember there are two bugs, the one you mentioned and also the fact that the chip does not generate parity... I really wonder if they ever tested their chip 🤔...
It will be interesting to see if you come up with a smart way to avoid the transmit bug (Sorry WDC "feature" ) on the W65C51 and to avoid having to use a delay as suggested by their Datasheet.
Sat on the kit for a few years, spent the last 2 weeks finally following through the series, I finally finished 30 minutes ago. How delightful to come back to the playlist and find a new episode! Thanks for waiting for me :)
This is such a great series. I showed my 6yo the final build, had him plug it in and reset it, his response: "Wow! How did you make it do that!?" Me: *starts explaining* Him (interrupting): "Can you make it say Hello, Arlo!?". I walked him through the whole process of modifying the program, building, looking at his name in HEX, pulling out the EEPROM, programming it and getting it back on the breadboard. When it printed "Hello, Arlo!" I think a new hobbyist was born.
Then, as I'm typing this, he's in People Playground and calls me over to show me he's put "Hello, Arlo!" on a terminal looking screen you drop into the world. Yeah, he's hooked :)
That’s so cool. Today I was doing the project where you hook up the video card to a monitor and I showed my daughter, and told her about the hex codes of the 64 color palette and the 100x75 pixel resolution. (She’s in a class learning html, css, and JavaScript so she’s aware of RGB codes in hex, and she makes a lot of digital art as a hobby).So she designed a 100x75 png file for me of a frog eating a fly (LOL) and I modified the python program to convert it since she didn’t index the colors, I had the convert program do it for me. Burned it onto the EEPROM and it shows the frog now :) I think this is helping encourage her too. (She’s 13 not 6 though, big difference.)
That's adorable
playing People Playground at 6 years old
I wonder if people remember those old Radio Shack kid's electronics kits? They were absolutely brilliant. This is kinda like that, but usually for bigger kids. :)
Hello Arlo!!!
Babe wake up! Ben Eater posted another video!! 🎉
Why Babe is sleeping?
@@pareshmhatre4019 She has chronic fatigue syndrome.
babe should always be awake waiting for the new ben video
Babe seems distracted.
@@manishholla yeah. Seems like babe is having "yoga sessions" with tyrone atm.
Ben... You do an excellent job of explaining both the electronic and software side of this. Not that everyone needs to be a bare-metal programmer, but we need more developers that understand what's going on "under the covers" in hardware. It's been a long time since I did 6502 assembler (back in the computer wars (C=64, Apple ][, Atari .. before the IBM PC!).
me, a python programmer, remembering people had to think about memory layouts, when he talks about picking a place to store his little asterisk… 😅
I've met programmers, good ones too, that have never even had a clue what their computers looked like inside. They'd probably be able to name some components, but that's it.
This guy's the best.
@@paulmichaelfreedman8334 Couldn't have been _really_ god ones though.
@@paulmichaelfreedman8334 That's most of them now.
"...and that's what we'll be doing in the next video."
Aww. Just when it was getting to the GOOD part! Please don't make us wait too long, Ben!
"Be conservative in what you do, be liberal in what you accept from others" - Jon Poster
Man, this is turning into a philosophy channel... and I'm here for it!
This philosophy made sense at the time, but led to the utter mess that was Web 1.0, and all sorts of security issues.
It's Postel's Law, probably auto-correct got you. It's the principle of robustness that all application developers and architects should strive for. TCP is a very robust protocol and has stood the test of time indeed. Application layer protocols are a different thing entirely - HTTP I'm looking at you askance.
Ben Eater’s videos are too advanced for me now but i still watch because i love watching this whole project form together
I leart so much in the past years from his videos
Learn digital logic and computer architecture! It will really change the way you see technology in general, it's more than just educational
I couldn't imagine a better source to learn the relevant topics than his own videos
I'm certain you can handle this series. I have no previous experience with breadboard builds. I've only soldered 2 pre-made PCB kits which, like Ben says at the beginning of this series, only really taught me how to solder. I sat on the kit for years because, every time I started, I felt the same way as you. But then lately I've been binging the LOOK MUM NO COMPUTER channel (curse the algorithm for not suggest the channel to me years ago), who's tag line is "Don't be afraid to try it". He knowledgeably, yet haphazardly, throws extremely cool stuff together without a single fear of making a mistake. It's incredibly inspiring. He happened to mention Ben's kit in one of the videos and I decided to embrace that mindset and just dive in to completing the kit, ignoring the voice telling me I'm not ready for it. After 2 weeks working on the clock module and this series, I finished today. You can do it!
Same bro. I'm a mechanical engineering student in uni but I've always had an interest in electronics and Ben fills that need perfectly!
It sure is great to really understand the functions of all the terms and protocols I've been using for almost 30 years.
Literally just yesterday I was trying to hook up a COM port on my headless server to a cheap USB UART adapter. Of course it didn't work and I bet it's because I was trying to interface RS-232 level port with 5V level adapter.
Great video and great timing.
Software person here: I love the order in which you write the code for demonstration. The loop, the if-then-else-logic, and then the body for each case. I vow to steal that when I try to explain stuff.
That was one of the most important things I learned early on. Don't write code like an essay. Write it "from the outside in". First the overall structure (with comments explaining what goes here), then the interior.
I’m finishing up the last kit now (I did the 6502, the 8-bit breadboard computer, and almost done with the video card) and a new kit just came out. Awesome!
If I tried this, I can imagine there being lots of smoke coming out of the breadboard, but man, I love watching this. Thanks, Ben
MAGIC smoke of course. 🙂
I've learned: Pay attention to your breadboard power rails. I got one that had split rails (The lines tell you! The lines maaan!) which I think meant I somehow created a short loop. The VRMs silently and smokelessly died and were passing 12v straight through into the circuit ("ooh that's a bit warm..."). Fortunately nothing else died, but that genie of the magic smoke is always there, trying to escape!
The 16550 UART was an amazing achievement. That one chip replaced entire circuit cards to do the same thing.
What does the 16550 do that the 6850 can't?
@@scottlarson1548 It had some cache memory on it, IIRC. So if the processor was busy, you could "ride through" and not miss any data.
There were several UART type devices out around the same time, all i know is the 16550 ended up being what pretty much every body used.
Your experience, however, might be different.
@@jeromethiel4323 The 6850 had cache memory: one byte! You better read it quick.
@@scottlarson1548 You have exceeded my rather limit knowledge on the subject! ^-^
Only did a very little bit of breadboarding serial comms, and it was always a 16550. So my experience is extremely limited.
But i know pretty much every laptop and desktop i owned from the mid 80's on were all 16550's for the serial ports. Don't know why, it's just all i ever saw.
@@scottlarson1548 The 16550 had a 16byte FIFO buffer. That was really something back in the day
I wish those chips had been around in 1979 when I faced the task of of interfacing a Commodore Pet to an ICL 2960 (I think it was) mainframe in order to download the 1861 census data for a district of Dudley which the mainframe held on magnetic tape. The Pet had no serial interface, so I had to create one using discrete logic and level shifters, and I ended up making one that ran at 300 baud. The database was 'only' about 600K in size, but that took about a day, if I recall correctly, to successfully download onto two double-sided 8-inch floppy disks, in a dual disk drive which was a custom addon for the Pet because the Commodore disks (on the IEEE interface) didn't have enough capacity.
Man, these videos are something incredible. Thanks so much for taking the time to share your knowledge with the world. I for one truly appreciate it!
It's almost like Ben heard i don't know how that i'm on my way to build his 6502 computer using his videos..
One again, great job Ben! I'll definitely used that in a while!
You might want to consider the MAX233 (instead of the MAX232). The MAX233 is similar in price, but does not require external charge pump capacitors.
Oh wow. How did they achieve the same functionality without capacitors? Or is it somehow possible to embed a capacitor in the IC?
@@shaunclarke94 I'm not sure exactly, but there's a lot of room inside that plastic that's not the silicon die, especially on DIP packages. Most of the space is just for the pins. The caps are probably just potted in there.
The MAX233 is around $11. The MAX232 is around $7, and clones (including high quality ones, such as TI's version) are under $2. Capacitors are a few cents. So unless you are really tight on space, it's significantly cheaper to use the TI clone of the MAX232 with external capacitors.
But I already have a MAX232 in my parts box…
What fortuitous timing! I was literally looking for a good primer on serial protocol last night.
Keep up the fantastic work, Ben!
this guy's talent in reading standards absolutely amazes me
I found your channel two days ago and have been glued to the screen ever since! I actually had the book you based your breadboard computer on, and built the mk 2 when I was 15-16 :)
I just wanted to mention that that you can run timer 1 on VIA in continuous mode to generate a square wave with an arbitrary frequency. Setting it to generate an irq when it restarts lets you run your interrupt handler on every leading edge of that wave. It makes it a lot simpler to handle the read/write timings.
It's worth pointing out that Postel's Law didn't work out so well for the Internet. With every implementation being liberal in what it accepts, it wasn't so easy to spot if your implementation had mistakes in what it sent to others, until certain combinations just didn't work at all. Nowadays, we want to have a clear specification and hold all implementations strictly to the specification.
heck, he immediately points out the problem with postel's law in the video!
I believe you can implement send and receive at the same time by using one of the timer interrupts of the VIA chip and handling receive in the Interrupt routine. Sending is done synchronously in the main routine. You can also use the second timer of the VIA for better timing.
Doing that would cause a fair amount of jitter in the send routine. Namely because it's unaware of any timing issues caused by interrupts for the receive. Additionally, send and receive are not necessarily synchronized as to the start of each byte. But since he's gonna use a UART in the next video, there's no need to go extreme low level bit-banging with microsecond level timing and frankly, both send and receive would be well served via interrupts at that point.
@@johncochran8497 If you want full duplex with no jitter, use one timer interrupt running at more than twice the speed (from sampling theorem) you need to keep up with 10 x 104uS (single byte time). It's not exactly high speed even for a 6502 (about 2kHz). Poll receive, and transmit when a byte to send is required, using two buffers. As far as I know, old 8 bit 6502 home computers were only half duplex, and used interrupts for send and receive (at least my Atari 800 worked like that).
@@threeMetreJim Since the hardware is doing pure bit banging, you need that interrupt at twice the bit frequency, not the byte frequency. So call it 52 uS. The Apple // had a clock speed of 1.023MHz, so we're talking an interrupt every 53 clock cycles. There is a 13 clock cycles overhead for taking the interrupt and the rti to return. So you've got only 40 clocks to handle the send/receive plus what ever else you're doing that isn't directly involved with handling the data communications. Not very practical.
The next video will use an UART so right there the need to handle individual bits goes away and the interrupts happen on xmit empty or recv full. This means that on average interrupts only happen 1920 times per second, or 520 uS which is 533 clock cycles on an Apple // or 520 clocks after excluding mandatory interrupt overhead. Much more reasonable for processing data outside of direct I/O support.
@@johncochran8497 Not bit banging, using the UART. Nowhere near fast enough to bit bang. My mistake of getting ahead as soon as Ben mentioned UART. Apologies for that.
@@threeMetreJim No problem. I assumed that you had read and knew that the context of this subthread was bit banging. And the interrupt frequency of the UART may actually be even lower, depending upon whether or not the UART has any FIFO queues for send and receive. Assuming no FIFO and Apple // clock speeds, I'd estimate the fastest practical RS232 speed would be 38400 baud giving an average of 133 clocks to handle each byte and other processing.
I have no idea why UA-cam stuck this in my feed but I've now watched pretty much every one of these videos and have been fascinated. I have also understood not a thing, but I eagerly await the next video.
Awesome video. Thanks for sharing. The binary code representing * is 00101010 which matches the scope reading with an extra 0 on the end.
Your videos have so much charm and it's hard to explain why. But the fact that I had the following interaction is a good example;
"The computer only has this five volt supply, but we need to generate this +-10v or so..."
"Didn't he just put out a video about a really simple way to do that? I think it was even his most recent-"
"Well in my last video I talked about how a charge pump is..."
How many people are out there now who can do this? I deal with Electrical Engineers and Software Developers a lot at my work. The former cannot design a circuit without a CAD simulator, and the latter cannot write an application without C#...
Ben, you are a gem! Hope you have a good employer.
That’s wild, my electrical engineering class in school did cover CAD but only after we’d gotten good at laying out circuits by pencil and bresdboard. Like the CAD lessons started by translating a breadboard design into CAD. But that was 13 years ago now. Maybe they’re not bothering anymore
I hope in future u talk about 8086,8259 PIC,8254 PIT
Because you are the only person on UA-cam who explains things in a detailed and organized way, you deserve a medal
I don't understand why learning these stuff are so hard? He never explained why there was a negative voltage used for rs232. I don't think he knows.
@@bayareapianist you could always say "hey Ben, why does the serial standard use positive and negative voltages?" You know, actually ask.
@@bayareapianist I think it was because that explanation isn't fully relevant to this lesson.
But to satisfy your enquiry, the RS-232 standard was intended to operate reliably in electrically "noisy" environments. In such an environment, making the voltage "swing" across a larger voltage range makes the connection more likely to reject any interference.
Or to put it another way, a "pulse" of voltage induced into the communication wiring by electro-magnetism from nearby electrical equipment is less likely to be misinterpreted as being part of the data transmission if you use positive and negative voltages which are widely separated from each other. That is also why the standard allows the voltage swing to go all the way from positive 25 volts to negative 25 volts (a swing of 50 volts).
TL;DR: It makes the data connection more reliable.
Sounds like "robustness" ;-)
@@adrianstovall I don't think he knew. Otherwise he would have mentioned it.
The 6502 is in my opinion the best teaching CPU ever built. People who owned Commodore computers could get into machine language in a few months thank to the kernel built routines. The memory addressing scheme by page memory and offset is simple compared to i386 base address and segment/offset scheme. This is the CPU to experiment and have fun with.
I didn't know about the page memory system in the Commodore. I had an Atari 8-bit that just addressed everything by address directly. Was the Commodore harder to program in 6502 than the Atari ?
@@bjbell52 I don't about the Atari. 8 bit addressing must be closely related. 256 pages each with 256 words (bytes). I really enjoy the symmetry. :)
@@mikecimerian6913 I think we're talking about different addressing schemes. I think you're talking about index addressing like (address),y . I'm talking about direct addressing like lda #5 sta address. my bad.
Thank you Ben, your videos are invaluable!
i'm being motivated by all of your videos and i think i'll create my own 6502 computer. thanks for all the expalations and help you give :D (maybe i'll get the kit as a birthday gift)
And gift it to myself
@@velmuruganr9321 i'll ask my parents actually or maybe yes i'll buy it for myself
Well! 6502s still available in the marketplace. Colour me happy.
I am pretty happy you put a new video up. Always entertaining and educational.
I have been hesitant to embark on a relatively simple learning project for work where I need to communicate via Modbus over RS485 using a simple microcontroller. I haven't started it due to really having a hard time understanding a lot of this stuff and finding anything on youtube that is straight and to the point was very hard. And now, you come out with this video. While its not exactly the same, it does give me enough to go on to feel a bit more comfortable with my project. I really an looking forward to your next video as it will likely also be very helpful. Thank you, Ben!!!
You should check out Ben's video about RS-232 if you haven't already then
I've always loved Postel's Law. It can solve so many issues, especially around file format support.
And in life.
Memories... breadboarding 6502 and C64 projects in the early 80's : )
I've worked in computer hardware and software since 1986. The best way to understand how a computer works is to watch Ben Eater's UA-cam channel.
...and hopefully we'll see the next video before the snow melts 🤗
You mean the polar ice caps 😆?
Awesome video! Thank you for posting it! Looking for UART next 😍
Absolutely amazing! Thank you for the great content Ben!
4:22 "TCP Robustness Principal - Be conservative in what you do and liberal in what you accept from others" - That's just good general life advice. 🤔
I'm finally in a place where I can start spending money on fun stuff. I'm so glad your store is still online.
AAAAAAAA YES! love it when there's a new video from you ben!
There's also an intermediate level you can go at for serial communications aside from that sort of "raw bit banging", using interrupts and a generic timer peripheral. The CPU never actually runs a delay loop, it just sets a virtual alarm clock for whenever it needs to next send a bit, and sets an interrupt for any transitions on the recieve line to record splits with a virtual stopwatch.
This style of programming is one that a lot of people aren't really aware is possible, and it can get you out of a lot of sticky situations when you need to deal with multiple tasks with tight timing and/or less-conventional protocols.
Do you mean protothreading?
@@harveyxing2329 Not quite, though that style of event-loop control is also useful. I'm talking about just a more advanced way of using interrupts and timer peripherals.
Is this scheduling?
@@jeremoisde9928 looks like some form of cooperative scheduling, with the cpu interrupting for a task switch
Problem with interrupts with slow processors like 6502 here, is that in a high speed communication the actual interrupt takes tens of cycles already. Interrupt, saving/restoring registers and returning from there all take their time. So in a worst situation, cpu is 'stuck' at re-firing the same interrupt all the time. It gets even worse if both send/receive are firing their own interrupts. (Have to remember there are only 2 interrupt lines in 6502 chip, IRQ and NMI, and they have priorities.)
Ben, sometimes I think your in-video mistakes work out to being great teaching tools. I don't think anyone here will ever forget that 9600 baud works out to 104 microseconds per bit for the rest of our lives 😁
Haha so true!
Btw, in case you didn't realize, the 104us comes from 1s/9600 (that's what bauds mean)
The exact value is 104.16us
@@dbuezas Yeah baud means symbols per second, so if your symbol is a bit then 9600 baud just means 9600 bits per second
@@vurpo7080 i didn't know it was a generic "symbols per second". I thought it was "bits/s including error detection and control signals". Thanks!
@@vurpo7080 That's a great catch, actually. It's not just that the symbol could be more than one bit, a quick search showed a way in which an entire nibble (one digit of hexadecimal) can be jammed into the space of one pulse using a complex signal. I doubt that's the limit, either.
@@sirnukesalot24 I believe modern fast Ethernet and Wi-Fi can go as far as one of 2048 options jammed in a single baud (11 bits per baud, though probably 3 of them are error correction)
Funny story -- I encountered the same microsecond/millisecond issue recently. -- I found a bit of old Amiga keyboard interface code that worked with Microcontrollers (i.e. to make a bluetooth keyboard out of an [un]dead computer); and something just didn't seem right... like it seemed like it was missing keystrokes at regular intervals... -- I think most people just assumed that's how those keyboards are? -- But it turns out, there was a bit of protocol code that was calling a delay_milliseconds, but it should have been microseconds (according to the data sheet even) -- I changed that bit of code and everything started working great, no more dropped keys! :D
Finally someone worthy, explained like no one ever 🔥❤️
I remember from back in the day, that RS-232 had rise and fall time restrictions. With some cables and some devices you needed to add a tiny bit of capacitance (330 pF would usually do it) between the transmitter output and ground, or you'd be able to hear computer hash on every AM radio on the block. I don't know if Maxim loads the outputs of the MAX232 with an internal cap, and frankly I'm too lazy to pull up the data sheet right now. But it might be something to be aware of.
Then again, there's probably enough stray capacitance around the breadboard that you don't need to worry.
Yup, slew rate is specified: SR Driver slew rate RL = 3 kΩ to 7 kΩ, see Figure 4 30 V/μs
Another top quality video. Cant wait to watch it.
Oh Ben, all those newfangled ‘C02 instructions are making me dizzy.. tsb, trb, ror! 1975 called - “that’s not a 6502” 😅
Well, most 6502s had ROR :p just not the very very first ones
You outdid yourself today, Sir thank you so much.
and ironically his rs232 interface probably has a max232 inside it converting back to ttl
I write programs for a living and the projects are all complicated and deep. They are also existing on several layers of abstraction at the same time, from very high level libraries to very low level numeric type implementations (think 128 bit floating point). Even this video (awesome, as always), which feels like bare metal tinkering compared to my daily work, is actually already several steps up the ladder of abstraction. You aren't making logic circuits from discrete components, each chip represents hundreds or thousands of such components. In actual fact, the abstraction goes all the way down, as levels of reality are based on the abstraction of realized properties in emergent realms arising from the generalized increase in complexity at each layer. As far as I know, this doesn't stop until you get to the "spacetime foam", which might itself be some from of reality arising from still more detailed underlayment, and itself is just an effect.
Whoa.
Upon reflection, I wonder if it goes up forever as well - once the complexity arises, the new level of abstraction emerges from the chaos. Humans aren't the limit, not even on earth. None of this abstraction would be possible if the complex human interactions among billions of us didn't exist first. The abstract layer of the group undoubtedly leads to interactions between groups of humans, and then that complexity leads to further abstraction as long as it keeps being complicated.
Whoa indeed 😳
Upon furhter reflection, it is the groupings of items throuout the universe, then groupings of universes??? then more groupings of shit, then some fat guy sitting in his mothers basement.
Sounds like someone’s been watching PBS Space Time :)
I imagine it'll be the WDC version of the 65c51 UART chip. I used it for a bit with my SBC but I've gone with the MAX3100 SPI UART and just bitbanged the SPI which was a great learning experience on it's own, but now I just can't go back to the older chips.. :)
I love the increasingly angry "104 _micro_ seconds" text whenever you say "104 milliseconds" XD
Looking forward to see a video on I2C someday
Cheers!
Really appreciate the videos and the level of explanation. Keep it up ❤
Awesome video! Thank you 😍
Thanks again Ben; another great video.
Your board designs are so cool.
i dont even know whats happening in this video but i'm always excited for benny boy's new videos nonetheless
where did the bot go :(
That keysight scope is nice. I use a tek mdo3034 at work and have siglent gear at home but it's tempting to go to keysight at home.
Great video, great explanation of RS232 serial. Thankfully I have been able to use "TTL serial" for most of my projects, which is far simpler to imp!cement.
Nice. Always love your vids.
Thank you Ben! 😍
wow.... the "conservative in what you do, liberal in what you accept from others" hit a nerve with me! This reminds me of the ancient Stoic principle and quote from Marcus Aurelius... "Be tolerant with others and strict with yourself." Very cool. Thanks for including nuggets of learning like that!
for the TI-83 and related calculators (expect the newer TI-84s) have a Link port, and the serial protocol across it works no matter how fast either calculator is
Great! Liked the quality of the video.
Awesome video! Thank you
When Ben posts a new video, I feel young again.
When Ben posts a new video, I remember why I love computers (now let's head back to javascript for real life stuff 😞)
Thank You.
Instructions unclear, Cheerios stuck in breadboard. I don’t think it’s interfacing, I might have used too much milk.
An easier way is to buy an RS232 interface board with built in level converters, they are kind of targeted at the Arduino fraternity, however that does not matter, they talk 5V for direct connection to your VIA
looking forward to the UART video!
Oh my god!!! Ben Eater's videos drop like Marvel movies!! Blockbusterrrrr!!!!!!
RIP Jon Postel a true pioneer in computing.
This is Excellent.!
TSB and TRB eh? Fancy schmancy new 6502 :D
I'm currently watching this video on my TV and I'm some distance away from the TV.
When Ben brought the paper in at 4:34, I thought he showed us some APL code, until I realised that it were words some moments later XD
One of the frustrating things in my job is to match a RS-232 to USB serial interface to the equipment I'm trying to interface. My job has many devices, both operational and test equipment, with craft terminals and other old data ports that require it. As Ben stated in the video, manufacturers of the interfaces very often cut corners, both in the adapter and in the equipment.
UA-cam dumped all my recommendations and all so I never got this video on my feed
If you put BASIC on a ROM so that I could use it with the serial port, I would buy this.
Holy I was just catching up on this series yesterday and wanted more can there be more than one video a month please?
The king has returned.
Just when I thought I was done building the 6502 computer.
I use 5V levels using a PIC program to read (with a 10K resistor in series) and talk (with a 1K resistor in series) to RS232.
Parabéns Ben seus vídeos como sempre são magníficos !!
Outstanding!
no way.. i finished watching series on 6502 about a week ago and now there is more
I've been trying to sell a MAX232 like chip on E. Bay for months... I wonder if the release of this video might prompt a sale. ;) Great video as ever.
Great videos. Glad to see a new one. Do you have any information or links describing your camera and lighting setup? I tried to make similar videos but I can’t come near the quality and sharpness of your setup.
That cliffhanger at the end, oof
Ah...the good old days of programming the 6502 for all kinds of embedded applications. Even more enjoyable was developing a Real-Time Executive for the 68HC11 microcontroller. I miss those days.
Toady I celebrate 🎉 new video hurrah!!
The legend is back!
Oh yes the content that makes me love engineering
well done
So do USB to Serial adapters have a charge pump as well? Or are those what you were talking about that abuse the protocol with 5V and 0V?
Yay! He’s back!
Nice, was waiting for this
Good video. I wonder if Ben is going to discover the bugs in the WDC 65C51S the hard way.
Yeah ... that bug .... made me waste 6 months of my life because I was looking at the first revision of the datasheet which did not mention it...
@@amiga8737 I thnk there are several. Is the one that you ran into the transmit-register-empty flag one?
Third try, apparently YT blocks any mention on 6502 forum. Ordered some of those chips, then started reading the forum, and ended up using different UART chips, out of which PC16552 was the better one. Hope this time the comment goes through :)
@@argoneum Yep this one madee it 😁. I think it's that it's a URL.
Yes, people seem to go for the PC16552 or the SC28L92 (or TI equivelent).
@@banedon8087 Yes, as far as I remember there are two bugs, the one you mentioned and also the fact that the chip does not generate parity... I really wonder if they ever tested their chip 🤔...
It will be interesting to see if you come up with a smart way to avoid the transmit bug (Sorry WDC "feature" ) on the W65C51 and to avoid having to use a delay as suggested by their Datasheet.