09/30/2019 at 14:41 •
A quick update with pictures of the updated D20. I am testing different combinations of materials and silkscreen colors for the dice.
The challenge here is to find a combination that diffuses the light nicely, without blocking most of it out and still looking interesting when off.---------- more ----------
08/25/2019 at 00:19 •
Hello again friends! It's finally time for an update on the Electronic dice. I just returned from showing the latest version at Gen Con, and it was fantastic! So, what's new?
Well, first and foremost, the new prototype is of a D20! Still regular size, still full of LEDs, still inductively charged, and still awesome. In fact, I think the D20 is by far the most fun light up die. There are, however, several other differences with previous prototypes.---------- more ----------
Because this die is 20-sided, the pcb had to be different, and while the volume of a 20-sided die is greater than that of a 6-sided die, each individual face is smaller. That made designing the PCB quite a challenge. Who am I kidding, I loved it! Figuring out how to fit everything in was delightfully painful :)
The PCB is an unfolded icosahedron with a couple extra bits. Each face has an LED on the side facing the outside, and possibly some components on the inside. This is still a 2-layer board.
This version of the dice revolves around a nrf52810 from Nordic. The previous version centered around a Simblee module, and while that was incredibly useful to get things up and running (with its arduino-compatible toolchain), the module itself was way, way too expensive. The best deal I could get for small quantities was about $16. The economies of scale couldn't bring that down far enough to make the dice remotely affordable. The Nordic chip, on the other hand, only costs $2.50 in small quantities. Adding a crystal and chip antenna to actually compare apples to apples only brings that cost to roughly $3. That is an enormous difference.
Of course, changing the main microcontroller / toolchain / SDK means that most of the firmware code had to be rewritten, which was a bit of a pain. On the other hand, it also means that I now have control over things I couldn't before, such as the bootloader or even customize the bluetooth advertising packets.
The Nordic SDK is full-featured and the developer community is very active, which means that getting answers to questions is a lot easier. RFDuino, on the other hand, has basically fallen off the face of the internet since they got acquired...
The new microcontroller is also faster than the Simblee module. Simblee internally used an nrf51, the previous generation compared to the nrf52. That is great because it means the firmware can do more work to properly identify dice roll state.
Along the same cost-reducing vein, the accelerometer is also cheaper (new part# VS old part#). It isn't quite as precise (10-bit vs 12-bit), but it is plenty good enough for this application.
New charging circuitry
Another big change to the design is the charging circuitry. With the previous iteration, I went with a standard Qi charger chipset. That turned out to be more trouble (and cost) than it was worth. The thing is, Qi chargers are really, really smart. The Qi receiver (inside the die) samples the current being received by the coil and sends that information over to the transmitter (inside the charger) through some clever load modulation. The charger then compares that value against the amount of power it is transmitting, and if the ratio (i.e. efficiency) falls under a certain value, stops the charge and tells the user that something is wrong. When you're trying to transmit several Watts of power at a time to fast charge your phone, this is a great feature, and prevents wasting energy. Unfortunately, because of the physical constraints of the dice design, my power transfer efficiency is pretty low. The coils are really small, and *relatively-speaking*, a lot further apart from each other than the coil in a phone charger is from the coil inside the phone. This caused me a lot of headache, when I didn't really care about wasting at most 100mW of power (for reference, the battery inside the die charges at between 20mA and 40mA).
So instead of that, I went with a dumb charger set up. On the receiver side, I used a <clears throat> FULL BRIDGE RECTIFIER, a couple caps and a linear regulator to create a stable 5V supply from the coil input. Then I added a standard single-cell LiPo charger. I didn't even add any circuitry to decouple the logic supply from the charger's output as the load bias is pretty negligible as long as LEDs aren't lighting up! :)
This, of course, also had the side effect of reducing the cost quite a bit. Roughly speaking, the rectifier + LDO + LiPo charger combo came in at $0.15 + $0.10 + $0.50 = $0.75 compared to $3.00 for the Qi receiver/charger chip (BQ51050B).
And that's not even the full story. The Bill of Materials for a Qi charger is quite large, in fact, the cheapest single-chip Qi transmitter (NXQ1TXH5) is another $3.00 or so. Compare that to the alternative, some cheap wireless charger chips off Alibaba (XKT-335 and XKT-412) for $0.15 a piece and you can imagine the overall savings. And since it seems likely that - on average - I'll need to provide a charger for each die, it's kind of like adding the cost to the die directly.
So obviously the lesson here is that being really smart isn't always a good thing. ;)
Excluding the LEDs, the parts come out to about $5.50 per die (for a D20, it's about $7.50) if I were to make 1000 dice. Of course that doesn't include any of the assembly / manufacturing costs, which is why I've been telling everyone that my target price will be between $25 and $30 per die.
It's really strange how sometimes you get so accustomed to something that you simply forget that things can be different. I think this is something most of us know, have seen or have been told about before, but it is really something you don't fully appreciate until it has happened to you! Sorry, I know this sounds very philosophical, but in this case I'm thinking specifically about an assumption I've made about the dice from very early on. That assumption was that the way to create the dice was to put the electronics inside a plastic shell in the shape of a die. In fact, the first design I uploaded on Hackaday.io featured a removable lid, so that you could replace the battery. Along the way, I figured out how to fit a rechargeable battery instead, and even an inductive charging coil. I was super happy with that upgrade, because it meant that I could try to pot the entire insides of the dice shell, battery, electronics and all, in resin, and make the dice that much more solid (and great feeling).
But it took me MONTHS to realize that I didn't need the shell at all anymore. I had been agonizing over how to design those such that they could be injection molded (and dealing with the draft angles, overhangs, etc...), and didn't even think for the longest time that, well, I don't need a shell at all! I could simply place the folded-up electronics inside a dice mold, and cast the whole thing just the way you would a regular resin die. It's one of those things that really make you go "Doh!!!".
So, yeah, the dice are now directly cast in resin. This, of course, brought a few issues of its own, but overall it was a massive simplification to the assembly process.
The first difficulty was simply me learning the ins and outs of mold making and resin casting. In the end, my process went like this:
- 3D-print positives
- Cast Silicone molds from positives
- Cast resin dice from Silicone molds
If you're interested in more details, there are tons of resources on Youtube. I followed all of them, got a vacuum chamber (for the Silicone) and a pressure pot (for the resin) and things mostly came out good.
I did have one thing that really tripped me up, which was mold release: make sure you use the correct mold release!
There are two kinds: Silicone-based sprays and Oil-based sprays. Do NOT use Silicone-based sprays when you are creating the molds (Step 2 above). Otherwise what will happen is that the silicone in the spray will flow into all the micro features of your positive (and if that positive was 3D-printed it will have lots of them) and then proceed to cure along with the silicone that you're using to create the mold. The end result is the complete opposite of what you expected in the first place: you won't be able to remove the mold from your positive...
For the resin casting, you can use either sprays, or none really...
Anyway, casting the dice ended up needing to be a two-step process. The reason for that was to make sure the electronics and battery would stay in the middle of the die, and not float up, sink down or drift. The idea is that the first casting can register with the circuit board / LEDs, yet have portions that stick out and can themselves register with the second mold (i.e. final die shape). In other words, I start by making a solid 'puck' out of the electronics, and then fit that puck inside the final mold.
This process worked well enough to create a few dice for me to show off, but it isn't great yet. Even though the puck kept everything centered nicely, it could still be placed inside the final mold incorrectly, causing some misalignment between the LEDs and the faces. I am investigating a different registration method that does require a bit of sanding afterwards, but that sanding is already necessary cut cut off the sprues left over from the casting process.
The jury is still out on how this process will affect manufacturing costs. Injection molding plastic shells is really cheap, cheaper than resin casting, but with the previous design I would still have needed someone to fill the shells with resin and then fit the top cover. All that while making sure there were no air bubbles - a difficult task. Here I need someone to do two resin castings / cleanup per die. It seems like more work, but it's fairly commonly done already. Obviously I need to get some quotes.
07/02/2018 at 17:03 •
This is the next revision of the Electronic Dice. I've spent a lot of time putting it together, and it is really coming along!
Looks pretty nice, doesn't it?
So first things first, this version is exactly 16mm, the same size as a regular dice. And as you can see here next to the previous prototype, it is also more rounded. It's amazing how much difference 1mm can make, both in how the dice feels in your hand, and how much harder it is to put together!---------- more ----------
Of course, the other thing you might notice, is that this version doesn't have screws, or a removable lid in fact. Actually, this is a great example why sharing your work matters. In the last video, I specifically mentioned how I wasn't able to find a rechargeable battery small enough to fit in the case, and therefore why I had to design the dice with a removable lid.
Well, somebody mentioned searching for Bluetooth headset batteries, and sure enough, as soon as I started plugging in the right keywords, I was able to find small lipos on Alibaba.
These things are nice, they can supply enough current to light all the leds at once, although, obviously, that would drain the battery really fast! Of course, having a rechargeable battery isn't much use if you can't actually recharge it, and this is how I got to research inductive charging. This was a completely foreign area for me, and in fact it turned out to be pretty complicated. Not being all that comfortable with analog circuitry and magnetics, I looked for two things: a wireless coil that could fit inside the case, and whether there were integrated chips that would take care of the transmitter/receiver pair.
Well it turns out, Qi charging is pretty popular these days, and so there are several integrated chips that will take care of everything for you. I even found a Texas Instrument chip that would rectify the inductive current AND charge a lithium-ion battery, and all in a tiny package too, the bq51050.
The coil was also not too hard to find, a quick search on Digikey turned up several candidates.
After that, it was ‘mostly’ a matter of following the application notes on the datasheet, using the formulas they provided to compute the values of certain key components and giving it a try. I was hopeful that a standard Qi charger would just work with the dice, but unfortunately it didn’t.
It turns out that the two coils involved in the transfer have to be pretty well matched in order for the magnetic flux to induce enough current on the receiving end. So if my receiving coil was going to be a lot smaller than normal, then my transmitter coil needed to as well.
The other thing I found out, was that when you scale down the coil geometry, you need to scale down all of it, including the distance between the coils. It’s obvious in hindsight, but it took me a while to realize that. And so, while with standard Qi chargers you the coils can be 3mm appart, with a 10mm coil, they needed to be less than 1mm apart to be able to transfer enough power.
This posed several problems with the design which I’ll get into in a bit. First let’s finish the tour.
So, the principle is the same as with the last prototype. The components are soldered onto a flexible pcb, that is then folded and placed inside the case, with the LEDs facing outward. The battery fits in the middle and then the top flap folds back in to finish the cube. This small panel here was made using GoldPhoenix batch flex service.
The main microcontroller is again the Simblee, internally it is just an nrf51, crystal and chip antenna in a single package. Now, while the simblee has been really useful to get up and running, they provide an arduino-compatible toolchain and libraries that make writing your first bluetooth program a breeze, I think for the next version I’ll actually switch directly to a nordic chip (the nrf51 or nrf52). RFDigital, the creators of Simblee, was acquired by somebody else, and ever since, support has been really lacking. Plus the chips are unreasonably expensive for any sort of batch manufacturing.
The leds are APA102 2020. These little guys are really great. The colors are amazing and they are very easy to control. They are also really simple to connect, as they are meant to be daisy chained. This turned out to be a huge advantage, as it reduced the complexity of the routing. In order to get affordable flex pcbs, you really need to stick to two layers, and with my size constraints, not having to route a complicated led matrix really helped! Of course, APA102s are a little more expensive than similar ‘dumb’ RGB leds, but thanks to Alibaba, I was able to find some for a decent price.
Now there are two issues with the APA 102s, or at least the ones I got.
The first one was that they draw a full milliamp of current even when off. I think what’s happening is that the internal PWMs that modulate the intensity are just ‘dumb’ and remain on all the time even if the intensity is 0. But with 21 leds, it means that the dice would constantly draw 21 mA from the battery, which would kill it in 2 to 3 hours for sure. To remedy this, I added a small transistor to cut off the power to the LEDs altogether, and had the microcontroller toggle that transistor when it went to sleep.
Unfortunately that was NOT enough. This one stumped me for a bit, but the best I can explain it is that the LEDs will drain current from the data and clock lines. So in order to make sure the LEDs don’t draw any leakage current, I had to make sure the data and clock lines were low before going to sleep.
Eventually though, I was able to get the current draw down. I still think there is some work to be done to minimize the current wasted in pull ups and pull downs in other areas of the circuit, but again, for this prototype this was good enough!
For power regulation, I was planning to use a small buck converter to get the Lipo voltage down to 3.3V, but ended up having stability issues (that I still haven’t quite sorted out) and ended up just ripping out the whole thing and powering the microcontroller directly from the Lipo battery. It is technically slightly outside the recommended range but it seemed to work, at least for a prototype.
The last IC on the board is the magnetic switch. The idea was to insert magnets in the dice’s carrying case, so that they would turn off while being transported. You don’t want the dice to light up and drain their battery for no reason. I had the magnetic switch connected to the power buck converter, so that it would turn off all the logic whenever a magnet was present. Unfortunately, turning off the power means that the LED control lines become floating, which, in turn causes the LEDs to turn on to arbitrary colors. Not acceptable…
So what I ended up doing was wire the output of the magnetic sensor to the microcontroller instead, and handle the ‘don’t turn leds on’ through software. It’s not as elegant a solution, but it did the trick. The magnet triggers an interrupt that in turn causes the micro to turn the led power off, set the control lines low and go to sleep.
I think that covers all of the internals! Let’s look at the design and assembly some more.
Unsurprisingly, for this next revision of the dice, I restarted the design from scratch. I wanted the dice to be exactly 16mm and have much more rounded corners. Well, you won’t be surprised to hear that it made the layout of the board quite challenging. Even though the leds are daisy chained, connecting all of them is slightly more complicated than I made it seem with the schematic. In the schematic it looks like there are only two wires going between each led, but of course, that’s ignoring power and ground. And unfortunately, the power and ground pins are not quite as conveniently placed that you can just connect 4 pins to 4 pins.
The other complication was that the board gets bent, and, aside from the obvious fact that I couldn’t put any component in the bends, the bends themselves put an extra amount of stress on the copper traces running through it, especially if you have a pad near a bend. The chances of causing a crack in the copper are really high. But, I didn’t really have a choice, the leds are pretty big and the dice really small.
So I tried to keep the traces going in the direction of the bend. I couldn’t, however, keep pads away from the bends, there just wasn’t room.
Annnd, of course, that did turn out to be a significant problem. I had a ton of boards start failing once I bent them to fit inside the case. Eventually I put together a small bending jig and tried to stress the boards as little as possible. That meant solder and test and program everything with the board flat, then bending the board with the jig, trying to concentrate the bend in the ‘safe’ areas, wire up the battery and drop the whole thing in the case in as fast a motion as possible.
To be honest, my success rate was pretty low, and when each board take around 4 hours to hand-solder and assemble, it’s pretty soul-crushing to have it just stop working on the next to last step. The worst part when that happened was that any attempt to get the board back out to try and fix the traces would inevitably cause stresses in another spot and cause some other crack to appear. Needless to say that this I will need to spend some time finding a proper solution to this problem, but anyway, obviously I did manage to get some of the boards fully assembled and working.
Remember when I mentioned scaling down the inductive coils for the charging circuit, and specifically how the coils needed to be much closer than with traditional Qi chargers? So yeah, it turns out that the only way to get the coils close enough together was to move the receiver coil all the way up against the case. Actually, even closer, I had to make a pocket so that the coil would be 0.5mm from the outside plane.
Of course that’s all fine and good except I still need at least one LED on each side, including the side with the coil. And to make everything even more complicated, the coil needs to have a ferrite backing, to focus the magnetic flux as much as possible…
As it turned out, I got lucky, the APA102 led can fit inside the coil, and it wasn’t *too* annoying to pull the ferrite backing off the coil so I could glue it to the other side of the pcb.
The very last step in assembling the dice, is to pot the entire thing in epoxy! This is a very simple thing, but it makes an enormous difference. I’m pretty pleased with the idea! Potting everything in epoxy serves many purposes at once. First, it keeps me from having to use fasteners to hold everything together. Then it makes sure that nothing moves around, which is a pretty big deal considering how fragile the flexible pcb. But that also gives the dice a really, really solid feel.
And that is probably the most underrated feature of this prototype. When you hold it in your hand, you can’t tell that it’s full of electronics, it just feel like a regular dice. You can even hear it when I roll it. The previous prototype sounds all rattle-y, whereas this new one sounds correct.
The third purpose of potting everything in epoxy is that it evens out the density, and makes the dice much more balanced. Of course, the density of epoxy isn’t exactly the same as the density of a lipo battery, or the pcb or the components, but it is much much closer to those than air. And so, by filling in all the gaps, the difference in density really decreases.
In fact, I haven’t done it yet, but I’m pretty sure I can make up the last remaining delta by adding a bit of lead here and there inside the case before filling it. And the best part is that because the dice can record every single throw, I can collect accurate statistics on how unbalanced it is and correct for it in the next prototype!
But there you have it, that’s how the dice is put together! And while there are clearly still a lot of issues with it, I’m pretty pleased with the result.
02/04/2018 at 22:47 •
I finally finished the second board for the Dice, the full RGB one this time! It's pretty awesome already! I don't have a flexible PCB version yet, but this here is a prototype board.
---------- more ----------
Of course I had to make a few changes to the schematics and the case design. For starters, I replaced the Linear voltage regulator with a switching one. Switching voltage regulators are much more efficient than linear ones (which end up mostly dissipating the voltage difference between the input and the output as heat) but they require a few more supports components, not least of which is a decent inductor.
Fitting all the components inside the case was also another level of Tetris mastery. The reduced size combined with the more aggressively rounded corners left me with very little room to fit everything. At this scale, even deciding where to put the folds is a major consideration, as a 1mm or 2mm bending radius will mean that that edge of the board can't be as long and there won't be as much room for components. In fact, fitting the Simblee chip on the board was almost impossible.
(The hatched areas are either bends or another component poking through to this face)
Then, of course, there are the APA102s. Because these are typically 5V devices, I wasn't sure if they would accept a 3.3v logic level. I knew they could be run on 3.7v, there is evidence of that all over websites like Adafruit, but I wasn't sure about 3.3v logic... In the end, I found out that they work just fine. They are, relatively speaking, huge though. Compared to the previous LEDs (that used a 0603 footprint) they are really thick, an ENTIRE MILLIMETER! :) I laugh, but at my scale, I couldn't afford to pull the PCBs inward any more, and so I had to make cutouts in the case to accomodate the LEDs.
Eventually I submitted a new prototype board to my favorite PCB house, Oshpark. The board came back, and I proceeded to try and assemble it by hand. It's funny, after you've soldered a bunch of 0402 resistors, a 0603 looks positively huge! :) I used a combination of techniques to do this, sometimes applying a bit of solder paste over all the pads, and then letting the solder flow to the chip pins as I heat it. It works surprisingly well.
I made a few bozo mistakes of course, most notably on the APA102 footprint and regulating inductor. First I dimensioned the regulator for a 2.2nH instead of the required 2.2uH, only 1000 times too small :)
The APA102s were somehow completely wrong, but in a rare stroke of luck, I was able to get them connected correctly by rotating them 180 degrees and flipping the clock and data pins. So, so lucky, but then again, that's exactly why I made a prototype board before sinking a bunch of money into flexible PCBs. But hey, they work, and OMG they look so nice. I can't wait to get the final boards made. I did notice a couple things in the process though.
The first is that the actual LED elements (the R, G and B) are not actually centered on the chip, but offset to one side.
This means that if I want the light to be correctly in front of the number dots, I'll need to shift the component positions slightly here and there. Of course because space is so limited, that in turns means that there are certain component orientations that I can't support, specifically next to the bends in the PCB.
The other is related to the fact that I power the LEDs directly from the battery in order to keep their supply voltage as high as possible (3.8v instead of the logic 3.3v of the rest of the board). It works great, except that it means the LEDs are CONSTANTLY powered, even if they are not technically turned ON. This has 2 side effects. The first is that they unnecessarily draw a little bit of current even when the die is supposed to go to sleep, which is no good for battery life of course. The second is that sometimes, if a LED is powered but not 'initialized' properly, it may decide to turn ON! That's really not cool because it means that when I try to forcibly 'turn the die off' with a magnet, the LEDs may just stay on forever...
Fortunately, that's something we can fix with a very-low-dropout transistor! In fact the same magnetic switch that will turn the voltage regulator off will now also turn off the power to the leds. Great!
Wireless charging is still a bit tricky too. Since I picked a chip that follows the Qi standard, I thought I'd be able to use an off-the-shelf charger, which would be great moving forward. Unfortunately, at first it just didn't work. Poking through the different signals with my scope, I finally figured out that the voltage on the receiver coil just wasn't high enough to turn the chip on. I replaced the coil with a much larger one, stolen from a known working receiver I bought from Adafruit, and low and behold, the connection worked! The problem was obviously a poor coupling between the two coils, which in a way made sense. The transmitter coil was so much bigger than the receiver that most of the magnetic flux was wasted.
Looking for a solution, I stumbled upon an application note from Wurth that specifies which transmitter coils work best with which receivers, and guess what? The transmitter coils compatible with my receiver are way smaller than the one in this charger! I now have some new coils coming in the mail so I can try a few different combinations and see what works best!
In the interim, I tried replacing the transmitter coil with one of my receiver coils, and it sort of works. The two coils (transmitter and receiver) have to be very, very close together to get a good enough power transfer to start the charging circuitry, but it works. Here's hoping that the proper matching coils makes it that transfer works from a few millimeters aways, that's all I need really!
Finally, I've been testing out if and how I can paint the cases. The difficult part is that I need a way to leave unpainted areas in front of the LEDs. It looks really nice when only the dots light up, not the entire plastic case. I imagine I'll probably make a hundred or so dice in this next batch, so that I can have some for other people to develop for, and so I don't really see myself painstakingly hand painting each die like a miniature. I need a process that is fairly fast, accurate and repeatable. What I've settled on, although it needs a bit of refining, is to print the cases with raises number dots. That way I can paint over the entire thing and then sand the face back down such that the dots are transparent again. I am still sorting out how many layers of paint I need, as well as what kind of paint to use in the first place, but I think I'll get there. Here is a test that mostly worked out!
So as you can see, things are moving along. There is still a lot of work to be done, of course. I think I'll pretty soon need to make a carrying case that will double up as a charger, sine it looks like off-the-shelf chargers won't quite work. That will be another whole thing, of course!
And obviously, I still need to create a GOOD game that takes advantage of the dice :) With the RGB dice coming soon, I am thinking of something centered around elements (fire, water, earth, etc...), where each die represent an element, and you pick and roll the dice you want to cast spells to defeat monsters. It'll be fun!
12/29/2017 at 19:52 •
Following a suggestion from a commenter on youtube, I was able to find a lipo battery small enough to fit in the dice! I received samples early this week, very exciting!
I got so excited to start seeing if I could make the next version only 16mm wide that I started working on the schematics and now 3D CAD. That's just as well, since now I can get prototype boards made while I continue to work on the firmware.---------- more ----------
Oh and I'm going to try and integrate wireless charging! Not only is it really cool, it'll allow me to never have to open the case (assuming I get over-the-air programming to work), in turn meaning I'll be able to just pot everything down and glue the case shut (no more screws).
I'm trying to stream my work as much as possible. So don't hesitate to follow me so you get notified! http://twitch.tv/jean_simonet/
12/20/2017 at 22:07 •
Going to do some streaming in just a bit, stop on by if you like! http://twitch.tv/jean_simonet
12/01/2017 at 00:25 •
I put together a shorter video, less technical and more like a sizzle-reel.
Hopefully I can get back to work soon! Taking pictures and editing stuff together, let alone re-recording stuff a gazillion times, ends up sucking up soooo much time...
Anyhow, hope you all like it,