Showing posts with label Computer. Show all posts
Showing posts with label Computer. Show all posts

Monday, January 2, 2017

Taken by a Strange Mood, Part 4

What do you do when you've permanently affixed a loud fan to your new homemade smartTV?  How do you quiet it down?  How about with lower fan speeds thanks to the new software PWM module in RPi.GPIO for python.

Do what now?

So we have all these extra pins on the Raspberry Pi. These pins are known as GPIO or "General Input Output Pins".  We can do some cool things with these pins in software.  One of the things we can do is, with a python script, control whether a pin is a sensor for 3.3v, or if we're sending a signal of 3.3v on each pin.  There's also another cool thing you can do, and that is send a variable voltage across a pin through a neat little trick called Pulse Width Modulation (PWM).  PWM emulates a variable voltage by pulsing the maximum voltage (3.3v in this case) at a high frequency.  In theory this will allow me to control my fan speed through code.

I say in theory though, because what I have is a 5 volt fan, and the GPIO pins only output 3.3 volts.  I tried hooking up the fan to the GPIO pins directly, but 3.3v apparently isn't enough to get the fan spinning.  It NEEDS a 5 volt pulse to go.

Well, now what am I supposed to do?  I can't control the fan directly because I can't pulse a high enough voltage to get it to spin up.  And I can't control the 5v pin, because its connected directly to power.  I can't interface with it through python code.  Enter the Transistor.

How transistors work is beyond my knowledge.  All I know is how to wire one up to do what I needed it to do. Basically, when wired properly, a transistor works kind of like a relay switch.  It has 3 pins, a base, a collector, and an emitter.  When a voltage is applied to the base, it connects the collector pin and emitter pins.  When the emitter is ground, and the collector is my fan in series with its 5 volt supply, it acts as a switch that I can control with a 3.3 volt pin.

Back to the internet!  I ordered a pack of PN2222 transistors, some 5050 LED breakout PCBs, and some assorted wire for me to solder to.  I followed along with this tutorial in order to figure out what needed connecting where.  After some fine wire work, soldering and clipping of legs, we have my finished transistor module:

All that remained was putting it into the case. Unfortunately I don't have any pictures of what it looks like in the case.  I'll be diving in later to make another modification later this week, so I'll try to get a picture then.  Suffice to say, it's become a bit of a mess.  BUT, I have the ability to control my fan speed programmatically through python.  BEHOLD MY CODE!

























Sorry for the pictures.  If you need to copy it for your project I have it here.  There are a couple of extra lines of code in there for the next phase of this project, which I will detail in part 5.

So a basic explanation is that we import the modules we need at the top, followed by initializing some constants like what pin is connected where, how much I want the fan speed to step up or down as a percentage (that's your duty cycle, percent of time the pulse is on vs off).  Then we define a few functions to get the temperature in a usable format, write temperature and fan speed to a file, and then run the meat of the code in a loop.  Every cycle, we check the temperature.  If its above my set max temperature, we'll increase the duty cycle by the "step" amount.  If its below the minimum temp we decrease the duty cycle.  This arrangement allows the temperature to sit between the low and high level with the slowest fan speed possible, minimizing fan noise.  Then we wait (sleep) for a period of time and do the check again.  I can tell you, after having run this for a number of days now, it works great, and its very slick.

In part 5, we'll talk about what happens when you hit the off button, and what SHOULD happen, and how we make what SHOULD happen actually happen.  Seeya later.

Taken by a Strange Mood, Part 3

As I intimated at the end of Part 2, there were problems that extended this project.  Sure, I had a working embedded Plex image running on the Pi, but I had more ambition for that.  I downloaded and burnt the latest RetroPie image to an SD card and got that started.  The original plan was to have 2 SD cards: one for games and emulation, the other for movie watching.  Then I found out that Kodi could be installed under retropie, and that there was a brand new Plex plugin for it.  Once I discovered that, I stopped using the Plex image altogether, and have stuck with retropie.

This is not a blog post about setting up retropie, however.  It went pretty standard as long as you follow along with their instructions on their page, so I won't address that.

No, the problem I started seeing almost immediately is app crashes, freezing, and unexpected behavior.  The IC on the Raspberry Pi 3 is rated at a max temperature of 80' C.  When I checked my temperature, even at idle, I was running mid 70s.  Yipes.  Too hot!

Even though the RPi shouldn't need active cooling under normal circumstances, I was not operating under normal circumstances.  Ambient temperature inside the TV was affected by the TV electronics heating up, so the pi could not passively cool effectively.  I needed a fan.  At 5V, 0.2A max, this fan seemed ideal.  So I bought it.  It can plug directly into the 5V rail of the GPIO on the pi, and connect to ground. There are 2 pins on the GPIO that seem like they were designed for just this, pin 4 and 6.  All we need to do now is open up my case, and install the fan.  Sounds easy, right.  Well it would have been easy, except that I had ALREADY permanently affixed the thing inside my TV, so I couldn't remove it to get the top of the case off, or do anything else much with it.

Fortunately, the case didn't snap closed, and there was just enough wiggle room for me to be able to fit the small fan into the gap I could create between the top and bottom of the case.  Here's the other problem: no vents in the case.  Time to get out my drill!
I picked the closest sized coring tool I had in my drill bit set, lined it up, and went to work.  Even at slow speeds the drill didn't so much cut through the plastic as it melted through.  My plastic chips were all melted together, and some of them are still stuck inside the case.  Now came the hard part, getting the fan in there, and also mounting it to the inside of the top half of the case.


Case with fan hole cut.
I ended up using two small allen wrenches as feelers to position the fan under the hole.  Got another JB weld mix going, and then tried to hold it in place for 15 minutes. That didn't happen.  I was shifting the fan all around as I tried to hold it steady.  I needed a more permanent temporary way to hold the fan in place while I waited for the epoxy to cure.  In came my good old friend, Masking Tape.
Pull up, apply masking tape, hope it doesn't fall




Now that I had the fan in place, I needed to do something about the metal plate that covered the Pi here.  You see, a fan doesn't do you very much good if it doesn't have any access to ambient air to blow.  I sized up the location of my fan relative to the edges, and laid out my new hole pattern I was going to drill.

Hole Pattern







Drilled holes.













Holes in plastic cover
I think I messed up the label.

By the time I was finished drilling holes, my JB weld finished setting, and it was time to bring it all together. I plugged in the fan into the two pins I mentioned before  Closed the whole thing up, and turned it on.  Fan spun up.  It sounded like the blades were brushing something, because it was loud, and getting louder.  Even completely covered up by the case, running at 10k and brushing something with each blade on every revolution, this thing sounded like a small dustbuster.  This was No Good for a media smart TV.  I opened the thing up again to see if I could find what we were running into.  Turns out that this particular fan doesn't keep its wires away from the fan blades very well, and the blades were brushing the wires.  This took lots of finagling over several attempts to get the fan where it wasn't hitting itself when it spun up.  But even then the sound was very loud.

I checked my temps, and this thing was running cool.  I want to say it was less than 55' C under full load with the fan fully spun up.  So it was doing its job, just at a audible level I was not happy with.  Remember how I used JB weld again, and this thing was now a permanent resident?  Yeah, time for some more engineering.

I almost forgot to mention.  Before all of this I was getting a lot of noise out of my speakers.  Anytime something would be busy on screen, or there was disk activity, I'd hear a little noise.  Turns out the AV cable I used wasn't of the highest quality, and in addition the way I had my power supply connected meant that my Pi wasn't getting properly grounded.  I fixed that (mostly) by adding a wire from a ground GPIO pin to the case.  No, that solder joint didn't hold, but the wire is sandwiched between the side plate and the top plate, so it stays in place.  And my noise was reduced significantly (but not totally).  Too bad that AV cable was now a permanent resident.

In part 4, you get to find out how I dealt with my obnoxiously loud fan.

Sunday, January 1, 2017

Taken by a Strange Mood, Part 1

About two or three weeks ago I was taken by a strange mood.  We had our annual Christmas party, and I decided "wouldn't it be great if I could have movies in the back of the house as well as in the front."

Westinghouse 32" TV.  Collecting Dust.
We have this old 32 inch, 1366x768 Westinghouse LCD TV.  It used to be our primary TV (and was our very first flat panel HD television).  It doesn't even have HDMI ports, it's that old.  It served us well in its prime, but it has since been replaced by a 47" LCD (which was struck by lightning) which was replaced by a 55" Sony Bravia (the old version that weighs like 80 lbs and is 6 inches thick).  When we got the Sony, the Westinghouse became the bedroom TV, where it served admirably until about 2 years ago, when I wanted a chromecast for the bedroom.  Since it didn't have HDMI ports, I ended up buying another TV (42" RCA, I think), and so the old reliable Westinghouse was put in a back room to someday be used for something, probably.  I got my spare Raspberry Pi out, connected it to the TV's DVI out, with RCA audio, and burnt an embedded PLEX image to a spare SD card.  It booted, but the PLEX image did not know how to handle 1366x768 properly. Christmas party TV was a bust.  But there would be other parties.

Then, I got a brilliant idea!  Why don't I use a raspberry pi to turn it into a smart TV.  And not just a smart TV, but a retro game playing, plex movie watching smart TV.  It might work.  It could work.  And after I checked out the back of the thing, I might even be able to mount the Pi INSIDE the TV.  MWAHAHAHAHAHAHA!  Did I mention it was a strange mood?  I wonder if other engineers get these.

I took my existing RPi that I use for my backup server out of its case and opened up the TV, just to size it up.

Low and behold, not only was there space for the Pi to sit, but it looks like there was an entire area of this particular TV PCB that was unused (probably for a model with more features).  Now that I look at the pinouts in this area, it looks like it might have been a SCART input, or something similar.  You know, one of those TV connections that nobody knows about unless they work in media and television.  This is where I checked to see if the pi would fit.  Spoiler warning.  It did.  The next thing I needed to do to make this viable was find me a 5V power source inside the TV that I could power my raspberry pi off of.  I checked numerous plugs and connectors, and found several 5V spots.  Problem was, evertime I checked across them, the TV would shut down after a moment.  These were no good.  I then took a look at the power supply, and what to my wondering eyes appeared, but an unused, 4 pin connector.  I got my voltmeter out and read across the pins.  Two of them were ground.  Two of them were 12V.  But they didn't cause a TV shutdown when I read across them.  If I could just get a voltage downverter, I could connect here.  If only there was something you could buy that took a 12V input, and output 5V for charging a cell phone... like... a car charger... TO THE INTERNET!!!!!

The strange mood was in full swing now.  I was powerless to resist this new mania.  I found the perfect device here. Only problem was it had the wrong kind of USB plug on one end.  No matter.  I have a soldering iron and spare micro-usb cables all over the place.  The other problem was I had no idea what kind of plug that was.  Fortunately, the nice folks at the Adafruit forums came to the rescue.  I got on the amazon and ordered this, a Raspberry Pi 3, along with a clear plastic case.  The USB and Ethernet ports would face out of the TV chassis just below the AV1 input.  The trouble with this is that the micro-sd card is in the opposite side of the pi, and would be facing the inside of the TV chassis, completely inaccessible without opening the TV up.  I really didn't want to open the TV every time I wanted to try a new Pi image.  I wonder if they make Micro-SD Card Ribbon Cables?  They do.

Two questions remained.  How did I want to hook up the AV from the pi, and how was I going to get it all to stick firmly inside the TV chassis.  After much deliberation, and the bad DVI experience I had before, I decided to just use the Pi's AV out and connect to the AV1 input on the TV.  I kicked around the idea of wiring it directly, but ultimately decided to just use a cable, run it outside of the chassis, and into the inputs on the outside.  This would allow me unplug if I ever wanted to use the AV port for something else in the future.

As for how I would stick it all in there without worry, I decided to go with JB-Weld epoxy.  I may ultimately regret going with such a permanent solution, and it did make a few future mods more difficult.  But I won't have to worry about this stuff falling out of the TV ever.  And I mean EVER.  Next time, I'll show you how it all came together.

Monday, November 21, 2016

Updates!

Hey all, just wanted to give you an update.

I won that contest that I mentioned earlier for the ultra small computer case.  I was on edge for a while there, because some of the other entries looked really good.  But while they all looked good, I don't think they would have been functional without a LOT more engineering work done on them. Anyway, here's what it looked like finished. Had a lot of fun putting this together, and big thanks to Ed who requested the contest for choosing me as the winner.

I have another update as well.  As I type, I'm uploading another version of Cubix Rube to the google play store.  Once updated you'll find an improved rubix cube experience, with more intuitive face selecting, pinch to zoom functionality, as well as a short solving tutorial thanks to how-to-solve-a-rubix-cube.com.

If you like rubix cubes, please check it out, have a download, and let me know what you think via reviews or comments on this blog.  I'll talk to you guys later.

Wednesday, October 19, 2016

And Now for Something Completely Different

Look at that.  Think of beauty, isn't it.  What do you mean you don't know what it is?

OK, so I entered a design competition on this site called cadcrowd.  Its a freelance CAD and design websites, where people who need something engineered for them on the cheap put up some dollars, and then the community of designers submit ideas in hopes of winning those dollars.  Anywho, one buyer was looking for a design for an ultra small Mini-ITX case, and I thought this would give me a chance to flex my old engineering design muscles.  He was looking for a case that weighed in under 9 liters of displacement, and would fit a full sized video card and  M.2 PCIe SSD.  Most of the other folks submitted designs that were 9.5-10L.  That sweet puppy right there is 8L.  Its actually my second concept for this project.

The first project placed the video card where it belongs, right inside the PCI-E slot directly on the motherboard.  The buyer is using a low profile heatsink/fan combo, so I was going to place the power supply directly above the motherboard (with some clearance for airflow).  I got everything laid out and took a measurement on my displacement: 10.5L.  Back to the drawing board.

Motherboard Cavity View
So then I came up with this concept.  I had seen some other small case ideas that involved using a PCI-E ribbon cable to basically move the video card in an orientation where it could be over or under the motherboard.  I decided to put a central "spine" in my case that the motherboard would attach to on one side, and the video card on the other.  The PSU would then have to locate in front of the motherboard, and the case would then be long enough to accommodate 10.5" long video cards.  Because of the somewhat "exotic" location for the PSU, I needed to source parts and a cable for the inside of the case, not at all dissimilar to the ML07 and RVZ cases from Silverstone.

GPU Cavity View
The whole case is made from sheet aluminum, with a brushed finish.  The spine is 3mm thick, and the outside panels 2mm.  The spine has a spot for the psu to attach to, and the spine itself will screw in to the side/bottom panel.  The back plate is actually welded/brazed to the spine.  Outside panels are well ventilated.

The only thing left to design is the front panel hookups (lights, buttons, and USB ports).  That is a whole design challenge in and of itself, since you can't really just buy a pre-made arrangement.  I think I'm going to have to design the button and light placements myself, and hope that I can make it look good.

Case with Panels
Here's hoping that I do well in the contest.  Wish me luck!