Design Nerding – Product Dissection of a Kid’s Meal toy

A while back, the CG version of the Lion King came out in theaters. As advertisement for the release Kid’s meals at McDonalds came with themed toys. One was a talking toy. I’ve long been fascinated by toys like this and took apart tons of them as a kid. They are great case studies for DFM (Design for Manufacture).  I wanted to see how they are making them nowadays.

As typical for McDonald’s, you need the tri-bit (or similar sized flat-head and some patience) to take this toy apart.

Once apart, I was amazed at how simple it was.  In the past, I recall a small PCB with a potted silicon die on the board (black blob tech). I was surprised to find that now they no longer have a PCB at all. Now they just have a 4-terminal IC in a custom package. The pins are Vcc, Gnd, and the 2 speaker outputs. Very minimal costs here.

One of the best parts of these kinds of cheap toys are the switches. It is much cheaper to make the switch yourself versus buy a pre-made switch. This one is an elegant design for sure. Th Gnd side of the chip attaches to a cheap stamped metal spring that is bent along two different axes. The long arm of the metal spring fits into a slot on the switch. The switch itself is molded such that it has a compliant spring that helps it “click” into one of two positions moulded on the base of the toy. (Second pic below makes this more obvious, look at the bump on the right side of the switch and the two indexed locations on the right side of the hole in the plastic base).

   

 

Overall the design is about as cheap as you can get for a talking toy while still being well-engineered and not feeling “cheap”. McDonalds typically has some really great engineering in the toys (if you’d believe it) when compared to some other fast food places. For example, the reinforcements in the base of this toy gives an experience that you wouldn’t know the switch was just an extra cobbled together bit of plastic.  The toys are always solid-feeling (not flimsy when you apply force when actuating the switch for instance) and I find it rare to see sunken areas on the outside of the piece opposite of the reinforcement ribs in the plastic. McDonalds only works with a few suppliers for their toys and rigorously check them for safety (after being sued in the 80s for toys being choking hazards, hence the “for ages 3+” warnings on all toys nowadays). Check out this article on one of the companies and see the journey of a toy from concept to reality.

McDonald’s has decided to stop making plastic toys January 2022. I’m sure there are billions of these types of toy in consignment stores, garages, landfills, and buried in back yards across the world if you want to get ahold of some to take apart.

Keep your eyes peeled for great design!

Transfer Files From Phone to PC Easily

I have a Pixel phone that for some reason always disconnects when I try to transfer files over USB to my laptop. it is almost full of pics and videos since I can’t really transfer them off. I finally filled the phone up and had to make space, so I figured out the method I’m going to use from now on to transfer files on and off my phone.

I set my phone up to be a simple little WebDAV server. This allows me to very easily map it as a network drive in windows and transfer files at will.

I downloaded HTTP File Server (+WebDAV ) on my phone. Then I opened it and clicked the “Start button to start the server. Obviously you have to give this app file permissions for it to work.

Then on my PC, I mapped the drive by right-clicking the “This PC” and selected “Map Network Drive:

 

Then type in the address from the HTTP Server app.

Once this is done you can access the file from the phone via whatever drive letter you selected when you mapped it. In the above image the drive is the Y:/

 

Using MPlabX to Program Arduino Boards in Straight C/C++

I wanted to use MplabX to replace the graphical front-end of the Arduino app and write my own bare metal C/C++ code, but use the arduino’s built-in USB programming function. The method below can be done in multiple different IDEs, but I show how to set up MplabX. It is important to note that this method expects the Arduino’s bootloader to be stay on the board.

1. Setting up the Path to the Arduino IDE’s Compiler:

These are different for every computer so you have to find it yourself. To do this, open the Arduino IDE , go to File–>Preferences and click “Show Verbose Output” for both Compile and Download.

Next, plug in a board and send an example project to your Arduino (such as Blink.ino). The command line will spill over with commands.

Scroll to the top of the command window in the ArduinoIDE and look for the line after it says “Compiling Sketch”:

Copy this entire line and paste it to a text file so we can edit it. (Double-click this line to highlight it to copy). Here’s mine:

"C:\\Users\\adamp\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\\Users\\adamp\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-IC:\\Users\\adamp\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\eightanaloginputs" "C:\\Users\\adamp\\AppData\\Local\\Temp\\arduino_build_752190\\sketch\\Blink.ino.cpp" -o "C:\\Users\\adamp\\AppData\\Local\\Temp\\arduino_build_752190\\sketch\\Blink.ino.cpp.o"

 

The highlighted portion above is the file path to the C++ compiler Arduino uses. If we want to write our own bare-bones C or C++ code for the arduino, this is all we need.  Open MPlabX and select “Tools–>Preferences.  In the popup, select the “Embedded” tab.  On the left side, click the Add… button to add a new toolchain. A new popup will appear where you can paste the “Base Directory”. Paste in the highlighted part of your path only up to but NOT including the “avr-g++” part.  This will allow MPlabx to use the AVR-G++ compiler for Atmel chips.

2. Creating a MplabX project:

In MpLabx, start a new standalone project. I’m using an Arduino nano so I will choose the chip “Atmega328P” I recommend you select “Simulator” for the “Tool” entry here as it can be really handy for debugging code.

Then select the new entry “AVR-GCC” for the toolchain.

3. Set up the Programming Tool in MPlabX:

Now to take advantage of the built-in USB programming of an arduino board we need to set up the correct commands. In the Arduino IDE scroll down in the command window and find the last line of white text before the red text begins. The red text is the output from the programmer app (called avrdude.exe).  The line just before this is the command that calls avrdude with the appropriate settings.

 

C:\Users\adamp\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\adamp\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM7 -b115200 -D -Uflash:w:C:\Users\adamp\AppData\Local\Temp\arduino_build_752190/Blink.ino.hex:i

Scroll to the rightmost of the command below to see the highlighted text in the line above. This is the path to the actual hex file the programmer is sending. This changes based on where you name the MPlabx project. You need to change this file path to the following to work with any MPlabX project:

-Uflash:w:${ImagePath}

Once you make this change, simply copy this entire command and paste it into the MplabX project properties.

In Mplabx, right-click the project you want to work on, select Properties, then select “Building” from the left sidebar in the popup window. Make sure to click “Execute this line after build” and paste the entire command from above in the blank.

***BIG NOTE: If you change the port number of the board you are programming (plugging in a different board, or using this same project on a different computer) you MUST change the COM port in this option in the project or it will fail to program and give a cryptic error.

4. Testing with a Blink project:

If you have set everything up correctly, then you can right-click your project and select New–>main.c

Replace the code in this file with the following:

#define F_CPU 16000000UL //You must define the clock frequency before you can use the delay function. This should match the crystal on your board.

#include <stdio.h>
#include <stdlib.h>
#include <util/delay.h> //must use this to use the _delay_ms() function
#include <avr/io.h> //Must use this to access port and pin numbers on our chip

/*
*
*/
int main(int argc, char** argv) {

       //this is where your setup() function goes
       DDRB |= (1 << PORTB5); //Make Arduino Pin13 (AVR PortD Pin5)) and output pin

      while (1) {//this is your "loop" function
           PORTB ^= (1 << PORTB5); //Toggle the value of this pin using an XOR function with itself
          _delay_ms(100); //Change this number to change the LED flashing frequency to know if it is working or not.
        }//end while 1

       return (EXIT_SUCCESS);
}//end main

Then click the build icon and it should compile, then you should see the familiar text from the Arduino IDE. The Avrdude programming information is the red text when you turn on Verbose mode.

Troubleshooting:

If you don’t see this text, a few things might be the cause:

  1. You forgot to click the “Execute after build” checkbox in the build properties
  2. You have the wrong COM port or U:flash setting in the line you want it to execute after building.
  3. Make sure you set your project up with the correct chip and correct toolchain (AVR-GCC)
  4. You have a compilation errors. This can be hard to see, but you can make it easier

If your Arduino isn’t doing what you want it to, then you likely need to debug your code. There’s a LOT to be said with this. The easiest method is to set up a UART library so you can print text out the serial port to your computer. Search github and AVR freaks for examples you can import.

Another method is to use the Simulator in MPlabx to see what bits are being set/changed in the memory location of the Atmega chip.

A third option allows you to run the code line by line on the actual chip. This would require a proper programmer (not just the arduino’s built-in USB programming).  Here’s an example of how to set that up.

Now you can learn to write your own libraries to better understand the magic of the Arduino project. Learn some of the tricks that are used to simplify the interface for programming on this site.

 

 

Teenage Engineering PO-80 or Gakken Record Factory 78RPM Hack

Recently, Teenage Engineering released the PO-80 Record Factory, which is a rebranding of the Japanese Gakken Record Maker kit.  It is a really neat record player that can also cut custom records.  One problem I had with it is that it only plays 33RPM and 45RPM, but we had a lot of 7″ 78s I wanted to play on it, so I fixed it.

Most cheap record players use the same 5-pin motor module which is a DC motor with a speed controller built in. This particular one uses the EG530SD-3F.  By wiring  3 of the pins in different ways, it will automatically play at constant speeds of 33RPM, 45, RPM or 78RPM. The 33 and 45 are basically the two built-in speeds, which is what this kit uses.  To add the functionality of 78RPM, you can add a resistor to the circuit.

There wasn’t a detailed datasheet explaining what’s inside the motor, but rather many listings for this motor had the following instructions.

Adjusting Method:

  • When the changeover switch reaches 33, use a small flat-blade screwdriver to adjust the resistance of the L hole of the motor, and the normal disc is 33 revolutions per minute.
  • When the changeover switch reaches 45, use a small flat-blade screwdriver to adjust the resistance of the H hole of the motor, and the normal disc is 45 revolutions per minute.
  • When the transfer switch reaches 78, use a small flat-blade screwdriver to adjust the resistance on the PCBS board. The normal disc is 78 revolutions per minute.

Luckily I found someone online who had taken one apart and described the controller circuit. This, along with the “official documentation” to get in the resistance range was all that was needed to make the simple hack.  The official info is as follows:

For this hack, I needed  a way to add in the resistance for when I wanted to play 78s, but I had to be able to completely remove the resistance to use the 33 or 45 speeds. For this I just found a JST connector, but any female wire connector would work. I soldered the wires of the JST connector to the motor based on the link above. I made sure my wires were long enough to reach out the side the connector for the record cutter extended to.

For the resistor, the only info I could find online were several schematics showing the use of a 300Ω potentiometer so you can adjust it, however, I only had a 5k so I threw a 1kΩ in parallel with it to get me somewhat within the range.  The actual resistance needed is around 160Ω but it is nice to have the knob for adjustment.  I intentionally left the resistor leads long so I could use them to plug into the JST connector. Notice that for this, you only need one side and the center lead from the potentiometer.

The final result looks pretty clean. It’ll look cleaner when I throw some heatshrink on the potentiometer. Again, this is only used for playing 78s so when playing the other speeds I disconnect the potentiometer and store it in the box the record player came in. Check the video out below.

COM Port Name Pop-up

When working with microcontrollers, especially helping students debug their work, I hate having to open device manager or a serial terminal to search for the serial port name of the device I most recently plugged in.  I wrote a small python script to hook into Window’s notification system to know when a new COM port has been plugged in, and then display its name in a popup window.

The first step in this was to find out when something is plugged in.  I tried all sorts of things with windows event viewer to see if I could detect this because I didn’t want to have yet another service running in the background on my PC eating resources all the time, and I wanted the reaction to be fast, so polling every 10 seconds or something would be too long to wait for a popup.  Alas, I couldn’t find any way to get USB port data to trigger an event in windows when you plug in a USB port.

Looking online for examples I only seemed to find C# or VS code.  I’m not installing anything more to develop this one project, and at first I wanted to see if there was a cross-platform solution since I was going to have to write it all from scratch.  Eventually I settled on a windows-only solution because I found an excellent site that is full of good code examples for win32 python interfacing from a user’s post on stackoverflow. these kinds of sites are few and far between, so I’m glad I came across it!  This code example connects into Windows Notification center and WMI (Windows Management Interface) to detect when USB items are plugged in. You can detect drives, networking, and serial ports based on the example in the link.

Once this info is gathered, the next step is to create a popup with the COM port name. For this I came across an example using the plyer library for python which is dead-simple.

When you run python code, by default, the command window is always visible, so I tried a few things to hide it. Firstly, you should be able to just use pythonw.exe instead of python to run the code and it should hide the window. For some reason, this didn’t always work. The next thing I tried was using the win32 library in python. This grabs the foreground window and hides it. Since the foreground window is likely this python script, it works fine. Running it sometimes takes a faction of a second for it to hide the window so sometimes you see it flash a command window.

The final step is to have this app start when you turn on the computer. Some folks said you could just put your python file into the windows startup folder, but this never worked for me. Instead, I keep the python script in my installations folder (where I keep all my useful apps) and I wrote a batch script to run the python code. I saved the batch script into my startup folder and rebooted.  It works great and doesn’t use many resources at all!

Get my python code and batch script here.  If you use it, let me know in a comment.

Now,  if you use linux or mac, I recommend you check out usb-ser-mon which has some of the same functionality of detecting plugged-in devices. Then you can use the same plyer code to generate a popup from what I understand.