Showing posts with label showandtell. Show all posts
Showing posts with label showandtell. Show all posts

Friday, May 26, 2017

Head Move Donkey V02: progress


After this post on my donkey update I learned some things, much of it from Adafruit Support on the forum in this thread.

First I was concerned with a statement in the MusicMaker Learning Guide "Don't forget to make sure you have a good strong 5V power supply - especially if you're using the 3W 4 ohm speakers! " It turns out that I was able to do what I needed with the 3.7V LiPo--I noticed no difference in output using the 5V 2A  wall wart.  I was even able to run everything off the 4xAA battery pack (using NiMHs only give 1.2V each, 4.8V total).  However, when I added the second Servo. I needed 2 power supplies.

Second I had trouble getting decent volume from an 8Ohm .5W speaker. I was directed to use 4Ohm 3W speakers.  I tried an 8Ohm 2.5W speaker I took out of a CRT television amd that was fine, but it's too big for the donkey.  I got some 1.25" 4Ohm 3W speakers off ebay, but they did not produce enough sound.  The smaller Adafruit version did the trick.

Third, I cooked an SD card and a MusicMaker.  I think it was while I was experimenting with power options...I may have mis-connected something.  First symptom was that it could not initialize the SD card.  I replaced it, and it got past initialization and said it was playing music but it wasn't.  Back to Adafruit for replacement board.

The reason for the second Servo is that I decided to move the donkey's tail, too.  I move the Servos in opposite directions, just because for grins.

Here's my appearance with the project on Adafruit's Show and Tell. I'm on from about 11:30 to 14:00.




Monday, December 26, 2016

I upgraded my computer--including stupid technician tricks

System Information (from Control Panel/System)


The last two times I was on +Adafruit Industries #showandtell, my video was unacceptable.  That's a minor irritation for me, but the second time I had my seven-year-old-granddaughter on. She was able to get through it, but it was a struggle.  Show and and Tell is a Google Hangout, and the minimum requirements include a quad-core processor.  I had been getting by with an AMD Athlon X2 dual-core processor and ASUS Motherboard for the 3 years I've been participating by shutting everything else down and running just one tab on Chrome for the hangout, but I guess Google's "enhancements" have rendered my computer obsolete.

The computer was an 8-year old home-build, and has served me well, but I decided that I needed to get my granddaughter on again in fine style, so I bought an AMD 8-core processor and ASUS motherboard. Actually I bought an ASRock motherboard first, but I had some issues with the build (see below) and I read reports of this mobo bursting into flames, so I returned it and ordered the ASUS. I will report here after I try Show and Tell again, but so far it's great.

Additions

I also ordered a new graphics card.  I'm not very happy with it. First, the description, the invoice, and the parts list all say it supports DirectX 12.  What Newegg sent me supports DirectX 11.2, according to the box. I returned it for replacement, expecting them to fix their error right away.  It turns out that they refused to replace it until the receive the one they sent in error.  So, I changed it to refund and ordered a new one.  I got the new one 5 days before they received the return. To my surprise, it was the same version. Newegg has been good in the past, but this is not good.  Over 2 weeks later I still do not have a refund.  

In addition, I got this card because Microsoft says that the Windows 10 video capture tool works with AMD Radeon R7 and later. However, it's still telling me that my video card is not good enough for them. More research.

The motherboard has an  M.2 slot for what is essentially and SSD stick.  When I get around to it, I will add a 250GB SSD using this new, smaller, faster technology.

The motherboard also has COM header for a serial port, Since my ham radios are able to work digital modes through a serial port I ordered one from China and will hook that up to enable me to experiment with digital modes. More learning and excitement!

Since the 650W power supply I had in the machine had failed recently, I had replaced it with a 800W supply.  Underpowering a system is an invitation to frustration, so if you're upgrading, don't forget to be sure that you have a power supply that will meet all the requirements of your new system.

Stupid Technician Tricks

I won't go into detail on the big one (it's embarrassing and I know better), but here are some suggestions for installing an AMD CPU on a motherboard:
  1. lift up the lever next to the pad on the motherboard
  2. align the arrow in one corner of the CPU with the arrow on the motherboard pad (also check the pattern of the CPU pins to be sure they align with the pattern on the pad
  3. only after the CPU is seated properly, push the lever down
  4. check that everything is secure BEFORE adding the heatsink/fan assembly
Enough said, except that the overarching recommendation is "Take your time!"  

The only other problem I had was minor:  the hard drive light was not lighting. Obviously, I connected it wrong.  Lesson: double check your connections before you plug in the unit, and check that everything works before putting the case all back together.

Activation

Initially, I thought I may need to buy a new copy of Windows, but I read up on Microsoft's digital license policy and made sure that I was all set up.  I had Windows 10 Pro, installed as part of Microsoft's free upgrade program. Since I had purchased Windows 8.1 Pro, it upgraded me to Windows 10 Pro.  After I fired up the  machine I was not asked to activate Windows (although Office 2010 did ask to be activated--quick and easy).  I did get a message "you need to fix your Microsoft Account."  Google revealed that I needed to update a user. When I went in to do that I was told I couldn't because Windows wasn't activated.  I went through the activation process--which tells you you need to buy a new copy but has a non-prominent link "I recently upgraded my hardware."  I clicked that, and after a couple of "our servers are down" messages, I was able to activate.  Done,

I use Norton Security provided as part of my subscription to Comcast.  Norton said it had expired.  I couldn't convince it that it hadn't, and Comcast help was typically useless, so I uninstalled it and reinstalled and all was forgiven.

Summary

I have a fast new machine that should work with the Adafruit Show and Tell Google Hangout. Everything is activated.  I have and upgrade path to an SSD and will have a serial port to use for ham radio digital modes as soon as it arrives.  Overall I'm happy with the build.

The only issue is the video card.  I read on the interwebs that others with this card have had the problem Windows 10 video capture.  I'm working on it.

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.

Saturday, November 1, 2014

Halloween Candy Cauldron

Here I am demonstrating this project on the Adafruit Show and Tell--my video feed wasn't working too well that night, but I got a Sticker!




While I was working on an Arduino project that involved sound, all the Adafruit shows I watch were talking about Halloween.  So, I decided to do a Halloween project. Here's a short video demonstration

It will be more elegant next year (see "Future" below), but here's how it went.

Project

The video really says it all. When someone reaches in the cauldron for candy, the cauldron shrieks/laughs/says boo/howls/etc, A distance sensor detects the hand, and code on the Arduino then plays one of 9 sounds stored on an SD card at random, through an amp to a speaker. That's it.

 Problems

The only real issue I had was with the sound files.  It took me a while to diagnose because I had some other dumb things going on at the sane time, but the key is that the TMRpcm library I used is fussy about file formats. See the "Software" section below--basically, I had to download a free sound editing program and convert the files to a format that worked.  

Also, I cooked an amp (not sure how, but there was smoke).  When I installed the replacement it didn't work, Then I noticed a blob of solder where it shouldn't be (probably my fault--left from when I soldered the headers and terminal block).  I got out my soldering iron and solder sucker, removed the blob, and it worked fine. 

I don't know if my problem with the PIR sensor was me or the sensor.  I have a replacement that I will try when I have time--for next year, anyway--but the ultrasonic distance sensor worked fine, so that't what I used.

I did have to work on the code to find the right value to test for from the sensor, but that is to be expected (see "Software" below).

I used the Adafruit Class D Mono amp because my DIY amps were not loud enough.  It's very inexpensive, reduces complexity, and takes less space (but does require a little soldering).

Cost/Skills

Cost depends on what you have on hand.  Assuming that you have an Arduino, a usable speaker, and the support stuff like wire, batteries, breadboard, SD cards, etc., the rest of what you need should cost under $15.You may have some of the other components, and that would bring the cost down.  If you don't have an Arduno, you can buy an UNO for ~$18.  Smaller boards are less expensive (as low as $5), but you may need to do some soldering and you may miss some features (and necessities like cables to connect to the IDE on your computer).

This project does not require a lot beyond a basic understanding of how an Arduino works. It's probably possible to buy all the components and get this to work. However, if you don't know what the Arduino IDE is, for example, you might want to read up a little. I recommend that anyone who is new to Arduino and/or microcontrollers get a starter kit like this or this or this, and find some tutorials like Jeremy Blum's or the Adafruit Learning System. I got mine for Christmas last year and I'm having a ball!

What you'll need
  1. Cauldron: (I got mine from CVS for $1.99)
  2. Arduino Uno: (I'll use a smaller board next year, like an Adafruit Pro Trinket)
  3. Arduino IDE
  4. Seeed Studio SD shield: (worked fine, but I'll use a breakout next year to conserve space--like this one)
  5. Adafruit Class D Mono Amp: (I tried two DIY amps--one with complementary NPN/PNP transistors and one with an LM386 IC, but neither was loud enough. The Adafruit amp for $3.95 is plenty loud, takes up much less space, and has many fewer connections).
  6. HC-SR04 distance sensor: (I could have used a PIR motion sensor, but I think the one I had wasn't working, and the distance sensor worked so I stuck with it)
  7. Speaker: I  harvested a 4" 8Ohm speaker from a clock radio that had an issue with a power surge; any speaker that works with your amp will do (4-8Ohms for the Adafuit)
  8. Audacity (or similar) for editing sound files (see "Software" below)
  9. Half-size Breadboard
  10. Hook-up wire
  11. SD Card that fits (I used an 16G standard size for this shield)
  12. 9V Battery
  13. Snap connector with 2.1mm jack: I bought a jack at Radio Shack and soldered it to a snap connector that I had
  14. Utility knife for cutting the cauldron
  15. Maybe a soldering iron and basic soldering skills, but this can be done without any soldering.
  16. Small project enclosure (if you decide to go the whole way; in that case you'll also need a drill to make holes in the enclosure to connect to power, the sensor, and the speaker)
Circuit


Wiring

HC-SR04 at top, speaker on right, amp on breadboard, sd shield stacked on Arduino Uno

Speaker:  the leads go to the corresponding connections on the amp. I soldered the terminal block to the amp, so my speaker connects there.

HC-SR04
4 pins: 5V and GND to 5V and GND
Echo and Trigger Pins to digital pins as defined in sketch (I used D7 and D8, respectively).

Amp:  
speaker as above
A+ pin goes to the speaker pin (Digital 9 in my sketch)
A- to GND
Vin to 5V rail
GND to GND

SD 
The shield just stacks on the UNO's headers.
For a separate breakout there are 6 connections: the 4 SPI connections (CS to CS as defined in the sketch--mine is Digital 10, MOSI to D11, MISO to D12, CLK to D13), 3.3V rail, and GND.
Note that some smaller boards only operate at 5V or 3V logic. In another application, I used a 3V Pro Trinket, powered the SD from 3.3V on the Trinket and powered the Trinket and all other components off the battery.
If you have a 5V board, you may need a voltage regulator and a logic level shifting board to get the SD card to work (a solution to that is the Adafruit board that can handle 5V--more expensive, but less work).


Arduino
9V to barrel  jack
5V to breadboard + rail
GND to breadboard - rail
Other pins are  connected as described for individual components:
D9 to amp A+
D7 & D8 to HC-SR04 Echo and Trigger
For the SD Shield, all Arduino pins for SD are handled by stacking the shield, but (only) if you're using an SD breakout board:
D10 to CS, D11 to MOSI, D12 to MISO, D13 to CLK, 3V to power in
Close-up (a little fuzzy) view of amp and Arduino


Software

I used the Arduino TMRpcm library to play the sound. First, I needed sounds, so I went to http://caseyscaverns.com/4/halloween5.html and downloaded some sounds (I selected 9).  I discovered that TMRpcm wants specific formats and sampling rates (check the wiki).  I had do download Audacity and use it to convert to 16Khz sampling rate and 8-bit PCM wave format. Once I did all that, I copied the files to the SD card.

The Arduino code checks the distance sensor, which returns time for a roundtrip of the sound in milliseconds.  Since sound travels 29.1 cm/ms dividing by 29.1 yields cm per round trip. Since we only care about the one-way distance, we divide that by two.  In my case, the cauldron is about 15cm wide, so I checked for <12cm (meaning that if it finds something closer than that, it's probably someone reaching in for candy.

The Serial stuff allows me to use the serial monitor for debugging.  I first had the distance sensor set at 16cm and that caused it to always see the other side. Using the serial monitor showed me what was going on--it was returning 15cm every time, always <16, so it always played a sound.

The random function returns a number from 1 to 9, and the sketch requests one of the 9 sounds accordingly. I have a long if/elseif construct to do this.I wanted to put the filenames in an array and just reference the one I want using the random number as an index, but the IDE did not like that. I also tried a switch/case construct that did not work. I'm sure I did something dumb in one or both of those cases. This code works, but I have more stuff to investigate.

/*******************Arduino Sketch*******************/

/*2014-10-05
Halloween Candy Cauldron: Play random sound when someone reaches in for candy
*/
/*2014-10-05 HC_SR04 Distance sensor code added
Needed to modify pins for Halloween (13&12 used by SPI)
 2014-04-26 Downloaded from Instructables
 HC-SR04 Ping distance sensor]
 VCC to arduino 5v GND to arduino GND
 Echo to Arduino pin 13 Trig to Arduino pin 12 (used 8&7 instead)
*/

/*includes*/
#include <Wire.h>   //SPI
#include <SD.h>     //need to include the SD library
#include <TMRpcm.h> //library for playing sound

/*constants*/
#define SD_ChipSelectPin 10  
#define trigPin 8
#define echoPin 7

/*variables*/
int song = 0;   // song number for random function

/*objects*/
TMRpcm speaker;   // create an object for use in this sketch

void setup(){
  randomSeed(analogRead(0));  //initialize random (A0 unconected)
  pinMode(trigPin, OUTPUT);   //pins for distance sensor
  pinMode(echoPin, INPUT);
  speaker.speakerPin = 9; //output to amp
  speaker.loop(0); //2014-10-05 do not play repeatedly
  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin)) 
     {  // see if the card is present and can be initialized:
     Serial.println("SD not initialized");
      return;   // don't do anything more if not
      }
   else
      { 
       Serial.println("SD initialized");
     }     
  speaker.volume(1); //may  make it louder
}
void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW);  
  delayMicroseconds(2); 
  digitalWrite(trigPin, HIGH);
//trigPin must me high for 10 microsecs to do ranging
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
//duration is the time between pings of the sensor  in microseconds as returned on echoPin
  duration = pulseIn(echoPin, HIGH);
//duration is a round-trip, so divide by 2; speed of sound is 29.1 cm/microsec, so distance is in cm
  distance = (duration/2) / 29.1;
//2014-10-05 If distance is <6in (~16cm) someone put his hand in
//2014-10-20 12cm works better in the cauldron I bought
  if (distance < 12)  
    {
      song = random(1,10); //get random number from 1 to 9
      Serial.print("song: "); //for debugging
      Serial.println(song); //for debugging
    if (song == 1)          {
       speaker.play("1.wav");
     } else if (song == 2 ) {
       speaker.play("2.wav");
     } else if (song == 3 ) {
       speaker.play("3.wav");
     } else if (song == 4 ) {
       speaker.play("4.wav");
     } else if (song == 5 ) {       
       speaker.play("5.wav");
     } else if (song == 6 ) {
       speaker.play("6.wav");
     } else if (song == 7 ) {
       speaker.play("7.wav");
     } else if (song == 8 ) {
       speaker.play("8.wav");  
     } else  {
       speaker.play("9.wav");
     }
     
  //      case 1:
//        sound = songs[song];
//          Serial.println(sound);
 //      speaker.play("5.wav");
          delay(5000);

  }
    Serial.print(distance); //for debugging
    Serial.println(" cm"); //for debugging
  delay(50);
}
/*************************end sketch**********************/

Cauldron

Since I didn't have the circuit enclosed, I put the Uno with the SD shield stacked on it, and the breadboard with the Amp plugged into it, at the bottom of the cauldron. I fixed the HC-SR04 under the lip of the cauldron top using hookup wire. The cauldron was black and has circles for faux handles on the sides, so I cut one of those out and fixed the speaker facing out with hookup wire.  After making the connections as described above, I cut out a circle of cardboard for the candy to rest on while protecting the speaker.  Aggressive hands had a tendency to pull the wires and disconnect them (hence the enclosure for next year).

I found that I needed the battery outside of the cauldron so I could detach it easily and also could swap out batteries as they drained. When the battery gets under 8V the circuit becomes erratic.That takes a few hours, depending on the battery quality.

One note: if the candy is piled too high, the sensor detects it and always returns a value less than 12cm, so the sounds play repeatedly, not just when someone reaches in.
Cauldron with cardboard insert--note battery on left

Future

Next year, I'll use a larger container. I will also use a project enclosure to protect the boards and wires. I'll use a Pro Trinket or the like with an SD breakout board. I may also try replacing the ultrasonic distance sensor with a PIR motion sensor. The sensor and the speaker will be external to the enclosure.  
I'll also work on the power.  I need access to the battery for changing, so it will probably stay outside. A switch would be nice, so I don't have to disconnect the battery to conserve power while the cauldron is idle.

Happy Halloween! 

This was fun!