Thursday, September 29, 2022

DJ Hero teardown

 

I was looking for something that could act as a rotating platter for clay sculpting, and came across a DJHero at the thrift store.  Mine is missing the adjacent gadget that is has slide controls.


There are interesting videos online that show how one could be used, but I didn't think they went into enough detail about the inner electronics, so here we go.

On the side that has the data port, there is the port itself, which contains 4 contact points inside, and a hole to its left, which houses a momentary switch.  That switch can be used to identify the device on I2C, so two of these can be on the same I2C bus, as long as they have different switch settings (depressed vs. not).

Overall structure

There are several layers to the device, and I take them apart from the bottom up.  Viewed from the top down, you have

1.  the spinning platter top (exposed layer, where you have buttons)

2. the spinning platter underside (holds the button PCB and optical encoder

3. the middle layer honecomb (supports the spinning platter and has a hole that lets the encoder stick through)

4. the middle layer underside (nothing too special)

5. the lower layer top (all those little teeth!)

6. the lower layer underside (another honeycomb-type support layer)

7. the base top and bottom

Once you remove all the screws, the base bottom can be removed from the base top.  There aren't any annoying plastic clips holding things together.

Base top/bottom

On the underside of the DJHero, which is the underside of the "base bottom", you find four circular feet, each held in place by a T-10 "star"-type screw.  Then, there are five more T-10 screws in the middle, and two T-9 screws closest to the data port.

With the bottom removed from the top, you can see the wires connecting the data port and switch, and all those send wires into the next layer.

The bottom of the DJ Hero has a sliding switch.  It's a physical thing that slides plastic into place so that it locks the side gadget to the DJ Hero.  That can be removed with a Philips screwdriver.  Don't lose the spring.  Also, those parts aren't really necessary, so if you want to route some wires through a hole somewhere, you could just take out the plastic bits and feed the wires through there.

It's a good idea here to unscrew the circuit boards.  You might have to break off some aged glue in order to do this.  It's just a matter of removing the plastic bits, and then removing two screws for each board.  The switch PCB has smaller screws.   If you don't remove the PCBs now, you might have too much tension in the wires as you try to get the other layes apart.

I should mention at this point that any further disassembly isn't really necessary.  In fact, getting to this level may not really be necessary.  It can be useful opening up this first layer (base top/bottom) in order to tap into the wires, or replace the switch mechanism (e.g., with a real SPST switch).  In short, you can stop here, or even stop before opening up the base. 

If you do go past this point, be very careful not to break off the little teeth seen in the next layer.  Don't say I didn't warn you.

Now, going to the combined lower+middle+top layers, remove the four Philips screws around the center.  That will let you separate the lower layer from the middle+top layers.


 

The lower layer

Be very careful here.  This layer has a ring of plastic teeth. The photo below shows the middle layer removed from the lower layer, and the middle layer is flipped upside-down.


Here are the little plastic teeth.  They serve as photo interrupters as part of a quadrature encoder-type mechanism.


After a few more Philips screws, you can remove the middle layer from the top platter.

The middle layer

This is what the innards of the middle layer top, and the platter underside look like:


 Note how there's a hole in the middle layer.  That's where the quadrature encoder sticks through (from the platter layer) and "reads" the light pulses formed by the ring of plastic teeth.

The wiring simply feeds through this layer up to the control board that's housed on the underside of the platter.

This is a closer view of the encoder board.  The white ribbon cable connects to the button PCB.


This is a view of what's happening on the other side of the button PCB.  It's just three contact-type (graphite paint-type) switches, just like in many keyboards, and a common ground (the red stripe).

This is what's going on on the opposite side of the encoder PCB.

The buttons connect to pins labeled P1, P2, P3, and G (ground).

The wires from the base connect as G, ID, C, D, G, and V.

By wire color, and based on other documents online, they correspond to

G = blue

ID = white = identifier

C = green = I2C clock, aka SCL

D = yellow = I2C data, aka SDA

G = black = ground

V = red = Vdd, 3.3v

The SCL and SDA lines appear to have 1k series resistors, which kind of suggests tolerance to 5v.  But the examples I've seen on other pages suggest using 3.3v works ok.

The onboard chip is labeled HA2003 | I/SS021 | 0933GHE.  I'm guessing its something aking to a PIC16.  All it has to do, I think is count quadrature events, light the quadrature's LED, do I2C communications, and handle button clicks.

The blue and white lines are interesting.  Blue is actually hardwired to ground way back at the momentary switch PCB.  When the momentary switch is pushed, white is connected to blue, meaning it's brought low.  Therefore, I assume ID is biased high.

Hooking in

I rebuilt things back to the point where I just have the base top and bottom apart, and the PCBs are removed.

This is what the back side of the data port PCB.  It's just direct wiring: green, red, black, and yellow wires hooked to connector pins.  


 

The ground line (black) hooks over to the switch PCB.  There, it's joined to blue wire directly.  The white wire comes off the switch, and gets joined to ground when the switch is depressed.


At this point, I had a few options for getting to the data signals.  One would be to disconnect the existing wires and port, butt-weld some wires, and feed them through a hole.   Another would be to solder to the same pads as the data port PCB itself, but that's not great, because they're already surface-soldered (which means attempting to solder there probably would cause the existing wires to pop off).

What I opted to do instead is make my own little board to use the actual data port.

The data port is just the right size for a double-side board to slot in.  There are two connection points on each side.  It's about 7mm wide.  With the device right-side-up, the inside port pins connect as:

yellow black

green red

I started down the path of Fusion 360'ing a board design, but then just decided to make it by hand.  (It's surprisingly hard to just draw some vectors and say "mill on or inside or outside the line" in F360.  It's way easier in VCarve.)  

I band sawed a 7mm-wide strip, and then sanded the edges and did a test fit for insert.  That worked great, and you could see visible scribe lines where the pins touched copper.

I then cut it to around 15mm length.

I scored a line down the center of the board (very carefully) with a razor, and tested to make sure the sides were not longer in contact.

Then, it was just a matter of a Q tip, dabbing on a bit of solder flux, tinning the pads, and soldering wires.  Along the way, I kept continuity-testing to make sure it was safe.


By the time it's all together again, and because there's no "keying" of the board, it's easy to get it upside-down, so I was careful to continuity-test the dongle's wires against the internal wires prior to reassembly.

Here's what it looks like when the patient's in post-op.


and zoomed in so you can see color coding

A side note re: the underside feet.  Note that they're "keyed".  There's a little nub in the base, and there's a corresponding slot in each foot.  Make sure they're aligned before screwing things back on.



 

What's next

Now that I have the breakout board, I have to decide on a programming platform.  I'm used to Arduino, but it runs I2C at 5v, so I'll need a bidirectional 5v/3.3v level shifter to get that working safely.  I may instead do this using Raspberry Pi.

I'll probably put a glob of hot glue onto the breakout board to make sure the wires stay isolated and solid.

Then, I'll do it all again, because I found a second DJ Hero at another thrift store!  Yay.

What that means, then, is that I can move from there to replicating the DJ Hero Etch-a-sketch that someone else did.  Or, make a wheelchair-type HID.

The other thing I want to do -- and part of the initial impetus for getting this device -- will be to use the DJ Hero as part of a 3D scanner.  I could use a vertical line laser alongside it, and use the encoder readings to know the rotation position.




Thursday, September 8, 2022

Roomba 655 DIY virtual wall

 I had the good fortune to get a Roomba 655 from thrifting the other day.  Along with it, I got two Roomba bases and a Goovi F007 base, just in case I might find it useful.  I gave everything thorough cleaning and then started into the electronics.

Putting the Roomba onto the base, I would see it light up to charge, and then immediately turn off.  This is typical of fully discharged, rechargeable battery packs that no longer have (or can sustain) a minimum charge.  The Roomba bases appeared to be generating a clean 3+ VDC charge, so they looked ok.

I removed the underside panel per documentation, and found the power pack..  Sure enough, there wasn't any power coming from it.  I don't understand why the power packs have four contact points on the bottom.  One clearly seemed to be a direct connection to GND (based on ohming out the lines between the battery pads and the charger connection points), but the purpose of the other three wasn't clear.

I was hoping to find some instructions for refreshing a pack outside of the machine using a NiMh charger, but there wasn't one on the web.  So, I ended up ordering a $20 pack online.  It arrived, and I put it in, and charged it up.  With just that, the Roomba worked!

My next step was to build a virtual wall.  There are multiple pages out there, but they seem to root to https://github.com/MKme/Roomba and the YouTube video linked from there.

The very basic idea of this: use the IRremote library for an Arduino, run it at 38 kHz, and pulse one for a second, and then off for a second.  That's all.  You get an infrared LED, which can be pulled from most any remote (these show up regularly in the thrifting bins for cheap).  The anode connects to 5v and the cathode (the side with the visibly larger metal inside the LED) goes through a 110- or 220-ohm resistor to the IRremote output pin.

I verified I had working components by connecting the IR LED with 5v - anode - LED - cathode - resistor - GND, and then looked at the LED through my phone camera.  It would show up pink-ish there when on.  That way, I knew I had the orientation correct, and that the LED wasn't burnt out.

Attempt 1

I tried setting up the sketch for an Arduino Pro Micro, and connected to pin 3 as defined.  After wiring it up, I got no light from the LED.  I read some other articles indicating there were issues with the IRremote library and the Pro Micro (32U4).

Attempt 2

I then tried the same sketch using an Arduino Mega 2560.  Again, no luck.  I read one article saying that the Mega 2560 uses pin 9, and if I were to just pinMode(9,OUTPUT) and digitalWrite(9, LOW), it would work.  Uh, no.

For both Attempts 1 and 2, there were pages suggesting making modifications to the IRremote library directly.  I looked into that, and found the lines they were suggesting to modify weren't even in the library any more.

Somewhere in this, too, I saw an example referring to "IrSender" as a known object instance or there were class-level methods associated to it, whereas the original MKme code used Irsend.

At this point, I realized I might be working off of the wrong library version.

Attempt 3 (success)

For my third attempt, I went to a plain Arduino Uno.  It turns out I got one from thrifting.  It was within a Thames & Kosmos electronics kit.  Nice build.  The Uno is buried inside of a handheld gamepad-type thing, and has its own rechargeable battery under the board.  The one I got had a faulty roller switch thing, but the Uno worked.

I first got rid of the old IRremote library that was at

$ARDUINO_HOME/libraries/IRremote

Next, I downloaded the IRremote library version 3.9.0.  I installed it as

$ARDUINO_HOME/libraries/IRremote-3.9.0/{examples, pictures, src, etc.}

Then, I looked at the example

$ARDUINO_HOME/libraries/IRremote-3.9.0/examples/SendDemo/

In that folder you'll find  

PinDefinitionsAndMore.h

and

SendDemo.ino

The sketch first includes the .h file before including <IRremote.hpp>.  Then, it does things based on the pin definitions within setup().  I didn't really care about what it was doing in loop(), since I knew I'd be replacing that.

So, I created my own sketch, vwall2.ino.  As normal, once I saved it, it went into $ARDUINO_HOME/vwall2/.

I copied the example's PinDefinitionsAndMore.h into that folder.

Then the sketch basically was:

#include PinDefinitionsAndMore.h

#include <IRremote.hpp>

Duplicate (verbatim, I think), what's in setup().  Some of that stuff you don't necessarily need, but it didn't hurt to have it.  And, the diagnostic stuff printed to the Serial Monitor was interesting.

Then for the loop(), I did this:

void loop()
{
  //These values should work for pre i models of roomba
  // See timeline at https://en.wikipedia.org/wiki/Roomba
  IrSender.mark(1000);
  IrSender.space(1000);
 
  //For "i" models (i3, i7 etc) use the following
//  irsend.mark(500);
//  irsend.space(7500);
 
}

So, basically, the loop is the same as MKme/Roomba's, but using IrSender.

Also, I googled the Roomba model timelines and found that the 655 preceded the "i" series, so I used the 1000 / 1000 timings.

With that sketch, the default output on an Arduino Uno is pin 3, and I got about 1.1 VDC by voltmeter, and observed the IR LED showing pink through the camera lens.

Physical build

I grabbed a chunk of 30-hole perfboard, and soldered things up.  At one end, I made a 5-pin edge connector with part of an old wire-wrap header.  I bent the pins (using another chunk of perfboard for spacing) so that the pins would end up parallel to the board.

 


The intent was to put the board in where the pins say 5v, reset, 3.3v, Aref, and 5v.  I chose to use 5 pins for the edge connection for stability -- but of course if you do the same, be sure to make sure you don't solder-bridge any of those pins.  The circuit only touches one 5v pin, and since that appears at either end, it makes it so that I could mount the board either way.  I like having it so that the board is on the inside of the headers, so I'm using the 5v pin that's closer to Aref.

Kosmoduino board.  Red = either 5v point.  Blue = used for support.  Pink = IR LED signal

 

The 5v pin then wires up to the top of the board, and connects to the anode.  The cathode side connects to the 110 ohm resistor (in the picture I have two 220 ohm resistors in parallel).  From there, I just soldered to a patch wire, so it lets me plug the other end of the patch wire to pin 3 on the Uno.  It's not as elegant as bulding a real Arduino Uno shield, but having the wire stick out is a hacky way of letting it be reversible.

That's all there was to it.  The great thing is that the Thames & Kosmos "gamepad" serves as a stable platform, and also provides a physical switch and a rechargeable battery pack.  So, I can just put it on the floor somewhere, turn it on, and point it where I want it.


 

The LED stands about 4.25" (11cm) above the floor, and that's tall enough for the Roomba to see it.

The LED points out from the perfboard, which means it's shining a cone of light that's roughly along a plane parallel to the floor.  I'm not sure what the specific field of view is for the LED -- that is, how wide the cone is -- but it's pretty tight.

Examples of light on/off as seen by the camera (not visible to the naked eye):



I'm also not sure how far the LED shines. In practice, it's at least 4' (1.2m), which is all I need to keep the Roomba from running down a hallway.

Thanks to MKme for the IR frequency and pulse info, and original code. 

Next steps

I think there are a couple of things I want to do next for this project.

First, I measured the floor-to-light height of the Roomba base itself, and it looks like the LED is at a height of around 9.5 or 10cm.

Second, I don't really need a circuit board for this, but I could use a proper shield.  So I might recraft this as a shield on the Uno, and then have a flexible, bendable thing that leads to the LED.

Where that takes things, then, is to make something more interesting as the virtual wall LED holder.  What kinds of things are 10cm floor to ground?  Well...

- Mrs Potato Head's hand is about that height.

- The face mask of my translucent robot dude might work.  But he is a little tippy.

- My Lego Ninjago clock dude.  His hand can be positioned to hold something.

Or, 3d-print something more interesting.  So many possibilities!

I also want to try to build this using something simpler than an Arduino.  I saw someone using an ESP32.  Something cheap, cheap, cheap.  I wonder if I could fake it out using some 555 timers.  Some of the IR remote controls I've broken open don't even have a crystal inside of them.  They use a dedicated IR chip that has a selectable frequency, and can be programmed to emit different things.  But that would get more expensive in terms of tooling...