Controlling Mechanical 7-Segment Displays?! How RS-485 and UART works! || EB#43

Recently, I received those mechanical seven-segment displays which, like the name implies do not use LEDs to highlight each one of their segments but, instead, they use a small piece of white plastic that moves around. To find out how exactly this display works, I opened one up and found out that each plastic segment has a magnet connected to it, which can either get pushed away or attracted by another magnet. In the case of the commercial display, the required seven magnets are electromagnets, who, by alternatingly hooking them up to 12 volts DC reverse their magnetic polarity and thus control each segments. And, best of all, all the electromagnets keep their magnetic polarity even when current is no longer flowing, meaning that as soon as you are done displaying a number it will stay there without requiring any more electrical energy. As you would expect, though, controlling just four of those displays would either require lots of microcontroller pins and simple code or a more sophisticated microcontroller circuit with complex code. which, in both cases, can be a very time-consuming task. Thankfully, the company, AlfaZeta, which produces those seven-segment displays and sent them to me also sent me a big module with ten of them which are attached to a pretty promising-looking control circuit. So, in this video I will try to find out how this circuit works, how we can tell it what to display through the Arduino’s UART and the RS-485 interface and, finally, I will use it in combination with an ESP8266 to build a subscriber counter for my YouTube channel. Let’s get started! This video is sponsored by AlfaZeta First off, in order to properly examine the control circuit, I removed its two mounting screws and then, lifted it off the seven-segment display PCB. And, judging by the number of used IC’s, I was afraid that this circuit will not be an easy reverse-engineering subject. But, never-the-less, I started searching for all the datasheets of the IC’s, as well as finding out how each component is connected to one another through the help of the continuity function of my multimeter. As it turns out, the head of the operation is the ATmega32A microcontroller which, through the help of of high-voltage source driver IC’s and Darlington transistor array IC’s controls all the electromagnets. As far as I figured it out, it seems like one side of all the electromagnets of one display are connected to one source while the other displays all use different source pins. The other sides of the electromagnets are individually connected to a Darlington transistor array pin. While this time all electromagnets with the same segment control function are connected together. Now, if you watched my video about multiplexing, you should by now understand how the microcontroller can control all the displays. If not, then let me tell you that the source IC only powers one display at a time. And, by activating the [unsure] of transistors we power the required segments to form a number. Then the source IC powers the next output, and we can once again set the fitting transistors to form the next number. This process repeats until all numbers are successfully created This is, of course, only my theory but, since the practical testing of the displays later on revealed that they cannot change numbers simultaneously but, instead, have to change numbers one-by-one I was pretty sure that my theory has to be correct. The only question remaining is, how can we tell the microcontroller to display a specific number? For such communication tasks, the PCB comes with two RJ11 female connectors which, according to the manufacturer feature this pinout. But, what exactly does RS485 mean? Well, RS485 aka TIA485 or EIA485 is an industry standard for asynchronous serial data transfer. And, speaking of data transfer, I already talked about the SPI and I2C communication protocols in previous videos which I will use as a comparison example. Both of them use the clock line which basically tells the receiver when to read the data on the data line. This is called a synchronous communication. The RS485, however, is asynchronous which means there’s no clock line, only data lines. That means when an RS485 transmitter starts sending serial data consisting of 1’s and 0’s to a receiver the receiver has to synchronize itself by recognizing the first voltage edge and then using its own clock and set baud rate in order to sample the sent data at the correct time. The transmitter of course also has to use its clock with the exact same baud rate in order to generate the serial data. Otherwise, both of the components will not understand each other. It is also very important to note that, unlike SPI or I2C, which are proper protocols the RS485 only defines the electrical properties of the communication signals. It is not a protocol, nor does it define connection plug arrangements. That is why when you work with RS485 you have to get the proper communication protocol and hardware pinout from the manufacturer which mine kindly provided. Before testing the code, however, I want to name the most important electrical properties of the system. It typically uses one twisted pair of wires where one carries the non-inverted data signal and the other carries the inverted data signal. The receiver then creates the original data signal by creating the difference between those two. That sounds needlessly complicated at first, but the data wires use symmetrical voltage levels, and thus, injected common mode noises equally exist on both lines and therefore get rejected by the differential receiver inputs which makes the system pretty interference-free. Of course, there are more electrical properties but, before boring you to death, and since you can easily look those up online let’s continue with the coding. Now, the given protocol seems simple enough. Just the start command followed by the address of the module, the actual 10 numbers I want to display, and then a stop command. To control the display, I want to first use the Arduino Nano, which luckily comes with a USART interface. If we ignore the letter ‘S’, it stands for Universal Asynchronous Serial Receiver Transmitter which certainly sounds promising when it comes to functioning with the RS485 interface. So, as a simple test, I set the baud rate of the Arduino to 9,600 just like I did for the control PCB and typed in the serial data with the last numbers to display being ‘1234’. After uploading the code to the Arduino, we can hook up an oscilloscope to the serial transmit pin of it in order to find out that it sends out the data we just typed in, in software. And, while this does look promising, we still have the problem that this one data line does not match the RS485 standard. That is when such a MAX485 break-out board comes in to play. This IC can basically turn our microcontroller serial data into RS485 standardized serial data. So, I hooked it up to my Arduino according to this schematic which only utilizes the write functionality of the IC, and not the read functionality, created a twisted wire pair through the help of my electric drill, soldered one side of it to the control PCB’s ‘A’ and ‘B’ line and hooked up the other side to the MAX485 breakout board, and finally, after all this theory it was time to power the control boards as well as the Arduino in order to find out that code does in fact work Brilliant! And if we look at the RS485 data lines with the oscilloscope we can see the non-inverted and inverted data signals pretty clearly. Now, the manufacturer also sent me a bit of example code to display any digit I want which I used to create a simple counter mode. After uploading the code, and me being quiet for a few seconds, you can enjoy the true beauty of mechanical displays. Needless to say, I do love the sound and look of it which is why I decided to use it as a subscriber counter for my channel All I had to do was to connect the serial interface of an ESP8266 to the MAX485 breakout board and merging the Arduino YouTube API library with the 7-segment control board code in order to create this rather lengthy piece of software. After uploading it we can not only see through the serial monitor that the ESP grabbed my YouTube data successfully but we can also see that the 7-segment display shows my subscriber number correctly as well! And with that being said, I hope you enjoyed this small mechanical display RS485 UART adventure and learned a bit along the way. If so, don’t forget to like share, subscribe, and hitting the notification bell. Stay creative and I will see you next time!

100 Replies to “Controlling Mechanical 7-Segment Displays?! How RS-485 and UART works! || EB#43

  1. I think you forgot to explain the ground reference problems of RS-485 or UART. For example, the maximum common mode voltage of A and B inputs, when to use isolator, and so on. Basically, the ground connection in differential signals

    7 seg modules:
    9 EUR apiece for 1-99 pcs
    21 EUR for 1-99 pcs
    190 EUR for a bundle of 1×10 digits with controllers

  3. I'm currently learning how the USART works in the Atmega328p in my ICT Engineering degree. The catch is we're learning to program the microcontroller in Assembly. We've yet to learn C and other languages. Assembly is pure masochistic.

  4. Nice video Scott but I was more interested in large size led seven segments… I am miopic and was planning to build a large size digital clock so even in the middle of the night I can see time without searching for my glasses first… Can you please suggest me where I can get those…

  5. RS-485 ? What 's the advantage compared to RS-232 ? Feels like peugeot using VAN bus for it's 206 cars rather than good old CAN bus. Those damn manchester bit !

  6. I was about to like this video until you showed that pre-made circuit…sorry i´m outta here, after 01:56….!
    This is more a basic introduction of the well known and understood RS-485 differential electrical protocoll, than a HowTo drive these displays….

  7. Hi scott, do you consider to make a lightning surege protection without a varistor. Is it possible to make a lightning strike protector with fast slew rate opamp or FETs? Because varistors are dead after couple of spike/strike and i need different soulution. By the way sorry for mu f*king english dude. If you are interested may be your viewers interests. Thanks for reading.

  8. But your subscriber counter has only 10 digits.
    You will look very silly when you surpass 10 billion subscribers!

  9. Hi nice display did you know how many cycle will last , and can you make a circuit to read the state of the display like old Magnetic-core memory

  10. Alpha zeta is great, they sent me some displays to make a sub counter with as well. I designed my own controller as I wanted a challenge and ended up open sourcing the design.

  11. ,, i wish you make a full video about more industrial protocols like the ones common in power system protection schemes

  12. RS-485 is similar to RS-232 which is a communication protocol.

    and those segments are controlled the same way memory of early computers like IBM-370 worked.

  13. Am I the only one who subscribed, unsubscribed, subscribed, a whole bunch of times, because you know that display is clicking somewhere?

  14. Nice explanation! I also figured out some fairly efficient techniques for driving these displays. Was pretty fun engineering challenge!

  15. Good. It may save battery. I hope the priciple to use my lcd of phone. The cell must be changed by magnetic force or move like eInk.

  16. I have to chime in, I was a part of building a massive flipdot sign for coke. Videos at the bottom. It worked very much along these lines, just at a massive scale. 485 is very important in this application. There is so much emi with so many magnets, its the only way to get data around. Nothing else works.

    Around 80 control boards in this sign, multiplexed 8×8 on one axis, and 6×16 on the other. A PIC micro to decode the bitmap coming in on 485, with a small FPGA driving a bunch of shift registers, driving a bunch of FETs actually controlling the individual x/y coil drive. A really awesome project. To supply enough energy to flick the coils, theres about 80x 680000uf caps in this. Yeh. 55 farad. The sound of this thing going from 0000 to 1111 is an incredible, physical thing. WH-CHOOM!

    Flipdots ftw. If you can find an excuse to, play with them, they'll make you smile. Even little ones. – the cameras shutter really lets you see how its driven. In reality is far smoother, a flowing, waterfall effect. Which is what coke wanted. Its not instant, its obviously mechanical and slow, but it looks pretty fluid, cos your brain is slow. Camera exaggerates the effect and chops it into blocks, which is what you chaps want to see. But damn does it sound good – a press peice, but there is some interesting guts of the machine shots among it. I think Petes nephew was doing a media degree, n it was a decent subject to film. We dont normally Vlog our projects. But it is kinda nice to have video.

    Of course, what isnt shown is the countless hours of hair pulling, yelling at n pleading with whatever gods you hold dear, chasing cable faults, comms issues, power spikes, ohsomany weird code bugs, all that fun stuff. None of that goes away when you go from hobbyist to pro. It just gets more stressful. Ya make some really cool stuff tho

  17. There's a small "mistake" on your video. It's not enough to just plug any twisted pair wire, the twisted pair has to have an impedance of 120ohm for the MAX485. This translates to a specific width, diameter, spacing and insulator material. Usually Ethernet cable has 100ohm impedance, which is close enough for many applications. I know you pointed out to some RS-485 documents for further clarification, but when you show that you can just twist some wires and it works fine it sends the word message.

  18. Hey great scott, I would love your help with creating a DC voltmeter with bluetooth that sends its readings to a raspberry bi or arduino.

  19. So sad that YT decided only give 3 significant figures instead of the live count. Even engineering is not safe from YT bureaucracy.

Leave a Reply

Your email address will not be published. Required fields are marked *