The Mechanical Seven-Segment Display: A Deeper Dive into Its Inner Workings
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. This got me thinking about how this display works in general, so I decided to take a closer look at the inner workings of the mechanical seven-segment display.
When I opened up my mechanical seven-segment display, I found that each segment was connected to an electromagnet. The electromagnets were controlled by a microcontroller, which was powered by a 12-volt DC source. The microcontroller used a protocol called RS-485 to communicate with the outside world.
The most important electrical properties of the system are: typically using 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. This makes the system pretty interference-free, as injected common mode noise equally exist on both lines and therefore get rejected by the differential receiver inputs.
Now, I want to name the most important electrical properties of the system, which typically use 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. This makes the system pretty interference-free.
Before testing the code, I want to name the most important electrical properties of the system. Typically using 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. This makes the system pretty interference-free.
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 RS-485 interface. As a simple test, I set the baud rate of the Arduinoto 9,600 just like I did for the control PCBand 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. While this does look promising, we still have the problem that this one data line does not match the RS-485 standard.
That is when such a MAX485 break-out board comes in to play. This IC can basically turn our microcontroller serial data into RS-485 standardized serial data. 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.
Finally, after all this theory it was time to power the control boards as well as the Arduinoin order to find out that code does in fact work. Brilliant! And if we look at the RS-485 data lines with the oscilloscopewe can see the non-inverted and inverted data signals pretty clearly.
Now, I have 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 RS-485 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!
WEBVTTKind: captionsLanguage: enRecently, I received thosemechanical seven-segment displayswhich, like the name implies do not use LEDs tohighlight each one of their segmentsbut, instead, they use a small piece of white plasticthat moves around.To find out how exactly this display works,I opened one up and found outthat each plastic segment has a magnet connected to it,which can either get pushed away or attractedby another magnet.In the case of the commercial display,the required seven magnets are electromagnets,who, by alternatingly hooking them upto 12 volts DCreverse their magnetic polarityand thus control each segments.And, best of all, all the electromagnetskeep their magnetic polarityeven when current is no longer flowing,meaning that as soon as you are donedisplaying a number it will stay therewithout requiring any more electrical energy.As you would expect, though, controllingjust four of those displays would eitherrequire lots of microcontroller pinsand simple codeor a more sophisticated microcontroller circuitwith complex code.which, in both cases, can be a very time-consuming task.Thankfully, the company, AlfaZeta,which produces those seven-segment displaysand sent them to mealso sent me a big module with ten of themwhich are attached to a pretty promising-lookingcontrol circuit.So, in this videoI will try to find out how this circuit works,how we can tell it what to displaythrough the Arduino's UARTand the RS-485 interfaceand, finally, I will use it in combination with an ESP8266to build a subscriber counter for my YouTube channel.Let's get started!This video is sponsored by AlfaZetaFirst off,in order to properly examine the control circuit,I removed its two mounting screwsand then, lifted it offthe seven-segment display PCB.And, judging by the number of used IC's,I was afraid that this circuitwill not be an easy reverse-engineering subject.But, never-the-less, I startedsearching for all the datasheets of the IC's,as well as finding out how each componentis connected to one anotherthrough the help of the continuityfunction of my multimeter.As it turns out, the head of the operationis the ATmega32A microcontrollerwhich, through the help ofof high-voltage source driver IC'sand Darlington transistor array IC'scontrols all the electromagnets.As far as I figured it out,it seems like one side of all theelectromagnets of one display are connectedto one sourcewhile the other displays all use different source pins.The other sides of the electromagnetsare individually connected to a Darlingtontransistor array pin.While this time all electromagnetswith the same segment control functionare connected together.Now, if you watched my video about multiplexing,you should by now understand how themicrocontroller can control all the displays.If not, then let me tell youthat the source IC only powers one display at a time.And, by activating the of transistorswe power the required segments to form a number.Then the source IC powers the next output,and we can once again set the fitting transistorsto form the next number.This process repeats until all numbers are successfully createdThis is, of course, only my theorybut, since the practical testing of the displayslater on revealed that theycannot change numbers simultaneouslybut, instead, have to change numbers one-by-oneI was pretty sure that my theoryhas to be correct.The only question remaining is,how can we tell the microcontroller todisplay a specific number?For such communication tasks,the PCB comes with two RJ11 female connectorswhich, according to the manufacturerfeature this pinout.But, what exactly does RS485 mean?Well, RS485aka TIA485or EIA485is an industry standard forasynchronous serial data transfer.And, speaking of data transfer, Ialready talked aboutthe SPI and I2C communication protocolsin previous videoswhich I will use as a comparison example.Both of them use the clock linewhich basically tells the receiverwhen to read the data on the data line.This is called a synchronous communication.The RS485, however, is asynchronouswhich means there's no clockline, only data lines.That means when an RS485 transmitterstarts sending serial data consisting of1's and 0's to a receiverthe receiver has to synchronize itselfby recognizing the first voltage edgeand then using its own clock and set baud ratein order to sample the sent data at the correct time.The transmitter of coursealso has to use its clockwith the exact same baud ratein order to generate the serial data.Otherwise, both of the componentswill not understand each other.It is also very important to notethat, unlike SPI or I2C,which are proper protocolsthe RS485only defines the electrical propertiesof the communication signals.It is not a protocol,nor does it define connection plug arrangements.That is why when you work with RS485you have to get the proper communication protocoland hardware pinout from the manufacturerwhich mine kindly provided.Before testing the code, however,I want to name the most important electrical propertiesof the system.It typically uses one twisted pair of wireswhere one carries the non-inverted data signaland the other carries the inverted data signal.The receiver then creates the original data signalby 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 noisesequally exist on both linesand therefore get rejectedby the differential receiver inputswhich makes the system pretty interference-free.Of course, there are more electrical propertiesbut, before boring you to death,and since you can easily look those up onlinelet's continue with the coding.Now, the given protocol seems simple enough.Just the start commandfollowed 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 forUniversal Asynchronous Serial Receiver Transmitterwhich certainly sounds promisingwhen it comes to functioning with theRS485 interface.So, as a simple test,I set the baud rate of the Arduinoto 9,600just like I did for the control PCBand typed in the serial data with thelast numbers to display being '1234'.After uploading the code to the Arduino,we can hook up an oscilloscope to theserial transmit pin of itin order to find out that it sends outthe data we just typed in, in software.And, while this does look promising,we still have the problem that this one data linedoes not match the RS485 standard.That is when such a MAX485 break-out boardcomes in to play.This IC can basically turn our microcontroller serial datainto RS485 standardized serial data.So, I hooked it up to my Arduinoaccording to this schematicwhich only utilizes the write functionality of the IC,and not the read functionality,created a twisted wire pairthrough the help of my electric drill,soldered one side of it to the control PCB's 'A' and 'B' lineand hooked up the other side to theMAX485 breakout board,and finally, after all this theoryit was time to power the control boardsas well as the Arduinoin order to find out that code does in fact workBrilliant!And if we look at the RS485 data lineswith the oscilloscopewe can see the non-invertedand inverted data signals pretty clearly.Now, the manufacturer also sent mea bit of example codeto display any digit I wantwhich I used to create a simple counter mode.After uploading the code, and me beingquiet for a few seconds,you can enjoy the true beauty of mechanical displays.Needless to say,I do love the soundand look of itwhich is why I decided to use itas a subscriber counter for my channelAll I had to do was to connectthe serial interfaceof an ESP8266to the MAX485 breakout boardand merging the Arduino YouTube API librarywith the 7-segment control board codein order to create thisrather lengthy piece of software.After uploading itwe can not only see through the serial monitorthat the ESP grabbed my YouTube data successfullybut we can also see that the 7-segment displayshows my subscriber number correctly as well!And with that being said, I hope you enjoyed this smallmechanical display RS485UART adventureand learned a bit along the way.If so, don't forget to likeshare, subscribe,and hitting the notification bell.Stay creativeand I will see you next time!