The RS-232 protocol

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 1,5 тыс.

  • @paradox9551
    @paradox9551 2 года назад +4270

    I'm so glad the Bob Ross of Computer Engineering is back.

    • @marred2277
      @marred2277 2 года назад +69

      Perfect description

    • @markgreco1962
      @markgreco1962 2 года назад +14

      Second that

    • @wmjowls
      @wmjowls 2 года назад +191

      It’s taken this long because he’s been uploading the video with a serial port, one byte at a time

    • @grillpig3860
      @grillpig3860 2 года назад +2

      Same. :D

    • @DW-indeed
      @DW-indeed 2 года назад +12

      "there's nothing wrong with having a port as a friend"
      ...officer.

  • @DavesGarage
    @DavesGarage 2 года назад +71

    I just wrote a bunch of 6502 serial code for our "C64 Spectrum Analyzer" video and I still learned stuff from this :-)

    • @TR3A
      @TR3A 2 года назад +7

      Dave, your videos are great. Really nice to see you watching and appreciating Ben’s videos.

  • @Ed_Stuckey
    @Ed_Stuckey 2 года назад +381

    As a former employee of Teletype Corporation, the description of the signal (mark, space, start, stop, bits, etc.) brought a smile.

    • @rty1955
      @rty1955 2 года назад +33

      Agreed. Peoole forget that it was a synchronous motor with a wiper that would engage a clutch to make the wiper rotate around a plate with pads on it. The start bit would engage the clutch and begin the rotor spinning that was in sync with the line voltage. Each bit would land on a pad and either current or no current on a 20ma current loop line (remember those days?) The stop bit would release the clutch and the char. Would be printed. Ever wonder why you HAD to send a carriage return BEFORE the line feed character? Its because the print drum would be traveling back to the beginning of the line WHILE the platen advanced with the LF character which would arrive DURING the CR.
      I still have a ASR-33 with repair manuals & spare parts.
      Amazing mechanical device!!

    • @rogervanbommel1086
      @rogervanbommel1086 2 года назад +5

      I also recognize them, because I use RTTY a lot(RadioTeleTypE)

    • @michaeldavison9808
      @michaeldavison9808 2 года назад +10

      Mark, space, start and stop, parity ..... the days when my 1983 Computer Science degree meant more than just 'software engineering'.

    • @rty1955
      @rty1955 2 года назад +5

      @@michaeldavison9808 back in 1983 I was doing lots of RS232, SLDC, BISYNC. I still have my breakout boxes and protocol analyzers. That came in handy for BISYNC & SDLC

    • @jslcom
      @jslcom 2 года назад +4

      My first job (late 70's) was at a company that sold printers based on the Teletype Model 40. My first experience with RS-232 was with the EIA/current loop interface on the Model 40. Teletype built great hardware.

  • @bardofhighrenown
    @bardofhighrenown 2 года назад +11

    Leaving in the bit with the error made this video so much more interesting rather than skipping over it and doing it all correctly, I feel like I learned a lot more about how the system functions than if it had be a straight shot to it functioning properly

  • @tiesetsomatsipa5402
    @tiesetsomatsipa5402 2 года назад +749

    Thank you for coming back sir, it really means a lot for us your viewers. 🙏

    • @lucasrem
      @lucasrem 2 года назад

      RS 232, nobody needs crap, old people understand it, noobs need it too ?????

    • @NobodyYouKnow98
      @NobodyYouKnow98 2 года назад +1

      @@lucasrem
      Rest assured, people like you don't need RS232.
      Go back to Minecraft.

    • @Hugh_I
      @Hugh_I 2 года назад +3

      @@lucasrem Well I doubt your assertion that young people don't understand RS 232. Probably some just learned about it by watching this video. And luckily so, because "nobody needs crap" is just wrong. RS-232 is still widely in use. For example for serial consoles in servers or appliances, or just hobbyists toying with microcontrollers. But if you prefer to not know anything, nobody forced you to watch this video.

  • @IceMetalPunk
    @IceMetalPunk 2 года назад +366

    You're alive! I'm so happy, not only that you're alive, but that you're continuing this series. It's one of the best computer science series on RUclips, and I come away from each video both more educated and more fascinated than I started. Thank you, Ben, for all you do!
    Seeing you do all the summation to create a delay makes me glad for higher-level modern functions like usleep() 😁

    • @ZeroPlayerGame
      @ZeroPlayerGame 2 года назад +12

      I think the I/O interface he uses actually has programmable timers, it's just easier for such a small example to make a little loop. In a more real application, you'd probably set up proper interrupts so you can do other stuff while the data is coming in.

    • @xboxbrocko
      @xboxbrocko 2 года назад +2

      im also glad hes alive

    • @TS6815
      @TS6815 2 года назад +1

      seeing the 'funny meme username' from that years-old Computerphile AI generated comments video in the replies here gives me a warm fuzzy feeling .. this little community of tech-y people is a bit smaller than I thought

    • @IceMetalPunk
      @IceMetalPunk 2 года назад +1

      @@TS6815 The world is a small place when we can all share ideas with each other :)

    • @debbiebernhardt5406
      @debbiebernhardt5406 2 года назад

      The serial port/parallel port was used for cars obd 2 for programming/complex Dtc record check for cars

  • @zorinlynx
    @zorinlynx 2 года назад +364

    Seriously, I've been using RS232 my entire life and I figure I knew more or less how it worked, but your video just raised my understanding of it to a whole new level. Thank you for this.

    • @haraberu
      @haraberu 2 года назад +24

      It's amazing. Even on microcontrollers, we've gotten used to writing UART.init(9600, 8, None, 1) and having the hardware take care of the timing.
      How does it work? It works just fine, thanks for asking.

    • @iancrone2906
      @iancrone2906 2 года назад +4

      Can't think of a good reply, something about protogens?

    • @phyphor
      @phyphor 2 года назад +7

      I've always known "9600, eight, none, one" as the mantra to make things work without knowing *what* each thing was for so I, too, have enjoyed this video.

    • @davidconner-shover51
      @davidconner-shover51 2 года назад +1

      @@phyphor these days, 115200 is pretty common, though not absolute
      9600 always seemed to run in that happy, Bob Ross range, from really old dayz when the processors couldn't handle it, quite, to the modern times, 96-- doesn't seem to want to die

    • @KurtisRader
      @KurtisRader 2 года назад

      Same here. I'm a grey beard who started programming in 1976 (more than four decades ago) and one of my first college classes was programming a Motorola 6800 computer in assembly language much like this series of videos. I'm fairly certain I had to write similar code for that course but thank dog those days are long past.

  • @shabybarel7666
    @shabybarel7666 2 года назад +116

    Ben is one of the best teachers i have ever seen on the topics of computer and hardware engineering. He always starts by explaining fundamentals at the perfect pace and builds the complexity step by step. I have both BSc and MSc EE degrees and i still wait for his videos to learn something new every time. Ben, you deserve to lead your own hardware engineering lab in one of the top universities. Keep making more fantastic content, people are waiting for this.

    • @lucasrem
      @lucasrem 2 года назад

      Shaby Barel
      therapy you need?
      understand bidirectional serial communication ?
      Webb, who need to understand it here, or is this just nerdy entertainment ? To lazy to be willing to understand it, eyeballing and wonder.....

    • @EmersonCapuano
      @EmersonCapuano 2 года назад +2

      I agree.

    • @berntolovhellstrom8891
      @berntolovhellstrom8891 2 года назад +2

      @@lucasrem I wonder who needs therapy? Why are you watching and derogatory commenting things yourself are "fully" understanding? It it just to drop BS comments because you got 63 subscribers and Ben got 1 Million?
      Ben brings an extraordinary educational value to the whole world - Do you?

  • @Aurora12488
    @Aurora12488 2 года назад +165

    Thank goodness you're back!! We've missed you and your incredible computer engineering videos. :)

  • @andrewwmitchell
    @andrewwmitchell 2 года назад +29

    Great to have you back, Ben. I used to use RS-232 all the time in the 80s and 90s but I never needed to learn it at this level; so this was fascinating for me. Looking forward to the next ep.

  • @lynch-mob
    @lynch-mob 2 года назад +51

    We've missed you Ben! Glad to have you back!

    • @marcel151
      @marcel151 2 года назад +8

      The Spambots are also back. 😅

    • @lynch-mob
      @lynch-mob 2 года назад +1

      @@marcel151 Of course - it wouldn't be RUclips without SpamBots!

    • @ohasis8331
      @ohasis8331 2 года назад +2

      @@marcel151 Just keep reporting them, yt gets something done when they get flooded with reports.

  • @Eclipsed_Archon
    @Eclipsed_Archon 2 года назад +29

    It's so very satisfying to see all that work translate into actual text transmission and show on the screen! Reminds me why I started to learn programming 15 or so years ago, and really has me wanting to do more work with physical parts like this again. I really love this channel

    • @lucasrem
      @lucasrem 2 года назад

      Nothing changed the last 15 years, we still use the same code here as in 2005, not needing to update the systems.
      non secure bidirectional communications, the old days was crap! anyone can get in !

    • @Hugh_I
      @Hugh_I 2 года назад +3

      @@lucasrem What do you mean "same code as 2005 here"? Ben just wrote his assembly code in 2022 for this educational example, not to deploy a control interface for a nuclear reactor. This has nothing to do with whether people update outdated insecure infrastructure or not.
      But if you're really concerned about someone hooking up a listening device to your serial cable, you can always send encrypted data. That is a question of whatever "protocol" you make up in software on top of your serial communication, not a question of how old your physical transport layer is. USB, Thunderbold, Ethernet or whatever you think is not "old days crap" is by itself "non secure bidirectional communication" as well.

  • @Gunbudder
    @Gunbudder 2 года назад +92

    The negative voltage requirement of RS-232 is why some ATX power supplies still provide a negative voltage reference on one of the pins. The power supply manufacturers want to provide it in case the end user has a motherboard that uses on board RS-232 (some industrial motherboards still use it). usually the available current for the negative voltage reference is pretty small though (around 1 amp or less).

    • @stevedonkers9087
      @stevedonkers9087 2 года назад +17

      Yes, most of the power supplies I have seen have -12v at around 300 milliamps. For a comparison I don't think I've seen a +12v rail lower than 10amps.

    • @eDoc2020
      @eDoc2020 2 года назад +3

      @@stevedonkers9087 +12v capable of less than 10 amps is pretty common on older power supplies before the 24-pin connector. Even my old P4 system with the 4-pin CPU connector only does 8.5 amps.

    • @petevenuti7355
      @petevenuti7355 2 года назад +1

      Is this why USB to rs232 adapters don't work?

    • @eDoc2020
      @eDoc2020 2 года назад +11

      @@petevenuti7355 USB to RS232 adapters use a chip like the MAX232. This chip uses a charge pump to create positive and negative from a single 5 volt input. It only generates around +-7 volts instead of the 12 volts RS232 devices are supposed to output but it still works fine with most devices.

    • @MattOGormanSmith
      @MattOGormanSmith 2 года назад +3

      Some old sound cards used it too, for proper op-amp IO without DC offset. Old BIOS EPROMS also used the -5V IIRC

  • @kmonyt
    @kmonyt 2 года назад +67

    While admittedly less used on consumer grade equipment, the full 25 pin connector was certainly popular for network equipment in the 1990s and 2000s. Routers w synchronous serial connections would come off as DB25, and connect to CSU/DSUs that would then connect to 64K or T1 circuits to go over a WAN. Often to a remote office or ISP. The flow control signals aren't optional or unused, quite the contrary, they were essential to a proper setup. Console ports are much simpler, but the full interface was used regularly for certain applications.

    • @benjaminkeebler4218
      @benjaminkeebler4218 2 года назад +7

      This brings back memories of conference calls with network vendor support while on-site with a telco rep, trying to figure out why the *insert nsfw-language here* circuit wouldn't come up.

    • @chrishartley1210
      @chrishartley1210 2 года назад +7

      And well before the 1990's too. Clock speeds in the 70's were not sufficiently reliable to allow asynchronous transmission at anything above about 300 bits/s (and 75 bits/s reverse). That was enough for a teletype console and keyboard since that was considered faster than the teletype could print or anyone could type, but for serious communication speeds synchronous comms was a requirement. I never saw any equipment that used the secondary channels though.

    • @devMashcom
      @devMashcom 2 года назад +3

      All my 80's retro gear uses 25 pin connectors too. I never really saw 9 pin connectors on anything except joysticks before the 90's!

    • @loudej
      @loudej 2 года назад +1

      @@chrishartley1210 fascinating! I've never heard of slower than 300 baud before, but esp if flow control was optional on those devices it would make sense.
      At 7-10 characters per second were those teletype physical printers?

    • @chrishartley1210
      @chrishartley1210 2 года назад +3

      @@loudej There were a lot of different styles of teleprinter, Teletype was probably the most successful and was a division of AT&T.
      10cps was typical so they were slow and quite noisy, but they were a fraction of the cost of the early video terminals.
      I remember using one of the early graphics terminals (a Tektronix 4010 if I remember correctly) around 1974. The university only had one, it probably cost a small fortune but paper costs for the Teletype 33 terminals would not have been insignificant.

  • @Wazzaps
    @Wazzaps 2 года назад +26

    Welcome back!

    • @briankimathi5033
      @briankimathi5033 2 года назад

      Wait, this video was uploaded 5 minutes back. How did you comment on it 2 hours prior??

    • @TotallyNotJason101
      @TotallyNotJason101 2 года назад

      @@briankimathi5033 prob patreon

  • @GrantMcLean
    @GrantMcLean 2 года назад +10

    Great video as usual Ben. It took me back to my days as a data communications technician. When you talk about the clock pins not being widely used, remember that RS232 supports two different modes of operation. Asynchronous communication works as you described and was commonly used with terminals and printers. Synchronous mode used the clock signal and was more efficient because it didn't need a start and stop bit for every character. Synchronous mode was commonly used on higher speed lines which used multiplexers, data concentrators or protocol converters. For example X.25 packet switched data links or SDLC communications to an IBM mainframe used synchronous mode, and the modem would supply a clock signal.

    • @lucasrem
      @lucasrem 2 года назад

      What did you do in the market ?
      sentimental reasons, why you watched it ?

    • @GrantMcLean
      @GrantMcLean 2 года назад +1

      @@lucasrem Heh, yeah maybe sentimental reasons 😄. I always enjoy Bens explanations of things I'm not too familiar with. I thought it would be interesting to see his take on a topic I was familiar with.

  • @smellysam
    @smellysam 2 года назад +74

    In the Subsea sector, RS 232 and 485 are still relevant on ROVs. They work very well in high noise environments (shielding can only go so far with multiple 3000V AC motors in close proximity). The systems are usually 3 pin...

    • @squelchedotter
      @squelchedotter 2 года назад +27

      They're relevant for almost anything industrial. Lots of things like Modbus (used to control basically anything industrial, including probably your buildings AC) run over RS 485.

    • @brianmiller1077
      @brianmiller1077 2 года назад +8

      Card access controllers talk to subpanels via 485.

    • @Elitekross
      @Elitekross 2 года назад +5

      Aircraft too!

    • @johannesgaida3137
      @johannesgaida3137 2 года назад +5

      With the NMEA standard? Because we use NMEA 0183 a lot with glider avionics.

    • @Elitekross
      @Elitekross 2 года назад +4

      @@johannesgaida3137 it depends on the simulation

  • @Pedro_MVS_Lima
    @Pedro_MVS_Lima 2 года назад +1

    On a previous spawn of my ethereal soul, I was the sysop of a self-owned amateur BBS. Dial-up, using modems over the PSTN kind of stuff, and the link between the computer and the modem was through an RS-232 connection, so I knew the protocol pretty well for my daily usage. Nonetheless, your description of the RS-232 protocol is by far the clearest and cleanest I've seen. Being a computer programmer, I've always wondered how it could work well without an explicit clock signal, even if both sides agreed on the baud rate, stop bits and parity. I admit, I never actually needed to explore it, but you cleared up that issue for me after nearly 35 years. 😁 Thank you!!!

  • @iMentox
    @iMentox 2 года назад +6

    Thank god you're alive, I was worried. Great to see you back!

  • @luqdude
    @luqdude 2 года назад +22

    The production quality of these vids is amazing, glad that you're back

    • @lucasrem
      @lucasrem 2 года назад

      just a home job, web cam, final cut skills !
      your channel ? play games ...? need quality channel, stop playing !!!!

    • @luqdude
      @luqdude 2 года назад

      @@lucasrem huh?

  • @mashrien
    @mashrien 2 года назад +54

    Holy crap. I thought the rona got him. Glad to know you're still alive man.
    Thank you for coming back and uploading the content we all love- My kit's been sitting on the shelf gathering dust ; ;

  • @Zhixalom
    @Zhixalom 2 года назад +13

    Ever since I encountered my first DB25 RS-232 serial port back in the '80s, I have wondered about this... Just brilliant! ❤

  • @sonovoxx
    @sonovoxx 2 года назад +7

    Whaaaattt!!! He's alive! Sooo good to see you back! Literally trawled the web occasionally for mention of your name in the hope to hear you were ok. Delighted to see a video! 💪👏👏👏

  • @tiger12506
    @tiger12506 2 года назад +8

    Had to do a lab in college using a similar architecture to create a musical tuner. So had to precisely measure freq, ex: 440hz. Your clock cycle counting and nop to balance both sides of a branch brought a smile to my face. Someday I'll go back to playing with those types of things again.

  • @somilamaloyi7544
    @somilamaloyi7544 2 года назад +5

    i’ve beeen waiting for a new Ben Eater video😭😭❤️‍🔥 keep up the hard work Ben 💪🏽💪🏽

  • @milk-it
    @milk-it 2 года назад +10

    Assembly programming interacting with hardware. Love it! More, please! Very well explained!

  • @DoctorMikeReddy
    @DoctorMikeReddy 2 года назад +14

    It’s been too long! Glad you’re back. Please don’t make us wait so long again

  • @bDub779
    @bDub779 2 года назад +4

    Never knew RS stood for recommended standard. Those little knowledge nuggets just add value to these videos. Thanks!

  • @BlackHoleForge
    @BlackHoleForge 2 года назад +270

    I can't believe I went my whole life without realizing that RS stood for recommended standard.

    • @ohasis8331
      @ohasis8331 2 года назад +5

      You're not Robinson Crusoe.

    • @BlackHoleForge
      @BlackHoleForge 2 года назад +4

      @@ohasis8331 I don't know what that means, but we used to make up random words for those standards when we were kids. And the sillier the better. My favorite one was RS 232 which I thought stood for robot servicing. I even went to school later for networking, and that never came up.

    • @ohasis8331
      @ohasis8331 2 года назад +6

      @@BlackHoleForge Robinson Crusoe from classic literature, lost on a deserted island, means all on your own, by yourself, the only one etc. though from ancient memory, he may have had a manservant at some time. Or maybe I am mixing stories but you should get the drift :)

    • @plumber1337
      @plumber1337 2 года назад +7

      "The best time to learn something was 10 years ago, the next best time is now."
      I remember hearing this somewhere, but can't remember where.

    • @jgharston
      @jgharston 2 года назад +2

      We have RS Components in the UK, and initially thought is must have been something related to them.

  • @SirKenchalot
    @SirKenchalot 2 года назад +7

    So glad you're back as your videos are fantastic. I still think your series on building your own 8 bit computer Is one of the best on RUclips.

  • @draggonhedd
    @draggonhedd 2 года назад +17

    You always do such a good job of explaining these concepts in a clear and understandable way. I feel like I understand this in a way I haven't before.

  • @ron.v
    @ron.v 2 года назад

    Who besides me fast forwarded through the clock cycles explanation? Except for that, I loved the video. I learned a lot more about RS-232 than I ever thought I'd know. My first computer was a Commodore-64. The video connector was poor at best (TV) so I bought an RS-232 adapter and connected surplus DEC writer I purchased from work (with free box of fan-fold paper). I wrote a simple BASIC program for my kids. They loved "talking" to the computer and answering its questions. Later, I worked with nothing but RS-232 links to all 66 of our PDP-11 minicomputers at work. I never knew more than the basic pins for the individual signals so this video was a real education.

  • @ThirdInLine
    @ThirdInLine 2 года назад +9

    I was just thinking how it had been a long time since is seen anything from you! Thank you for all your amazing content!

  • @Rukkus333
    @Rukkus333 2 года назад +12

    Thanks Ben. These videos have immense value to the world.

  • @-UPH-KRISHNAM
    @-UPH-KRISHNAM 2 года назад +5

    Great to see you again Ben 😍

  • @eqwerewrqwerqre
    @eqwerewrqwerqre 2 года назад

    This is a gift from god! I've just received my first RS-232 to USB connector that I'll be using in my physics laboratory project with the oscilloscope. Reading data from fiber optics, testing attenuation and error/data loss effects and eventually getting to single photon polarization to experiment with quantum key distribution. I've been mulling over tons of ooollldd documentation for programming to the oscilloscope through the connector and I've been wondering about the specifics of the connector. And here it is!! Imagine my surprise when literally the day I receive the connector, I also receive the best comprehensive overview of the standard I could ask for. As well, I'd never understood what exactly the "clock rate" was for, while you've explained it beautifully
    Your timing is impeccable and your information, invaluable. Thanks a million mate :)

  • @AsmodeusMictian
    @AsmodeusMictian 2 года назад +11

    Fantastic to see a new video posted from you, sir! Thank you, as always, for educating me a bit more. It's always something interesting :)

  • @elamperti
    @elamperti 2 года назад

    I used these cables for years when I was a kid and all those config options (bauds? parity?) were just magic numbers. It's amazing to finally understand what they mean and how the protocol works. Thank you very much!

  • @Mr_ToR
    @Mr_ToR 2 года назад +10

    haven't watched it yet, just got the notification for the new video. so anxious to go home and watch. we're so lucky to have you on youtube ben eater! you're the best teacher!

  • @phlosen7854
    @phlosen7854 2 года назад +1

    You show every step of your Process in detail. I fully understand what you are doing and why you are doing it. It still is magical and impressiv when it just works. You are great!

  • @Hiphopasaurus
    @Hiphopasaurus 2 года назад +144

    Nice tight loop, gone are the days (at least in PCs) that you have a known fixed clock rate and execution time, but so awesome to see that in action!
    Have you ever thought about getting a ZIF socket adapter for that EEPROM on the breadboard? I always get so nervous watching you pry out and insert the chip with all those wires around it! :)
    Fantastic video as always!

    • @CraigBrideau
      @CraigBrideau 2 года назад +10

      I thought the same thing about the ZIF socket. So many bent DIP pins doing this over the years...

    • @WolfePaws
      @WolfePaws 2 года назад +3

      Hah, yes, absolutely - I've been thinking this since the start of the project. Alternatively there has to be a way to program it in place.

    • @CraigBrideau
      @CraigBrideau 2 года назад +5

      @@WolfePaws PIC and AVR have ICSP (In-circuit serial programming) where you just leave a pin header attached to the programming lines on the chip. A cable connects from your programmer to the header and you can program whenever you want without having to move the chip.

    • @richardbanks2669
      @richardbanks2669 2 года назад +9

      I tried this once, but typically ZIF sockets themselves have legs which are too fat to fit into standard solderless breadboard :(

    • @Hiphopasaurus
      @Hiphopasaurus 2 года назад +3

      @@richardbanks2669 Very good point. The ZIF sockets I have do have very stubby leads too and I don't recall ever trying to put them on a breadboard.
      Though I think the reason he doesn't is just because of the way he explains things so clearly and non-distracting way, like only using what you actually need to do this. Just like he shows the assembly and EEPROM writing steps each time, so it's absolutely clear what is happening.

  • @TheTomCruiseLover
    @TheTomCruiseLover 2 года назад +1

    This is suuuuper cool! Just 7 videos ago, we were all in 1952 in ENIAC era on breadboards... Now, were all at 1992 Basic Instinct era !!
    Thanks Ben eater, you have inspired my own breadboard project, which is an FPGA programed by an Arduino nano and Dc-4017 made out of 555 timers, the cheapest IC I could get that works on Digikey !! Since my family doesn't have much, As of now it's got 7 555's on a double bread-board in fully functioning gate array mode and building up strong!

  • @scrimpysquare1485
    @scrimpysquare1485 2 года назад +4

    the legend has returned

  • @sandyleask92
    @sandyleask92 2 года назад +1

    I use RS232 nearly everyday at work and was very interesting learning more about how it works. For debugging I found a USB-C to RS232 converter so I can use my phone for a terminal rather than using a laptop. Saves so much time.

  • @Controllerhead
    @Controllerhead 2 года назад +4

    Incredible video quality and technical explanation! So glad you're back!

  • @colonelbarker
    @colonelbarker 2 года назад +2

    So happy to see you're alive and well. We've missed you greatly.

  • @markm0000
    @markm0000 2 года назад +11

    Bro you got to keep regular updates on the community tab because I was genuinely concerned for a while.

  • @waitemc
    @waitemc 2 года назад +1

    What a teacher. I'm a 44 yo mechanic/welder and you have explained this perfectly. I fix stuff on the side or I should say "I try to fix ". Thank

  • @soundspark
    @soundspark Год назад +9

    I had a lab in community college where we scoped out RS-232 protocol, bit-banging the UART with ASM.
    We didn't have digital storage oscilloscopes and as such we wrote a simple program to repeatedly send a single character. When the PC was on Windows 98 the timing was all over the place, much more stable when booted to plain DOS.

  • @devMashcom
    @devMashcom 2 года назад +1

    To echo the sentiments of others, this was a wonderful video. I've used RS-232 my whole life (I wired up my first null modem when I was about 13 or 14), but this video helped me to see it at a deeper level. There is no substitute for visualizing the data on the Scope - the start/stop/parity bits become instantly clear. The mark/space reference finally makes sense too! I'm excited to see how this evolves; that little read/timing loop works just fine, but I bet there is a better way coming. I know they take a ton of work, but please keep making these most excellent vids! Cheers!

  • @64jcl
    @64jcl 2 года назад +23

    Great tutorial on RS232 ! Btw you could simplify a couple of things in your code. Use Y index register for delay countdown instead of X to avoid the phx plx. Also reuse same delay routine by setting Y to either #13 or #6 before calling the wait routine depending if you want to wait a full bit or a half bit. Btw, an interesting thing about the Commodore 64 was that they never did a real RS232 implementation as part of the hardware but delegated that to the CPU so the machine actually had to this identical bit fiddling to transfer or receive a byte. However they did make use of a timer triggering a NMI (non maskable interrupt) so that the read bit was done quickly and a return from interrupt passed control back to the program running. However, the max speed you could use was 2400 baud with this method, and even then they messed up the timing table for PAL computers so it is in fact broken on all machines made! However, one could code this yourself and get as high as 9600 baud like you do here on your 6502, but then have no time to do other stuff while you were sending or receiving. A hack was done to enable this though by simulating a clock signal to trigger an interrupt as all transfers always started with a 1 but required a hardware hack for the receive signal.

  • @vdubjunkie
    @vdubjunkie 2 года назад

    I have to say again how much I appreciate the way you explain these things. It really works for me.
    I’ve been using RS232 for years, console access to various networking devices, and now I understand it on a completely different level!

  • @75slaine
    @75slaine 2 года назад +4

    Welcome back Ben, great to see you making videos again.

  • @theoneandonlymeshe9174
    @theoneandonlymeshe9174 2 года назад +1

    One of the few channels I have the bell turned on for and stop whatever I’m doing when a new video comes out.
    Thank you Ben 💞

  • @lithou4689
    @lithou4689 2 года назад +3

    Glad to see you back making videos. As someone who works troubleshooting both old and new tech, your videos have helped me gain a huge insight into how things work. We infact still put RS232 on new products we make for backwards compatibility with older equipment.

  • @hashtagPoundsign
    @hashtagPoundsign 2 года назад +1

    Very satisfying to watch.

  • @sunipmukherjee2130
    @sunipmukherjee2130 2 года назад +11

    Hey glad to see you back man! Hope everything is alright with you. Great content as always.

  • @moshesakajo
    @moshesakajo 2 года назад +1

    as always, it is a great pleasure to watch your tutorials. It is good to have you back in business

  • @xmcblxck
    @xmcblxck 2 года назад +3

    Ben you are a genius! Seriously, I love your videos they are very informative and I am learning a lot. I think we are all happy when a new video from you comes online 👍

  • @xoeriphenburg4413
    @xoeriphenburg4413 2 года назад +1

    I just dropped out of my classic mechanics course (first step in the 4 levels of physics required for a CS/CE bachelor's) and you've given me a lot of inspiration to keep going... this was so engaging, and I was able to follow all of it - even being someone who never took high school physics and have not gotten past my first level of physics or calc 2. This is lovely. Thank you so much.

  • @SuperMurrayb
    @SuperMurrayb 2 года назад +6

    Interesting video. Thanks for posting it. For the IBM PC there was a LAN that used the 25-pin RS-232 connectors joined in a ring configuration. The LAN did not require a network card only a 25-pin serial port on each machine. Zero-slot LANs were fairly popular until affordable Ethernet cards became available.

    • @Chris-ib8lw
      @Chris-ib8lw Год назад

      These were the original token-ring protocol networks correct? I remember reading about this many, many years ago in a MCSE class I took.

    • @SuperMurrayb
      @SuperMurrayb Год назад +1

      @@Chris-ib8lw Token Ring was IBM's system with real expensive cards connected using heavy coaxial cable we called "frozen yellow garden hose". It used an expansion slot. All I recall was there was a zero slot LAN for up to seven workstations that used a 25-pin RS-232 connector for each machine. For each connector there was one cable connected to one transmit and receive pair of pins and another cable to the other pair. One cable went back to the previous machine and the the other went on to the next machine. A small TSR (Terminate and Stay Resident) program in each station would receive each packet and use it or forward it to the next machine. I do not remember anything else because I never worked on any zero-slot LANs. They were quite slow at 115 Kbaud, or so, and were only used for tiny networks.

  • @kevinmcnamee6006
    @kevinmcnamee6006 2 года назад +2

    Its amazing that engineers could design a 25 pin interface to carry serial data between DTE and DCE. Even when they reduced it to a 9 pin connector, only 4 pins were actually used. I loved the programming example in the video. It was great to go from the example that printed an "X" when something arrived to actually printing the ASCII characters. Great video.

  • @danielhermanus6909
    @danielhermanus6909 2 года назад +5

    Been waiting for this!

  • @lmiddleman
    @lmiddleman 2 года назад

    RS-232 signals are defined as referred to the DTE. When you mentioned this simple fact, often missed by even experienced people, you earned a thumbs up.

  • @munzeralseed
    @munzeralseed 2 года назад +15

    "A while ago I built this breadboard computer..." This is like your father who went out to get milk, but he is back after 23 years with a carton of milk in his hand, asking why the breakfast isn't ready yet.

    • @Ozhull
      @Ozhull 2 года назад +1

      How is it like that in any way, even remotely?

  • @tylerbunnell8714
    @tylerbunnell8714 2 года назад +1

    New Ben Eater video?! Just what I needed after a brutal week! Haven’t even watched it yet and already know it’s gonna be fantastic!

  • @EdgeGaming
    @EdgeGaming 2 года назад +35

    This is so interesting. Out of my depth and you lost me at times but still fascinating. I've never seen bits on an oscilloscope like that!

    • @chicken_punk_pie
      @chicken_punk_pie 2 года назад +13

      If this interests you enough you can go back and watch his older videos and learn exactly what all of it means. This channel is amazing.

    • @leong108
      @leong108 2 года назад +1

      Just watch for RTS and CTS ... and cross over (DTE to DTE , or DCE to DCE ) connections.

    • @ohasis8331
      @ohasis8331 2 года назад

      @@chicken_punk_pie And it is well worth doing, you can do it at leisure rather than force it. I took months but got the whole lot.

  • @Hanschri
    @Hanschri 2 года назад +1

    I love the fact that he took the time to put on a Patreon t-shirt for the outo, you can barely see it in the reflection of the terminal! Fantastic video as always!

  • @oneeyefpv
    @oneeyefpv 2 года назад +7

    Great video. Also great to see someone programming in assembly so fluidly!

    • @rty1955
      @rty1955 2 года назад +2

      Ive been programming in assembly for over 50 yrs
      Best Language ever

    • @ivarnordlkken8082
      @ivarnordlkken8082 2 года назад

      @@rty1955 Me too. Both 6800 and Z80.

    • @rty1955
      @rty1955 2 года назад

      @@ivarnordlkken8082 I had began my work on IBM unit record equipment like the 407 using plugboard wiring then the IBM 1401 and then the IBM 360/30 ans on up. I played with the Intel 4004, and found it to be a toy. I built my own processor built around 7400 chips that mimicked the IBM mainframe instruction set. When the 8080 came out, I used it for an S-100 bus microcomputer. Coming from a mainframe environment, I found the instruction set to be VERY limiting. And could not grasp a SP register, as mainframes don't use that. I wrote major applications in assembly lang on mainframes with only 48k of memory. I was always amazed on what i can do with such limited memory. I would watch a tape sort on a mainframe (which was way faster than using disk) and was in awe. After it read alp the input data, it would print out how many passes of the data it would have to make before final output. You could even tell it which tape drive you wanted the output on even though it used that drive as a work drive! The instruction set was VERY powerful in mainframes and I missed that when I wrote for the Intel platform. For example I could clear 16meg of memory with just ONE instruction. Also the absence of 16 general purpose registers boggled my mind! Who would design such a limited processor! To me, the processors in a PC will always be a toy. They never matured. I now code on TI processors like the MSP430 and PIC type decixes8

  • @philc2729
    @philc2729 2 года назад +1

    What can I say? I'm flabbergasted by the ease that he does this stuff. Great presentation as usual

  • @sylpisophia5612
    @sylpisophia5612 2 года назад +2

    i used to be so patient and diligent in doing stuff like these. now, my attention got diluted by so much stuff. I'm glad to see videos like this. I could at least feel the excitement without needing to commit to another project 🤣

  • @fredinit
    @fredinit 2 года назад +2

    Ben, Glad to see you're alive and well - and continuing this series.
    Reminds me of many serial debugging sessions... where some device manufacturer would use the wrong gender (M when it should have been F), 25P on one end, 9 on the other... so we'd bolt together gender blenders, 25-9 pin adapters, maybe a null modem, and an LED module (for the user... are there blikenlights?).. all behind a desk with about half an inch of dust, paper clips, thumb tacks, coffee stirrers, get well cards, and the occasional half-eaten doughnut.
    Also, love you showing the assembler (and your mistakes :). Another blast-from-the-past doing 8086 during my CS degree times. With all the high-level languages out there (C and higher) we forget how nested and spaghetti assembler can be. As well as where the CPU meets the real world (pins).

  • @clooskey
    @clooskey 2 года назад +7

    Okay, I have to let it out.
    I missed your videos so much that I started looking for another places where you might have had been doing... anything 😂 Also made sure that there is no rumours anywhere saying that something bad happened. I was thrilled to discover the Ben Ben and Blue podcast, oh, that was a great listen! The 'origins of Ben Eater' are so inspiring. I love your story and keep learning so much from your videos. I'm glad they're back 😀
    Actually I'm using a lot of industrial RS-232 speaking devices (barcode scanners, measuring equipment) at work and still learned new things from this video 😀

  • @IT10T
    @IT10T 2 года назад

    Didn't think I would find a serial port video so interesting. I always learn something from these wise guys on the tube.

  • @the1spyderryder
    @the1spyderryder 2 года назад +3

    In RS232 there are 10 bits sent 1 START bit followed by 8 data bits and a stop bit so ten bits also there can be one or two parity bits sent before the stop bit. Also there can be seven data bits and one parity bits. So the maximum number of bits sent before resyncing the data is eleven or possibly twelve then when the next start bit is sent the clock is resynched. The start bit is longer than a regular data bit that is why in some devices the receiving device can calculate the baud rate just from timing the start bit and set its own baud rate from that.

  • @renjunathp6376
    @renjunathp6376 2 года назад +1

    Welcome back Ben. So happy to see you back in action.

  • @GrenYT
    @GrenYT 2 года назад +4

    Great video! Few improvements that could be possible:
    1. Use a conditional jump subroutine to get a 3 cycle delay instead of 2 NOPs for 4 cycle delay, to allow getting the more exact 104us delay
    2. Half bit time routine wasn't exactly half a bit time. Would be closer to 69-70us when half bit time is 52us. But not super important here.
    3. Could be cool to parameterize your delay subroutine so you have the same sub routine for 1 cycle and half cycle, but that's just for overachieving:)

    • @leong108
      @leong108 2 года назад

      He is just doing bitwise ttl receive for this video ? I think it will fail when he has a longer cable .. more capacitance... he will show you then show how a UART handles it still.

    • @Zarazaize
      @Zarazaize 11 месяцев назад

      I was also concerned about half bit timer :)

  • @lennywintfeld924
    @lennywintfeld924 2 года назад

    On the level converter: many transistors have a base-emitter breakdown voltage smaller than the rs232 mark voltage. If you don't exceed the reverse breakdown power for this junction the circuit will continue to work fine for awhile, but the transistor's beta will gradually degrade and the circuit will eventually fail. A series diode on the base (cathode to base) or a shunt diode from base to ground (cathode to base) would fix this. BTW the reverse breakdown base-emitter maximum power is never specified, because the manufacturer doesn't want you to run the transistor in that mode. They specify the b-e reverse breakdown voltage so you know what not to do.
    One other point: half of 13 isn't 6. I won't tell anyone if you don't :-)
    Finally: I love your coding and explanations, they're crystal clear! Your whole approach is a pleasure to watch. Thanks!!

  • @MohammadAlmeqdadi
    @MohammadAlmeqdadi 2 года назад +6

    This video made this day so much better! You're a great teacher, and I enjoy your videos, and learn so much even though I know I would likely never be this capable, but brings a smile to know that at least I understand how things work. I always had those questions as a kid and it feels good to finally 'get it'. All the support :)

  • @ChrisHorneVL
    @ChrisHorneVL 2 года назад +1

    Man, what a great breakdown of serial.. I honestly always wanted to know what the stop bit/parity etc meant since I was a kid. Seeing it like this makes it seem so simple!

  • @the1spyderryder
    @the1spyderryder 2 года назад +6

    It has bee. A while since i wrote assembler and it was mostly Z80 and 8051 code. But i have done 6502 a very long time ago on the VIC 20 and the C64...lol it was a joy watching someone else coding in assemler! Great Video.

  • @zadinal
    @zadinal 2 года назад

    I'm not an engineer or programmer, just an occasionally dabbler in these topics and this is actually a very handy subject. Thank you for posting

  • @GuildOfCalamity
    @GuildOfCalamity 2 года назад +2

    It was nice to see you address the rising edge/falling edge timing. It's wonderful when you don't have enough ICs to be concerned with fan-out and de-bounce.
    Would love to see a follow up on flow control or half vs full duplex.

  • @EinChris75
    @EinChris75 2 года назад

    25:42 "that's awesome". Indeed it is. As always an excellent video. Happy you are back.

  • @joeglens
    @joeglens 2 года назад +6

    This reminds me of my days doing assembly programming on a PIC16F84. I had implemented a bit-bang UART driver that drives an rs232 interface.
    Also a 232 interface using a simplified ttl level voltages is prevalent in embedded programming for debug purposes

    • @saitamapreetsingh3057
      @saitamapreetsingh3057 2 года назад

      git ?

    • @TheWeepingCorpse
      @TheWeepingCorpse 2 года назад +1

      I also used the PIC16F84. The program memory was so small that I had to write a single bit bang routine to handle rs232, i2c and rs485 for an amusement arcade machine monitoring system, I remember using an interrupt pin for the rx line, causing the start bit to trigger an ISR . Now we have atmega328 its a different world. LOL.

  • @ludovicfrochot5774
    @ludovicfrochot5774 2 года назад +1

    Hi Ben, glad to find a new video from you! Very clear and inspiring as usual. Thank you!

  • @hh-yz8nw
    @hh-yz8nw Год назад +6

    Great Ben thanks to have you are back after this "pandemic" period. Wish I could have learned all this from you in my early days. Best Regards from Hans in the Netherlands.

  • @bharadwaj297
    @bharadwaj297 2 года назад

    Fanstastic !!! I am very glad that there is channel which is doing fundamentals so eloquently.

  • @raymitchell9736
    @raymitchell9736 2 года назад +4

    Excellent tutorial, I don't think many people programming today would get, or appreciate counting CPU cycles... but that is how we had to do it back in the day! Even at UBICOM in the year 2000 their microcontroller would read the ethernet traffic in the ISR it did cycle counting... It was a Hard real time requirement, and the branching through had to balance in time regardless of the data received. Next when you get to the UART part of your tutorial, when I wrote my Master's thesis in Computer Science I did a study on Real-Time communications and used RS-232 and did the deep dive into that protocol and the whole architecture of the IBM's UART, PIC Controller, and learned just how flawed that was... I figured out the hardware bugs, I think 5 to 7 gotchas that did things like: prevent Full-Duplex ISR driven TX/RX, what the source of those mysterious callbacks when the line was enabled or disabled, instruction overlap in the x386 and the I/O instructions, etc. Back in the early 90's I researched this deeply, and I never saw printed in a book!

  • @saturten
    @saturten 2 года назад

    I took several classes that covered serial protocols in college, and I'm ashamed by how much I didn't understand until watching this video. Awesome resource, thank you for making this

  • @christianm6052
    @christianm6052 2 года назад

    I recently started using MODbus and RS485 for my job and the first thing I did was check your channel for a video since yours have been the easiest to digest. Great work!

  • @andreweastland9634
    @andreweastland9634 2 года назад +2

    The clock pins were commonly used and are required for synchronous modem connections, typically used on private wire circuits. In the days before the internet this was how you interconnected branch sites, originally with a copper circuit patched through the local exchanges between sites.

    • @leong108
      @leong108 2 года назад +1

      But as it turned out, switching to asynchrous meant it worked on longer cables , noisier environments.. noise on the clock signal would send it haywire... the async UART works with about 5 samples of the received bit.. See, sometimes the circuit would be a bit assymetric (eg for mark vs space) and so the timing of the signal coming through would be a bit skewed.. as the main problem with a long cable is capacitance, the charging of it takes a bit of time.. if the circuits are not perfectly symmetrical, the timing of the pulse is not symmetrical (between mark and space.)

  • @jengelenm
    @jengelenm 2 года назад

    As a service tech, i use RS233 for 20 years and ongoing. It is still very much used in industrial PC’s and PLC’s today. Finally i understand why i always have to set baudrate equal for transmitter/receiver!

  • @supergreatlifewithgames1080
    @supergreatlifewithgames1080 2 года назад +15

    I learned more from him in a day than my entirety of schooling years.

  • @whatthedeuce47d68
    @whatthedeuce47d68 2 года назад

    I use RS 232 on a daily basis at work communicating serially with various plc based systems that are 20 odd years old..
    Great video as always

  • @der.Schtefan
    @der.Schtefan 2 года назад +5

    Finally a video again! :) It's crazy to think that 1 MHz is barely fast enough to read 9600 bps comfortably. Can't go much faster and do anything useful with the data. Btw, you should have probably subtracted the time it takes to write the character on screen from the stop-bit-wait-time to be super correct, even though it is probably a fast action anyway.
    Looking forward to the video showing this with a dedicated chip.

    • @josephbuys
      @josephbuys 2 года назад +3

      The print doesn't happen until all the bits are properly put into the A register. The looping only happens while he is reading the bits from the serial port, which has very specific timing. The whole point of RS232 is that the clock is synced on the first read of a bit, basically the second line of code in rx_wait. So the print is not happening until after the looping, so it is not counted in the clock cycles.

    • @ChrisBouchard
      @ChrisBouchard 2 года назад +2

      But he does need to be careful that it doesn't take more than 104 cycles, so that it runs while the terminal is transmitting the stop but, or else he may miss the start of the next start bit.

    • @billr3053
      @billr3053 2 года назад +2

      In real computers there is normally a dedicated chip “UART” (universal asynchronous receiver / transmitter) that does all this timing and shifting. The CPU is not expected to do all this. The UART chip is told what baud rate and it does its thing in parallel with whatever else the computer is doing. The computer may just be waiting for each character or do real work.

    • @fredov10
      @fredov10 2 года назад +1

      You can get away with it as long as you allocate a circular buffer to store the received data AND use interrupts to do the reading. The display timing requirements are really not that strict. Check out The 8-bit Guy video on character LCDs, he used push buttons to write data to the display at normal human speeds.

    • @andreweastland9634
      @andreweastland9634 2 года назад +1

      @@ChrisBouchard That is what the cts signal is for, all he has to do is to drop cts at the end and the sending device should then wait. When ready to receive the next character he raises cts again. cts = clear to send.

  • @theProtoster
    @theProtoster 2 года назад +1

    A new Ben Eater release, finally some good news in the world!

  • @gdclemo
    @gdclemo 2 года назад +5

    This was interesting! One apparent mistake: when you calculated the timing for the half-bit you didn't account for the other cycles which were part of the read loop, you just divided the loop value by two, though I expect that was accurate enough to read from somewhere within the stable part of the bit. It would be nice to cover audio and MIDI in a future video.

    • @DerHeiligste
      @DerHeiligste 2 года назад

      It probably works out with 6 being a little less than half of thirteen, too :)

    • @jmarkmurphy
      @jmarkmurphy 2 года назад +1

      By my calculations, 9 would have put it right in the middle, even closer if you put a nop outside the loop. But as you say, hitting the middle exactly isn't real important. Throwing the bit delay routine to skip the stop bit is a little more questionable as it doesn't wait a whole bit without all the read logic, in fact it waits maybe 24 or 25 ms less than a whole bit. But you really want to wait 1.5 bits because you have the last half of the last bit, plus a whole stop bit to wait if you are going to do that. Probably best to just wait for the next start bit.

    • @kallewirsch2263
      @kallewirsch2263 2 года назад +3

      It is not a big deal.
      If the sampling point is exactly at 50% of the bit time or 40% or 60% into the bit time, doesn't matter.
      The purpose was to shift the sampling point away from the signal edge, since at that time (and only at that time) a few nanoseconds may make all the difference.

    • @kallewirsch2263
      @kallewirsch2263 2 года назад +2

      @@jmarkmurphy
      No
      You do note want to wait the stop bit time at all!
      The purpose of the stop bit is for the sender to provide the receiver enough time to process the received byte. In his case it is the output to the lcd.
      The stop bits are a setting for the sender only. A receiver can ignore this setting completely since the sender will start with a new start bit for the next byte anyway. There is no point for the receiver to wait when he can use that time for much more important things (as eg. storing the byte in a queue).
      You may want to wait for the last data bit to be finished (but not the stop bits!). But you don't need to when the UART read loop is constructed like that
      wait for mark

  • @nixiejanjurado5727
    @nixiejanjurado5727 2 года назад +1

    I missed you ben eater. I've been checking for your new posts at least every week!. Glad you're back!

  • @JDS928
    @JDS928 2 года назад +5

    Ben can u make a video on the popular RS485 protocol as well

    • @ohnoitisnt
      @ohnoitisnt 2 года назад +1

      Agreed, RS485 is everywhere in industry (probably in my field about the same as rs232!) but is better in harsh environments, transmits further and faster, and is a bus so you can hook up more than 2 (hundreds of?) devices

    • @randomdebris
      @randomdebris 2 года назад

      and for compatibility with old hardware maybe RS/TIA/EIA-422 as well?