Brainwarp was one of my favorite toys (of the few I had at all) and spent quite a bit of time playing it. I eventually got good/fast enough to the point that the tilt sensor couldn't keep up. Years later I finally decided to upgrade that toy.
Making sure it was the tilt sensorTo test if the tilt sensor was indeed the limiting factor, I removed the sensor replaced it with buttons. Essentially the button will serve as inputs to the game. Then I played the the game and fortunately I could keep up and was able to determine that the game responded without noticeable delay. This gave me confidence that I won't be wasting time on this project.
How does the old sensor work?The old sensor was essential a cube with contact pads inside each corner and a metal ball which shorts the pads allowing the toy to determine tilt. With this sensor there's a bit of delay as it needs to wait for the ball to fall (approx. 45ms best case using free fall calculation). There's also a potential of false reads with the toy being tumbled around. The obvious solution is a 6 axis IMU and a microcontroller. Right?
HardwareIMU
For the 6 axis IMU, I decided to use the gy-80, which is really a board with 4 different sensor.
- Accelerometer - ADXL345
- Gyroscope - L3G4200D
- Magnetometer - HMC5883L - not used
- Pressure BMP085 - not used
The MPU-6050/6500 is probably the better option with the on board processing but I had the gy-80 lying around and thought coding a solution would be fun. If it got too difficult I would have probably swap to the MPU-6050/6500. But its fine.
Multiplexer
The old sensor shorted two pins which allowed the toy to determine tilt. Unfortunately simply pulling those pins up or down did not work. Thus a multiplexer or mux for short, is needed to short the pins. Here are the specs I'm looking for.
- Works on 3V- Will be using the 3.3V LDO from the gy-80
- At least 6 channel (will get 8 since we're dealing with power of 2)
With many mux fulfilling these requirements I picked 74HC4051P since it was relatively cheap on Amazon.
Microcontroller - TinyCore32 ATTiny3217
Requirements
- Small - This is in a handheld toy so small is necessary.
- Runs on 3.3V
- Minimum 11 total pins (include VCC and GND)
- 4 pins for mux (yes 4 not 3)
- 2 pins for i2c
- 1 sense pin to know if the toy is on/off. Battery savings (maybe)
- 2 UART for debugging (really just need tx)
I've known about TinyCore32 for a while and though it be a good fit. It features the ATTiny3217. TinyCore16 would have been fine but the TinyCore32 was on sale which was cheaper between the two. A cool feature of this attiny series is the single pin programming. It reduced difficulties with pin requirements and design.
AssemblyPerfboard assembly isn't too difficult as long as you have a layout already which I used upverter to help me with that.
I used 22/24 gauge bare copper wire for multi-point connections like power and ground 30 gauge wire for the rest.
Othershttps://upverter.com/design/oprospero/b0c5ba9af3ba5618/brainwarp-sketch/
TODO & Probably Won't DoPower Saving
Since the toy is battery operated, power consumption matters. The mcu we use will need a way to detect when to wake up as well as sleep, so we should dedicated a pin for this. Or we can add a power switch, or both! For now getting the toy to just work takes priority.
Calibration (Probably Won't do)
Given that the toy only need to know the orientation and not absolute position, I can probably get away with no calibration.
Comments
Please log in or sign up to comment.