Categories
Raspberry Pi

Raspberry PI B+

Hardware

Needed

  • Raspberry Pi
  • MicroSD Card 4GB or larger
  • USB Keyboard
  • USB Power Supply and cable with micro USB Connector
  • Display (Composite or HDMI)
  • Display cable (Type of cable depends on monitor)
  • MicroSD Card to SD Card Adapter (Needed only if your PC has a SD Card Reader but not a MicroSD Card Reader)

Nice to Have

  • Raspberry Pi B+ Case (Note cases for other models may not work)
  • WiFi module or Ethernet Cable

Steps

  1. Download the Raspbian Image from http://www.raspberrypi.org/downloads/ (As of this post, the file is 2014-06-20-wheezy-raspbian.zip)
  2. Unzip the Raspbian Image File
    Image2
  3. Follow the instructions at http://www.raspberrypi.org/documentation/installation/installing-images/README.md for your operating system. I will be using Windows and will mirror the steps from the installation instructions page

Windows Installation

  1. Insert your MicroSD card into the card reader on your PC (NOTE: You may need a MicroSD to SD Card Adapter)
  2. Download the Win32DiskImager utility from http://sourceforge.net/projects/win32diskimager/ (As of this post, the file is Win32DiskImager-0.9.5-install.exe)
  3. Install the Win32DiskImager Utility by double clicking the downloaded file
  4. Click on the “Next >” button on the setup wizard
    Welcome to the Win32DiskImager Setup Wizard
  5. Select the “I accept the agreement” radio button and click the “Next >” button
    License Agreement
  6. Click the “Next >” button on the destination location dialog
    Select Destination Location
  7. Click the “Next >” button on the Select Start Menu Folder dialog
    Select Start Menu Folder
  8. If you do not want a desktop shortcut, uncheck the “Create a desktop icon” checkbox
  9. Click the “Next >” button on the Select Additional Tasks dialog
    Select Additional Tasks
  10. Click the “Install” button on the Ready to Install dialog
    Ready to Install
  11. Wait for the installation to complete
    Installing
  12. Click the “Finish” button on the Completing the Win32DiskImager Setup Wizard dialog
    Completing the Win32DiskImager Setup Wizard
  13. It is possible that you may see the following error message
    Unable to execute file
  14. If you see the error message above
    1. Click the “OK” button
    2. Right-click on the desktop shortcut and select “Run as administrator” from the pop-up menu
      Run as administrator
    3. When the User Access Control dialog is displayed, click the “Yes” button
      User Access Control dialog
  15. The application is now open
    Win32 Disk Imager
  16. Click the folder icon and select the Raspbian image file downloaded earlier
    Selecting the image file
  17. Select the drive letter for your MicroSD Card
    WARNING: Be very careful to select the correct drive letter as the utility will erase all data on the drive! You have been warned!
    Select the MicroSD Card
  18. Click the “Write” button
    Write the image
  19. Click the “Yes” button on the confirmation dialog
    Confirm Write
    If you see the following error (), check that there are no open Explorer Windows or other applications attempting to access the SD Card
    Write Error
    If you see the following error, check the write lock switch on the MicroSD Card Adapter
    Lock Error  SD Card Lock Switch
    Wait for the process to complete
    Wait
  20. When the process is complete, click the “OK” button
    Write Sucessful
  21. The main window will display the status as “Done.” Click the “Exit” button to exit the utility
    Done.
  22. Eject the MicroSD Card

Once the Raspbian Image has been written to the MicroSD Card, you are ready to boot and configure the Operating System (OS).

Booting and Configuring the Raspberry Pi using Raspbian OS

  1. Insert the MicroSD Card in the Raspberry Pi
  2. Connect the monitor, keyboard, mouse (optional), and power
  3. The Raspberry Pi Software Configuration Tool (raspi-config) will launch
Categories
Product Review

A look at Adafruit’s Electret Microphone Amplifier – MAX4466 with Adjustable Gain (1063)

I purchased Adafruit’s Electret Microphone Amplifier – MAX4466 with Adjustable Gain (1063) and wanted to incorporate the circuit into a board that I am making to make a sound responsive decorative light. I saw a post from Adafruit that stated that the schematic was taken directly from the datasheet however looking at the component values on the board, it was obvious that some values had been changed. After a bit of reverse engineering of the board, it was confirmed that the schematic is indeed Figure 2 from the datasheet.

Figure2

Board Layout

Component Listing (Note Capacitor Values taken from Datasheet Schematic and not verified)

      • IC1 – MAX4466
      • R1 – 1KΩ
      • R2 – 1KΩ
      • R3 – 1MΩ
      • R4 – 1MΩ
      • R5 – 1KΩ
      • R6a – 100KΩ
      • R6b – 22KΩ
      • C1 – 0.1µF
      • C2 – 0.01µF
      • C3 – 1µF
      • C4 – 100pF
      • L1 – Ferrite Bead
      • L2 – Ferrite Bead

I wrote a simple program on the Arduino to capture 100 points of data per second for one minute and write the results to the serial output.

// Based on the Adafruit Trinket Sound-Reactive LED Color Organ
// http://learn.adafruit.com/trinket-sound-reactive-led-color-organ/code

#define MIC0_PIN 0 // Microphone is attached to Trinket GPIO #2/Gemma D2 (A1)
#define MIC1_PIN 1 // Microphone is attached to Trinket GPIO #2/Gemma D2 (A1)
#define DC_OFFSET 0 // DC offset in mic signal - if unusure, leave 0
#define NOISE 30 // Noise/hum/interference in mic signal
#define SAMPLES 60 // Length of buffer for dynamic level adjustment

int pointsPerSecond=100;
int captureMinutes = 1;
int delayMS = 1000/pointsPerSecond;
int datapoints=pointsPerSecond * captureMinutes * 60;
int curIdx=0;

void setup() {
 // put your setup code here, to run once:
 Serial.begin(57600);
 while (!Serial) {
 ; // wait for serial port to connect. Needed for Leonardo only
 }
 Serial.println(F("Idx\tAdaFruit\tMAX4466"));
}

void loop() {
 
 if(curIdx < datapoints)
 {
 // put your main code here, to run repeatedly:
 int adaFruitMic = analogRead(MIC0_PIN); // Raw reading from mic
 int max4466Mic = analogRead(MIC1_PIN); // Raw reading from mic
 
 Serial.print(curIdx);
 Serial.print(F("\t"));
 Serial.print(adaFruitMic);
 Serial.print(F("\t"));
 Serial.println(max4466Mic);
 
 curIdx++;
 delay(delayMS);
 if(curIdx >= datapoints)
 Serial.println("End of Sample");
 }
}

Here is the circuit diagram for the first test with values from the datasheet.

TestSchematic01
Test Schematic 1 – Values from datasheet

At first, I tried to use the values from the datasheet and noticed that the gain was not as high as the Adafruit module.

Test01_Chart01
Adafruit (ID: 1063) and MAX4466 Typical Schematic
Test01_Chart02
Adafruit (ID: 1063) Capture
Test01_Chart03
MAX4466 Schematic from Datasheet

Modified values to be close to the values used by the Adafruit 1063 module. The results showed that the gain was much better so these values will be good enough for my application, If you need to use this for a different application where you need better performance, you may want to look into the RC values. By modifying the capacitor values, it may be possible to achieve a cleaner output.

TestSchematic02
Modified resistor values to match Adafruit 1063 module
Test02_Chart01
Adafruit (ID: 1063) and MAX4466 Typical Schematic modified values
Test02_Chart02
Adafruit (ID: 1063)
Test02_Chart03
MAX4466 Typical Schematic modified values

This is not a thorough analysis of the performance of these two circuits but as stated above, it was good enough to give me the performance that I needed. (Test with Datasheet Figure 2)

BTW: The values read by the Arduino ADC are between 0 and 1023. The signal is centered around 511 and  has a noise level of ±50.

FYI: The gain for the circuit may be calculated as:

Gain = Rf/Rin = R6/R5 = 100KΩ/10KΩ = 10 (Dtasheet Circuit)

Gain = Rf/Rin = R6/R5 = 120KΩ/1KΩ = 120 (Modified Circuit)

You can also see from the graphs that the amplifier is driven to saturation. For my application that is acceptable but it may not be acceptable for your application particularly if you are creating a purely audio application.

Categories
Arduino

Arduino Due Issues

I have been working with the Arduino Due and version 1.5.2 of the Arduino IDE. I have been attempting to port a mini digital picture frame that I wrote for the Arduino Micro and have not been having much luck. The problem is that the Arduino Due is still relatively new and is a different family than the previous Arduinos.

The errors that have been encountered due to references to the avr libraries. (In particular avr\io.h and avr/pgmspace.h.)

In my attempt, I did the following:

  1. Created the program shown below to workout the library issues. Once I am able to resolve the library issues, I will be able to start porting the code.
  2. Replace the Adafruit_ST7735 library with the modified version at https://github.com/sngl/Adafruit-ST7735-Library” target=”_blank which has been modified to support the Arduino Due
  3. Update the Adafruit_GFX library with the changes found at https://github.com/elechouse/Adafruit-GFX-Library/commit/69e355325312a57412d8c4d0ec6298aa3b4ed917
  4. Create a new folder in the Arduino IDE location at hardware/arduino/sam/cores/arduino/avr/
  5. Create a new file at hardware/arduino/sam/cores/arduino/avr/pgmspace.h and enter contents found at https://github.com/arduino/Arduino/commit/0f5a5259ec038537ea51de0059e711fdeebc6ece

Some issues are resolved but others remain.

Code

#include <Adafruit_GFX.h> // Core graphics library // OK after changes to libraries
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h> // OK
// #include <SD.h>

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}


Errors

In file included from sketch_may19a.ino:20:
C:\arduino-1.5.2\libraries\Adafruit_ST7735/Adafruit_ST7735.h: In member function 'uint16_t Adafruit_ST7735::Color565(uint8_t, uint8_t, uint8_t)':
C:\arduino-1.5.2\libraries\Adafruit_ST7735/Adafruit_ST7735.h:116: error: 'newColor' was not declared in this scope

Commented line 20 in the Adafruit_ST7735.h file as the Color565 function does not appear to be called elsewhere and the newColor function does not exist in any libraries. The following errors are then produced.

C:\arduino-1.5.2\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::commonInit(uint8_t*)':
C:\arduino-1.5.2\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:266: error: cannot convert 'volatile RwReg*' to 'volatile uint8_t*' in assignment
C:\arduino-1.5.2\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:268: error: cannot convert 'volatile RwReg*' to 'volatile uint8_t*' in assignment
C:\arduino-1.5.2\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:276: error: 'SPI_CLOCK_DIV4' was not declared in this scope
C:\arduino-1.5.2\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:283: error: cannot convert 'volatile RwReg*' to 'volatile uint8_t*' in assignment
C:\arduino-1.5.2\libraries\Adafruit_ST7735\Adafruit_ST7735.cpp:285: error: cannot convert 'volatile RwReg*' to 'volatile uint8_t*' in assignment

Why is it when people provide fixes they are rarely documented completely? This is one of the most frustrating things that I encounter. I can solve these issues if given enough time but unfortunately I do not have the luxury. I will come back to this later and attempt to resolve the remaining issues.

Here is a post of someone else trying to get the Adafruit display to work with the Arduino Due. http://21stdigitalhome.blogspot.com/2013/02/arduino-due-spi-display-nearly-defeated.html

To be fair, the Arduino Due is a totally different architecture and it will take time to port the libraries over to the new architecture. I hope to get some more time later to tackle this problem again as this is a great opportunity to learn more about the Arduino Due but I suspect that I will not be able to devote the time I need to accomplish much.

Categories
Raspberry Pi

Setting up the WiFi Part I – Supported Adapters

Video Coming Soon

<<FIRST  <PREVIOUS

This entry is for configuring the Asus USB-N10 USB Wireless-N USB Adapter. If you have any other WiFi adapter please refer to Chapter 4 Network Configuration of the Raspberry Pi User Guide book or perform Google Searches for your adapter.

003_001

NOTE: There is a WiFi Config tool included with Raspbian “wheezy” distribution however I have not had much luck with it. I t did work one time for me and that was it. You may give it a try but I recommend using the steps below as they have worked 100% of the time for me.

 

You will need to perform these steps from the command line. If you have the desktop loaded, open a terminal window by double clicking on the the LXTerminal shortcut on the desktop.

  1. At the command line, type the following command and press enter to view available wireless networks.
    sudo iwlist scan | less
  2. On the wlan interface, you will see the SSIDs listed on the lines starting with ESSID:. Verify that the network you wish to connect to is listed.
    003-002
  3. Press Ctrl+z to return to the command line
  4. Edit the network configuration file by typing the following command and press enter.
    sudo nano /etc/network/interfaces
  5. You should see the following content in the interfaces file.
    auto loiface lo inet loopback
    iface eth0 inet dhcpallow-hotplug wlan0
    iface wlan0 inet manual
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet dhcp

     

  6. Replace the bottom block with the following.
    auto wlan0
    iface wlan0 inet dhcp
    wpa-conf /etc/wpa.conf

     

  7. The resulting file should have the following contents.
    auto loiface lo inet loopback
    iface eth0 inet dhcpauto wlan0
    iface wlan0 inet dhcp
    wpa-conf /etc/wpa.conf

     

  8. Save the file and exit
    • Press Ctrl+o
    • Press Enter
    • Press Ctrl+x
  9. Now edit the wpa.conf file by typing the following command and pressing enter.
    sudo nano /etc/wpa.conf
  10. Enter the following for the contents of your file based on the type of security used by your WiFi network.
    NOTE: Do not type the word [Tab]. It indicates that you need to include a tab.

    No Encryption network={
    [Tab] ssid=”Your_SSID
    [Tab] key_mgmt=NONE
    }
    WEP Encryption network={
    [Tab] ssid=”Your_SSID
    [Tab] key_mgmt=NONE
    [Tab] wep_key0=”Your_WEP_Key
    }
    WPA/WPA2 Encryption network={
    [Tab] ssid=”Your_SSID
    [Tab] key_mgmt=WPA-PSK
    [Tab] psk=”Your_WPA_Key
    }

     

  11. Save the file and exit
    • Press Ctrl+o
    • Press Enter
    • Press Ctrl+x
  12. Connect to the wireless network by typing the following command and pressing enter.
    sudo ifup wlan0
  13. If you see the message “ifup: interface wlan0 already configured,” type the following command and repeat the previous step again.
    sudo ifdown wlan0
  14. If you are successful, you will see several lines starting with DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 … with the last line stating that the adapter is bound to an IP address on your network
    .
    003-003
  15. If you are successful at this point, you may close the terminal window and open a web browser to verify that you are connected to the internet.
    003-004
<<FIRST  <PREVIOUS
Categories
Raspberry Pi

Initial Configuration of the Raspberry Pi

First Step – Getting the Raspberry Pi to Boot

Required Items

  • Raspberry Pi
  • 2 GB or larger SD Card
  • Keyboard
  • Monitor (Composite or HDMI)
  • Display cable (Composite or HDMI)
  • USB Power Supply
  • USB Cable for power (Micro USB)
  • PC connected to the internet with a card reader

Optional Items

  • Case for Raspberry Pi
  • USB Mouse
  • Book – Raspberry Pi User Guide
    by Eben Upton & Gareth Halfacree
    ISBN: 978-1-118-46446-5 (Amazon Link)

NOTE: I am running these steps from a Windows 7 PC. If you are running from another OS be certain you read the information on the http://www.raspberrypi.org/downloads page for information for your OS. I am also using a 16 GB SDHC Card.

Steps

  1. Go to the download section at http://www.raspberrypi.org/downloads
  2. If you are running a Windows PC, download Win32DiskImager
    I downloaded the version 0.5 binary (win32diskimager-binary.zip)
  3. Download the Raspbian “wheezy” image
    I downloaded via the direct download.
    The version at the time of this blog entry is 2012-12-16-wheezy-raspbian.zip
  4. Open the zip file (2012-12-16-wheezy-raspbian.zip) and extract the image file (2012-12-16-wheezy-raspbian.img)
    The following steps are modified from the “Easy Way” section from http://elinux.org/RPi_Easy_SD_Card_Setup
  5. Insert the SD card into your SD card reader and check what drive letter it was assigned. You can easily see the drive letter (for example G:) by looking in the left column of Windows Explorer. If the card is not new, you should format it; otherwise Win32DiskImager may hang.
  6. Extract the Win32DiskImager utility files from the zip file (win32diskimager-binary.zip) and run the Win32DiskImager utility (Win32DiskImager.exe). You should run the utility as Administrator! (Right click on Win32DiskImager.exe and select “Run as administrator from the context menu.)
    001
  7. Select the 2012-12-16-wheezy-raspbian.img image file you extracted earlier
    002
  8. Select the drive letter of the SD card in the device box. Be careful to select the correct drive; if you get the wrong one you can destroy your computer’s hard disk!
    003
  9. Click Write and wait for the write to complete.
    004005
  10. Exit the imager and eject the SD card.
  11. Insert the card in the Raspberry Pi, power it on, and it should boot up. There is an option in the configure script that comes up to expand the partitions to use all of the SD card if you have used one larger than 4 GB

Second Step – Initial Configuration of the Raspbian “wheezy” distribution

When you boot up the Raspberry Pi, the Raspi-config utility will launch.

There are a few things that you should configure right away or you may have problems later.

  • Expand the root partition if your SD Card is greater than 4 GB (Optional)
    1. Select “expand_rootfs” from the Raspi-config menu
    2. The Raspi-config widow will disappear for a bit then a new window will display telling you that the root partition has been resized and the file system will be enlarged upon the next reboot. Click enter to close the dialog.
  • Configure the keyboard (You must do if you are not using a UK keyboard!)
    I did not perform this step the first time I booted up the Raspberry Pi and I had issues as I could not use the pipe symbol. The “|” was mapped as a tilde “~” symbol. 

    1. Select “configure_keyboard” from the Raspi-config menu
    2. You may keep the default “Generic 105-key (Intl) PC” model or change it to match your keyboard
    3. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    4. If you are not using a UK keyboard, select “Other”
    5. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    6. Select your country of origin from the list (i.e. English (US))
    7. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    8. Select the keyboard layout (i.e. English (US))
    9. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    10. Select the option for the AltGr modifier (i.e. The default for the keyboard layout)
    11. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    12. Select the option for the Compose key (i.e. No compose key)
    13. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    14. Select an option for the Control+Alt+Backspace key combination
    15. Press enter
    16. There will be some delay as the options are saved
    17. The Raspi-config menu will reappear
  • Change the locale (You should do if you are not in the UK)
    1. Select “change_locale” from the Raspi-config menu
    2. Scroll down to the “en_GB.UTF-8 UTF-8 option and deselect it by pressing the spacebar (You do not need to remove it. You may keep it if you like.)
    3. Scroll through the list to find the locale(s) you wish to install and select it/them by pressing the spacebar (i.e. en_US.UTF-8 UTF-8)
    4. Tab to the bottom options and select “<OK”>” and press enter
    5. Select the default locale for the system (i.e. en_US.UTF-8 UTF-8)
    6. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    7. There will be some delay as the options are saved
    8. The Raspi-config menu will reappear
  • Change the time zone (Unless you want to stick to UTC)
    1. Select “change_timezone” from the Raspi-config menu
    2. Select your geographic area (i.e. US)
    3. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    4. Select your time zone (i.e. Eastern)
    5. Press enter or Tab to the bottom options and select “<OK”>” and press enter
    6. There will be some delay as the options are saved
    7. The Raspi-config menu will reappear
  • If you have a hardwired internet connection, you may try to update Raspi-config
    1. Select “update” from the Raspi-config menu
    2. Press enter or Tab to the bottom options and select “<OK”>” and press enter
  • Once you are done making changes, press the tab key to jump to the options at the bottom of the screen and select “<Finish>”
  • Depending on the options selected, you may be prompted to reboot. If given the option, reboot your Raspberry Pi as most options do not take effect until the Raspberry Pi reboots.
<<FIRST  <PREVIOUS | NEXT>
Categories
Raspberry Pi

Introduction to the Raspberry Pi

NEXT>

 

Raspberry Pi Model B Board

NEXT>
Categories
Product Review

USB Video Capture Devices Review

I wanted to grab some video of the Raspberry Pi booting up with the Raspbian “wheezy” distribution. To do this, I planned to capture the video on my PC by using a USB video capture device. I bought two devices from Microcenter in hopes that one would work reasonably well but I was disappointed with the results from both devices. I later purchased another device from Newegg which worked much better and is used for all of the initial screen captures of the Raspberry Pi.

First a review of the low cost devices

Other than the quality of the video, I was rather disappointed with the way they did not play well with other video capture software. Each comes with some video capture software but I wanted to use Corel’s VideoStudio Pro X4 or Windows Live Movie Maker. At first it did not appear that the hardware devices would work with either software but I was able to figure out how to use them with Corel VideoStudio Pro X4. The default input on the device is S-Video not composite. In Corel VideoStudio Pro X4, you need to select composite input in the Options > Video Properties.

Neither device would work in Windows Live Movie Maker. When the capture device was selected and an attempt was made to capture video, the following message would be displayed. “Sorry, Movie Maker can’t record audio or video from the selected device.”

Devices tested

  • Sabrent USB 2.0 Video and Audio Capture Device (USB-AVCPT)
  • Sima GO DIGITAL Transfer Cable (SFG-1)

Sample video of the Sabrent

Sample video of the Sima

Now, the device I am currently using

  • DIAMOND USB 2.0 HD 1080 Game Console Video Capture Device (GC1000) USB 2.0 Interface

The Diamond GC1000 has much better quality however there are still some issues. The biggest issue is that it will not work with any software other than the included capture software. The good news is that the software works well. I did have a few issues at first but I was able to work through them and get it to work well. The other issue with the device is that the video displayed on the PC lags considerably from the live video. This is not too much of an issue and can be worked around by connecting a monitor to the output and working with that monitor rather than the video on the PC.

Sample video of the Diamond GC1000 – Composite Video with S-Video adapter (Now I connect to the Y jack of the Component Video)

Sample video of the Diamond GC1000 – HDMI

Conclusion

The bottom line is you get what you pay for, The cheaper devices I purchased from Microcenter work but the quality is not very good. I found them unacceptable for capturing video from the Raspberry Pi as the text was difficult to read in the captured video.

The Diamond GC1000 has much better video quality however there are still a few quirks that you need to deal with but they are not difficult to overcome and the resulting video is acceptable.