{"id":162,"date":"2012-08-26T12:13:58","date_gmt":"2012-08-26T12:13:58","guid":{"rendered":"http:\/\/retroramblings.net\/?p=162"},"modified":"2012-08-26T12:17:05","modified_gmt":"2012-08-26T12:17:05","slug":"latching-power-circuit-in-the-flesh","status":"publish","type":"post","link":"http:\/\/retroramblings.net\/?p=162","title":{"rendered":"Latching power circuit &#8211; in the flesh!"},"content":{"rendered":"<p>Having breadboarded the latching power circuit from my last post and found it works pretty well, I&#8217;ve made a more permanent version that plugs directly onto the headers on my Cyclone 3 board.\u00a0 While I&#8217;d normally build something like this on stripboard, it&#8217;s not really appropriate for this project because the pins on the 40-pin headers are only one row of holes apart.\u00a0 Therefore I&#8217;ve used matrix board this time around.<\/p>\n<p>This is the case I plan to use to house this project.\u00a0 It&#8217;s the case from an old, dead Acer Aspire L320 &#8211; a nice looking machine that, unfortunately, seems to have insufficient chipset cooling, so tends to die a horrible death.\u00a0 Dead ones crop up on Ebay fairly frequently, and with a little bit of cleaning up and removing of label residue, they&#8217;re an ideal housing for a project like this one.<\/p>\n<p><a href=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/L320case.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-163\" title=\"L320case\" src=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/L320case.jpg\" alt=\"\" width=\"500\" height=\"183\" srcset=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/L320case.jpg 500w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/L320case-300x109.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Behind the power button is a little circuit board with four LEDs (actually only three on mine, but space for a fourth) and the actual power button switch.\u00a0 I rewired this board slightly &#8211; removed the blue LEDs (*please* people, can we get over the blue LED thing now!) and replaced them with green, yellow, orange and red ones.\u00a0 I also wired the LED anodes in common, to keep the component count down.\u00a0 The common anode will be fed from 3.3v through a small resitor, then the four LEDs&#8217; cathodes will be tied directly to FPGA pins.\u00a0 When the respective FPGA pin is low, the LED will light up.<\/p>\n<p><a href=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/SwitchBoard.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-164\" title=\"SwitchBoard\" src=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/SwitchBoard.jpg\" alt=\"\" width=\"752\" height=\"320\" srcset=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/SwitchBoard.jpg 752w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/SwitchBoard-300x127.jpg 300w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/SwitchBoard-500x212.jpg 500w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/a><\/p>\n<p>The obvious problem with this arrangement is that when more than one LED is lit, the current will be shared between them, making them dimmer &#8211; to avoid this, I&#8217;ll use a pulse-width modulation system, giving each LED a 25% duty cycle, and alternating between them, so no two LEDs will be lit at the same time.<\/p>\n<p>The VHDL code for this is as follows:<\/p>\n<pre>library ieee;\r\nuse ieee.std_logic_1164.all;\r\nuse ieee.std_logic_unsigned.all;\r\nuse IEEE.numeric_std.ALL;\r\n\r\nentity statusleds_pwm is\r\n\u00a0\u00a0 \u00a0port(\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0clk : in std_logic;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0leds_in : in std_logic_vector(3 downto 0);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0leds_out : out std_logic_vector(3 downto 0)\r\n\u00a0\u00a0 \u00a0);\r\nend statusleds_pwm;\r\n\r\narchitecture rtl of statusleds_pwm is\r\n\u00a0\u00a0 \u00a0signal counter : unsigned(18 downto 0);\r\nbegin\r\n\u00a0\u00a0 \u00a0process(clk)\r\n\u00a0\u00a0 \u00a0begin\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if rising_edge(clk) then\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0counter &lt;= counter+1;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if counter(16 downto 0)=X\"0000\"&amp;\"0\" then\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0leds_out&lt;=\"1111\";\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0case counter(18 downto 17) is\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0when \"00\" =&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0leds_out(0)&lt;=not leds_in(0);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0when \"01\" =&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0leds_out(1)&lt;=not leds_in(1);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0when \"10\" =&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0leds_out(2)&lt;=not leds_in(2);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0when \"11\" =&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0leds_out(3)&lt;=not leds_in(3);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0end case;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0end if;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0end if;\r\n\u00a0\u00a0 \u00a0end process;\r\nend architecture;<\/pre>\n<p>As I mentioned in my previous post, the Cyclone 3 board I&#8217;m using has four general purpose IO headers, but two of these headers share FPGA pins with the RAM chips, so on a board like mine that&#8217;s populated with two RAM chips, there are only a handful of available IOs on headers J3 and J4.\u00a0 There are, however, enough to run my latching power circuit, the LEDs, and a couple left over which I&#8217;ll use for an RS232 port.<\/p>\n<p>The following matrix board layout describes a board which connects directly to headers J3 and J4 on the FPGA board, leaving the IO-rich J1 and J2 free for A\/V, SD Card and joystick interfaces.<\/p>\n<p><a href=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DualHeaderMatrixLayout.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-165\" title=\"DualHeaderMatrixLayout\" src=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DualHeaderMatrixLayout-1024x437.jpg\" alt=\"\" width=\"584\" height=\"249\" srcset=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DualHeaderMatrixLayout-1024x437.jpg 1024w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DualHeaderMatrixLayout-300x128.jpg 300w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DualHeaderMatrixLayout-500x213.jpg 500w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><\/p>\n<p>I&#8217;m currently waiting for delivery of some MAX3232s (MAX232 variant that runs from 3.3v) &#8211; so that part of the board isn&#8217;t yet built &#8211; but the power aspect is built and working. <a href=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DSC_6783.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-167\" title=\"DSC_6783\" src=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DSC_6783.jpg\" alt=\"\" width=\"752\" height=\"500\" srcset=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DSC_6783.jpg 752w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DSC_6783-300x199.jpg 300w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/DSC_6783-451x300.jpg 451w\" sizes=\"auto, (max-width: 752px) 100vw, 752px\" \/><\/a><\/p>\n<p>(The above is not quite the final version &#8211; I moved one signal to a different IO pin, and added a small capacitor between LED+ and GND.)<\/p>\n<p><a href=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/FinishedBoard.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-166\" title=\"FinishedBoard\" src=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/FinishedBoard.jpg\" alt=\"\" width=\"775\" height=\"500\" srcset=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/FinishedBoard.jpg 775w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/FinishedBoard-300x193.jpg 300w, http:\/\/retroramblings.net\/wp-content\/uploads\/2012\/08\/FinishedBoard-465x300.jpg 465w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having breadboarded the latching power circuit from my last post and found it works pretty well, I&#8217;ve made a more permanent version that plugs directly onto the headers on my Cyclone 3 board.\u00a0 While I&#8217;d normally build something like this &hellip; <a href=\"http:\/\/retroramblings.net\/?p=162\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-162","post","type-post","status-publish","format-standard","hentry","category-fpga"],"_links":{"self":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162"}],"version-history":[{"count":8,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":174,"href":"http:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions\/174"}],"wp:attachment":[{"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}