Showing posts with label Radio Shack. Show all posts
Showing posts with label Radio Shack. Show all posts

Wednesday, April 19, 2017

Fun with Robots, IR Decoding, LED Matrix, etc.

Fig 1: Three experiment--two with the samsung remote on the left, one with the Radio Shack remote on the right--to control a +Adafruit Industries 8x8 Bicolor LED Matrix
I haven't posted in a while because several interests have kept me very busy. This all started withe the +Parallax Board of Education (BOE) Robot kit. I asked for and received on for Christmas a couple of years ago and let it ripen until I was ready.  I decided that it would make a good project to do with my 7-year-old granddaughter when she visits this summer--but first, I should make sure that I can build it without a lot of fumbling. Fumbling is good, but watching me figure out what dumb thing I did is not always interesting to a 7yr-old. I followed the tutorial and learned quite a bit, The last project that I did used infrared for proximity sensing to avoid obstacles. At the same time, +Adafruit Industries, via The Desk of Lady Ada, provided some great information on IR. So, I decided to play and learn further.
Fig 2: +Parallax BOE Bot with 2 IR transmitters aand 2 IR receivers

IR Decoding the Hard Way

Following the +Adafruit Industries tutorial on IR Sensing, I was able to decode only some of the buttons on my Samsung TV Remote (see Figure 1). Using the remote is a 2-step process: first decode the signals send by the buttons, then use the decoded signals in a different sketch that takes action based on the buttons. Using this method (see the Raw IR Decoder and ircommander code on github), I was able to decode some of the buttons and use them in a sketch.  

Quick diversion:  I have had big plans to use a 32x32 LED Matrix that I bought in a parking assistant project that will display faces to convey the emotions evoked by a car getting increasingly closer. I decided to use the 8x8 bicolor matrix and backpack to prove the concept, and use the remote to signal which face to display. Figure 1 shows the initialized yellow face (looks orange to me). So, I needed to follow the tutoral for the matrix and backback library.

I was able to merge code from the bicolor8x8 example code in the Adafruit LED Backpack library with code from the ircommander sketch referenced above. After adding the decoded remote buttons to a newly created library (see the IR Sensor tutorial and the project video cited at the end of this post), I was able to change the face on the matrix based on the remote buttons.

I found both the coding aspect and the operation of the technique to be less than perfect.  Maintaining a separate library with very long sequences of numbers just to test what button  was pressed seems a bit much. In operation, the code seems to reset itself randomly, and only respond to buttons when it feels like. This may be me, and I will investigate, but read on to see a much neater technique.

IR Decoding an Easier Way

After working through the above, I watched Lady Ada work through Chris Young's IRLib2 in one of the Desk of Lady Ada epdisodes cited above.  Chris, aka cyborg5, is a frequent visitor to the Adafruit Show and Tell, and has done a lot of great work (see his blog).  Both the decoding and the processing techniques are simplifies greatly, and his library handles several IR protocols. The IRLIB2 tutorial describes it all very well.  You wind up with one simple code that you supply in a sketch so you can determine what button was pressed--straightforward, and I was able to decode all the buttons with no missed presses. From there it was a matter of simplifying the sketch I wrote earlier to display faces on the LED matrix.  Again, the project video shows all this.

Controlling Motors with IR

Since we started with robots, I thought it would be interesting to control motors with IR.  It was a simple matter to modify the IRLib2 sketch above to direct the continuous rotation servos.  I took code from the BOE-Bot project, and code from the Adafruit_PWMServoDriver library tutorial, and it went smoothly.  The servos in the BOE-Bot are different from the Adafruit ones, so I had to go to the data sheet to see what values to use to get them to move as I wanted. I was able to decode all the buttons on the Samsung remote, and used the arrow keys to simulate moving the robot forward, back, left, and right.

I first did this without the PWM Servo FeatherWing. Because the feather is 3V logic, I needed a level shifter to handle the signals from the board to the servos. That worked, but added a few connections and I used the Arduino servo library as opposed to the Adafruit library which allowed for simpler code.

Another thing I needed to worry about was timer conflicts. I had come across this before, in my Donkey Project, but Chris' tutorial gave a straightforward explanation and solution. The problem is that the servo library uses Timer1 and on the 32u4 Feather IRLib2 does too. It was necessary to go into one of the associated libraries and change one line of code to re-assign the timer.  You'll get better instruction in the tutorial than I can give here.  Again, the project video shows the results.
Controlling 2 FS90R continuous rotation servos from an Adafruit BLE Feather and PWM Servo FeatherWing

Trying a Different Remote

A while back, Radio Shack sold some MAKE project kits, including robotics. During an earlier RS bankruptcy, I acquired a RS remote at a big discount and still had it in inventory, so I decided to try it out. Using the IRLib2 approach to decoding, I found the the protocol was not one of supported ones. A look at the datasheet for the PT2248 chip in the remote revealed that ot used the Toshiba protocol. So, I had to go back to the hard way, and I got that to work.  See the video.

IR Affects the BOE-Bot

Just for grins, I took out the BOE-Bot, let it runon the floor, and chased it with a remote.  The bot's IR retrievers detected the transmissions, and the bot reacted accordingly (moving left or right as if it had detected an obstacle).

Project Video

See the project video on YouTube

Wednesday, July 1, 2015

@MAKE #Electronics Experiment 29: Filtering Frequencies Part II


Note: first, apologies to +Eric Buijs who noted that the TEA2025B runs hot at 9V.  I either did not notice or did not perceive that in part 1. However, in part 2 I experienced the same thing. Using an adjustable wall wart, I was able to apply different voltages.  9V works best, but it runs at safer temps at 7,5V and 6V. Besides the heat, the biggest difference is the volume coming out of the speaker (see video at link below).

Part 2 of this experiment involves adding a 555 timer in astable mode (with resistors and capacitors) and two pots: a 500 Ohm for volume control (between output pin 3 of the 555 and the input of the TEA2025B) and a 100K to manipulate the waveform (between 555 discharge pin 7 and threshold pin 6). I skipped the buttons for this exercise, and connected it with each filter and with no filter at all. The differences are discernible.

I did not have a 500Ohm pot, so I used a 1K.  It really only worked as a volume control at 9V.

Charles says to disconnect the audio source and use the timer as input to the amp.  I also added my cell phone playing Pandora back in.  It works for that, too.

A very worthwhile experiment. I'm looking forward to doing more with audio.

Here's the video.

Monday, June 22, 2015

@MAKE #Electronics Experiment 29: Filtering Frequencies Part I


I know very little about audio, etc., so this experiment is very interesting to me.  When I was 10-12 years old, I read about people making hi-fis, ham radios, and the like, and thought I'd like to do that someday.  With neither persistence nor guidance, that interest was never nurtured, but it was always somewhere within me. Thank you Charles for helping to bring it back. 

The photo below shows the breadboard, nearly complete according to the instructions.  The two momentary, normally open push-button switches are for the two filters. The coil is not shown--110ft of 20 gauge hook-up wire, which I had to unwind./rewind to get access to both ends. I used two 22uf electrolytic capacitors, back-to-back, instead of the 10uf NP cap Charles had in the schematic.  I could not find .15uf caps, so I used .22uf. I took the speaker out of an old Sony Trinitron TV before I took it to the dump (also got some pots and other useful stuff). Since I'm totally ignorant, I wasn't following Charles' instructions for connecting audio, so I bought some plugs to fit into the adapter. Once I took the plug apart and saw the connections, I understood what he meant. Since I spent the money (US$4.99 for eight at Radio Shack), I'll use it. Besides, it gives me an excuse to solder. The box for the speaker is a US$1.99 pencil box from K-Mart.  I use them for project boxes, but this seemed like a good application.

Breadboard almost ready, speaker taken from an old TV set, RCA adapter from Radio Shack, and a pencil box from K-Mart

The next photo is the speaker box after I drilled holes. Not the tidiest of jobs, but I think it will work.

Pencil box ready to be a speaker enclosure

Next step, hook up the filters and the music (I'll plug the adapter into my cell phone and play something on Pandora).

The idea is to bring mono input into the amplifier chip. The output goes through either a high-pass (caps) or low-pass filter (coil) to the speaker. I used the RCA adapter to get sound from my cell phone, plugged into one of the jacks in that adapter, and wired the plug to ground and to the 33K resistor/amp input.

Everything hooked up as expected. There is a big difference with and without the coil, not so much with and without the caps. The coil provided more difference after I removed the 33K resistor (also less noise). I will try using smaller caps. In the next post I will add the 555 timer and pots.  I'll add video there too.

This was another simple, but informative experiment.  I love this book. See you in part 2.


Sunday, April 19, 2015

Regulated 5V Power Supply


Taking a break from the book experiments, I decided to make my own 5V regulated power supply, since we've been including it in many experiments.

This took WAY longer than it should have. I though it would take an hour--instead it took most of two afternoons, including 2 trips to Radio Shack.  The first day was setting it up on a breadboard so I could replicated it on a PCB.  I made a bunch of stupid mistakes...finally took it all apart and re-did it and it worked.

The second day was taking the model and putting it on a PCB.  I wanted it on perfboard, and I wanted header pins to plug into a standard breadboard.  Plain perfboard does not facilitate soldering. I had a one sided PCB, and I got the header pins on, but that made soldering connections on the bottom side difficult.  First trip to Radio Shack: unsuccessful, no double-sided PCBs. I have several Adafruit perma-proto boards in 1/2, 1/4, and 1/8 sizes.  They don't fit the breadboard, but I made due with the 1/4 size.  After a bunch of wiring errors, I got it working.

Parts:
Adafruit barrel jack
Adafruit 1/4 size perma-proto board
LM7805 Voltage Regulator
PCB mount toggle switch
22 Gauge Hook-up wire
Tinned Copper Bus Wire
10uf electrolytic capacitor
.1uf electrolytic capacitor (I ran out of the mylar versions)
LED
330 Ohm resistor
standoffs and screws

The barrel jack takes 6-12V in.  The power from the jack connects to pin 1 (power in) of the LM7805 and ground to pin 2 (ground).  the 10uf cap goes between LM7805 pins 1 and 2, and the .1uf between pins 2 and 3 (power out) Since both capacitors are electrolytic, the negative side for both goes to pin 2.  Pin 3 goes to the PCB power rail, and Pin 2 to the ground rail.  Hookup wire connects the rails from side to side of the PVB.  Pin 3 also goes to one side of the toggle switch, and the other side of the switch goes to ground (WRONG!--see "Update" below). The LED goes from power to the 330 Ohm resistor to ground.

Since I could not plug this into a breadboard, I added hook-up wire (22-gauge, solid core) soldered to the power and ground rails.

Here's the video.

Update: see my comments, below.  The voltage regulator overheated when the device was turned off with the toggle switch.  Dumb mistake: I should have put the switch between 9V in from the barrel jack and the 9V side of the LN7805.  I fixed that. Here's  an annotated photo of the bottom of the PCB. I know it's messy--I haven't trimmed the wires yet.
DIY 5V Power Supply Wired Correctly (bottom view)