Digital Electronics Lecture 2018 – Assignment for Week 13: Final Project Writeup (for Lecture, Week 3)

This week, I finished up all the hardware I’m going to work on in the time left devoted to this final project.

Back on Thursday, I installed LEDs in their holes and wired them up to the circuit board. First, I bent the positive end to an angle conducive to attaching a long piece of stripped, stranded wire. I soldered the four respective joints and cut the excess. Next, I applied some heat-shrink tubing around the joint to prevent shorting with the bases of the potentiometers or the ground wires on the LEDs (which were installed next).

IMG_7434

To mount the LEDs in their holes, I applied some hot glue around the flanged end of each of the bulbs. Then I pressed them into the appropriate spots on the top of the panel.

I decided to use some tinned, non-insulated copper wire to connect all the grounds. I pulled off a piece from the spool (to straighten it), then wrapped it once around each of the LED leads. I soldered the joints and cut the excess wire. Finally, I installed a long piece of black wire to the exposed end on the newly-created grounding bus. There was no need to put heat-shrink tubing over the joint.

IMG_7451

When this was all done, I used four zip-ties to consolidate the five wires (four outputs and one ground).

IMG_7452

On the other end, I cut all the wires to the same length, and stripped a bit of conductor off each. I tinned the ends to prepare them for attachment to male pin headers. I placed the pin headers in a breadboard and tinned their ends. Then I melted the wires to the pins. I had to ensure that I was attaching the right wires to the correct rows to avoid confusion later.

IMG_7456

At this point, I realized that I would need more female pin headers on my PCB so that I could manually connect the new ground pin to the grounding rail. So, much like before, I cut two bits of female pin headers to an appropriate length to straddle either side of the existing construction atop the board. Then I soldered the far ends of the female pin headers to ensure that they would be flush with the board. Once this was sorted out, the middle pins were easy enough to solder in place. For the new grounding connection, I simply took a piece of black, solid-core wire, and bent it to the same shape as I had originally on my breadboard. Essentially, I now have a custom-made breadboard that’s much smaller and lighter, containing only what I need in terms of connections.

IMG_7464IMG_7466

 

By the end of that day in Lab, I had decided to create a box for my project. Some suggested holding this step until later, but I knew it would be nearly impossible to troubleshoot without some sort of stand atop which my monstrosity could rest. (This is similar to how a car mechanic uses a hydraulic lift to peer at the underbelly of a vehicle to perform sensitive work.)

I booked a time on Friday for the eLab in the afternoon. On a piece of paper, I sketched out a crude diagram of the box I wanted to make. I knew that Jack had already designed his to a height of 4 inches, so I used this dimension value as well. Then, I cut a plate for the bottom and two small sticks for the sides. This housing is not meant to be a fully enclosed box, just something to keep my hands free while tinkering. I was in a hurry, so instead of using the proper welding agent to bond the acrylic pieces, I settled for hot glue. Because this is technically not the best way to construct the box, I was suspecting the thing to collapse pretty quickly. Surprisingly, it actually has held up all week; my connections are pretty strong! when attaching pieces, I used other rectangles of acrylic to ensure that the pieces were being stuck together at exact 90º angles. A little bit of tape did the rest. It all worked on the first try! (Though I had to troubleshoot the printing of the laser. This was the first time that Franklin was not available to help me, so I made a few mistakes during the cutting process. But thanks to Franklin’s training, I was able to rectify anything I messed up. Thanks, Franklin.)

IMG_7487

IMG_7478

Finally, I was free to work on coding. I first got the lights flashing in the proper sequence. Then, I spent some time consolidating bits of code from different .ino files to get the serial properly sent to processing. I created a method that sends out all 6 values (the step number and the pot values for that step) at once when called.

On the Processing end, the serial data was fed into an array that updates every frame. Much like the toggle button syntax used in some of the labs, I recorded the last step value and compared it to the current step value. When they were no longer equal, I triggered an event. The test patch first drew ellipses in rapid succession, with their centers and major/minor axis values mapped to the five pots. The last row of pots was reserved for step length. I’m just using a simple delay() in the loop() in the C++ code on the Arduino side; no need to make things more complicated with millis() as of yet.

Since that point, I continued to work on different visuals. I’m still playing around with different ideas. Some friends were nice enough to make different suggestions. I also talked to Mort, who made suggestions I would only be able to implement in another iteration of this project (that’s for the summer). Each of these different designs have been turned into their own classes, so I can call as many instances of them as I want at a time. Their constructors pass in the relevant pot values, an update() method changes certain values per frame, and a sketch() function is called in the draw() function to put the visuals on the canvas.

Here are some examples of the sketches I’m playing around with:

Screen Shot 2018-04-25 at 4.42.16 PMScreen Shot 2018-04-25 at 12.23.13 AM

Screen Shot 2018-04-25 at 4.44.21 PMScreen Shot 2018-04-25 at 4.42.38 PM

Screen Shot 2018-04-25 at 4.47.33 PM.png

Screen Shot 2018-04-25 at 4.49.04 PM.png

Other than that, I’m basically done with the essential elements of this project! I’m so happy with how this turned out. In the time I have between studying for my other classes, I will continue to work on designing more visuals and sending different types of information via MIDI to a DAW.

 

Advertisements

Digital Electronics Lab 2018 – Assignment for Week 12: Final Project Progress Report Writeup #3

Today was a bunch more soldering and also largely the beginning of getting serial communication up and running.

With holes cut yesterday for four LEDs (indicators for the current step), I went about installing the lights. I soldered four long blue cables to the positive leads on the LEDs. Because the leads on LEDs are close together, I decided to put heat-shrink tubing on the connections so there would be no accidental shorting to ground. Then I pressed the bulbs through the holes and hot glued them. By the last of the four, I figured out a cleaner method of installation: create a small ring on the flanged end of the bulb, so less leaks out over the sides (it looks nicer with the clear acrylic). So, I reheated the joints, cleaned up the excess, and reinstalled the bulbs. Next, I took some solid-core, tinned copper wire and wrapped it around the negative leads of each LED, connecting them all in a row. Because it was of a small diameter, the wire bent very easily around the LED legs, and it was easy to solder. On one of the LEDs, I allowed a bit more metal to protrude so I could run a grounding wire back to the PCB. Once I soldered everything, I cleaned up the ends. There was no real need to cover these ends with heat-shrink tubing.

IMG_7451

I collected all the long ends of wire and kept them together with four zip-ties. The ends were of slightly different length, so for the next step I trimmed them down so the ends were in line with one another. I stripped tiny bits off the ends, and tinned them. I also tinned five male pin headers (four signals and one ground), just like for the four columns of potentiometers. Then I fused the wires with the pins in the proper order. (My trick to keeping the wires in order is to label them with a silver sharpie, with the number of lines corresponding to their placement.)

IMG_7452

IMG_7456

Next, I realized that in order to connect a separate ground, I would benefit from adding more female pin headers. So, I took extra lengths of headers that I had cut yesterday and trimmed them down to straddle either side of the Teensy. I carefully soldered them flush with the other headers. (I learned from my mistake yesterday of not making sure the ends were flush with the surface of the circuit board.)

IMG_7464

I plugged everything together and quickly wrote some code to test that they LEDs function properly — they do!

IMG_7466IMG_7468

On the software side of things, I figured out how to send values in a way that did not require having to parse strings into integers. It was simply a matter of removing my string object on the processing side of things and changing the Serial.available() count from >0 to >=2.

That is all for today!

Digital Electronics Lecture 2018 – Assignment for Week 12: Final Project Writeup (for Lecture, Week 2)

The past lab session was very successful: I managed to wire up all the grounding and bus lines, directly on the panel-mounted potentiometers.

The next day, at home, I decided to wire up all the middle pins, which provide the variable outputs that are read by the Teensy. For the sake of wire management, I used 10 strand ribbon cable (shown below), so all the wires would be stuck together. I divided it into two strips of 5. Each column of the grid would be connected to one of these strips.

 

There was a slight learning curve to figuring out how to best wire these correctly while minimizing cable slack. The center wire of the strip should be the shortest, while those towards the outside should be longer. This way, we do not have extra cable for the center row potentiometers. For the first two rows, I was unsuccessful. (I also wired up one with a color code opposite all the others.) But, by the third column, I had gotten the knack for properly determining the lengths.

IMG_7262.JPGOnce I was done with that, I used a zip-tie to keep all the ribbon cables from getting tangled. I tried to make all the remaining lengths of the ribbons approximately the same, which would become important in the next step. (In retrospect, perhaps I should have used a greater length of ribbon cable, so that I could easily work with the teensy while it was not physically attached to the panel.

Now with the wires to carry the signal, I had to also supply the panel of pots with powers and ground connections. I took four lengths of red and one of black stranded wire and soldered them into their respective places on the ground bus and the individual power busses (per column).

Next, I carefully soldered the ribbon cables to male pin headers. Early on, I realized that a shorter exposed length at the connection is easier to handle. I also figured out that coating the pins with solder in addition to the wire strands made for an easier connection. (Even though they are not all that pretty to look at.) I had a row of 10 headers for the first 2 rows, and another row of 10 headers for the second two. I also had 5 pins for the power and ground wires. (The larger wires in the latter step were harder to handle, because their larger diameter required a greater time to heat up and fuse with their respective pins.) It was important to solder the wires to the pins in the proper order to facilitate proper readouts when I am coding for the Teensy.

Once all this soldering was complete, I used multiple zip-ties along the lengths of these wires to keep everything tidy.

IMG_7289

For now, the Teensy remains on a breadboard, suspended by a vise to reduce stress on the wires. I plan on exchanging the breadboard for a small PCB with the same layout (here are the ones I plan on using: https://www.amazon.com/Gikfun-Solder-able-Breadboard-Plated-Arduino/dp/B071R3BFNL/ref=sr_1_2?ie=UTF8&qid=1523917213&sr=8-2&keywords=gikfun+pcb ). This part of the project is on hold until I receive more female pin headers, so I do not have to permanently solder the Teensy to the PCB. They should arrive within the next day or two, and I can get to cutting them to the correct length (24 pins long) and soldering them to the PCB. Hopefully, the Teensy’s male pins will slip into the headers comfortably. I will also mount female pin headers in parallel to the ones for the Teensy, so that I can connect the male headers attached to the signal, power, and ground wires.

Image result for gikfun breadboard

For now, the Teensy remains in the breadboard. I wired four LEDs in parallel to the digital outs that sequentially power the four rows. One of these did not work. After thinking about it for a while (and unsuccessfully trying to rewire that pin), I intuited that there was a short circuit. Indeed, the bottom-most knob on the third row, when all the way counterclockwise, forms a short; at any other point in its rotation, this problem no longer exists. This is pretty irritating, but for now I’m not going to worry about swapping the problematic potentiometer for another; I will simply (manually) keep this one from being set to zero! Priorities, priorities.

At this point, I realize that my eyes may have been larger than my stomach: the original grand plan was to include another panel of knobs, sliders, and switches. However, I am not in the least dissatisfied, because I have all of time after the semester ends to continue the project. What I have accomplished up to this point has pleasantly surprised me; just “doing it” and ending up with what I have now is super exciting. I have to thank Steve once again for encouraging me to stop pondering and start building the damn thing. The results are tangible and rewarding.

The last bit of electrical work I plan to embark upon is adding an LED atop each row. I’ll probably use some hot glue or tape to mount them (unless I can get my hands on a drill and can realistically make holes without cracking the acrylic). They will be soldered in parallel with the pots for each respective column. I will keep them the same color so as not to confuse things. The addition of LEDs is a functional addition (for debugging purposes) and an aesthetic one (as long as I cleanly mount them and don’t make a mess with the hot glue. If I have time, I might measure out some paneling, so I can finally work with the grid of knobs without having to flip everything upside down (I’m just nervous about putting strain on the wires).

Now, it’s time to spend most of my energy on the coding side of things. The serial communication code on the Teensy side should hopefully be relatively easy; the work on the Processing side of things will be where I concentrate most of my time and energy.

(Time spent so far this week: 4.5 hours.)

Digital Electronics Lab 2018 – Assignment for Week 11: Final Project Progress Report Writeup #2

This week, after having cut the acrylic sheet and installed the potentiometers in their places, I’m starting to create the electrical connections.

As seen below, I intended to connect the grounds on every pot. I also connected the vertical columns of pots to common power lines.

IMG_7228

I had considered several different methods connecting the pots, including stripping midsections of longer wire and using copper tape. However, Steve wisely advised me to just stick to something and get the job done. So, during class today, I wired up all the ground and power wires to the pots. I took great effort to make sure everything looks neat, because the clear acrylic will make my handiwork visible to everyone.

I stripped a bunch of little sections of wire and looped them through the solder lugs on the pots, one by one. I wanted everything to stay in place, even before I had soldered everything down.

IMG_7231

When I was satisfied, I went over to the soldering iron and fused all the joints together with a healthy dose of solder. Using the fume extractor was quite effective when placed over my work in the right place. Beginning with neat wire work made the soldering very straightforward.

IMG_7244

Finally, I went back to my desk and, with a wire cutter, snipped off the exposed ends of surplus wire, radiating in every direction like spines from a cacti.

IMG_7245

The result was a very clean and functional wiring job!

 

img_7246.jpg

Digital Electronics Lecture 2018 – Assignment for Week 11: Final Project Writeup (for Lecture, Week 1)

As Mark suggested, I’ve spend most of my focus this week on the actual hardware for my project.

This past Friday afternoon, I travelled with Jack to pick up a 1/8″X18″X24″ sheet of clear acrylic at Canal Plastics.  (They have quite an interesting selection of different plastics there, who would have figured.)

In addition, my potentiometers (knurled shafts) and knobs arrived in the mail. It turns out that the knobs were poorly labelled – they are meant for pots with smooth shafts, but the description mislead me by saying “knurled.” That was annoying, so I then ordered 20 different knobs, which turned out to be correctly labelled. Also, as Mark suggested, I bought a pair of digital calipers. These would prove very useful in the coming days.

The latter shipment arrived on Monday. I booked a time to use the prototyping lab (in the basement of the Leslie eLab) for Tuesday during the weekend, indicating that I would need someone to stop by and assist me in the design of the Adobe Illustrator file.

IMG_7201Franklin, a guardian at the eLab, read my request, and set aside his time to help. I read out the measurements I acquired with my digital calipers of various important dimensions, including the diameter of the potentiometer shafts, the length and width of the stabilizing metallic protrusion on the sides of the pots, and the distance between these two items. I then determined how far apart I wanted the pots to be placed in relation to one another. Here is a list of the important measurements we found:

  1. Diameter of shaft: 0.27″ (radius = 0.135″)
  2. Distance between edge of shaft and stabilizing protrusion: 0.155″
  3. Width of protrusion: 0.05″
  4. Height of protrusion: 0.083″
  5. Distance (in both x and y-axes) between adjacent pot shaft centers (decided upon by me): 0.65″
  6. Sheet width (decided upon by me): 5.255″
  7. Sheet height (decided upon by me): 6.17″

We first cut a test piece to ensure the measurements were right before we went ahead and duplicated the holes for the other pots.

Carefully inputting these measurements one at a time into Illustrator, we came up with the following file:

img_7200.jpg

Franklin doubled the pass of the laser, just to ensure that all the unwanted pieces would separate. The result was impressive: very clean and even. Thank you Franklin!

 

Popping out some of the small pieces proved difficult, but I eventually managed to wiggle them free with a very small box cutter:

IMG_7210

The whole boxcutter process was reminiscent of wiggling out my baby teeth as a kid: some fell out easily, while others were rather stubborn.

To remove residue, I used cleaning pads containing isopropyl alcohol. This actually took a long time to do thoroughly.

IMG_7214

When I arrived home in the evening, I began placing the 20 potentiometers in their spots. Strangely, it was easier to mount them on one face than the other. I suspect this is due to the fact that the laser may have done a slightly better job on one – the one that was directly facing the beam. Like before, some went in with an audible snap, while others required quite a bit of force on my part. (I just had to be careful not to break the acrylic.)

IMG_7217

Finally, I placed on the knobs — the ones that had the knurled insides. However, they ended up being really long, and I’m afraid that they may fall off too easily. Therefore, I might try to use a hand power tool (like a Dremel) to shorten them.

So, here’s what I’m left with as of now! I’m quite happy and excited with how it’s turning out.

IMG_7221

 

Time Spent: 3.5 hours.

What I have left to do

  • Solder the power and grounding wires.
  • solder wires to a board onto which the Teensy will be mounted.
  • Create a serial communication protocol
    • testing this protocol
  • Interfacing with Arduino and Processing
  • Building outwards: making commit functions and adding functionality
    • [simply dependent on time]

What left to buy:

  • Perhaps mounts or a box? Not essential at the moment.

Digital Electronics Lab 2018 – Assignment for Week 10: Final Project Progress Report Writeup #1

Today, I met with Mark, and we discussed the possibilities for mounting my potentiometers. As of now, it appears that I will use either acrylic or wood, depending on the type of finish I want. Clear acrylic seems like the way I’ll go. It’s also a great opportunity to learn how to work Adobe Illustrator for the purposes of designing files that will work with a laser cutter.

Tomorrow, I’ll head downtown to a shop that sells acrylic sheets. I’ll purchase one that’s large enough to create a box that will house all of the components. The general shape will be roughed out using the resources found at http://www.makercase.com/.

Although my potentiometers had arrived during class back at the dorm, I only had one pot on me. I traced its circular base 20 times in a 4X5 grid on some looseleaf to get a better sense of the dimensions of my design. It’s important to consider the bases of the pots – not just the shafts – because those will be adjacent to one another behind the paneling. I believe the image below demonstrates that I was able to strike a balance between spacing and compactness. This is important because I want to easily handle (and troubleshoot) the components and connections — a cramped spacing would make this excessively difficult. I’m ordering a digital caliper to accurately measure the dimensions of all my components.

Next, I figured out how to send data between the Teensy and Processing. So far, I’ve watched the tutorial below:

This video mainly describes how to send information from Processing to the Teensy, not the other way around. I’ll follow another video for going in the other direction (which I intend on using more). Here are some snippets of code that I wrote today:

Screen Shot 2018-04-05 at 6.25.30 PM
Arduino-side code. Receives information from Processing.
Screen Shot 2018-04-05 at 6.25.48 PM
Processing code (Java). Sends messages to Teensy (Arduino/C++).

Because I plan on reading multiple values at a time from my circuit, I will have to set up some sort of serial protocol for sending multiple values at one time, then making sense of them on the other end (in Processing).

These are the items I successfully worked on during class. Other than that, I was trying to implement a way of adjusting the transparency of subsequent frames in my processing code. Up to now, I have been unsuccessful. I was occupied with this for much of class time, until I realized that it was probably a better use of my time to move on and start designing the physical interface. That was a good decision.

Digital Electronics Lab 2018 – Assignment for Week 9: Creating and Using Custom Classes and Objects

Link to the code for this week:

https://github.com/hexbokeh/Custom_button_class_001

How the BetterButton class works

The BetterButton class is a neatly-packaged way of handling many of the common requirements of working with buttons. Basically, it streamlines the process of working with buttons by hiding much of the code away in the .h (header) and .cpp files. It is also convenient because an unlimited number of instances of a class – objects – can created, thereby recycling the same bit of code, for whatever circumstances the programmer intends to implement.

BetterButton.h

The .h extension implies that this is the “header file” of the BetterButton class. This means that it contains a rough outline of the class, including its public and private components. It contains the declarations for things like the constructor method (which will be called outside the class to instantiate objects), variables, and more. Reading over the header file provides a good understanding of what the BetterButton class is capable of doing.

As far as implementation is concerned, there are several preprocessor commands at the top and bottom of the header document. These ensure that no class with an existing name of ‘BetterButton’ is overwritten. In addition, the main ‘Arduino’ class is invoked by calling its respective header file.

Within the class, all elements are public, meaning that they can be accessed by code outside those that define the BetterButton class. The method with the same name as the class is the constructor. Other functions are named, with return types and arguments; however, none are defined. Finally, essential variables for proper class functionality are named at the bottom.

BetterButton.cpp

The .cpp contains the “meat” of the class, in that it defines the functionality of the constructor, the other methods, and variables. At the top, it also invokes the Arduino class header file, as well as the BetterButton header file just created.

The constructor is set up to receive incoming arguments, and pass these parameters to a newly-created object, an instance of the BetterButton class. Internal variables will store and modify these incoming arguments as necessary, through the execution of other functions.

The three methods other than the constructor (defined below) are also fleshed out.

Explaining the purposes of:

process()

This is the primary method of the BetterButton class. It is constantly running because it is called in the loop() function on a per-object basis. Its purpose is to monitor incoming digital signals from the respective physical button. If it detects a change in state (either a HIGH or LOW) from what there was in the last frame, it calls the appropriate functions. (Read on.)

pressHandler() and releaseHandler()

How does process() know what to do upon detecting a change in state? It needs to know what user of the class wants to happen. To do this, process() calls pressHandler() or releaseHandler(), depending on the nature of the incoming signal. These methods are called upon in the setup() of the code made by the user (I’ll refer to it as the example file). As arguments, they receive the references to the methods that the user has defined, which describe exactly what should happen upon the detection of a button press or release (respectively). pressHandler() and releaseHandler() update the references of the variables pressCallback and releaseCallback, respectively, to point to the user-defined functions. That way, when process() detects a button press or a button release, it knows what function to call, and thus what operations the user wants the Teensy to perform. (In this case, it was to print the on/off state of the button, the number of the button, and send out a MIDI note.)