Saturday, January 31, 2015

@MAKE Electronics Experiment 19 - logic chips (Part III)-Latching with a NOR

At the end of the chapter, Charles shows how to latch an AND gate to HIGH by putting a diode between the output and input 2, which goes to a 10K resistor and GND, as well as to a switch. Input 1 goes to power. So, at power up, on input 1 is H and input 2 is L, AND ing to L, so the LED does not light.  When the switch in pushed, input 2 goes H, ANDing to H, and the LED lights.  By feeding the output to input 2, when it goes H, the circuit stays H.

As I mentioned, I do not have my 74HC08 AND chips yet. I got a shipment from China today, but it was my 555s, not my 74HC08s.  I wracked my brains trying to figure out how to replicate this latching with the chips I have.  I found a useful example here That got me thinking.  However, I think I really need a gate that is H when both inputs are H. The only other one that might work is XNOR, but I don't have that either. I may be wrong--but I can't figure that out.

Then I figured that what I really need is a latch, and should focus on that.  A google for "latch a logic ic to low" yielded this.  I followed the directions for an "Active-high circuit: Both inputs are normally tied to ground (LOW), and the latch is triggered by a momentary HIGH signal on either of the inputs" (same web site).  That's what I have on the NOR Gate.  Both inputs are L, and are taken H the corresponding button is pushed.  

So, I used the gate on the opposite side of the chip. I added 10K resistors to GND on the inputs. Input 1 was tied to the output of the other gate.  Input 2 was tied to switch 2, so it goes H when the switch is pushed.  The output goes to Input 2 of the other gate.  Input 1 of that gate is still connected to the switch, and output to the NAND gate as before, in addition to input 1 of the other gate.

As before, on power up the both inputs to NOR gate 1 are L, so it's output is H, causing the NAND gate to output L in response to it's 2 H inputs, and the LED is dark.  Also as before, when we press switch 1 the output of NOR gate 1 NORs to L and the NAND gate goes H and the LED lights. HOWEVER, when we let go of the button, the LED stays lit because the output also goes to the other NOR gate which now goes H and feeds that back to input 1 of the other gate. The light stays on until it's reset, which happens when the other button is pressed, causing input 2 of gate 2 to go H and the output to go L, causing input 2 of gate 1 to go low, causing the output of gate 1 to go H as at power on.

Not as complicated as it sounds. See the reference for diagrams and further explanation.

Here's the video.

Friday, January 30, 2015

@MAKE Electronics Experiment 19 - logic chips (Part II)

I still do not have the 74HC08 AND chips, so I moved ahead and used what I have.  I took out the 00 and replaced it with a 74HC02 NOR chip. NOR is not or. OR logic yields a HIGH result (or TRUE, or ON, or 1) when either input is HIGH, and LOW if both are LOW (or FALSE, or LOW, or 0). NOR is the opposite--only HIGH if both inputs are LOW.

I was reminded that NOR chips are the only ones with different pinouts, so I had to do some minor rewiring, but that's OK.  Once I got the chip in, I pushed the buttons like yesterday.  On power up the LED is on, just like yesterday. However, if either or both buttons are pushed, it turns off.

Next I wired up the NAND chip again, moving the LED and 1K resistor down to its output, connecting one input to power (so it's always HIGH), and the other input to the output of the NOR chip. Now the light will turn off if the output of the NOR is HIGH.  We know how to do that: as in the previous paragraph, if neither button is pushed, it sends a HIGH signal to the NAND chip, making both inputs HIGH and turning off the LED.  If I push either button, the signal is LOW, and NAND turns on the LED.  Very cool.

Here's the video.

Thursday, January 29, 2015

@MAKE Electronics Experiment 19 - logic chips (Part I)

There is not much to Experiment 19, but it's still really neat.

This is the first use of logic chips, and Charles is just introducing the concept. In this experiment, we use a 74HC00 quad 2-input NAND chip and a 74HC08 quad 2-input AND chip.  My 08s have not arrived from China yet, so Part I deals with the 00.

Logic chips use Boolean logic, taking False as 0 and True as 1.  Since there are two inputs, the Boolean operation yield an off or on (logic LOW or logic HIGH) condition.

The 00 applies a NAND, or negative and, operation on the two inputs.  This means that it's the opposite of an AND operation, in which both inputs must be true (or on or HIGH) to yield a true (or on or HIGH) output.  The negative of that means that NAND yields a true (or on or HIGH) result unless bioth inputs are true (or on or HIGH).

Here's a truth table (T=true or on or HIGH, F=false or off or LOW):

input1     input2   AND  NAND
  F             F            F          T
  F             T            F          T
  T             F            F          T
  T             T            T          F

In the experiment, we first have to supply 5V, regulated, to the chip.  We take the 9V input (in my case from a Compact Switching Power Supply - Selectable Output 3-12VDC from Adafruit), through a 7805 voltage regulator and 2 capacitors to smooth it out. The output of the 7805 (4.95V by my meter) supplied the chip. Charles calls for a 33uF capacitor, but I only have 22s and 47s, so I used a 47.

The circuit only used one of the 4 gates. 74HC00 is a 14-pin chip.  Pins 1, 4, 9, and 12 are input1. Pints 2, 5, 10, and 13 are input2.  3, 6, 8, and 11 are the outputs from the corresponding inputs. 14 is power and 7 is GND. Gate 1 is pins 1 and 2 with output on pin 3.  All other input pins are tied to GND (LOW), and the other 3 outputs are floating.

The inputs 1 and 2 (pins 1 and 2) are connected to power through a normally open momentary switch., with 10K pull-down resistors connected to GND. Output (pin 3) is connected to a low-current LED, which is connected to a 1K resistor to GND. Each input is LOW unless the button it is connected to is pushed, closing the connection to power and taking it HIGH.

Here's the schematic and breadboard layout:

Figure 4-46
Figure 4-47

Both figures are from Charles Platt, Make: Electronics, First Edition, Maker Media, Inc., 2009, p. 182.

Both inputs are LOW on power up. Pressing a button takes its input HIGH. Referring to the truth table above, we expect the LED will light unless both inputs are HIGH. This is in fact what happens: when the power is connected, the LED is on and stays on unless both buttons are pushed. See the video here.

Sunday, January 25, 2015

@MAKE Electronics Experiment 18 - 7-segment displays, 4026 counters, 555 timers

Here's the latest, from +Make: Electronics. Experiment 18 uses 3 single digit 7-segment displays, 3 4026 decade counter chips (1 for each digit, chained together so they roll over), 3 555 timers to get the circuit to run by itself.

I did a video but it was too big for Blogger to handle. See it in this post on Google Plus.

After I did the video, I added another 555 (actually the other side of the 556), an LED, and some additional resistors and capacitors.  The book gives really clear directions, My only variations were using the 556 (because I thought that would be interesting), using 3 1-digit displays instead of a 3 (my 3s are not individually addressable--only 12 pins as opposed to the 28-pin version Charles used). Also, I turned on the decimal point between digits 2 and 3 just for grins.

This was fun.  I just got a bunch of 7-segment displays from ebay, and it's interesting to see how to control them through chips only--no programming,

On power up, the counter runs. You stop it and clear it, then hit the start switch, After a delay, the LED lights and the counter starts.  You the hit the stop switch to time your reflexes. I almost got there, but I had some sparks and some component is likely fried. Since I got it almost working, I'll move on.

The next exercise is using logic chips, and I really want to do that. I ordered a whole bunch of them from ebay, but not all have arrived yet, including one of the 2 chips I need for this experiment.

While I'm waiting, I think I'll get the 7-segment displays working with arduino. In addition to the 1-digit displays I have some 3- and 4-digit ones., That could be interesting.  Less clutter on the breadboard...kind of cheating, which is why I wanted to do it Charles' way first.

Update 01/26/2014:  it turns out that the only thing I fried was the LED.  I got it working again (there were a couple of loose connections, too).  I think I will go on and fuss with the capacitor values to see if I can get it to count close to real time by 1/100s of seconds. could be fun. That, and the Arduino thing.

Update 1/27/2014:  the closest I could get was replacing R8 (2K2Ohms) with a 10K potentiometer (actually a knob I took from a fried clock radio) and 22 microfarad capacitor for C2.  Spec for C2 was 68uF but all I had was a 47.  Charles said to use a .1uF (then on the next page he said 1, which I think is what he meant because he said a 10 was 10 times the value).  I tried several values from 1 to 100, and settled on 22 because that gave me the most responsiveness from the pot.

This whole thing was really interesting--using different chips in multiple configurations, playing wiht the speed of the timer displayed on the 7-segment devices, etc.

Monday, January 19, 2015

Mario Question Block from @adafruit - Final(?)

It's finished. See video

The final steps were:
  1. desolder the floating wire on the LED+
  2. desolder the GND wire, cut it to the same length as the + wire, resolder
  3. cut wires to go from LED1 to LED2
  4. solder LED1+ to LED2+ and LED1- to LED1-
  5. uncscrew the Piezo, drill the holes to expand, and refasten
  6. use tack to fix the backpack on the Trinket
  7. place the switch in it's holder
  8. mount the Trinket (this was not great--the screw head strips, but I got enough in to hold it)
  9. close it up (this was hard, because there's a lot of stuff in there and the cover still does not fit perfectly, but I got it)
This was not +Adafruit Industries' greatest tutorial.
  1. It says that the LEDs should be connected in series when only a parallel connection works
  2. There is no mention of the battery--where to position it, etc--the answer apparently is "stuff it in any way you can."
  3. The wiring diagram shows all wires coming out of the top of  the Trinket. Some must come out of the bottom. There is no mention of that in the text.
  4. The stuff about tolerances for 3D printing was not obvious (to me which is OK because I don't know anything, but it was also not clear to the 3D printing service I used)
But, it's done. On to the next project.

Sunday, January 18, 2015

Mario Question Block from @adafruit - Part V

I got the LEDs to work.

  • I verified all the other connections
  • I tried a 5mm LED in the circuit instead of the LED sequin I desoldered--no change
  • I put the LED sequins in series on a breadboard, powered by a 5V 1500mA wall wart--they both lit
  • I checked the datasheet for the LED sequins, Max forward current is 25mA. Average forward voltage is 3.4V at 20mA.
Trinket Pin #4 puts out 20mA.  I'm not sure there's enough juice juice to power the LED sequins in series.  Everything I've read says to put them in parallel, but I'm going by the instructions in the tutorial. I never got a response to my query on the Adafruit Support Forum.

However, I wired the LEDs in parallel as opposed to series, and they both light. I have given feedback on the tutorial.

Next: put it all back together and wear!

Friday, January 16, 2015

Mario Question Block from @adafruit - Part IV

I drilled the hole in the case for connecting the Trinket.  From the webs, I ascertained that I needed about a 1/16" bit (.0625 for a .067 screw).  That worked. I was able to attach the Trinket, but I'm holding off on the final solution until I get through some of the following issues. I got some 2-56 3/8" screws, Philips head, and they work much better (I replaced the screws for the Piezo, also).

I put my meter on the circuit (DUH--learning the obvious lesson: do this DURING assembly to assure the connections will work).

First, I verified what the switch was telling me--I did not completely remove the trace between the pads on the backpack, so the circuit is always open and the switch had no effect. It looked OK to me, but I did some more scraping and now it works.

Second, I checked the LED connections.  My meter showed continuity throughout.  Using alligator clips to jump various connections, I could get one or the other LEDs to light, but not both.  I desoldered one, and tried various combinations of connections with no luck. It occurred to me that maybe the battery did not have enough juice, but according to my meter it's putting out 3.96V, and it's rated at 3,7V. I also tried it connected via USB--no change.

Meanwhile, the Piezo wires came loose from the Trinket and I had to resolder.

I have posted a query on the Adafruit Support Forum about the LEDs. If I get an answer, I'll move on. If not, I may try it with 1 LED (which was the original design).

Sunday, January 11, 2015

Mario Question Block from @adafruit - Part III

OK. Problem 1 is that, despite +Phillip Burgess ' warning, I soldered the Piezo to the Trinket before I wired it correctly (in my defense, I did heed the warning, I just wired it wrong). I thought I knew which hole to pass the wires through, but after I did it I realized something was wrong.  Here's what that was:

  1. the tutorial is not crystal clear
  2. the hole I was supposed to used was partially obstructed by printing debris so I did not recognize it as a hole
  3. I did not pay attention closely enough
So, today's work:
  1. search local stores for shorter 2-56 screws
    I got 3/16" flat, slotted heads--the Phillips were beveled and did not provide enough thread (I would have liked more detail in the tutorial for this because I'm ignorant, but I got there)
  2. detach the Piezo and re-attach it with shorter screws (as noted in the last post, the ones I used were too long)
  3. deburr the hole for the Piezo wires
  4. cut the wires from the Piezo, string them through the newly deburred hole, and splice them to the other part of the wires connected to the Trinket
  5. tack the backpack to the Trinket
  6. cover the on-board LEDs with black tape (I know I have several rolls someplace, but in the interest of sanity I went back to the hardware store)
  7. screw the Trinket to the enclosure
  8. modify the diffuser so it will fit in the new cover  (also had to clean up the location for the diffuser--I guess I should have anticipated this, but I expected a cleaner print from the service--now I know why Charles Platt in +Make: Electronics wanted me to by a bunch of files and deburring tools)
  9. hook up the LiPo and charge it
  10. test and rework as required
However, I have some serious problems.
First, the screw hole for the Trinket is filled in and I cannot get it to screw in.  
Second, the switch does not turn the circuit off--I have to disconnect the battery. I followed the instructions on clearing the connection between the holes on the backpack--maybe I did not get it right.
Third, the Piezo chimes, but the LEDs do not flash. The connections look right to me.

So, I have more work to do.

Saturday, January 10, 2015

Mario Question Block from @adafruit - Part II

When last we saw this, I was waiting to get replacement 3D printed parts back from the service I used. The first print was missing the handle and the cover did not fit. New parts arrived yesterday.  It has the handle, and the cover fits. I'm a little disappointed because I started this about 6 weeks ago, but I'm ready to go. I'll put on my white lab coat and get to it.

The first thing I tried to do was upload the code to the Trinket (so I will have when I get the product assembled).  After I located a mini-USB cable I found that I forgot to update my Arduino IDE (I knew that because I got "PLLCSR not defined in scope" etc. on compiling).   DUH--I needed to set the board to Trinket 8MHz, but first I needed to update my hardware folder. Then, I went to upload and got my favorite avrdude messages.  DUH--I forgot to add some other changes. Of course, the Adafruit Learning System has all this spelled out here.  I'm sure I saved some frustration later on when I'll be anxious to try this out.

Later that day...
The good news is that my new soldering iron and heated solder sucker work really well. I made it mostly through the project, to get here:
I got the soldering done, following the tutorial I had one issue: the first diagram shows all the wires from the backpack coming out of the top. That's wrong: the wires to the slide switch come out the top, but the 5V, BAT, and GND wires go out the bottom. So, I got out the new solder sucker and re did them.  I am supposed to attach the backpack to the trinket with tack...I need to redo that.  I also need to fix screw the trinket to a standoff.  T

Also he only 2-56 screws my local hardware store had were too long too attach the piezo. I can make do until I get a shipment from sparkfun next week. 

The only other problem I have is that since my frindly 3D printing service did not re-print the diffuser, it doesn't fit. I'll had to do some modifications..  

I should get back to this tomorrow.

Software Recall for Autonomous Cars?

On the theme of +Adafruit Industries Show and Tell ad hoc series on retrotech, the appearance of autonomous cars at CES 2015 reminded me of a presentation by the late Dan McCracken in 1982. By pure coincidence, we were speakers at the same conference.  Since the first program I ever wrote relied on one of his +FORTRAN books, I was excited to go to his session. What I remember most is his discussion (in 1982!) of the ubiquity of technology.  He talked about his car, saying is scared him that he did not know whether or not it had a computer, but he knew his next one would.  This, he said, raised the specter of the first major auto recall due to a software error.

He envisioned this scenario for his friend who like to go ice fishing in northern Maine:
The friend gets up one morning to find his car won't start. He calls the local garage, and is asked "What release of the operating system do you have?"  "2.43"  "That's your problem: 2.43 has a bug in the square root routine. It won't start below zero."

Friday, January 9, 2015

@MAKE Electronincs Experiment 17 Done

In my return to Charles Platt +Make: Electronics I finished Experiments 17 today. 16&17 used 555 timers. I have 10 more on order from eBay, and will do some more fooling around when they come. Interesting that my Elenco learn-to-solder kit that I used almost a year ago resulted in a siren using the 555.

I went through the author's shopping lists for the rest of the book and ordered a bunch of everything, mostly from eBay, some from other suppliers. I'll get mail everyday for at least a month.

Experiment 18, a time reaction game, will have to wait for the 4026 decade counter chips I ordered. That should be a fun use of the 7-segment LED displays I have.

Fun times to come!

Thursday, January 1, 2015

Great things in 2014

Here are some of the great things that happened in 2014 (maybe the best year ever):
  1. I found Adafruit!
    +Adafruit has made my life better. Through this company have have learned more than I imagined I could, and watched and participated in multiple internet shows (4 appearances on Show-and-Tell, a question answered on air on Wearable Wednesday).  My questions on the support forums always get prompt, clear, informative responses. Adafruit is a community more than a company, and I am really happy to be a part of it. AND--I love their products, too.
  2. My electronics projects (and learning to solder)
    I asked for and received a bunch of electronics stuff for Christmas last year (+Arduino, books, etc.). In addition to Adafruit, I got help from +JeremyBlum 's tutorials, and Charles Platt's book "+Make: Electronics." 
    I constructed a bunch of circuits for learning purposes, and will get back to that next year. I also recruited my former (and now current) boss to teach me to solder once I could go no further without soldering.  I'm now have adequate soldering skill. I plane to learn to solder surface-mount components next year.  Some highlights:
        .  In an early success, I could not get the component I needed for Jeremy Blum's tutorial #8 involving digital potentiometers. His spec was for a quad from Analog Devices, but I could not find one.  I got 2 duals from Microchip Technologies.  I ran into trouble following the datasheet to daisy-chain the 2 devices. In the process, I learned about schematics and Eagle CAD. I sought help on the Arduino Forum , but did not get an answer.  Finally, I went to Microchip tech support, and after a phone call I got the answer I needed to get it to work.
        .  The Adafruit candle-flicker hair bow for my granddaughter. She loved it. I made one for my daughter, too. She was less impressed.    . An exhaust fan for soldering using a case fan from an old computer, scrap wood for the frame (it's what I had), some brackets and screws for mounting, a toggle switch, a potentiometer to make it variable speed, a power jack, and a 12V power adapter from a dead laptop. I use it every time I solder.    . A useless flashy thing from the Charles Platt book--taking it a step further by putting it in an enclosure and adding a toggle switch.
        . Talking Halloween Candy Cauldron (see entry on this blog)
        . The Head Move Donkey--also on this blog
  3. My granddaughters continue to be wonders
    Nora loves "playing electronics with Grandpa," including  the candle flicker hair bow, "the E is for Electronics coloring book," and the Adafruit videos (which she calls "Adabot Videos"). We made a lemon battery that she thinks is really neat.
    Frankie turned one this year.  We had the great fortune to have her here for over two months in the summer, including her birthday, and got to see her learn to walk.
  4. My daughters and their husbands are great
    I am very proud of all of them and all they have accomplished.  What a blessing!
  5. Our trip to Canada
    I have always wanted to see the Maritimes, and we were able to go to Prince Edward Island, returning through Maine with a stop in Bar Harbor, where we honeymooned 43 years ago.  It was wonderful.
    PEI was beautiful and peaceful, just the break we needed form Cape Cod in July/August.  Bar Harbor was crowded, but the hotel we stayed in kept us out of craziness, and there was good public transportation into town.