{"id":912,"date":"2017-06-03T16:38:11","date_gmt":"2017-06-03T20:38:11","guid":{"rendered":"http:\/\/www.deepsoft.com\/~heller\/?p=912"},"modified":"2017-06-03T17:17:12","modified_gmt":"2017-06-03T21:17:12","slug":"sir-topm-hat-gets-a-new-hat-and-starts-work-at-raspberry-pi-junction-at-mile-post-314","status":"publish","type":"post","link":"https:\/\/www.deepsoft.com\/~heller\/2017\/06\/sir-topm-hat-gets-a-new-hat-and-starts-work-at-raspberry-pi-junction-at-mile-post-314\/","title":{"rendered":"Sir Top&apos;m Hat gets a new hat and starts <br \/>work at Raspberry Pi Junction at Mile Post 314"},"content":{"rendered":"<h3>The hardware<\/h3>\n<p><a href=\"https:\/\/www.deepsoft.com\/~heller\/wp-content\/uploads\/2017\/06\/P1040913.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.deepsoft.com\/~heller\/wp-content\/uploads\/2017\/06\/P1040913-150x150.jpg\" alt=\"Sir Top&#039;m Hat with his new hat\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-922\" \/><\/a>I have designed an <a href=\"https:\/\/github.com\/RobertPHeller\/RPi-RRCircuits\/tree\/master\/SMCSenseHAT\">add on circuit board<\/a> for the Raspberry Pi to control stall motor turnout motors. This board uses a quad op-amp circuit to drive a quad output transistor to drive the motors.  It also features a 74AHCT00 Quad 2-input Nand Gate IC, wired as a pair of RS Flip-Flops to debounce switch contacts used to sense the position of the points. This small board uses 4 of the &#8216;Pis GPIO pins to control and sense two stall motors:<\/p>\n<dl>\n<dt>WiringPi 0, BCM 17<\/dt>\n<dd>Motor Select 1: select the position of stall motor 1<\/dd>\n<dt>WiringPi 1, BCM 18<\/dt>\n<dd>Motor Select 2: select the position of stall motor 2<\/dd>\n<dt>WiringPi 2, BCM 27<\/dt>\n<dd>Point Sense 1: return the state of the points for stall motor 1<\/dd>\n<dt>WiringPi 3, BCM 22<\/dt>\n<dd>Point Sense 2: return the state of the points for stall motor 2<\/dd>\n<\/dl>\n<p><a href=\"https:\/\/github.com\/RobertPHeller\/RPi-RRCircuits\/raw\/master\/SMCSenseHAT\/SMCSenseHAT.pdf\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.deepsoft.com\/~heller\/wp-content\/uploads\/2017\/05\/SMCSenseHAT_thumb-150x150.png\" alt=\"SMCSenseHAT Schematic\" width=\"150\" height=\"150\" class=\"alignright size-thumbnail wp-image-920\" \/><\/a>The stall motors are optically isolated from the Pi and use their own 12-16 Volt power. The outputs are through output transistors that can handle up to 1A each, far more than enough to handle any available stall motors, including pairs wired in parallel (as for cross-overs). The point sense inputs expect a SPDT switch to sense the point position (one pole of the built in switch contacts in a Tortoise can serve this purpose).<\/p>\n<p><br clear=\"all\" \/><\/p>\n<p><a href=\"https:\/\/www.deepsoft.com\/~heller\/wp-content\/uploads\/2017\/06\/P1040908_rot180.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.deepsoft.com\/~heller\/wp-content\/uploads\/2017\/06\/P1040908_rot180-150x150.jpg\" alt=\"Unpopulated Board, right side up\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-931\" \/><\/a>I had a batch of unpopulated boards made through <a href=\"http:\/\/www.allpcb.com\">ALLPCB (www.allpcb.com)<\/a>. This is a great way to get prototype or test runs of PC boards made.  It is low-cost, fast, and it is an easy process. The boards were quickly made and were shipped quickly. <\/p>\n<p><br clear=\"all\" \/><\/p>\n<p><a href=\"https:\/\/www.deepsoft.com\/~heller\/wp-content\/uploads\/2017\/06\/P1040911.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.deepsoft.com\/~heller\/wp-content\/uploads\/2017\/06\/P1040911-150x150.jpg\" alt=\"Completed Board, ready to go\" width=\"150\" height=\"150\" class=\"alignright size-thumbnail wp-image-924\" \/><\/a>With the parts I ordered from <a href=\"http:\/\/www.mouser.com\/ProjectManager\/ProjectDetail.aspx?AccessID=259711af97\">Mouser<\/a>, I quickly assembled one of the boards. I installed it on a Raspberry Pi 3B (sirtopmhat). Once I installed it an added a 12Volt power supply for the Tortoise I was able to test it.  And it worked!  Sir Top&#8217;m Hat is now working for the railroad!<\/p>\n<p><br clear=\"all\" \/><\/p>\n<h3>The Software<\/h3>\n<p>On the software side, I am using the <code>OpenLCB_PiGPIO<\/code> program from <a href=\"https:\/\/www.deepsoft.com\/\">Deepwoods Software&#8217;s<\/a> <a href=\"https:\/\/www.deepsoft.com\/home\/products\/modelrrsystem\/\">Model Railroad System<\/a> to manage this little board. There is a sample XML configuration file on <a href=\"https:\/\/github.com\/RobertPHeller\/RPi-RRCircuits\/tree\/master\/SMCSenseHAT\" target=\"_blank\">GitHub<\/a> with the circuit board.  I am also using a CTC Panel created with the Model Railroad System&#8217;s Dispatcher program. The CTC Panel is a simple one my Raspberry Pi Junction demo layout, which consists of a short section of main line track with a spur leading to the Mad Hatter Pi Shop (a modified 50&#8217;s style drive in restaurant).<\/p>\n<p>The <code>OpenLCB_PiGPIO<\/code> and the CTC Panel program exchange LCC event reports, with the CTC panel sending events to activate the turnout motor to change the point position and the <code>OpenLCB_PiGPIO<\/code> sending event reports to indicate changes in the point position to the CTC Panel program so the CTC Panel program can update its display of the turnout.  I have another batch of PCBs on order that will have the logic to interface with the block occupancy detectors.  This will allow me to implement the logic to drive the signals and also control the lights in the Mad Hatter&#8217;s Pi Shop.<\/p>\n<p><!-- p>In the meantime, I have uploaded a short video of the switch motor in action to YouTube:<\/p -->\n","protected":false},"excerpt":{"rendered":"<p>The hardware I have designed an add on circuit board for the Raspberry Pi to control stall motor turnout motors. This board uses a quad op-amp circuit to drive a quad output transistor to drive the motors. It also features a 74AHCT00 Quad 2-input Nand Gate IC, wired as a&#8230;<\/p>\n<p> <a class=\"continue-reading-link\" href=\"https:\/\/www.deepsoft.com\/~heller\/2017\/06\/sir-topm-hat-gets-a-new-hat-and-starts-work-at-raspberry-pi-junction-at-mile-post-314\/\"><span>Continue reading<\/span><i class=\"crycon-right-dir\"><\/i><\/a> <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,26],"tags":[60,67,66,62,55,28,57,25,63,65,56,59,64,61],"class_list":["post-912","post","type-post","status-publish","format-standard","hentry","category-model-railroad","category-railroad","category-whats-on-the-bench","tag-allpcb","tag-deepwoods-software","tag-dispatcher","tag-lcc","tag-model-railroad","tag-model-railroad-system","tag-news","tag-open-source","tag-openlcb","tag-openlcb_pigpio","tag-programming","tag-raspberry-pi","tag-raspberry-pi-junction","tag-stall-motor"],"_links":{"self":[{"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/posts\/912","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/comments?post=912"}],"version-history":[{"count":18,"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/posts\/912\/revisions"}],"predecessor-version":[{"id":935,"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/posts\/912\/revisions\/935"}],"wp:attachment":[{"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/media?parent=912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/categories?post=912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.deepsoft.com\/~heller\/wp-json\/wp\/v2\/tags?post=912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}