# Of stackmats and smartphones



## jfly (Sep 12, 2014)

Hey all! I got something working this year that I'm very excited about. Check it out!






This was not easy to do. If you're interested in the details I wrote a blog post detailing the whole saga.

I intend to continue working on this until we have enough infrastructure to start using this in competitions .


----------



## ryanj92 (Sep 12, 2014)

That's pretty exciting 
Nice work!


----------



## zhmeigen (Sep 12, 2014)

I also did this two years ago.


----------



## jfly (Sep 12, 2014)

zhmeigen said:


> I also did this two years ago.
> View attachment 4498



Nice! Details? What kind of phone is that? Is the stackmat plugged directly into your phone?


----------



## primarycuber (Sep 12, 2014)

After browsing a bit in the internet I've found this, seem's interesting.
I don't have an android phone, but I tried it in an emulator, and it has stackmat options (and the code also contains stackmat related things)... I'll try borrowing a phone to test it.


----------



## cubizh (Sep 13, 2014)

Nice to see a live demo of this!
This is particularly joyous to witness considering you wanted something like this for ages.
Great work!


----------



## JasonDL13 (Sep 13, 2014)

This reminds me of an idea I had. Since I can code in Java.

Code a timer in my, device, I only have an iPod Touch that doesn't run Java. So either I'm getting an Android or I'm using Jailbreak tools. Then when you stop the timer it sends it to my computer. This is defiantly possible using Packet-Objects and Sockets in Java to connect a computer and iPod or whatever together to send Packets within. Then I can store all my times and what-not on my computer. And have it synced to my iPod.

I made a timer in Java for Rubik's Cubes. I kinda quit coding it, but I should really make it better.

Good job, by the way. I hope your device can get implemented.


----------



## Me (Sep 13, 2014)

Congratulations on getting this working! Even better post summarizing it too.
I've been looking into doing something like this, seems now like I was heading into a larger minefield than anticipated. I can't wait to see what this turns into now, if you find a way to get the chip made, this is going to be huge.



cubizh said:


> Nice to see a live demo of this!
> This is particularly joyous to witness considering you wanted something like this for ages.
> Great work!


I almost posted that same link, and lo, it _is_ awesome cool!


----------



## zhmeigen (Sep 13, 2014)

jfly said:


> Nice! Details? What kind of phone is that? Is the stackmat plugged directly into your phone?



Yes. I used an Android phone (HTC Desire-Z) to connect the stackmat, and the signal seemed very nice.

Then I copied some codes of CCT to my timer app, and finally it worked well.


----------



## Andreaillest (Sep 13, 2014)

This is really neat! Also pro timer compatibility ftw. If you ever start some sort of kickstarter, I will definitely support it.


----------



## DanielH (Sep 13, 2014)

I did a post in the forum years ago with a video of a stackmat connected to my computer in the USB-port. For some month ago a tried the same cable on a phone and tablet with a USB host cable (OTG cable) and it worked real nice.


----------



## cubizh (Sep 13, 2014)

DanielH said:


> I did a post in the forum years ago with a video of a stackmat connected to my computer in the USB-port. For some month ago a tried the same cable on a phone and tablet with a USB host cable (OTG cable) and it worked real nice.


How exactly did you go about reading the signal of the stackmat to produce the string?
Just read from serial that exact number of bytes?


----------



## DanielH (Sep 14, 2014)

cubizh said:


> How exactly did you go about reading the signal of the stackmat to produce the string?
> Just read from serial that exact number of bytes?


The stackmat sends out serial data. In the usb-cabel (I give my friend creed for that one, both know how to do and some soldering) there is a chip that creates a "virtual com port". It uses a standard driver witch is available on Windows/Linux/OS X. This chip is reprogrammable so my friend configured it to invert the signal. In the phone/pc you just read serial data on right baud rate. I have thoughts about to get hold of a bluetooth-unit that a can connect to the cable instead of the host-cable. With that I should be able to read the signal on all smartphone (and many "dumbphones") wireless and not be dependent on working drivers of the cables chip.


----------



## jfly (Sep 14, 2014)

JasonDL13 said:


> This reminds me of an idea I had. Since I can code in Java.



Yeah, there are potential applications for this outside of competitions. Anyone who wants to use the android library I created is more than welcome to (https://github.com/jfly/fskube/tree/gh-pages/android). Without the board, it will only work on a select few smartphones (see http://www.jflei.com/stackmat-phones/). For now, I want to focus on changing the way we run competitions.



zhmeigen said:


> Yes. I used an Android phone (HTC Desire-Z) to connect the stackmat, and the signal seemed very nice.
> View attachment 4499
> Then I copied some codes of CCT to my timer app, and finally it worked well.



Yay CCT! If you still have the phone, could you record a bit of the signal and send it to me? I'll put it up on http://www.jflei.com/stackmat-phones/ so we have a record of it.



Andreaillest said:


> This is really neat! Also pro timer compatibility ftw. If you ever start some sort of kickstarter, I will definitely support it.



Thank for the kind words. Current plan is to move forward with phones that don't need the chip, but I am looking into mass production on the side, so people can use this with any smartphone they own.



DanielH said:


> The stackmat sends out serial data. In the usb-cabel (I give my friend creed for that one, both know how to do and some soldering) there is a chip that creates a "virtual com port". It uses a standard driver witch is available on Windows/Linux/OS X. This chip is reprogrammable so my friend configured it to invert the signal. In the phone/pc you just read serial data on right baud rate. I have thoughts about to get hold of a bluetooth-unit that a can connect to the cable instead of the host-cable. With that I should be able to read the signal on all smartphone (and many "dumbphones") wireless and not be dependent on working drivers of the cables chip.



Daniel, I'm so sorry for not mentioning your USB cable in my post! It honestly completely slipped my mind. The reason I wanted to go through the microphone jack is to have an option for iPhones. However, now that I'm just interested in building something for competitions, buying a bunch of cheap Android devices and connecting via USB becomes a real option, if your cable can be made for less than the cost of producing the board we made. Any idea how much it costs? Just curious, does the microcontroller in the cable need a battery, or is is powered over USB?


----------



## plusCubed (Sep 14, 2014)

primarycuber said:


> After browsing a bit in the internet I've found this, seem's interesting.
> I don't have an android phone, but I tried it in an emulator, and it has stackmat options (and the code also contains stackmat related things)... I'll try borrowing a phone to test it.



I'm not sure about the details, but if I remember correctly, DCTimer is a popular timer in China (I recall a forum on Baidu Ba about it). Never knew it read StackMat signals. I don't have the cable to connect the stackmat, I'll try to obtain one. Looking into this...

Update: 
Found this post on the functionality: http://tieba.baidu.com/p/1835672089
If you look at the fourth post, the app apparently allows you to choose the sampling rate
Anyway, if anyone wants to test to see if it works, the apk is in the link primarycuber posted.

Update 2:
Downloaded the app, here's a screenshot of the stackmat settings:


----------



## primarycuber (Sep 14, 2014)

plusCubed said:


> I'm not sure about the details, but if I remember correctly, DCTimer is a popular timer in China (I recall a forum on Baidu Ba about it). Never knew it read StackMat signals. I don't have the cable to connect the stackmat, I'll try to obtain one. Looking into this...
> 
> Update:
> Found this post on the functionality: http://tieba.baidu.com/p/1835672089
> ...



I tried it out with a borrowed phone, but unfortunately it didn't work (2.5-3.5 jack cable, it works on my computer with prizma for example). 
I'm not sure if it's the app's fault, 'cause it doesn't even recoginse that the timer is plugged in, it might be an issue with the cable/phone jack input not recognising mic properly.
The timer itself seems really cool, so if somehow it can be connected to the stackmat, I'm definately buying an android device...


----------



## jfly (Sep 14, 2014)

primarycuber said:


> I tried it out with a borrowed phone, but unfortunately it didn't work (2.5-3.5 jack cable, it works on my computer with prizma for example).
> I'm not sure if it's the app's fault, 'cause it doesn't even recoginse that the timer is plugged in, it might be an issue with the cable/phone jack input not recognising mic properly.
> The timer itself seems really cool, so if somehow it can be connected to the stackmat, I'm definately buying an android device...



What kind of phone? Send me a recording of the signal, and I'll upload it to http://www.jflei.com/stackmat-phones/.


----------



## primarycuber (Sep 14, 2014)

jfly said:


> What kind of phone? Send me a recording of the signal, and I'll upload it to http://www.jflei.com/stackmat-phones/.



PM sent.


----------



## zhmeigen (Sep 15, 2014)

jfly said:


> If you still have the phone, could you record a bit of the signal and send it to me? I'll put it up on http://www.jflei.com/stackmat-phones/ so we have a record of it.


Here it is:
View attachment signal.zip


----------



## primarycuber (Sep 15, 2014)

primarycuber said:


> I tried it out with a borrowed phone, but unfortunately it didn't work (2.5-3.5 jack cable, it works on my computer with prizma for example).
> I'm not sure if it's the app's fault, 'cause it doesn't even recoginse that the timer is plugged in, it might be an issue with the cable/phone jack input not recognising mic properly.
> The timer itself seems really cool, so if somehow it can be connected to the stackmat, I'm definately buying an android device...



More details: I tried with the wrong cable (what I use for my computer), so no wonder it didn't work 
jfly kindly pointed out that I'd need something like this.
If I can get one, I'll try to investigate the app a bit more.


----------



## jfly (Sep 15, 2014)

zhmeigen said:


> Here it is:
> View attachment 4517



Thanks! http://www.jflei.com/stackmat-phones/ updated in https://github.com/jfly/jfly.github.io/commit/9aa0a56107df5e7ab7690a53ccd9f43cd85eac00. That is one nice signal, good find =)


----------



## primarycuber (Sep 15, 2014)

Drumroll


----------



## suushiemaniac (Sep 1, 2015)

Bump.

I recently thought about using a Raspberry Pi or Arduino to achieve similar results instead of using phones.
A Pi is approximately the same price range as a cheap Android phone, it would require no custom soldered board to transform the Stackmat signal and is equally versatile and programmable as an Android phone. 
Thoughts?


----------



## jfly (Sep 1, 2015)

suushiemaniac said:


> Bump.
> 
> I recently thought about using a Raspberry Pi or Arduino to achieve similar results instead of using phones.
> A Pi is approximately the same price range as a cheap Android phone, it would require no custom soldered board to transform the Stackmat signal and is equally versatile and programmable as an Android phone.
> Thoughts?



I don't think a pi or arduino is the way to go here. These devices don't have batteries, don't have any form of keyboard/screen, don't do wifi, and don't have a case. I'm sure there are addons that make all of these things possible, but also push the price way up. For what you're getting, cheap phones are an amazing deal.

Quick update: one year later, I have been pulled into WCA website work, but am hoping to a run a competition this year with smartphones supplementing scorecards. I'll be sure to send out an update if it does happen.


----------



## suushiemaniac (Sep 1, 2015)

I get your point, thanks for the fast feedback  Here's what I think about it:



jfly said:


> These devices don't have batteries


In fact, you can run these things on plain AA batteries, instead of having a rechargeable internal battery as with smartphones. This makes things easier when the battery is empty: Instead of having to plug in a charger (which requires a plug often not present close to the actual timing stations) you simply swap out batteries and you're good to go.



jfly said:


> don't have any form of keyboard/screen


Good point. However, is a screen really necessary? Although the idea is very cool and I don't want to downplay your hard work at all, the user interaction with these devices at competitions is quite simple. So why not use cheap control LEDs and maybe transmit log files to a nearby workstation using the same connection that also transmits the actual results when things go terribly wrong?



jfly said:


> don't do wifi


Indeed. But addons exist and you could maybe use bluetooth if it turns out to be cheaper...



jfly said:


> and don't have a case


Is a case necessary? People who can bring order to the chaos of a Rubiks Cube should be able to properly treat a piece of hardware, when told so.



jfly said:


> I'm sure there are addons that make all of these things possible, but also push the price way up. For what you're getting, cheap phones are an amazing deal.


The price tag probably is the best quick argument you can give. It indeed pushes the price up about $20 judging by a short amazon search I did. Question is if there are any actual advantages that outweigh the additional cash spent... Or if smartphones turn out to have a major flaw that makes them inappropriate for this usage. Time and tests will show 

All in all I'm not against smartphones at all. I was just trying to maybe show up an alternative, not to overthrow the current system. I'm still astonished by all the hard work and thoughts that have gone into this project so far 



jfly said:


> Quick update: one year later, I have been pulled into WCA website work, but am hoping to a run a competition this year with smartphones supplementing scorecards. I'll be sure to send out an update if it does happen.


Sweet!  TheCubicle.us stated something about a "new timer technology" being unveiled at US Nats on their website, but my post in the relevant thread was pretty much ignored when the competition took place. Was that your idea they showed off? If so, how did it turn out?


----------



## jfly (Sep 1, 2015)

suushiemaniac said:


> In fact, you can run these things on plain AA batteries, instead of having a rechargeable internal battery as with smartphones. This makes things easier when the battery is empty: Instead of having to plug in a charger (which requires a plug often not present close to the actual timing stations) you simply swap out batteries and you're good to go.



Oh, nice! Batteries would certainly be better, but this does go back to my point about needing a case =).



suushiemaniac said:


> Good point. However, is a screen really necessary? Although the idea is very cool and I don't want to downplay your hard work at all, the user interaction with these devices at competitions is quite simple. So why not use cheap control LEDs and maybe transmit log files to a nearby workstation using the same connection that also transmits the actual results when things go terribly wrong?



IMO, a touchscreen is pretty key: I want judges to be able to enter times by hand if the stackmat connection isn't working. I was imagining the smartphone could double as a stopwatch (a la http://www.cubing.net/inspection/). Other stuff I forgot: RFID reader and/or camera for identifying competitors. An onscreen keyboard for entering names is also a nice fallback if RFID/QR code doesn't work.



suushiemaniac said:


> Indeed. But addons exist and you could maybe use bluetooth if it turns out to be cheaper...



I believe the range we're talking about, bluetooth wouldn't be great. To be honest, our experience with the wifi at US Nationals this summer was really depressing: I do not believe we could not have run the competition with it. It's not that the internet connection to the outside world was a problem, it was just that the room was just completely flooded with wireless signals. I don't know if bringing our own router would have helped, or just made the situation even worse.



> Is a case necessary? People who can bring order to the chaos of a Rubiks Cube should be able to properly treat a piece of hardware, when told so.



With addons and battery case, I do think a proper enclosure would be necessary.




> Time and tests will show
> 
> All in all I'm not against smartphones at all. I was just trying to maybe show up an alternative, not to overthrow the current system. I'm still astonished by all the hard work and thoughts that have gone into this project so far



Agreed. We need to actually build some stuff and see how it works at real competitions. If you're interested in pursuing any of these ideas, let me know, we could definitely use more help!



> Sweet!  TheCubicle.us stated something about a "new timer technology" being unveiled at US Nats on their website, but my post in the relevant thread was pretty much ignored when the competition took place. Was that your idea they showed off? If so, how did it turn out?



Unrelated to this project, but it was really awesome to see how it spread through the grapevine. AFAIK, they never did demo anything at US Nationals.


----------



## suushiemaniac (Sep 2, 2015)

jfly said:


> IMO, a touchscreen is pretty key: I want judges to be able to enter times by hand if the stackmat connection isn't working. I was imagining the smartphone could double as a stopwatch (a la http://www.cubing.net/inspection/). Other stuff I forgot: RFID reader and/or camera for identifying competitors. An onscreen keyboard for entering names is also a nice fallback if RFID/QR code doesn't work.



Well the confirmation thing is a great idea, maybe use NFC tags? Similar to http://www.amazon.de/Tags-Sticker-NTAG213-Circus-168Byte/dp/B00BTKAI7U (sorry it's German amazon, but I think you will find similar things on amazon.com)
Easily programmable and re-programmable, maybe so that in addition to Comp preparations like printing the schedule also doing a NFC tag programming session with an automated app for the delegates/organizers? 



jfly said:


> I believe the range we're talking about, bluetooth wouldn't be great. To be honest, our experience with the wifi at US Nationals this summer was really depressing: I do not believe we could not have run the competition with it. It's not that the internet connection to the outside world was a problem, it was just that the room was just completely flooded with wireless signals. I don't know if bringing our own router would have helped, or just made the situation even worse.



Signal range is surely something to consider here. Maybe sending Wi-Fi on different frequency bands would help? But please don't ask me about any details as I don't know any :/



jfly said:


> With addons and battery case, I do think a proper enclosure would be necessary.



Agreed. 



jfly said:


> Agreed. We need to actually build some stuff and see how it works at real competitions. If you're interested in pursuing any of these ideas, let me know, we could definitely use more help!



I don't have access to either a Pi or an Arduino. The idea actually came from a friend of mine who isn't much into Cubing apart from being able to solve a 3x3 in ~2 minutes. He would never go to competitions and I finished school two months ago so I don't have access to his hardware any more.
What I do have to offer however is some Android application programming basics and a very solid Java knowledge and experience, although not on a professional level... Don't know if you could need another software guy... 



jfly said:


> Unrelated to this project, but it was really awesome to see how it spread through the grapevine. AFAIK, they never did demo anything at US Nationals.



An official announcement on their website is not quite my definition of "through the grapevine", but it's nice to have an official word on this issue


----------



## jfly (Sep 3, 2015)

suushiemaniac said:


> Well the confirmation thing is a great idea, maybe use NFC tags? Similar to http://www.amazon.de/Tags-Sticker-NTAG213-Circus-168Byte/dp/B00BTKAI7U (sorry it's German amazon, but I think you will find similar things on amazon.com)
> Easily programmable and re-programmable, maybe so that in addition to Comp preparations like printing the schedule also doing a NFC tag programming session with an automated app for the delegates/organizers?



I think NFC is potentially a very good route for us to take. Taking things to the logical extreme, I'd love to have a WCA id card =)



suushiemaniac said:


> What I do have to offer however is some Android application programming basics and a very solid Java knowledge and experience, although not on a professional level... Don't know if you could need another software guy...



If you're interested, we'd love software help! Shoot me an email (you can find my email over on https://www.worldcubeassociation.org/delegates), and I'll put you in touch with Patricia, who's doing the Android work.




> An official announcement on their website is not quite my definition of "through the grapevine", but it's nice to have an official word on this issue



Oh, I meant that it was neat to hear that there were rumors that this announcement was a stackmat integration system.


----------



## suushiemaniac (Sep 11, 2015)

Sorry for the late reply, I was on the move for some days and then became ill afterwards...


jfly said:


> I think NFC is potentially a very good route for us to take. Taking things to the logical extreme, I'd love to have a WCA id card =)


At the logical extreme, yes. But practically no. I think you can't force every competitor to have such a card created for him. And to bring it to every competition. What happens if someone forgets his/her card at home? Who pays for these cards? Etc.



jfly said:


> If you're interested, we'd love software help! Shoot me an email (you can find my email over on https://www.worldcubeassociation.org/delegates), and I'll put you in touch with Patricia, who's doing the Android work.


Consider it done 



jfly said:


> Oh, I meant that it was neat to hear that there were rumors that this announcement was a stackmat integration system.





http://thecubicle.us/thecubicleus-nationals-a-11.html said:


> TheCubicle will be unveiling some new cubing technology at this year's Nats, *including a snazzy new timer* and other cool applications.


I thought this was about you...


----------



## biscuit (Sep 11, 2015)

I don't know if there is anyway I can help on the arduino side without a stack mat, but I'm willing to offer the services of the arduino. I only have some basic stuff (a small bread board, connector wires, a couple of buttons/switchs, LEDS) but if you want to pursue that idea we can try to make something work.


----------



## jfly (Sep 14, 2015)

Hey Biscuit,

Thanks for the offer, but I'm pretty set on pursuing things with smartphones for now. If you're interested in exploring the arduino side of things and have any questions, feel free to shoot me an email, and we can talk!


----------



## Awesomeroks (Sep 29, 2016)

Why didnt I see this before? I have been trying to do something similar for a long time now. I'm trying to make a timer sort of thing which behaves like a stackmat. I have got my arduino to interface with any android phone,and store times. The timing device is the arduino itself.


----------



## mark49152 (Sep 29, 2016)

KingEn timer on Android has a nice feature called pull to start, drop to stop, where the phone picks up vibrations from hands on the table. So you can just use your table like a Stackmat. 

KingEn is no longer in the store but can be found on download sites. Do any other phone timers do this? It's neater than having a bunch of extra electronics attached to the phone.


----------



## Me (Sep 29, 2016)

mark49152 said:


> Do any other phone timers do this? It's neater than having a bunch of extra electronics attached to the phone.



Most (if not all?) timers for iOS or Android have this capability. I think having a stackmat connected to a phone is cooler though.


----------



## biscuit (Sep 30, 2016)

mark49152 said:


> KingEn timer on Android has a nice feature called pull to start, drop to stop, where the phone picks up vibrations from hands on the table. So you can just use your table like a Stackmat.
> 
> KingEn is no longer in the store but can be found on download sites. Do any other phone timers do this? It's neater than having a bunch of extra electronics attached to the phone.



The point of this project is to make results nearly instant in competitions.


----------

