Hacker News new | ask | show | jobs
by vbezhenar 1404 days ago
Usually Ethernet support requires some dedicated modules. It's possible to implement protocols with "big-bang". MCU have Analog-Digital-Converters (which allows to measure voltage on selected pin) and Digital-Analog-Converters (which allows to produce a signal of some voltage on selected pin). Basically signals on line are analog and your software is digital. You use ADC to receive signal and DAC to send signal. Then those recorded voltages have to be translated to actual protocol.

Bit-banging low-speed protocols is easy. When your MCU does 8 million operations/second and you need to measure 1000 times/second, no problem. You usually use dedicated modules even for low-speed protocols, but that's basically convenience and lower power consumption.

Bit-banging high-speed protocols is not easy and usually not possible. 10 Mbit ethernet is 10 million bits per second. So it's almost always requires external modules which implement this protocol in hardware and provide some high-level interface to MCU.

Rpi Pico MCU has an interesting feature called PIO. It's basically a dedicated module with some extremely simplified assembly support. It works independently from the MCU cores. People implement various kinds of protocols using bit-banging with PIO.

Basically if you don't care about power, you can theoretically save some money by not including an ethernet module in your device, but rather implementing things with bit-banging. Or it might be an interesting experience for someone who implemented it.

Usually in reality you just buy STM32 with ethernet support and let it deal with all the protocol intricancies.

2 comments

I like this explanation, but the first paragraph mixes up things. ADCs (and sometimes DACs) are parts of most micro-controllers, but those are never used for digital communication. The most low-level primitive is GPIO block (general purpose input/output). This block can be found on most of chip pins, and it does the conversion between analog voltage and digital bit (as well as value latching and some other functions). With just them and the CPU you could manually receive and send digital bits and build complete communication protocols in software.

Also even if your STM32 has ethernet support, you still need a PHY transceiver that accesses the physical medium (wire or optical bus). This project implements both inside the Pico and requires just 3 external resistors. Very impressive feat of engineering, but not something you'd deliver as a field product.

DACs and ADCs are frequently used for digital communication - for anything RF/wireless they are a key part! Some high-speed SerDes receiver designs are even digitising using fast ADCs and DSP techniques internally now to do things like equalisation in the digital domain too, which is interesting (e.g. [1], [2]). Previously, slower (like 25Gbps and less) SerDes have tended to be purely analogue circuits until near the very end.

1. https://www.youtube.com/watch?v=OY2Dn4EDPiA

2. https://ieeexplore.ieee.org/document/8778136

I think the GP meant that you wouldn't normally want to try to use an ADC for digital communication because the general-purpose ADCs in, e.g. microcontrollers are either overkill (10 bits just to detect a level!?) or too slow (max sampling rate) to do high-performance I/O. You'd be better off using an existing protocol with just two voltage levels and the GPIO pins. You can make an analog circuit to transform the two voltage levels you do have into the (typically 0-5V) levels detected by the GPIO on the microcontroller.
Thanks for this explanation!