Saturday, May 21, 2011

I2C Master Implementation in Verilog - Part 3


Continuation from part 2.5...
So I've learned that making a bidirectional port isn't as hard as I thought. After declaring SDA as an inout, I would use this assign statement:
assign SDA = (SDAinout) ? 1'bz : dataOut; Now, whenever SDAinout is 1'b1, SDA becomes in input, and when SDAinout is 1'b0, SDA becomes an output (dataOut). I don't remember which forum I found this information but a quick search on Google yielded many results.

Continuing with the rest of the project...
Since the data on SDA has to be valid by the time SCL is high, I first tried making a sepparate clock that is two times faster than SCL. This way there would be a clock edge present at the middle the negative level of SCL as well as at SCL. I quickly realized that by doing this, I would need to trigger SDA and SCL at different clock edges as shown in the picture. To make things more simple, I decided to use a clock that is four times faster than SCL so that the center point and the start of SCL can both be clocked with the positive edge.

Now, using this 4xSCL clock, I have created several routines which handle the start/stop, address/register sending as well as the data sending.

My last step is to create a state machine that ties all of the routines together and the project is finished.

Thursday, May 12, 2011

I2C Master Implementation in Verilog - Part 2.5

Because SDA needs to be bidirectional, I realized that I would have to declare SDA as a INOUT port. I've never used an INOUT port so now's the time to learn!

Tuesday, May 10, 2011

I2C Master Implementation in Verilog - Part 2

After reading on the basics of the I2C protocol, I drew a flow chart to try and map my understanding. The left half shows the Master Read routine and the right shows the Master Write routine.

One part I was unsure about was that if the slave would send an ACK signal after it receives a valid register address. The single master I2C tutorial on best-microcontroller-projects.com shows that there is such an ACK signal but other resources do not mention this.

Another part of the protocol which is unclear to me is what data should I have in SDA when I send the ACK bit. I assume that D0-D7 are don't cares when checking for ACK, so for now I will send all zeros.


Whats next?...
  • Start creating the verilog modules for an I2C Master including:
    -Start/Stop signal generator
    -Shift Registers for parallel to serial/serial to parallel functionality
    -ACK signal detector (probably not a separate module)
    -Clock divider (50MHz to 100kHz for SCLK)


I2C Master Implementation in Verilog - Part 1

From today, I will post on my progress on writing an I2C Master implementation in Verilog on my Xilinx Spartan 3E FPGA board.
I will be using the I2C master to read time and date data from a Maxim DS1337 Real Time Clock.

I have used this particular RTC before for my senior design project, but I had simply used a preexisting library on an Arduino with the I2C implementations specific to the RTC.

Here is a list of references I have found that may be useful:

Whats next?...
  • Draw a flow chart mapping the design
  • Re-familiarize myself in the Xilinx ISE Suite

Tuesday, February 1, 2011

Remote Shutter Release

I own an Olympus E-PL1 and I love the camera but one thing I wish it has is a remote shutter release.

I first wanted to make a mechanical shutter release adapter similar to ones for the Sigma DP1 (http://www.amazon.com/Mechanical-Release-Adapter-exposure-photograph/dp/B003JFMYWA/ref=pd_rhf_p_t_2), but I would still need to buy a mechanical shutter release.

Looking through my closet for usable junk, I found my old remote control car which uses a servo for steering and a bunch of Legos.
I mounted the servo to the hot-shoe portion of a broken flash unit and I control the servo with an Arduino.

I programed the Arduino so that the system can be used as an intervalometer. The blue button on the left is used to enter the duration in seconds and the button on the right starts the shutter action. The RF module sitting on the board will be used later to release the shutter from a distance.

Tuesday, January 18, 2011

Pinhole Camera 2

先ほどのピンホールカメラの弱点はウァインダーの部分が回した後、ぜんまいみたいに戻ってしまうことです。
The flaw of this paper pinhole camera is that the winder unwinds itself due to the springy nature of the film.


戻らないようにヘアーピンで留めてみました。
To correct this flaw, I am using a hair pin to prevent it from winding back.

Pinhole Camera

去年のクリスマスのワイトエレファントでもらったピンホールカメラです。
This is the pinhole camera I had received for white elephant last year.

けっこ前から組み立ててたんだけど使い方がよくわからなくてフィルム1ロールだめにしちゃってそれから使ってません。。。
I had put it together quite a while ago but after ruining a roll of film in it, I hadn't used it since.

最近暇なのでもう一度挑戦してみようかとおもってます。
Since I have a lot of free time now, I've decided to have another go at it.