Showing posts with label cheap. Show all posts
Showing posts with label cheap. Show all posts

Wednesday, September 23, 2015

Look Ma, No Wires!

I’m blogging after aeons! Been really busy; work is such :-/ It’s not like I haven’t been tinkering at all, it’s just that I’ve been tinkering less, and haven’t had the time to document it.

A few weeks ago I decided that I needed a Bluetooth-to-audio adapter for my home (which has a decent but dated Sony home theatre) and car (which has an old stereo system). So this vacation I decided to make one.

bluetooth-audio-adapter
Logitech’s Bluetooth Speaker Adapter has got a 3.5mm socket as well as RCA outputs

I was looking for an end result similar to Logitech’s Bluetooth Speaker Adapter, available on Amazon for INR1,100 (~USD16) as on Sep, ‘15. There are predominantly two types of Bluetooth audio adapters available online – one, which outputs analog audio through a 3.5mm jack, and connects to your sound system’s AUX/RCA input. The second, slightly more interesting version (to my mind, at least), plugs in to the USB port of more modern mp3-capable sound systems. The adapter ‘appears’ as a regular USB flash drive with an MP3 file on it. The audio streamed over bluetooth is constantly written and buffered to the ‘mp3 file’. Pretty ingenious!

As with most of my projects, I turned to the internet to do a little pre-hacking research. I took a look at a few DIY hacks – google “hack car stereo bluetooth”, and you’ll get links to several people who’ve given new life to the old cassette deck in their dad’s rickety jalopy.

Pretty straightforward: http://www.instructables.com/id/Add-bluetooth-to-your-car-stereo/?ALLSTEPS

A bluetooth speaker modified to do the business: http://www.instructables.com/id/Bluetooth-Speaker-Hack-Home-Theater-Streaming/?ALLSTEPS

And for those people still rocking cassette tapes in 2015 (my mom, for example), this guy made a ‘bluetooth cassette’: http://car-mods.wonderhowto.com/how-to/hack-your-cars-cassette-deck-into-wireless-bluetooth-music-player-0139843/

I was initially thinking of modifying the BT earpiece I use with my phone, however that would limit me to a mono output only (there are earpieces which have stereo outputs, so these too, may be good contenders for a hack). I had an old Corseca/Byte brand on-ear headphones lying around. The ear pads were crumbling, and the sound quality was absolute rubbish. But it was still working, and I was pretty certain that the poor audio was only due to the low cost sound drivers. So naturally, I took a screwdriver to the headphones, hehe.

IMG_1757
Not sure if the brand is ‘Corseca’ or ‘Byte’

Disassembly was rather painless – just a few screws and plastic retention clips. The electronics were crammed into the plastic cover over one ear, and the battery was stuck with double sided tape in the other cover. The cover which had the electronics also had control buttons on the other side – FF, REW, Vol Up, Vol Down, Call Answer.

IMG_1758
Teardown time!

No surprises about the main chip being from CSR (now acquired by Qualcomm). CSR is a major in BT consumer electronics ICs, and you’d find CSR chips in everything from keyboards, to headsets, to smart microwaves. The main chip is a CSR57F68 A2DP streaming audio chip. The chip is fully integrated, and has two onboard differential audio outputs, button handling capabilities (debounce, etc), GPIOs, and of course, the BT radio itself.

IMG_1759 IMG_1760
The electronics were on a double-sided board – one side with the chips and support circuitry (Left), and the other side with buttons and status LEDs (Right)

The TSSOP chip is an L24C32, 32kbit I2C EEPROM, which probably stores config data, descriptor strings, etc.

I then desoldered the sound driver and battery wires.

IMG_1770 IMG_1771 IMG_1772
Desoldering the mini-USB charging socket, and replaced it with a micro-USB connector for convenience. The micro-USB’s pin pitch didn’t fit the board perfectly, and the connector itself had a different footprint, so I had to use mod-wires

I also removed the mini-USB charging connector, and soldered-on a micro-USB connector (side rant: just like everyone else, I get totally frustrated pulling out ten different cables to charge ten different devices. With most manufacturers now standardizing around the micro-USB connector, things have become a bit easier, but Apple still stubbornly pushes its weird proprietary connectors, each one different from the previous).

IMG_1773 IMG_1774
The covers, before (Left) and after (Right) modification

My idea was to use the two covers – one from each ear – to form a sort of ‘case’ for the final product. I used my Dremel to trim away the plastic standoffs for the screws on the plastic covers. I then fashioned some new screw inserts out of acrylic. The inserts were hot glued into place. Small holes were drilled into the inserts and the bottom cover to allow for the screws.

IMG_1775 IMG_1776
The acrylic inserts/standoffs for screws, and the 3.5mm audio connector

I had a 3.5mm audio socket (probably scavenged from an old motherboard or CD drive) in my junk box, which I also hot glued in place. Wires were then used to connect the audio outputs from the board to the socket. I took care to connect the left and right channels to the correct legs on the socket. The negative output of each differential pair was soldered to the ground pin of the socket.

Connecting the wrong output to ground would result in an out-of-phase output from the speakers. While this may not be such a big deal with headphones, it would result in sound ‘cancelling’ itself out (primarily poor bass response) if I used the BT adapter with speakers. The AudioCheck website has cool online audio files that help you determine if your speakers are connected correctly.

 
IMG_1778 IMG_1779
The finished project – screws on the sides, and the PINK (!!) audio socket sticking out – not the prettiest

A small slot had to be cut in the bottom cover to accommodate the audio jack. The covers are held together by three screws. The final device is not the prettiest, but it’s functional and works really well.

  IMG_1780 IMG_1781
Charging through the hacked-on micro-USB connector

Tuesday, July 3, 2012

USB OTG on a Sony Live With Walkman

I have a nice Android phone – the Sony Live With Walkman, affectionately called the ‘LWW’. The phone specs state that it has USB OTG – USB On-the-Go. OTG is a funky specification that allows phones (and other devices) to act both as a slave (so you can connect it to your computer an use it as external storage) or as a host. The host mode potentially enables you to use mice, keyboards, USB flash disks, and a whole host of other cool USB peripherals.

Now some phones have hardware that supports OTG, but it is not enabled in software. Presumably, this was because support for this was not widespread at the time of manufacture and the phone company didn’t want to go through the extra headache. Who knows! Anyway, other phones, like the LWW, support OTG natively, and you can simply plug in a mouse or a keyboard and use it with your phone. Of course you need an appropriate cable – apparently the Nokia CA-157 works fine (though I haven’t actually tested it).

Where I currently live, a USB OTG cable is not easily available, however, it isn’t really all that difficult to build your own. All that is needed is a USB Micro-B male (the same kind that your phone charger has) and a USB A-type female. Connect the four USB wires (Vcc, Gnd, D+, D-) between the connectors. You’ll notice that the Micro-B has got 5 contacts; one of these contacts is the ‘ID’ pin. If this pin is left unconnected (as is the case in a regular USB cable) the phone stays in slave mode. If, however, the ID pin is connected to Ground, the phone switches to host mode.

 Pics
1:Vcc (5v)  2:D-  3:D+  4:Gnd (on type A), ID (on Micro B)  5:Gnd (on Micro B)

In the cable I made for myself I brought out the ID pin and the ground pin to a berg header. Now, if I want the device in host mode I jumper the header. If I want to use the cable as a regular USB cable, I simply disconnect the jumper (naturally, I’ll need a male-to-male USB cable for this).

DSC02506
My OTG cable. I bought a Nokia CA101D and cut the end off it.
Yeah, I’ve still got to encapsulate it properly.

Once my cable was ready I just plugged in a mouse and a keyboard using a USB hub. Both devices were detected immediately and I had absolutely no problems with them. USB flash drives were another story. Getting them to work was a total PITA, but then that was the point of this whole exercise :-P The process far from painless and the reason I’m documenting it is twofold – one: so that others may read this post and find it helpful; and two: a log, just in case I have to go through this again and I forget how I did this in the first place.

1. The first step is obviously to have a working USB OTG cable. Test it out with a mouse. If it works you’re good to go.

2. The next step is to root your phone. I followed the exact instructions noted in the first post of this thread. This is a nice method since you don’t have to unlock the bootloader (unlocking leads to a whole host of other problems – DRM keys get wiped, etc). Rooting itself was relatively painless; what took time was getting the damn ‘Windoze’ drivers to work. If you have Android’s PC Companion installed, then all the necessary drivers should have been installed by default. However the ADB (Android Debug Bridge) drivers did not install on my PC and I spent the better part of the morning trying to get it to work. I finally had to manually point Windows to the file (sa0102adb.inf) and force the install.

3. To check if the phone is truly rooted, scroll though the installed apps and search for the ‘Superuser’ icon. If you find this icon, it means you’re doing fine.

SUA rooted phone. See the first icon?

4. Install busybox.

5. Now download the USB Host Controller app (v0.44 at the time of writing this) from the Android market. Once installed, run it. The app will ask for superuser access. Once you grant it you’ll be presented with a wait screen (this took about 1 minute of waiting on my phone).

6. Connect your flash drive through the OTG cable. Ignore any ‘Unsupported device connected’ message. Click on the ‘USB’  tab. The flash drive should show up in the listing under ‘Connected Mass storage Devices’. Click on ‘mount’. I mount it to ‘/sdcard/ehdd’ so that AirDroid (which is a non-root file explorer) can read the files. However, if you use ES File Explorer or any other root browser you can mount the flash drive to a partition of your choice.

No cable connected           Cable connected
A: No OTG cable connected                       B: OTG Cable connected

Nothing connected           Unsupported Device
C: No USB devices connected                       D: The ‘error’ message

Note 1: I also tried using this method, which is actually a bit convoluted. The kernel Module Loader loaded usb-storage.ko fine, and Q5 USB Memory Manager would appear to mount my flash disk, but for some reason I couldn’t see the mounted folder using even a root explorer.

Note 2: when I first used this app it took a while to load the menu screen, but after that I was able to mount my drive properly. At the time of installing, I was also checking out other OTG mounting apps – Q5+Module Loader+usb-storage.ko . When I found that UHC worked fine, I uninstalled the other apps. Subsequently UHC would only show me that a USB device was present, but would not show the mounting option. I tried using UHC v0.42 as well. No go. Installing Module Loader and reloading usb-storage.ko was the fix. Q5 isn’t required.

Mount
This screen shows detected USB devices.
The lower half shows which of those are mass storage type.

Note 3: the first time I tried mounting the flash drive I got a “mkdir failed for –p” error. A simple workaround to this it to create the folder ‘ehdd’ yourself using a PC. Just plug your phone into the PC (using a regular cable) and make a new folder on the SD Card. After this I had no problems.

Read Only
Another ‘error’. My card as well as the folder are write enabled

Anyway, now I can watch movies off flash drives, copy data from a friend’s HDD all on the move! Word of caution – don’t run very power hungry devices directly off the phone. You won’t damage it, but it’ll get hot real quick and the battery will run out of juice superfast.

DSC02505
Mounting a flash disk

The tools used are pretty generic (if I can use that term) and support a large number of devices. I don’t know why but OTG functionality is still relatively uncommon. I would think that phone manufacturers would have advertised the heck out of it. Or maybe they’re waiting to sell you a ‘value adding upgrade’ at some later date :-/

Wednesday, October 14, 2009

Scrounging Around…….

This post is similar to one I had made on BITS 360 a while back. Having finished my Bachelor’s degree from BITS-Goa, I’ve now transferred to the Pilani Campus. So this is my first post after coming to Pilani.

As was in Goa, here too several ‘poor’ students (a point to note is that the word ‘poor’ refers to the usual scarcity of money that college students, being college students, face, and not an actual financial constraint :-D) wanted to know where they could cheaply source components. Obviously, I feel it my moral obligation to provide scrounging references. Read on to find out where I usually source a large part of my components.

Some excellent sources for jugaad are mentioned below. The list format is -
"Old electronics - many students throw out...."
"You will be able to scavenge...."

  • UPS systems
    buzzers, relays, power transistors, resistors, SRCs, triacs, massive heatsinks, even more gargantuan transformers (these are bl**dy heavy), awesome lead acid batteries (be warned, a faulty lead acid battery may be the very reason for the UPS' demise :-/ )

  • Electronic ballast tubelights (the new kind of 'slim' tubelights), CFL bulbs (I find loads of faulty ones in BITS - just ask the electrician, he'll only be too glad to get rid of them!)
    Ferrite chokes, thick wire to make air core inductors, high voltage capacitors, diodes, SRCs.

  • Alarm clocks (I don't really know how these get damaged...most BITsians claim that they fell down, or someone sat on them - I personally think they were chucked at the wall when they woke their owner up too early in the morning! ;-) )
    High pitched buzzer / speaker, 32768KHz crystal, tiny gears

  • Keyboards, mice (optical and ball), CD/Floppy drives, other PC junk
    JACKPOT!!! - buttons, leds, capacitors, optical sensors (optical mice have a very cool 18*18 pixel CCD - Google ADNS2610; anyone looking for advice or interface details, buzz me, I've done this), motors, heck maybe even a working 12 / 5 / 3.3V SMPS!

  • Phones (the traditional telephones, and newer cellphones)
    Magnetics, audio stuff. Mobile phones are a veritable source of ultra-small components: you need a steady hand, an SMD rework station, and guts of vanadium-steel to take these babies apart. I've used LCDs, very powerful white LEDs, joysticks, memory card connectors, buttons, etc from (discarded) mobiles. Most Nokias use the BL5C / BL4C - this is an uber-cool LiIon (old) and LiPoly (new) flat battery, 3.7v @ 700-1200mAh. I've drawn 15Amps from this thing for 60sec! No kidding! My multimeter leads got hot and one of the tips actually melted. I would not recommend doing this at all - you may damage the battery irreparably, and worse still risk explosion-caused burns (remember the Nokia battery-replacement drive a couple of years back?). Still, the BL5C is very good for small bots and compact electronics. You can get it for 750 bucks (original) or 120 bucks (cheapo duplicate). The duplicate seems to work fine, but test it out before buying.


While the phrase “one man’s junk is another man’s treasure” fits aptly, be warned that scavenging can be time consuming and the components obtained from the abovementioned sources can be unreliable. Having issued my warning - good luck, and happy scrounging!

Friday, July 3, 2009

The Super Probe

I remember mentioning in one of my earlier posts that an Oscilloscope was very high on my wish-list. The other day I entered into a bidding war on eBay-USA for a no-name DSO. It was pretty inexpensive, and the features it had seemed reasonably good. Sadly, I was outdone by some chap from Germany, who was willing to pay more than four times the amount I was.

After the eBay misadventure, my electronics toolkit continued to remain woefully incomplete. Apart from a simple multimeter and the PICKit2-Logic Analyser, I lacked the resources to take essential circuit parameter measurements – frequency, event counting, capacitance, inductance. I would also like a function/signal generator which would be able to output a PWM signal, pulses, pseudo-random number sequences and such like. Was there a multipurpose, do-it-all out there that would enable me to do all of this without breaking a bank?

About two years ago I had chanced upon the Super Probe while googling for a low cost capacitance meter. The Super Probe, designed by Luhan Monat, is a DIY low-cost and very low parts-count tool. As its name suggests, the Super Probe is capable of taking a variety of measurements with a fair degree of accuracy. It can also be used to output some useful waveforms and signals.

When I first saw Luhan’s site, I built a solderless-breadboard-prototype for myself. It lasted all of three days before the rats-nest of wires and components was deemed unsightly and cumbersome, and was relegated to the corner of my room, before being cannibalised for parts. I’ve finally gotten around to building my self a ‘proper’ Super Probe – the ensuing photos are ‘proof’' :-)

1 

My 'Probe is enclosed in an old Orpat ODM-100 Multimeter case. I ripped out the insides (naturally keeping some of the components – the LCD, and some precision resistors – for future projects :-D ), replacing them with my own circuits. The entire 'Probe is built on proto board using DIP components. I plan to design my own PCB later with SMD parts.

Using my Dremel XPR400, I cut a slot in the side of the old multimeter to accommodate an ON-OFF slide switch. A circular piece of acrylic was glued in place of the rotary switch of the multimeter. Openings were also cut for buttons, which were ‘borrowed’  from an old non-functional calculator. Both, the button holes, and the switch slot, were made using the etching bit of the Dremel. To make the circular acrylic piece, I started by trimming the sides of a square piece. I drilled a small hole in the circular-ish piece and mounted it on a mandrel. This setup was spun at about 20,000RPM on a rough file till a circular shape was achieved, and then on a smooth file for finishing. You could just as well use a lathe to do this, but I had to make do with what tools I have :-( The circular acrylic piece was super-glued into place, as was the slide-switch.

The images below, from left to right, are of the slot cut for the switch; the switch glued from the inside; and, the modifications made to accommodate the buttons.

There are four PCBs inside the multimeter case – the display board, the actual 'Probe, a button mount, and a 7805 regulator. The reason I used a ‘modular’ approach is for ‘upgradeability’. Yeah, yeah, don’t laugh! I’ll tell you how ‘upgradeable’ this device is – I plan to replace the just PCBs with just one, which integrates everything. But until the time I actually design and etch the integrated PCB (I use the toner-FeCl3 method, and I no longer have access to a good laser printer) I would like to tinker and test the individual circuits. Each time I fiddle with a certain sub-circuit, and I wouldn’t want to build a completely new 'Probe.

inside2insides

The PCB wrapped up in red electrical tape is the 7805. The tape was necessary to prevent shorting. In the second pic, the crystal, wrapped in black electrical tape (also to prevent shorting) is visible.

For example, tomorrow I’m going to swap out the power-hungry and inefficient 7805 regulator with the much nicer, and comparatively power-thrifty MAX1836 buck converter from Maxim. I’m currently running off a 9v PP3 battery. With the 7805, I’d get 5v on the output as long as the PP3 voltage is above 7v. Current draw by the circuit is 20mA peak and about 10mA average, so with 9v on the PP3, I’d lose clip_image002[9]across the 7805. With 7v, I’d lose 20mW.

Now, although this doesn’t seem like much, I could improve battery life tremendously by using a buck regulator which is near about 85-95% efficient. So I’d reduce the power lost across the regulator to about 8mW – a reduction in power loss of 80%. Another advantage of Maxim’s 1836 is that it allows me to run the PP3 down to 5.5v, and it will still give me a nominal 5v on its output.

Back to the construction. For the display, I used individual 7 segment LED displays. The original 'Probe uses a 4-digit multiplexed display, but individual display blocks can be used as well, though soldering them is one hell of a pain in the butt (literally! Hehe :-D ). I put a sheet of cellophane paper (plastic) on top of the display to improve contrast.

The 'Probe uses a PIC16F870 as its brain. Luhan has been kind enough to provide a pre-complied HEX file which only needs to be burnt onto the PIC. He’s also provided the source code for download so you can modify the code as per your needs.

The Super Probe does have its limitations. It certainly is very inexpensive; the caveat is accuracy. The device’s readings are only as reliable as its components. Measurements should not be taken as God’s Word and whenever possible, must be checked against standard tools.

Anyway, the 'Probe has rapidly become one of my most useful tools. Of its 17 functions, I use the Frequency Counter, Event Counter, Servo Pulse Generator, Square Wave Generator, PWM Generator, and 38kHz IR Pulse Generator most often. For a list and description of all its functions look at the list below or visit the Super Probe website.

 

Super Probe Functions
Logic Probe – High, Low, Tristate
Logic Pulser with variable pulse rate
Autoranging Frequency Counter
Event Counter
Voltmeter 5v max.
Diode Junction Drop
Capacitance Meter
Inductance Meter
Signal Generator – 0.5v, 500Hz square wave
NTSC Video Signal Generator
Serial ASCII Generator – selectable baud rates: 1.2/2.4/4.8/9.6K
MIDI Note Generator
Hobby Servo Pulse Generator
Square Wave Generator – 1 to 9999 Hz
10kHz Pseudorandom Number Generator
38kHz Generator – useful for testing IR receivers
PWM Generator – 3 to 97% duty of a 6kHz square wave

Monday, November 17, 2008

My वायरलेस प्रेसेंटर


Wow! Hindi transliteration on blogspot! That's an interesting feature! :-) Useless, but interesting, nonetheless.

Just a small point to note: I'm typing these first few lines from 15 feet away, using my wireless presenter. (Big smile :-) )

Naturally, you scoff, "How can you do that? Oh! You have a wireless keyboard! Umm, hang on a sec! You said वायरलेस प्रेसेंटर . How are you typing text?" (Bigger, mysterious smile :-) )

Well, I made my own Wireless Presenter-cum-Keyboard-cum-Mouse. (Biggest smile yet :-) And, in Sheldon's words - TBBTS02E07 - Muaa-hah-hah). Here are the details.

This project originally started off beacuse I used to get exceedingly irritated with the abysmal lack of dexterity afforded by standard keyboards. This lack was / is felt, most painfully, when getting fragged in a fast-paced game of CoD. "I need my grenade! Where the hell is the 'G' key. Dratted keyboard." My rifle! My rifle! '1'! '1'! '1'. Shots fired! Duck! 'Q'! 'Q'! 'Qqqqqqq....!'. I'm sure you get the point. I also do a lot of 3D modelling in AutoCAD, and image editing in Photoshop. My mouse, which would ordinarily be considered reasonably good, fares pathetically at this zoom-in-zoom-out-click-to-do-this-tap-to-do-that kind of stuff. Wouldn't just be great to have an additional fully customizeable keyboard? It would have a zoom slider, a wonderfully sexy scroll wheel (much like the iPod's), multiple buttons, and special keys which have several keyboard buttons bound to one (so to press 'Ctrl-Alt-Del', I'd just need to press one key on this keyboard). The mouse would be integrated into this device, and would have similar useful features.

I can, of course, buy such a device, but that would mean shelling out absurd quantities of cash - something that I don't have much of! Making one would mean I'd save potloads of money. I have been reasonably successful; hence this post.

So far, I've only made a Wireless Presenter, but this same device can be adapted to do all the stuff I mentioned above. A little effort, some pain, and a couple of milk-and-cookies-filled all-nighters are all that are necessary.

Without going into the overly-technical details of the device I'll tell you what the system consists of:
- a full speed USB PICmicro (the 18F2550) (free from Microchip);
- a TSOP1738 IR detector (Rs.10);
- a cheap roadside SONY TV remote (Rs. 60);
- a USB cable (free from an old mouse), crystal (Rs. 4), capacitors (Rs. 4).

The SONY remote sends IR data to the TSOP, which is connected to the '2550. The PIC decodes the IR signals (which are in SONY's SIRC format). The '2550 then sends this data through USB to the PC. Now, I've programmed the PIC to enumerate as a USB keyboard-mouse combo device. So my PC, for all practical purposes, thinks that it has a second keyboard and mouse. I have mapped certain keys of my laptop keyboard to keys on the remote. So pressing the 'Program +' key on the remote, is equivalent to pressing the 'Right Arrow' key on my keyboard. Pressing the 'Power' button on the remote is like pressing 'Esc' on the keyboard.

This is the nice thing about putting software (firmware) onto a microcontroller - you can fiddle around, and map virtually any key combination to any remote key!

I use this device to control MS Powerpoint slides from upto 30 feet away. I've mapped most of the Powerpoint keyboard shortcuts to buttons on the remote. The 'Contrast' button is 'F5', the 'Program Jump' button is 'Enter', and so on.

For a full listing of the source code go here .

I've made this using a PIC, but if you get the logic and code right, I'm pretty sure you could use any processor.

Future modifications include adding an accelerometer to provide intuitive mouse support (right now I'm pressing 'Mute' and the 'Volume / Program +/-' buttons for mouse-like action). Maybe I'll even port the whole thing to RF (Zigbee, or MiWi); it's running IR now - the great thing about IR is that its laughably cheap and easy! RF would involve additional cost and effort (protocols, and other crazinesses). For now, this is good. Anyway, in the beginning you had asked (well, alright, I had made you ask) how I was typing out text using my वायरलेस प्रेसेंटर.....I think you have the answer now.

I will be, at some point in time, making the gaming device I talked about earlier, but until then, I'll have to amuse myself with this :-) If anyone is planning on building something similar drop me a mail - I'll be glad to help.

Visitors