Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1362000 Posts in 63514 Topics- by 55393 Members - Latest Member: sherylbutler

June 25, 2019, 03:07:27 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsMy Game & Watch
Pages: [1] 2
Print
Author Topic: My Game & Watch  (Read 4576 times)
jmptable
Level 0
***



View Profile
« on: June 21, 2013, 05:59:26 AM »


I'm making myself a smartwatch, and then I'm making games to play on it. Sticking to 8 bit microcontrollers so far, so the games are coded in assembly or C or Forth. I've attempted this twice before today. First attempt looked like this:


Complete disaster, which you can read about here if you would like.

Second attempt is the first pic. The guts look like this:


And here's a side pic of it on my arm:


Hardware
This second one has:



If you want circuit diagrams I have none yet - I'm making up the design as I build it.

Specs relevant to programming:
  • 32 KB Flash
  • 2 KB RAM
  • 8 bit RISC
  • 1 Mhz clock (~1 MIPS)

Status of the second attempt: failed pretty sure the LCD screen is internally busted and not fixable. I had a hell day yesterday trying to figure out why the display would randomly gray out and back in, work well for a while, and then not work at all for hours. Thought it was a wiring bug (super easy to have a short in this dead-bug, un-planned-out mess) so I checked everything, ripped off parts, put them back on, resoldered connections, etc. to no avail. Eventually I was reduced to literally poking it all over (this is actually a good way to debug shorts in dead-bug circuits - just keep poking and watching what it does until you poke a spot near the short and it goes haywire). That eventually convinced me that the transparent wiring embedded in the LCD is cracked, or the flexy connector going from the glass to the LCD's metal IO bus is slightly out of place. Unfixable, and since most of the parts are epoxied to the back of the LCD, I have to start the hardware over completely! A chance to rework the design at least, and maybe fit in some new features.

Status of the third attempt: ? working on that now...

Software (github)


Making/debugging the hardware is a masochistic endeavor. But the software is coming along nicely. It includes 3 things:
  • Watch OS - C and assembly stuff that runs on the hardware.
  • Forth compiler - Java program that turns Forth source into bytecode that can run in the watch OS's VM. Based on the wonderful Mako VM project.
  • Simulator - I wrote two makefiles. One handles turning the C / assembly source into an image suitable for loading onto the hardware. The other turns the source into a program that can run natively on my computer. I was very careful to modularize the code, so all I had to do was write "good-enough" simulators for the hardware. For example: I render the LCD image with SDL, and mouse input is fed to the light-based gesture thingy

Some details

The OS supplies a ton of fast ROM calls written in assembly that do nice high-level things with the hardware to user programs (written in Forth) running in the VM. A VM is important because AVR microcontrollers can only execute code in flash memory. Loading native code into the flash every time a user program wants to run would burn it out in no time (100,000 writes only).

The Mako VM and Forth compiler were designed for PCs. I had to change a lot to make them work well with this project. The biggest changes so far:
  • Switched it from every value taking 32 bits to every value taking 8 bits, and sometimes 16 when necessary.
  • Removed the memory-mapped IO system and replaced it with a new bytecode instruction that can do ROM calls.

Game: Miasmata


Hardware is not done but I still know what the first thing I am going to try to write for my watch is!

A new take on an idea I have been trying to realize for a long time. I attempted it for the PC and on another gaming device of my own invention.


  • .




Logged
Pineapple
Level 10
*****


~♪


View Profile WWW
« Reply #1 on: June 21, 2013, 06:16:11 AM »

Whooooaa. This is an amazingly cool project. Any plans to share the software and instructions on how to build the hardware when you're done?
Logged
sublinimal
Level 8
***



View Profile
« Reply #2 on: June 21, 2013, 06:38:24 AM »

Low-level stuff is always cool. Keep us posted with gory technical details.
Logged
jmptable
Level 0
***



View Profile
« Reply #3 on: June 21, 2013, 07:14:17 AM »

@_Madk - thanks  Smiley And yes, I intend to share all of the source code and hardware designs. The software is already up on Github, and I'll put the hardware up there too once it has stabilized. But it would be difficult to replicate the project. The construction is more art than engineering because of the difficulty fitting everything in the small space. And I may be using 'weird' parts in the next build that can't easily be sourced. But the info will be available if someone wants to try (and for curiosity's sake) and I'm always happy to help.

@sublinimal - I agree. Guts will be splashed.
Logged
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile
« Reply #4 on: June 21, 2013, 07:38:02 AM »

You must be some kind of genius to do this!
Impressive project and one that I'd really like to succeed.
Logged

Yeah.
Netsu
Level 10
*****


proficient at just chillin'


View Profile WWW
« Reply #5 on: June 21, 2013, 10:27:18 AM »

This is awesome. Sometimes making tangible, real-life stuff is so much cooler than writing stupid video games Durr...?
Logged

Sarge
Level 1
*



View Profile
« Reply #6 on: June 21, 2013, 02:12:10 PM »

Nifty project.  Well done!
Logged

[TWEETER]
If it is stupid, but it works, then it isn't stupid.
Whiteclaws
Level 10
*****


#include <funny.h>


View Profile
« Reply #7 on: June 21, 2013, 04:16:14 PM »

I would sell my Farming Simulator 2013 steam key for one of those stupidly genious gadget  Kiss



Logged
moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #8 on: June 21, 2013, 05:41:31 PM »

the next TIG compo should be games made for this thing
(but it would be difficult to judge the games lol- unless there is an emulator)
Logged

subsystems   subsystems   subsystems
Impmaster
Level 10
*****


Scary, isn't it?


View Profile WWW
« Reply #9 on: June 21, 2013, 06:29:47 PM »

Built anything else cool?
Logged

Do I need a signature? Wait, now that I have a Twitter I do: https://twitter.com/theimpmaster
jmptable
Level 0
***



View Profile
« Reply #10 on: June 22, 2013, 06:06:43 AM »

Thanks for all of the enthusiasm.

@ moi - there will be an emulator (currently is one, but incomplete). I would be thrilled if anyone else wrote any code for it, let alone doing a TIG compo with it haha. If anyone wants to attempt it, after it's stable, I will provide plenty of documentation. Making my projects as easy as possible for others to enjoy is important to me.

@ Impmaster - I have a website with some projects I've done called hackniac.com. For things I built when I was slightly littler there's also this website.

For example, here's one of my watch's progenitors (click for Youtube video):
Logged
eyeliner
Level 10
*****


I'm afraid of americans...


View Profile
« Reply #11 on: June 28, 2013, 06:53:20 AM »

the next TIG compo should be games made for this thing
(but it would be difficult to judge the games lol- unless there is an emulator)
Or the machine would be easy enough to make by anyone worthy of messing with a soldering iron...
Logged

Yeah.
baconman
Level 10
*****


Design Guru


View Profile WWW
« Reply #12 on: June 28, 2013, 08:47:12 AM »

This reminds me of the few times I tried to build a homemade DDR controller. Granted, by first PC and PS2 were each two parts machines with parts swapped to make one that works (fortunately simple stuff!); but I wouldn't call myself a hardware wizard by any stretch. This kind of thing is tough.

Now, one thing I notice with your working portable system is that it's wired to an NES controller; but your watch/PDA-like thing doesn't have that luxury. So how does your newer builds handle user input?
Logged

jmptable
Level 0
***



View Profile
« Reply #13 on: June 28, 2013, 09:41:13 AM »

@ eyeliner - I intend to keep things that simple if I can. But there's some inherent difficulty fitting everything into a watch-sized form-factor. Maybe I'll do a tutorial on building it in a more easily constructed size. An alternative is designing a PCB for it, getting some of those manufactured, and selling a kit. But that takes a lot of effort at a high risk (requires a big investment, so if people didn't buy it then I'd be out a lot). I could do a Kickstarter, but school starts up for me again in 2 months so the logistics of that might not be workable.

@ baconman - It's tough for sure, but isn't it wonderfully satisfying when the thing works?

And on input: I'm trying a few different things out. Attempt 2 used that light sensor system, but it needed a really complex chunk of code (taking up a lot of space in the MCU) to guess at gestures, and the reliability was terrible because changes in ambient lighting would throw it off.

Attempt 3 is using capacitive sensors for human input. There is a wire on either side of the screen that is connected to part of the microcontroller that can read voltages, another part that can supply current, and to a very high-value resistor (only lets a little charge through) that goes to ground. To take a measurement I use the secondary pins to put charge on the wires. Then I use the voltage-reading pins and a timer to figure out how long it takes for the charge to bleed out through the resistors.

Normally the charge bleeds out pretty quick. But if a finger comes near to one of the wires then it takes a lot longer for the charge to bleed out of the wire. If you know how a capacitor works then this should make sense. One plate in this capacitor is the finger, and the other is the wire. The charges on the finger rearrange themselves when brought near the charge on the wire, and pull on the charges in the wire. So it takes longer for the charges to leave with a charge-carrying thing like a finger nearby.

Bottom line on input: In the best case I'll have a touchless interface where I can just wave my free hand around in the air over the device, and it will know where my hand is by comparing measurements on the two wires. Medium case is that I'll have to touch the wires, but I'll get pressure sensitivity (other experiments I've done with the effect show a log response, which means it will need a lookup table and won't have great resolution). Worst case is that they work like buttons (touch / no touch).

If this input system doesn't pan out then I'll try hacking apart and connecting a Wii Nunchuck PCB, which has an accelerometer, 2 analog channels (X and Y on joystick), and 2 buttons. Already have done this for another project so I know how easily it could be accomplished. Much harder would be fitting it satisfactorily into the device.

Project update: Attempt 3 is going to have an SD card and the system for that is what I'm working on now. Should make it very easy to update the OS, add programs, and have lots of room for graphics and whatever other data I want. But so far getting it working has been hellishly difficult. For it to work right I need both to figure out how to talk to an SD card on a low level (setting values in the registers of the card's controller), and how to create a proper filesystem so I can see the files on the card from a regular PC (aiming for FAT32). I'm now using (after a very wasteful false start) a pre-written open-source solution called FatFS that amazingly comes with an example use with SD cards on AVR microcontrollers (type that I'm using), but it wasn't written for easy porting and I've spent the last few days digging through datasheets, poking wires on my breadboards, and making stabs in the dark in-between annoying minutes of compilation and program flashing.

Debugging pain:
If you've only ever coded for PCs, then it might be tough to realize the pain of debugging an embedded system. There are no printfs and no log files, unless you write them from scratch. The code will run inside of the chip without any feedback at all. Right now I have text getting sent back to my dev PC over a serial connection, but the very act of printing a message (a blocking operation) can screw up the program being debugged (because interrupts are firing from timers and a long print statement in one of those will cause the next interrupt to interrupt the first interrupt and enter a recursive hell where nonsensical dark magic happens). Anyway, it might be a few more days before I get past this block and have a chance to construct the next proper prototype, and have pretty pictures to show.
Logged
Little Nando
Level 1
*


Working on Tough Coded Project


View Profile WWW
« Reply #14 on: June 28, 2013, 04:12:23 PM »

Whoa. This is great. Keep us updated with lots of vids!!  Gomez
Logged

Little Nando / Twitter / Blog
Kurt
Level 5
*****



View Profile
« Reply #15 on: June 28, 2013, 04:18:33 PM »

This is actually really neat.
Logged

Juan Raigada
Level 3
***



View Profile
« Reply #16 on: July 01, 2013, 09:52:06 AM »

This is an insanely cool project.
Logged

eyeliner
Level 10
*****


I'm afraid of americans...


View Profile
« Reply #17 on: July 02, 2013, 01:08:49 AM »

@ eyeliner - I intend to keep things that simple if I can. But there's some inherent difficulty fitting everything into a watch-sized form-factor. Maybe I'll do a tutorial on building it in a more easily constructed size. An alternative is designing a PCB for it, getting some of those manufactured, and selling a kit. But that takes a lot of effort at a high risk (requires a big investment, so if people didn't buy it then I'd be out a lot). I could do a Kickstarter, but school starts up for me again in 2 months so the logistics of that might not be workable.
Don't Kickstart this. You can, however, and considering this is in a workable state, and assuming you could get interest out there, get in talks with an online store to sell the parts as a DIY kit, like arduino, raspberry pi, etc, except assemblage. Maybe even getting a bit of kickback?

Or you could do that yourself, getting parts for 10 units, for example, bag all the needed components for a unit in a pack, and sell them, ready to assemble. If the price for the raw components would allow you to, of course.

I'd surely get a couple to mess around and probably burn trying to assemble it, but what the hell.
Logged

Yeah.
jmptable
Level 0
***



View Profile
« Reply #18 on: July 30, 2013, 07:49:13 AM »

@eyeliner - Good advice that I will take. If it gets finished I'll see about selling a few kits via Etsy, but it won't be any large effort.

It's been a while since I've worked on this project because life intervened as it likes to do. But here, almost as good as a video update, a GIF of me disassembling the old prototype to make the new:



(sorry it's so huge)
Logged
mushbuh
Level 9
****


Epic Laughs await you, traveler *tips steampunkhat


View Profile WWW
« Reply #19 on: July 30, 2013, 08:28:08 AM »

This is awesome, we need more stuff like this.

Reminds me of a project a while back where this guy made an android powered watch, he had a touchscreen and everything but it fell apart since all the components were too big
Logged

Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic