Message Boards Message Boards

The periodic table - powered by Mathematica

GROUPS:

Recently, I've been working on a project called Mandy, an interactive periodic table that displays different element trends depending on what the user says to her. The Raspberry Pi/Mathematica duo has played a very strong role in all aspects of the project design and implementation.

I'm not allowed to provide too many details about the project (not because it's secret, but because I am moving in a month and my wife has ordered that all of my toys and hobbies get packed or I risk them being left behind). Therefore, I created a teaser trailer showcasing the design with a promise to provide more details when I get settled in my new location.

enter image description here

enter image description here

That said, I wanted to highlight a couple of areas where Mathematica played a pivotal role in the the project. My goal was to create a periodic table display (approximately 24x18") that has a RGB LED for each element. The color of the element would then be based on a given periodic trend (atomic radius, weight, ionization energy, etc.). Controlling 118 3-color LEDs turns out to be very easy when the LEDs are Neopixels and the controller is an Arduino. Because I envisioned a wall display, I wanted the user to interact with the piece in some fashion other than a mouse or keyboard. I have started working on a voice recognition system based on pocketsphinx which I call Simplified Command and Control - SCAC but since it is a C/Python project, I'll leave that component for another forum. In summary, the final project requires that SCAC (a python script) interact with Mathematica (data manipulation) that then speaks to an Arduino via a serial connection. But Mathematica played a big role prior to the implementation as well:

Design

  • With access to ElementData, I was able to very quickly create an image that could be sent to a laser cutter for carving the birch-wood frame and the acrylic element pieces.

    o = Table[
       Map[ElementData[i, #] &, {"AtomicNumber", "Symbol", "Period", 
         "Group"}], {i, 118}];
    (* Need to massage the f-block elements,giving them fake groups and \
    periods.Making their periods 9 and 10 with their groups 3 through 16 \
    works nicely *)
    o[[57 ;; 70]] = Module[{i = 1, rep = Range[3, 16], tmp},
       tmp = Select[o, 57 <= #[[1]] <= 70 &] /. {6 -> 9};
       tmp /. {Missing["NotApplicable"] :> rep[[i++]]}];
    o[[89 ;; 102]] = Module[{i = 1, rep = Range[3, 16], tmp},
       tmp = Select[o, 89 <= #[[1]] <= 102 &] /. {7 -> 10};
       tmp /. {Missing["NotApplicable"] :> rep[[i++]]}];
    o = o /. {"Uut" -> "Nh", "Uup" -> "Mc", "Uus" -> "Ts", "Uuo" -> "Og"};
    piece = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}];
    Clear[box]
    box[array_] := Module[{x, y, m = 10},
      {x, y} = array[[{4, 3}]];
      {FaceForm[None], EdgeForm[Thin],
       Rectangle[{m x, m (10 - y)}, {m (x + 1), m (11 - y)}]
       (*Inset[Style[array[[2]],10,Bold],{m (x+0.5),m(10.7-y)}],
       Inset[Style[array[[1]],8],{m(x+0.5),m(10.2-y)}]*)}
      ]
    makePiece[pt_] := GeometricTransformation[
       GeometricTransformation[piece, {pt[[1]], 10 - pt[[2]]}*{1.2, 1.2}],
       ScalingTransform[{10, 10}]];
    ptpuzzle = 
      Graphics[{EdgeForm[Thin], FaceForm[None], 
        makePiece /@ o[[All, {4, 3}]]}];
    Clear[letters2]
    letters2[array_] := Module[{x, y, m = 10},
      {x, y} = array[[{4, 3}]];
      {FaceForm[None], EdgeForm[Thin],
       (*Rectangle[{m x,m(10-y)},{m(x+1),m(11-y)}]*)
       Inset[Style[array[[2]], 8, Bold, 
         FontFamily -> "Cambria Math"], {m (x + 0.45), 
          m (10.55 - y)}*{1.2, 1.2}],
       Inset[Style[array[[1]], 6, 
         FontFamily -> "Cambria Math"], {m (x + 0.45), m (10.2 - y)}*{1.2,
           1.2}]}
      ]
    ptpuzzlelt = letters2 /@ o // Graphics;
    Show[ptpuzzlelt, ptpuzzle, ImageSize -> 600]
    

enter image description here

There are easier ways to create a periodic table, but the above method allowed me to create SVG images suitable for tweaking in vector graphics software and cut with the laser cutter.

Data

Naturally, ElementData can provide the physical and chemical properties of the elements that I want to display on Mandy. There's nothing inspiring about this code (grabbing the data, rescaling it and converting values to a corresponding color scheme). Mathematica provided a useful platform for sandboxing what the trends would look like:

enter image description here

Implementation

Since speech recognition (SCAC) is written in Python, I needed to control a Mathematica Kernel from within Python. I've played with this idea before which results in a functioning platform that is error-intolerant (READ: not ready for prime time). Communication with the Arduino is done through a "Serial" device instead of the "Arduino" device because I started this project before the latter was working. That said, it was pretty straightforward to create a Mathematica Package that (a) opens serial communication with the Arduino, (b) Reads in the element-LED data (c) sends a command to the Arduino to light the LEDs.

I plan to post more details about the project, including code and design pictures, in due time. See my website for updates. RIght now, it sounds like I've used up my daily allocation of blogging time and have to go pack some boxes.

POSTED BY: BoB LeSuer
Answer
5 months ago

enter image description here - Congratulations! This post is now a Staff Pick as distinguished on your profile! Thank you, keep it coming!

POSTED BY: Moderation Team
Answer
2 months ago

Group Abstract Group Abstract