{"id":4220,"date":"2020-11-10T17:42:05","date_gmt":"2020-11-10T23:42:05","guid":{"rendered":"https:\/\/www.scottdanesi.com\/?p=4220"},"modified":"2020-11-10T17:42:05","modified_gmt":"2020-11-10T23:42:05","slug":"tna-numeric-score-display-integration","status":"publish","type":"post","link":"https:\/\/www.scottdanesi.com\/?p=4220","title":{"rendered":"TNA Numeric Score Display Integration"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.pinballlife.com\/mm5\/merchant.mvc?Screen=PROD&amp;Product_Code=PBL-600-0473-00\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"145\" src=\"https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_124239-1024x145.jpg\" alt=\"\" class=\"wp-image-4230\" srcset=\"https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_124239-1024x145.jpg 1024w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_124239-300x43.jpg 300w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_124239-768x109.jpg 768w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_124239-1536x218.jpg 1536w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_124239.jpg 2000w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Hey Pinball Homebrewers!<\/p>\n\n\n\n<p>I have had a couple people ask me about using the Total Nuclear Annihilation Numeric Score Displays in their homebrew games.  Now that Pinball Life has these display assemblies in stock, I figured I would do a little tutorial on how to use these.  <\/p>\n\n\n\n<p><a href=\"https:\/\/www.pinballlife.com\/mm5\/merchant.mvc?Screen=PROD&amp;Product_Code=PBL-600-0473-00\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.pinballlife.com\/mm5\/merchant.mvc?Screen=PROD&amp;Product_Code=PBL-600-0473-00<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Powering up the display<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155055-1024x768.jpg\" alt=\"\" class=\"wp-image-4233\" srcset=\"https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155055-1024x768.jpg 1024w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155055-300x225.jpg 300w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155055-768x576.jpg 768w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155055.jpg 1110w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>The display assembly has a 3 pin 0.156&#8243; header on the back.  This is the main power input for the display.  You will need to look at the silkscreen on this header and make a connector that supplies a solid ground and a solid +5vdc.  Just make sure it is plugged in the correct orientation.  <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Arduino Nano<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155100-1024x768.jpg\" alt=\"\" class=\"wp-image-4234\" srcset=\"https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155100-1024x768.jpg 1024w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155100-300x225.jpg 300w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155100-768x576.jpg 768w, https:\/\/www.scottdanesi.com\/wp-content\/uploads\/2020\/11\/20201110_155100.jpg 1110w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>On the back of the display assembly, you will find a pre-programmed Arduino Nano ready for you to send it some instructions.  This Arduino will not power up with the main power input and will need to be plugged into an active USB port to come alive.  This is a Mini USB connection.  Make sure when plugging this in, you use the included strain relief located by the main power input header.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sending Data<\/h3>\n\n\n\n<p>Now into the more fun stuff.  The display assembly needs to be sent some serial data from the USB to the Arduino in order to display stuff.  I am going to provide some Python samples, but honestly all that is happening here is the PC is just sending the display a line of text.  The Arduino will parse it, do all the heavy lifting, and display the numbers on the LED displays!<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Text Format<\/h4>\n\n\n\n<p>The Arduino is looking for a text string in the following format.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">\"A:B:C\\n\"<\/code><\/pre>\n\n\n\n<p><strong>A:<\/strong> A is the mode of the display.  This can indicate whether you want the score to flash, not flash, clear the data, or flash a match (last 2 char flashing).<br>1 = Not Flashing, just display the score<br>2 = Flashing, used for current player up<br>3 = Clear the display<br>4 = Match display, will flash the last 2 characters of the score<\/p>\n\n\n\n<p><strong>B:<\/strong> B is the number of the display.  This value will be between 1 and 4.  This is so you can address the correct display when sending score data.<\/p>\n\n\n\n<p><strong>C:<\/strong> C is the actual score!  This is a numeric value between 0 and 99999999.  Do not put commas here, the Arduino will handle that.  <\/p>\n\n\n\n<p><strong>\\n:<\/strong> This is the terminating character so the Arduino knows it got a complete line of code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Examples<\/h4>\n\n\n\n<p><strong>Example 1:<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">\"2:1:100000\\n\"<\/code><\/pre>\n\n\n\n<p>In this example, the first display will receive a flashing on 100,000.  <\/p>\n\n\n\n<p><strong>Example 2:<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">\"1:2:200000\\n\"<\/code><\/pre>\n\n\n\n<p>This example will display 200,000 solidly on display number 2.<\/p>\n\n\n\n<p><strong>Example 3:<\/strong> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">\"3:1:0\\n\"<\/code><\/pre>\n\n\n\n<p>This example will completely clear display number 1.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code Examples<\/h4>\n\n\n\n<p>In order to send serial text strings over USB with python, I use <a href=\"https:\/\/pypi.org\/project\/pyserial\/\" data-type=\"URL\" data-id=\"https:\/\/pypi.org\/project\/pyserial\/\" target=\"_blank\" rel=\"noreferrer noopener\">PySerial<\/a>.  This will allow we to easily send this data to the display assembly.  <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Opening The Serial Port<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">    def openSerial(self):\n        i = 0\n        while (self.serialOpen == False and i &lt;= 9):\n            try:\n                device_path = '\/dev\/ttyUSB' + str(i)\n                self.game.log('Attempting to open serial port ' + device_path)\n                self.ser = serial.Serial(device_path, 115200)  # attempt to open serial port\n                self.serialOpen = self.ser.is_open\n                self.game.log('Serial Info:')\n                self.game.log(str(self.ser))\n                self.serialOpen = True\n            except:\n                self.game.log('Attempt failed to open serial port ' + device_path)\n                i = i + 1<\/code><\/pre>\n\n\n\n<p>This code will scan through the USB devices and try to connect to the Arduino.  This code is probably not the best way to do it, but it has worked out well for the TNA project.  \ud83d\ude42<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Closing The Serial Connection<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">    def closeSerial(self):\n        try:\n            self.ser.close()\n            self.serialOpen = False\n        except:\n            self.game.log('Attempt failed to close serial port')\n            self.serialOpen = False<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Testing and Sending Data To The Display<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">    def testSerial(self,String=\"1234567\"):\n        self.ser.write(\"1:1:\" + String + \"\\n\")\n        self.ser.write(\"1:2:\" + String + \"\\n\")\n        self.ser.write(\"1:3:\" + String + \"\\n\")\n        self.ser.write(\"1:4:\" + String + \"\\n\")<\/code><\/pre>\n\n\n\n<p>The above code will be how you should be able to send the data to the display assembly!  This test method will send the score of 1,234,567 to all 4 displays.  <\/p>\n\n\n\n<p>I wanted to take a moment to thank Jim Askey (MyPinballs).  This text string is based off of a serial data project that he did for integrating Bally displays into P-ROC games back in the day.  I really liked the text format, so I kept within the same style for this, but added extra functions.  Thank you Jim!<\/p>\n\n\n\n<p>That should be all you need to get running.  If you find any errors in any of this, please <a href=\"https:\/\/www.scottdanesi.com\/?page_id=23\" data-type=\"page\" data-id=\"23\">let me know here<\/a> and I will correct it.  <\/p>\n\n\n\n<p>Thanks Everyone!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey Pinball Homebrewers! I have had a couple people ask me about using the Total Nuclear Annihilation Numeric Score Displays in their homebrew games. Now that Pinball Life has these display assemblies in stock, I figured I would do a little tutorial on how to use these. https:\/\/www.pinballlife.com\/mm5\/merchant.mvc?Screen=PROD&amp;Product_Code=PBL-600-0473-00 Powering up the display The display assembly [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,12,8,13],"tags":[],"class_list":["post-4220","post","type-post","status-publish","format-standard","hentry","category-arcade","category-hardware","category-how-to","category-software"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=\/wp\/v2\/posts\/4220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4220"}],"version-history":[{"count":17,"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=\/wp\/v2\/posts\/4220\/revisions"}],"predecessor-version":[{"id":4240,"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=\/wp\/v2\/posts\/4220\/revisions\/4240"}],"wp:attachment":[{"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scottdanesi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}