Tagline

The Studio of Eric Valosin

Tuesday, April 22, 2014

Pushbutton Prayer Bead Progress - 3D Prints and Electronics for Dummies

The last couple weeks have presented a HUGE wealth of new knowledge and small victories I was totally not prepared for. I've made quite a bit more progress on my Pushbutton Prayer Bead project (follow the link to see how this all started), notably designing a prototype for the bead itself, expanding the circuitry to involve more than a single LED, and tackling the electrical practicalities that I wasn't even aware would be such a challenge.

My First 3D Print


Wary of the immense learning curve of designing in Blender, I decided to go with SketchUp to design my bead models, which I had much more experience with. Essentially the model needed 4 things:
  1. To be hollow so that the wiring and connections can be housed inside
  2. To have a "floor" that would support the pushbutton, with the button part accessible at the top surface and through-mounted so that the leads could be soldered to the wires inside the button
  3. Side holes where the wires can be fed from bead to bead
  4. Some way of assembling and, inevitably, of disassembling the bead once its ready to go.
And it had to be small. We're talking less than a 2 cm diameter. So I took to designing, with a big help from the Solid Inspector plugin and NetFabb software to make it manifest and watertight, ready for printing at Shapeways. (See here for a post that will save your life if you're attempting to 3D print from SketchUp)




my model on Shapeways, complete with latches to snap the model shut and 2 "oh crap, wait..." holes through which a paper clip can pop the latches open again when I inevitably realize I shouldn't have closed it yet!

Got my model back and it looked great! Needed some tweaking - through holes didn't quite punch through, and walls were a fraction of a millimeter too narrow for the button after printing.
Talk about a hack - Went at it old school style, with an exact-o and a push pin, and got something that will work! Still needs a thinner floor so the leads stick out a bit more.
I then went back in and made some adjustments to the original model for round 2, and I'm excited to send it off and see how it works!

Now just have to learn to solder... (ha!)

Electronics


The next big task came with the arrival of this glorious bunch of 200 common anode RGB LEDs! 



I naively dove in and started hooking up some of the LEDs, only to learn that I had been prototyping with the common cathode type before, not common anode. When I started it up, first it did nothing at all. Then, after rewiring it was on when it was supposed to be off, and all the colors were the exact complement of what they were supposed to be! Lets just say I've spent a LOT of time surfing electronics forums this week. Luckily it was as simple as connecting the common pin to the power source rather than ground, and inverting all the Pulse Width Modulation (PWM) values that would tell it what color to be. No sweat.


Once I got my LED color fade working properly, I decided to start looking into what it was going to take to string up 200 of these things in parallel. Apparently all my extensive training in abstract conceptual theory has utterly destroyed my capacity for concrete thought, as my eyes glazed over at Ohm's Law (which I knew readily in High School), and I became someone I would have made fun of in physics class. The numbers and formulas all looked like Greek to me (to my credit, actually, some of it was in fact in Greek - ahem Ω) I totally got it in theory...

Tempted to just say "screw it" and fudge the numbers, I finally cleared my bleary eyes and buckled down to learn the very basic tenants of electrical engineering needed to see what I was up against. And its a good thing I did! After calculating resistances and amperages at different voltages, and poring through data sheet after data sheet (I'm talking 7 hours of research - I'm talking really starting from scratch here), it became clear to me that the setup shown above was one full-white pixel away from destroying my Arduino's digital output pin! The only reason it didn't was because the blend of colors was not drawing the full current it could potentially have if the LED were fully lit.

Not only that, but if I proceeded with more LEDs and my original plan, I would have blown out the +5V and Vin pins, melted my AC adaptor wall wart and fried every LED I had just purchased!
(I will post my most basic vital discoveries and disambiguations here)




I started seeking other options, and soon added to my shopping list a +5V 30A external power supply and 3 n-channel MOSFET transistors (to protect the Aduino input pins from that high current and drive the LEDs). The MOSFETs arrived in a matter of days, and I began cautiously proceeding with 4 LEDs, wired and protected the proper way.


My probably very unconventionally drawn schematic for the LED's wired in parallel and hooked up to the MOSFETs and pushbuttons

Oddly enough, the MOSFETs seem to invert the voltage coming through the gate, so that whole on-when-it-was-supposed-to-be-off LED problem ended up correcting itself (which still has me a bit puzzled, but I'm not going to argue with simpler code).


 And Here you have it...


The Remaining Challenges

The first of the remaining challenges is of course cost. The bigger this scales up to be, the more I need to seek funding of some sort. Besides that, I am beginning to consider installation layouts and locations.

Before I can get to that though, The code and the hardware still need quite a bit:
  1. It has to reset by itself when a user disengages with it so that a new user can start fresh rather than where the old user left off
  2. I've been using a placeholder image this whole time. I still need to to decide what image will be meditated upon, whether it be a static image, taken from a live video feed, or an array of images, etc
  3. As you can see in the video, for some reason the code is acting like it's executing functions out of order. Despite the sequence its written in, it fades the LEDs before highlighting the pixel in the image itself, and I want that to be the other way around. I'm sure I'm missing something very simple, but it's driving me nuts right now.
  4. I have to figure out the actual lighting fixtures (what they are made out of, how to most efficiently light the room, and where to place them so that all the necessary cords reach each other
  5. I have to learn to solder (duh) and actually put this stuff together off the breadboard
  6. I still haven't decided if the beads should be wireless, which will be a whole other can of worms
Definitely fun stuff!

Arduino and LED's for Complete and Total Morons like Me

I've been working on a project using an Arduino to control RGB LED's with PWM and discovered there's a WHOLE TON of stuff people just assume you know. It took many hours to get the basic understanding to even know what to google. So here you go.

WHAT YOU NEED TO KNOW SO YOU DON'T MELT STUFF


First some clarification -

PWM, or Pulse Width Modulation means controlling the R, G, and B components of the LED values from 0-255 through digital output pins that tell it how frequently to turn on, giving the effect of dimming, fading, or being at partial brightness.)

Choosing your LED. I went with common Anode as opposed to common Cathode, so that's what this is written for. With common Anode, the long pin ("common") needs to be connected to the +Voltage, and the R,G,and B pins need to be connected to a resistor (to protect them) and then to the digital output pins of the Arduino. Then the LED lights up when pulled HIGH, which essentially means the PWM color scale goes from 0(fully on) to 255(fully off). This is counterintuitive, and you can easily fix your program by writing your color value "r" as "255-r"

Common Cathode are just the opposite - Common goes to Ground, not +5V, and it turns on when pulled LOW; PWM = 0(fully off) to 255(fully on).

OK NOW THEN...

First look at the LED's data sheet for two things - the Forward Voltage (Vf) and the Forward Current (If).

Forward Voltage is the amount the applied voltage drops when it passes through the LED. You'll need this to calculate how much resistance you need. For the sake of argument we'll say it's 3, but check your data sheet.

Forward Current is the amount of current (in mA) that each diode draws (remember RGB LEDs are actually 3 diodes in one, and each needs to be accounted for separately)

PROTECTING YOUR LEDS

If you don't want to blow out the LED, you need resistors connected to the R,G,and B pins. To figure this out, you first need to know how much voltage you plan on supplying. The typical Arduino supplies 5V, so we'll go with that, but this can be adjusted accordingly if, say, you're hooking it up to a 9V battery, etc.

1) Finding your Resistor with Ohm's Law - when solved for Resistance, Ohm's Law says the Resistance (R) you need in order to get the proper current at a given voltage is equal to the Voltage (V) divided by the Current (I).
R = V/I

Remember that you're supplying 5V, but there is a drop due to the LED's Forward Voltage. So, you must subtract the forward voltage from the total voltage
V = VDD - Vf
in this case V = 5 - 3
V = 2

So, R = 2/I
I is in this case 20mA (or .02A)
so R = 2/.02
R = 100 ohms (shown as Ω)

So you need to connect your LED's terminal to a Resistor of at least 100 Ω so that when it draws the 20mA of current it doesn't blow itself up. Always round up if you land on a value that's not a common resistor value.

2) JUST in case, you should also make sure the resistor is the right Wattage (usually they come in 1/4W, 1/6W, 1/8W, etc), using the following formula:

Power (P) = Current(I) Squared times Resistance (R) [pardon my lack of superscript and subscript... blogger and I are fighting right now]
we now know the resistance is 100, so in this case
P = .02squared x 100
P = .04

Since 1/8W (.125) is well above .04, you should be fine with pretty much whatever you choose, but just pick one that's higher than the value of P so that you don't overheat the resistor.


Series or Parallel?
Single color LEDs can be wired in series, meaning the anode of one is connected directly to the cathode of the next and so on, and they can all share one resistor. However this is not possible with RGB LEDs since they share a common pin between the three colors. They must be wired in parallel, meaning each LED is connected directly to the power source and ground, rather than to each other. Every pin therefore needs its own resistor or else you'll end up with inconsistent color and insufficient protection.

- LED's wired in Series share the same amount of current but multiply the amount of voltage per LED.
- LEDs in Parallel are the opposite, they all share the same Voltage but the current is multiplied per LED.

SO, if you have 5 LEDs in series, each wanting 3V and 20mA, you'll need to provide 15V (3V x 5 LEDs) and 20mA.
If you have 5 LEDs in parallel, each wanting 3V and 20mA, you'll need to provide 3V and 100mA (20mA x 5 LEDs)

PROTECTING YOUR ARDUINO

We're not commonly told this, but the Arduino pins can only take so much power. I'm using the Arduino Uno, so if your model differs, this is stuff you'll want to google. In general, try googling things like "Arduino max voltage" or "arduino [insert name of pin here] max current"

Check here for starters - You'll definitely want to google these limitations for yourself. EVERY PIN ON THE ARDUINO has its limitations. Don't just take my word for it. My bad memory or misread data sheet, or incomplete information here is not worth your fried arduino pin.

It naturally supplies 5V, but can handle up to about 12V using the power barrel plug thingy (a technical term). Don't exceed that unless you like the smell of burning electronics. That power can be converted to 5V with the +5V pin, or sent straight through the Vin pin. Each of these pins can handle only so much current running through them

+5V pin = max 450mA - 600mA current depending on power source
Vin pin = max 1A current

Then you need to know how much the output pins you're using can take. These are the ones you really want to pay attention to:

Digital I/O pin = max 40mA current
total max current from all I/O pins combined = 200mA

This means that any given output pin can actually only support 2 LEDs in parallel at full brightness without risking damage! ...whoops.

MOSFETs for More Power...
Clearly there is an way you can still hook up more LEDs, but you'll want to look into an external power supply if the voltage or current demands get too big for the V pins, as well as something to isolate the output pins from the massive current being drawn by the LEDs

I recommend n-channel MOSFET transistors (see here for a great reference article by Adafruit), which can handle up to 16A and essentially acts like a switch that passes the higher current straight from a power supply to the LED to ground without ever touching the Arduino, whenever it's "gate" is triggered by a smaller current sent from the Arduino I/O pin. Here's a great MOSFET tutorial

The MOSFET has a "gate" "source" and "drain." I won't go into why here, but suffice it to say that to drive a common anode LED with a MOSFET you should connect the following:

Gate --  to the digital I/O pin that sends color/PWM signal
Source -- to the LED leg that corresponds with the arduino output pin
Drain -- to ground 

Then you can connect each leg of the LED to it's own MOSFET (using 3 MOSFETS, one for each color - you don't need one for each LED, all of the red LED terminals can be connected to the red MOSFET and so on) and the common Anode to the high-current power source!

For added protection, you should have a low value resistor between the gate and the pin (lots of argument on exactly how low since the current is not consistent, but I've seen between 100 and 330Ω recommended), as well as high value (pull-down) resistor connecting Gate to Drain, essentially to prevent things from going the wrong way inside (I've seen 1k, 10k, and 100k recommended).

A PWM side note: I still don't quite understand why, but the n-channel MOSFET inverts the voltage applied to it. So, remember before that we had to write our "r" value as "255-r" to get it to cooperate with common anode? well now it gets inverted back, so you can leave it as good ol' "r" (as if you were coding for a common cathode LED. Don't change the wiring though...)

I think that about covers it, and I hope this is helpful! Good luck to you as you try to light stuff up without blowing it up!






Monday, April 21, 2014

Good Grief: An Easter Crisis, Mindfulness and the Absolute

EASTER
- this profoundly joyous time of resurrection - is not time of the year I expected to grieve. Holy week has passed, yet I find myself returning to an empty tomb to weep a bit. I grieve not the loss of a person right now, but of an ideology I didn't know I had.

Disclaimer: If you're looking for fully digested philosophical treatises or flashy epiphanic discoveries, this is not that type of post. I do those every now and then, but the conclusion of this Lenten season and the arrival of Easter has left me in a far messier, unresolved place - albeit, a good one I think. This is one of those posts where I crack my heart open a bit and pour out the contents, partially grasping at cathartic straws, and partially because I know I'm not alone in my quandaries. I share these here because I know that the outcomes of these sorts of struggles have everything to do with my work as an artist and thinker, and, more directly, with the way I live my life in a public manner. This is going to be a long post, and you're lucky it has any organizational strategy at all.

A Look Back at Lent

These past 46 days my church, under the leadership my wife, its Pastor, embarked on a theme of repentance and reconciliation - reconciliation with nature, diverse people groups, within families, the church community, the self, and of course reconciliation with God. Each week focused on a different topic and provided tools for recognizing how we as individuals and as a community have fallen short of right relationship, and how we might reconcile those relationships in our daily lives.

I personally took this opportunity to invest in some reconciliatory practices of self-care, since the rigors of grad school had pretty much undone most of my better habits in this respect. I took up daily mindfulness practices (daily is a very generous description, but at least a good start), tried to eat better (embarking on a 30 day smoothie challenge that tasted great but ended up making my wife sick), and exercised more regularly (again a generous description, but a good start). I also tried to very intentionally reconnect with my family and take time away from the workaholism instilled in me through grad school under threat of career death. It's been a far more difficult task than I expected, but one that I think made me more prepared for and receptive to the this upcoming crisis of faith.

Resurrection Reconciliation

Today my wife gave one of the most brilliant Easter sermons I've ever heard. That's not me being biased, that's me being blown away. Having heard and thought deeply about the Easter story over and over again, I was not expecting to hear it in a fresh way that clicked any differently than it had in the past. Yet, it left me in tears and got me thinking new, deep thoughts. I tried recounting the sermon's brilliance to a coworker today and failed miserably, so I'll spare you my troubled synopsis. Instead, suffice it here to discuss this one main point of hers:

Matthew 28:1-10, Jesus appears to the two Marys who had just discovered his empty tomb and the angel. The resurrected Christ says to the women "Greetings, do not be afraid. Go and tell my brothers to go to Galilee; there they will meet me." What we often overlook is that he does not call them his disciples, or even his friends, he calls them his brothers. These are the same "brothers" that within the last week had fallen asleep on him 3 times while he went through a point of crisis and begged them to stay awake with him, ran away when the authorities came, denied ever knowing him at all, and then stood and watched him get killed. That would be no friend of mine, much less a brother! Yet, as if it never happened, he greets them as beloved family.

The model of repentance and reconciliation gets flipped on its head. In every other case we studied, first you repent (acknowledge a wrong behavior and apologize) and then reconcile (reconnect and establish a better relationship). But here reconciliation is offered... and there seems to be no sign of repentance. At least not yet. These "brothers" had never so much as said they were sorry. But Jesus extends to them his familial love. He simply wants to see them again in Galilee.

The whole Easter story - in fact the whole of the Good News - is simply that. That even though we sometimes don't take God seriously and "fall asleep" on him, even though we put on our blinders and flee the scene in favor of our own agendas and self-preservation, even when we deny the intimacy we may have had with God for fear of rejection or persecution, even when we stand idly by as we watch our strained faith die... God choses to take no offense, calls us "brother" and "sister" and simply longs to see us again in Galilee. That had me in tears, and I even choke up a bit typing it. This is God's Easter Basket to us - a gift of guilt-free reconciliation undeservedly given.

I don't easily tear up, so that's usually an indication I've got some major crap going on behind the scenes that I'm not aware of. So I began digging. It's not a new message; why did it goad me so much this time?

Clinging to the Absolute

For a long time I've been obsessed with a search for absolute truth. I know, I know. The good postmodernist in me knows that there's either no such thing, or that if there is we simply have no access to it, mired in our relative subjectivity. But that hasn't stopped me from seeking it. I don't want an absolute in the Platonic ideal sense; there are too many terrible ethical implications like an inherent intolerance of diversity. However, if the absolute dies entirely, then where's the anchor of our faith? Wheres the logic of metaphysics? How do we not get lost in a relativistic ethical free-for-all? (Many of these I address in my thesis monograph, seeking a relational metaphysics).

Relational models of truth are the immediate answer, and for this reason non-anthropomorphic ideas of God have become very popular, since they sidestep the problems of correspondent truth and allow for more theological adaptability. I don't disagree with these ideas (in fact I cringe at the anthropomorphized God we create in our image rather than the other way around), but I am wary of the pantheism that can result. As a result, I clung desperately to the idea of some absolute truth that might one day disclose itself in some unfathomable, ineffable way.

Without knowing it, this for me took the form of Heaven. By this I mean eternal life - eternal union with a pure sense of deity outside of the constraints of our individual contexts (no time, space, physical bodily limitations, etc). I may have no access to absolute truth in this life, but at least I can bank on becoming one with the absolute once I'm outside of this earthly mixture of complications (ab-solute).

I had never realized it, but this focus on heaven shifted my entire paradigm in a very particular way:

A Crisis of Options

This is the classic tug of war between the subjective and the absolute, the immanent and the transcendent, the temporal and the eternal, the kingdom on earth and the kingdom of heaven.

Assuming for the sake of argument that there is indeed both this life and eternal life in one form or another, I began to realize there are 4 ways of navigating these realities.

1) put all your focus on this life and completely ignore eternity
2) put an equal importance on both and focus more on this life since it's all we have access to right now
3) put an equal importance on both and focus more on eternity since that is the goal to be striven towards
4) put all your focus on eternity and completely ignore this life.

...I wonder if there's a 5th way, putting equal importance on both but focusing on neither - maybe that's the more apophatic approach, but I'm not sure yet what that looks like...

(Of course you can put no importance on either and become a nihilist, but then why bother writing this at all?)

1 and 4 seem irresponsible and implausible, so I was left with 2 options, and it became clear to me that my bias towards the absolute had me subtly leaning toward option 3 (we'll call the "heaven-focused" option), focusing my life around eternity, rather than the here and now; all my works on earth - though supremely valuable - are an attempt to live in a way that grows out of my respect for eternity and the eternally transcendent God's commands. I discovered my wife, as it turns out, leans more toward option 2 (we'll call it the "world-focused" option), living in the here-and-now so that all her works are an attempt to participate with an immanent God in the time we have, bringing eternity and the kingdom of God to the present.

The increasing implausibility of a dogmatically prescribed anthropomorphic God - and don't misunderstand me, I'd want nothing other than an implausible God, for there could be no God that is entirely plausible; I seek to unknown this God all the time - has inevitably got me questioning my most basic pre-assumptions, even down to the very existence of God. So, I examined each scenario and what you're left with if you then ask if God really exists.

After I had worn down the tolerance of my wife's patient ear, I began scribbling down my thoughts in a flow chart.

The conclusions in the flow chart from left to right if you can't read my handwriting:
"is your focus on this life or the next?" ->
this life -> yes -> "sweet, you lived well and get to enjoy heaven as a side benefit"
this life -> no -> "oh well, you tried your best, but at least this life was lived well"
next life -> yes -> "you must take God's instructions for life seriously and act in this life accordingly"
next life -> no -> "everything is meaningless" (and not in the Ecclesiastical sense)
To my horror, my wife's world-focused viewpoint was pretty much a win-win situation, while my heaven-focused one logically terminates, at best, in business as usual, and at worst nihilism! My gut said her way was clearly the better approach. As I recount it now, it seems obvious that a focus on the present is in fact the way of mindfulness and relationality, while a focus on heaven the way of idealism and fundamentalist evangelicals. That should have been my first red flag as I seek to be neither of the latter two, but then again I've always been a recovering idealist at heart.

The Grieving Process

So why, then, if it is so painfully clear that I should release my grasp on the absolute and be focusing elsewhere, do I feel so reluctant to do so?

Then it hit me. Grace. My wife's sermon illustrated grace - undeserved reconciliation even before repentance takes place. I've always believed in this grace, but that was actually the problem. Real grace is a hard thing to swallow, especially when you know you don't deserve it, and my eternally-focused viewpoint allowed me to hide from the painful reality that I'm not pulling my weight here on earth and the humiliating feeling of receiving something so beyond my deserving (also therefore missing the incomprehensible grandeur of the true grace that God offers). Grace in this heaven-focused paradigm is watered down to a mere shadow of itself, for the full gravity of it is logically inconsistent in that setting. For this reason, life took on a subtle meaninglessness, leaving me only the absolute to cling to. Allow me to explain:

If live rightly at an 80% capacity, let's say God's grace covers that 20% failure and gets me into heaven. I appreciate that greatly, but since the real goal is heaven anyway, I appreciate it only in the sense that God has picked up my tab, so to speak. The fact that the finite world is 20% short of being a better place doesn't really matter much in an eternal sense. This makes complacency easy, and sincere repentance (that should follow the undeserved reconciliation) very hard.

However, with a world-focused spiritual paradigm, that 20% failure in the world really matters. Now, not only is grace picking up my tab and getting me into a heaven I don't deserve, it is also God forgiving the personal affront of my complacency in the one area that really matters. Thinking that my main goal in the universe has been handed to me and it is only a secondary task that is 80% complete is palatable. However, realizing that my main purpose in the universe and God's top priority for me is only 80% complete when I could have easily striven for 100% pains me greatly. Getting into Heaven would happen anyway. That's grace, and that's up to God. But the one part that really matters, that was really up to me, I blew. Ouch. 

That's why I clung to the absolute. It let me justify mediocrity and complacency. It let me pretend I don't actually have to go out and feed the hungry, donate a liver, or what have you, to bring the kingdom of God on earth no matter the personal cost. It let me stay numb and never have to truly repent.

Resolution

I now see, for the first time, the true importance of mindfulness. I now see, for the first time, the real value of relational truth. I now repent, for the first time, more earnestly for I am utterly ashamed and horrified at my satisfaction with 80%.

Over the coming weeks I'll be reevaluating a lot of lifestyle habits and ideologies, weighing them against this new paradigm shift, and making sure that the implications of my artwork support this new worldview (I suspect it has in fact led me here and supported it all along, and it is only now that I'm catching up with it, but it can't hurt to double-check).

And so I feel like I've been led by the hand of the resurrected Christ back to the empty tomb in order to lay down my idealistic tendencies towards the absolute. They must be buried there so that I can rise to a fuller eternity, one that encompasses the here and now in its breadth. Does the absolute still exist? It very well may (in fact I think it does), but it cannot be my primary focus. I feel like my wife was Mary in the story, passing along Jesus' greeting to me on the street. I for one am eager to meet him in Galilee.

If you've read this entire post, first of all, God bless your tenacity! (I'd apologize for the time you've lost reading it, but frankly look at how much time I spent writing it!) I can only hope it has been edifying to you in some way. Secondly, I urge you to think deeply about the logical conclusions implicit in your own most basic pre-assumptions, whatever they may be, and take a good hard look at the way you live in response to that. Lastly, I sincerely hope you discover the joy of this world so that you might have both this world and the next to their fullest, being reconciled to the great Creator in unfathomable ways.

Peace, Introspection, and Easter Baskets,
- Eric