Tuesday, November 10, 2015

Playing night rider with three 74HC595s

Connected three 74HC595s in series and entertained myself by simulating KITT from Knightrider.  Would have hooked up the fourth one but was running out of realestate and LEDs.  I should have a another breadboard in a few days along with some 7 segment leds that I will be hooking up and controlling with the 74HC595s.
NOTE:  The breadboarding of 4 seven-segment displays and driving them with the 74HC595's is an exercise in digital electronics and programming not meant to be a recommendation for implementation in an actual project.  If you need a 7 segment display in your project I recommend using I2C like I am doing in this photo using the Adafruit 0.56 4-digit 7-Segment Display w/I2C backpack (assembly with soldering required).



Till then, enjoy the video and code.

UPDATE - Found that with zero delay the data is getting clocked to the registers at 58KHz.  I thought it would be faster but then if you divide 58Khz into the 16MHz clock of the arduino you get 275 (275 machine cycles). That means it takes the Arduino 17 microseconds to complete the loop when there is no delay.  Looking at the code it is hard to believe 275 machines cycles are required to prepare the next unsigned long integer to be shifted out then clock it out, but I do not know how many of those are used up by the ShiftOut() library function that is called three tiems to shift out all 24 bits.




SourceCode on GitHub

Sunday, November 8, 2015

Serial to Parallel Shifting-Out with a 74HC595

 Using the 74HC595 to control 8 leds (outputs) without giving up 8 ports on the arduino uno. Three outputs from the arduino are used to shift the data out in serial to the 74HC595 were it is then parceled out to each of its individual pins. You can link multiple registers together to extend your output even more, without giving up any more pins on the arduino.
Note: The shift register is not what gives the appearance of the led going back and foth...ie shifting. All the shifting happens prior to the output states changing. The led appears to be shifting because it is in a loop writing int 1, 2, 4, 8, 16, 32, 64, 128, 64, 32, 16, 8, 4, and 2.
Next, I will be connecting four of the  74HC595s together to experiment with controlling 32 outputs with 3 pins from the arduino.  Then modify the circuit to control four seven segment leds with 3 pins.  Why do this instead of using the low cost I2C interface?  Speed.  I2C runs at 100k where these shift registers can be clocked as fast as for for loop that shifts the data out, which is well over 1mb/sec.



This is the code used in the video above.  Pin out for the 74HC595 along with a short tutorial by Simon Monk can be found here.

Source Code Here:

Wednesday, November 4, 2015

Controlling an RGB LED with PWM

This is an example from the Arduino Workshop.  You can breadboard the circuit or use a squid


Squid connected directly to Arduino


RGB LED Pinout


Sample code from Arduino Workshop that will demonstrate the RGB Led.



Here it is in Action




Tuesday, November 3, 2015

Playing Music With Remote Control

This was the first experiment I did with Ken Shirrif's Infrared Remote Control Library for the Arduino.

The circuit uses a TSOP382 IR photo sensor to receive the codes from the Clarion remote controller I had lying around.  Once the code is received the program then decides which tone to play.  In this example I have 8 tones set up, middle c through middle b.  For added fun and visual effects I turn on a led for each of the notes as they are played.

Here is a short video of a few notes being played on the Arduino.  Below the video is the code along with some instructions on how to modify the library so it will work with the tone() function.



If you try to use this you will need to install the Arduino library written by Ken Shirrif.  You will also need to modify the library so that it uses TIMER1 instead of TIMER2 because TIMER2 is used by the tone() function.

Technology librarian Trey Ford explains how you modify the library to use TIMER1

  1. First, go to Libraries\Documents\Arduino\libraries\IRremote , the files for the library would be there.
  2. In IRremoteInt.h, at line 194 we have this

    //Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
    #else
      //#define IR_USE_TIMER1 // tx = pin 9
      #define IR_USE_TIMER2 // tx = pin 3
    #endif
  3. We’d need to uncomment the IR_USE_TIMER1 line and comment the IR_USE_TIMER2 line like this:
        // Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
        #else
                #define IR_USE_TIMER1 // tx = pin 9
               //#define IR_USE_TIMER2 // tx = pin 3
        #endif


Now if your using codebender you will need to upload the modified version of Ken Shirrif's library to your personal libraries so that when compiling it will user your modified version rather than the default version that is allready registered with codebender.

Here is the code:


Monday, November 2, 2015

Remote Controlling Arduino Robot Shield

Received my board of education arduuino robot shield last Friday and the first thing I wanted to try after assembling it was to control it with an IR remote using Ken Shirrifs IR Library.

The motors on the robot are 360 degree servos that are controlled by sending them a digital pulse ranging in duration from 1300 to 1700 microseconds every 20milliseconds.  The width of the pulse determines the speed and direction they rotate.  1500 would be no motion at all, 1300 full speed counter clockwise and 1700 full speed counter clockwise.  While this is modifying the width of the pulse it is not the same as the PWM functions found in the Arduino library.

When polling for commands from the IR receiver I found that that this particular remote requires me give it at least 175 ms before attempting to read its next transmission.   That, combined with the IR remote being single channel makes for a choppy RC because within 200 ms the servos have already repeated the last command 10 times.

Oh and if you are wondering why no beeping from the Robot it is because the tone function is unable to access TIMER2 because it is being used by the IR Library   The servo library uses TIMER1.

Here is a short video




Here is the Code:

Saturday, October 17, 2015

Raspberry Pi Laptop!

I stumbled across this while looking for a low cost portable kbd/mouse/display option for my Raspberry pi.  Thought you would find it interesting


I like what they have done but would want to have access to the GPIO header and camera port.

Using the Pi 2 as a computer is really not a bad idea.  Especially if the come up with a small solid state drive for it.  Currently I think the bottle neck is the data transfer rate of the Micro SD card.

Read more about this cool laptop kit here

Thursday, April 23, 2015

Speeding Up Outlook 2013 - Setting Outlook 2013 In Cache Mode

If you are experiencing slowness with Outlook 2013 it may be because it is not set to run in cache mode.  To set Outlook 2013 in Cache Mode do the following

1.  Click On File


2. Click Account Settings

3. Click Change

4.  Check "Use Cached Exchange Mode"

5.  Click Next then Finish and restart Outlook