Monday, 1 February 2016

Line Tracking Robot

While surfing around the internet one evening, I was drawn into an ad on Facebook for a product from Banggood.com. It was a video clip of a small robot following a line, a DIY kit for under ten bucks! See HERE.





While it wasn't really a good kit for a small child to do, I thought it would be fun to do it together, and great to play and explore with later too.


When I first saw it, I thought it must run on a little micro (like ATtiny), and after looking at the site, I discovered it was a set of op-amps. This helped to get me excited, mostly because I dislike this online trend where everyone just throws a microcontroller at all of their problems.

We have a few things here that I like:
Things that blink!
Things that move!
Op-amps!
Transistors!


The circuit design is simple enough, and was easy to solder together. One issue I had was that none of the kit was in English, but anyone who is into hobby electronics should be able to put this thing together without much trouble. This does seem like it is intended to be an educational kit, as it has lots of cool information about the various parts.... which I can't read, but they look good.

So basically between the pictures online and the schematic, I was able to assemble it. The motors don't come with wires already on them, I used the slack from the battery pack to make wires to go from the motor terminals to the PCB, no issues with that whatsoever.

I also had a little difficulty soldering the photo-sensor and LED's onto the board backwards, as they need to be left long and sticking out so
they're close to the surface the robot drives on. I'm not sure if a distance is specified in the instructions, but I simply left the leads as long as they could be, and it seems to work just fine like that. The tubes on the photo-sensors also appear to be heat shrink, I've just left them as they were without shrinking them, and that seems fine too.

Precision resistors are also a little different than what you may normally have. They have three digits with a multiplier behind it, so the 3.3K resistor is banded as orange orange black red (330 plus 2 zeros on the end or 33000 ohms), rather than orange orange orange (33 plus 3 zeros or 33000ohms)... geh, you'll figure it out I'm sure!
One packing issue was that all the parts were dumped into one bag together, but it did cause the op-amp to somehow get stuck inside of the spring on the battery holder. I needed to carefully remove it with a pair of tweezers. All the parts were there, and nothing was broken, but I am a fan of bags for little bits. Anyway, here are a bunch of pictures of the building process.










And that's about it! If you have any questions, type them in below. Follow the link, get a kit and have some fun. You can't put the parts together for that price tag, even if you decide to do something else with the parts, it's still a great deal. The kids liked the project and are still playing with the robot.

Wednesday, 26 August 2015

LM386 Stereo Amplifier

*The information found in my blogs is provided for free; I do want people to use the information and reproduce or expand on my projects. If you produce a blog or publish work using the information found here and are using elements that are unique to my designs, I simply ask that you link back to my blogs and videos and credit the resource as a courtesy to myself and others who take the time to add to the online electronics hobby community. 

The magic surrounding the LM386 is mostly because of how common it is, how easy to use it is and the cost. I purchased a bulk package of these IC's off of eBay some time ago. They have made their way into a few radio and audio projects, and I will have no issue using them all in future projects.




I recently built a small arcade machine around a Raspberry Pi computer, and I needed a solution for providing the audio component. This was not the easiest way to get sound into the cabinet, but I feel it took the customization up, and added a component showing that I could handle DIY electronics too, and I don't need everything to be "plug and play".

 While most of the parts I already had available to me, I feel that sourcing the parts from the fine vendors in China over eBay drove the cost of this project down. I would be surprised if the cost of this board was greater than 5 bucks. The most expensive part of this project was buying the actual speakers, which I found at the local surplus store at a reasonable price.

Q: I thought the LM386 IC was only capable of handling one signal, stereo is two signals?
A: True, this is why we used two chips to produce the desired results!

 

Q: How do you get two separate signals going to two different chips to amplify at the same level?
A: With a dual potentiometer! (In this project I selected a dual 10K potentiometer with a logarithmic taper).


Q: Can I drive my giant speakers with this?
A: Nope, think headphones and small projects (~1/2 watt per channel).

Q: Why don't I just buy an audio module off of eBay instead of building my own?
A: You're only learning how to buy stuff, build something on your own and learn.

In this project I knew I would be stealing power from the 5V rail on the Raspberry Pi. For your information: LM386 IC would like to see 4-12VDC, except for the LM386N-4, which likes to see 5-18VDC. (It's common to see LM386 Projects supplied from 9V batteries).

Another consideration: depending on the project, you may wish to use a small value capacitor (Think 0.01uF or 0.001uF) to remove the DC component of an audio signal, this was necessary for my FM radio project: TEA5767 FM RADIO W/ ARDUINO.

It's up to you how you make the connections!
I ended up hacking a 3.5mm extension cable in half to get a male audio adapter for my circuit (I simply soldered the wires directly to my perf. board. I used screw terminals to hook up some small stranded wires as the speaker wire running to the speakers.

The only really unique aspect about this project is the linear taper dual potentiometer. If you google the datasheet for the LM386 you will see several different configurations, and some may be more well suited to your project than what I'm using. I decided to use the configuration with the lowest part count.

****Use bypass caps to reduce noise and clean up the audio****
(See schematic)

 *You don't need to use electrolytic capacitors, I just used what I had - replace 220uF with a poly type if available.

I added the bypass caps after I built the board, I would use space more effectively if I repeated this project.

There you have it, a cheap and easy stereo amplifier for small projects!

Thursday, 16 July 2015

Tabletop Arcade Machine


 *The information found in my blogs is provided for free; I do want people to use the information and reproduce or expand on my projects. If you produce a blog or publish work using the information found here and are using elements that are unique to my designs, I simply ask that you link back to my blogs and videos and credit the resource as a courtesy to myself and others who take the time to add to the online electronics hobby community. 
 
While trying to decide on a project for a capstone project, I thought it would be fun to build an arcade machine; No one was on board, so we instead built a home automation/monitoring system (boring). Link to Home Automation Project

Moving along... I decided that I still wanted a machine anyway, so it might not be as polished as it
would have been if I made it as a capstone project, but it definitely has all the components needed for a good time! My only partner for this home project was my son Max.

The system is based around the popular Raspberry Pi model B computer (Check the link if you don't know about this computer), running the RetroPie software, which is available free (or donation) which boots your machine directly into a menu which allows you to select your emulator.

The first thing I did was acquire a monitor, which I actually picked up at a college asset sale in October (8 months ago). It was only $5 for a 17" monitor, and I don't think the aspect is quite 4:3, but it is close, which makes it more suitable for emulating older consoles. If you were to use a modern 16:9 screen, you would either have black bars on the left and right sides, or you would be stretching the image. Cocktail games are actually meant to be run on a monitor flipped 90 degrees, so the black space on the sides with a 16:9 monitor with cocktail games would be very large! If I build another machine, I will either hunt down a suitable CRT monitor, or another "square" monitor. The only issue with a VGA monitor on the Pi is that the Pi has an HDMI port, which I handled by using an HDMI to VGA adapter from eBay, which worked out just fine! Expect to pay less than $5 bucks, and make sure it actually has the support circuitry, and isn't just a "dumb" adapter.

The next component to worry about was the joystick and buttons. I dug around on eBay, and it looked like my best bet was to buy a kit. It's hard to link to auctions that end, but here's a try: joystick I bought
 This is a  picture of the kit if you wish to find the auction or buy one similar. The seller was fair, and I did receive it in a timely manner. I was however unimpressed with the buttons. The final arcade machine has the board with the controls screwed in, so I can remove it later, as I may yet swap them out. They do seem to do the trick and haven't given me much trouble, but they are a non-standard size; I didn't have a hole-saw the proper size, so the fit wasn't great. I did do an unboxing video for this set on YouTube. I was pretty upset in the video, but it worked out, the seller was fine, and the USB joystick adapter board did work fine with Mame/RaspberryPi, so if you're on a budget, you may still consider this set as an option.

 


The next step in the project wasn't mandatory, but it did simplify the project. I took the monitor apart so that I could remove it from the stand and enclosure, and also so I could try to steal power for the Raspberry Pi from it. I made the assumption that the circuitry and buttons on the monitor were being powered by a 5V supply line, and I was curious to see if I could tap into that.
I moved ahead and took the monitor apart and attached a cut-off MicroUSB cable to a 5V power line inside the monitor's guts and I was successful at powering the Pi. The only draw back to this is that I don't know what the max current output of the monitors 5V rail is, so this may fail in the future, or be unable to supply a Raspberry Pi 2 down the road; for now, I'll take it! The 5V rail is also used to power the audio system. The bonus of this technique is that I can simply plug the power cord into the monitor to power the entire project!



I had to decide on dimensions for the cabinet now, and the only thing I really knew for sure was the size of the monitor. I went into draftSight and started drawing out what I thought would work well, and I came up with this:
DWG File

To build the cabinet, I decided on a 4'x4' sheet of 1/2" MDF, as it was only $20 at Home Depot and the texture is preferable to plywood. Cutting and painting was the most time-consuming aspect of the project. Here is the video we made of us cutting out the parts using a table-saw and a jig-saw.
 
The panels were assembled by pre-drilling holes then putting nails in. A better method would be to use a router and cut grooves in, but I made due with what I had, and it worked out just fine. If you don't drill first, you will most certainly split the wood! I also cut the bottom part of plastic off the monitor which originally held the user buttons (I simply used a back-saw).

To add sound to the project, I decided to use LM386 amplifiers attached to speakers I picked up from the surplus store. I had all the electronics parts I needed on hand, so it worked out well. You may consider using computer speakers instead, but I feel my approach made the project a little more personal.
Link to Stereo LM386 Amplifier project
(It is complex enough that I don't want to get into too much detail here). This is a video demonstration of the LM386's in a stereo configuration, mechanically joined by two  logarithmic potentiometers, and being powered off of a 5V pin from the Raspberry Pi:
It's worth noting: The Raspberry Pi has no shielding, so even if you're listening to the audio with headphones, you will notice click and popping and noise. I may in the future put a metal shield which is bonded around both the Pi and my sound board. If you look closely in my video, you will also notice that the shielding on the cable I used for speaker wire is tied to ground to help suppress it from picking up additional noise. I think I made this video before attaching some 104 (0.1uF) caps directly in front of the + and - supply to the LM386 chips, which helped a lot with knocking noise off from the Pi.

Here we have the unveiling of the arcade cabinet:

This is pretty much how it will stay until I get the new Raspberry Pi. The project was fun, and I think I enjoyed building it more than I like playing on it! You may find you need to go into the RaspPi config and overclock it to 900MHz (if you're using an original Pi, not the Pi 2), as I was having some stutters in some games, but at 900 MHz, most of the stuff I was doing ran just fine.


 There you have it, the Pi Arcade Machine. I know this project has been beat to death, and loads of
information has been done, but hopefully this info still encourages or helps someone out. This has also been one of my more popular projects (as far as social media goes), and I'm happy to add more Raspberry Pi projects to the internet! Thanks for checking this out, and I'll leave you with one last thing, my blooper reel from building the cabinet.







Wednesday, 31 December 2014

Repurposing Security Motion Detector for use with Raspberry Pi

Update:
I ended up removing the internal resistor and using two external resistors to hold it down to ground so the input didn't float. Also note that the motion is OPEN when there motion is detected (which makes sense, right?). Here is a schematic for something else I am working on, but shows how I attached a motion and a door contact (among other things) to the GPIO of a Pi. Please also note that the Aurora is being replaced, however, the new Honeywell version will likely be indistinguishably different from the installers perspective.


Add motion detection to your project using an off the shelf security system motion detector!
This example is not limited to just the Raspberry Pi, will also work with your 5V projects (recommend 4.7K resistor instead if you do this).


This motion detector is a quality component used for security system installations, this ‘Aurora’ model is made by Honeywell/Ademco and can be found new in the $15-25 range.



These hardwired models age well if you're considering re-purposing one; this one has been around for well over ten years and still works great. Bosch has a slick looking model too. Worth noting, you can see inside attached to one of the signal lines is a 1/2 watt resistor, (200 ohm I believe for that panel) - these are used to produce current so that the security panel can see if there is trouble, or if someone tries to short the wires out along the line it will detect the tamper.

On the inside of this model you will see 4 screw terminals. Two of these are to power the unit, the other two are for the signal. To power up the unit, the data sheet says

its operating characteristics as 8-16VDC with a form A SPST 90mA @16VDC relay. I used a 12VDC power supply to play with this. If you are using a Pi or an Arduino, you will need access to that 8-16VDC to power it. I performed measurements  on both the power input as well as the relay signal contacts.


On 12VDC supply lines:
No motion current: 3.82mA
Motion current: 9.38mA

Resistance on relay contact terminals:
No motion: 16 ohms
Motion: Infinite
Relay is closed while unit is powered and no motion detected, it opens if no power is present, or if motion is detected.

If you choose to disable the internal LED I would imagine you could shave off a few more mA if you're concerned about consumption.


To make the motion suitable for our Raspberry Pi, I attached a ¼ watt resistor with a value of 3.3K ohms onto the relay terminals; The current used by this device will now use <= 1mA with the 3.3V supply voltage of the pi, which will be suitable for our demonstration.

This picture to the right is with the new wire installed, which I used 22/4 station wire (standard for telephones and security systems). I also attached the new resistor inside the motion detector, which could just as easily be placed outside on a breadboard, a perf board....

When 3.3VDC was applied to the contact wires it measured 1.01mA when closed & 0 mA when open. 
From left to right I used the scheme of red for +12V, black for ground, green is one side of the relay contacts, and yellow connects to the other side of the contact (this has the resistor attached between the yellow wire and the screw terminal - I used a 'b connector' to connect it, which is common in security and telecom). It doesn't matter how you connect the green and yellow to your project board, as the circuit is either open or closed with a current limiting resistor in there - connect one two the Pi's ground, and one to your I/O pin which is configured as an input.

The only other thing I feel I should mention is that since we're using 22 gauge wire at 3.3V, the length of the wire should be fairly short, or local to the project board. If you wish to run it 20-50' away, I'd strongly recommend using the 12V line for the signal and using an opto-coupler or a transistor or something like that to achieve your low current low voltage signal to your controller.
Above is photo of it completed, reassembled, powered with contacts being monitored. Looks like everything is working great, and stylish too! Good luck with yours!