Jun 1 2014

Breadboard-friendly i2c logic level converter

By Max

IMG_20140531_222803 (2)Lately I’ve been using my 5V Arduino in concert with 3.3V devices via i2c, and so I’ve found myself requiring an interface part to convert the two logic levels.

I had previously done this on the breadboard with two 2N7000 MOS-FETs according to this Philips application note AN97055:

i2c Logic Level Shifter Schematic

This worked, but it was a lot of parts to set up on the breadboard each time, and I wanted something hardwired so that I could focus on other things when it came time to troubleshoot.  So I cooked up this little guy:

IMG_20140601_134500~2

Testing the waveform with an oscilliscope, you can see some noise is introduced on Channel 1, but I always wonder in these cases how much of that is just because I have a bunch of probes stuck everywhere– the act of measuring changes the measured behavior and so on.  But, it should be perfectly adequate for prototyping purposes.

i2c SCL line

5V signal in blue (channel 2). Resulting 3.3V signal in yellow.

Downloads:

If you’d like my Eagle files to incorporate this into your file, 3V to 5V i2c Eagle Files.

A pdf ready to etch is here: 3V to 5V i2c Eagle Files Level Shifter Rev0.

One note: if you look at the pictures of the finished product, you’ll see that rather than the usual way of doing things where you put the PCB on the bottom plane, then drill through and put the components on top, I’ve instead mirrored the layout, and soldered the components on the top plane.

 I did that so that I could solder the pin headers on top, as you can’t solder them to the bottom traces because the plastic connectors get in the way.  If you download the pdf I linked to, it’s already been flipped and is ready to go.  If you download the eagle files, make sure you select “mirror” from the print options.

Hope it comes in useful for you!

 


Nov 18 2012

Interfacing the Arduino to the Taos TCS3414 via I2C, continued

By Max

Taos TCS3414

November, so soon!  I kind of had to put this one down for awhile and work on things that were not laptop-centric, I just was spending too much time in front of a computer screen.  Luckily, Tiuri De Jong was on the case, and he has developed the proof-of-concept code I posted earlier into a fully-working demonstration.

I uploaded it to my Arduino, and I’m getting stable results with an apparently linear response, although the specific numerical values themselves aren’t particularly meaningful.    For example, under my workbench lamp that I metered at about 40fc and has a CCT of 5000K, it measured 290fc at 3500K.  I get that the part would require calibration before it would be useful, but it’s strange to me that it would be off by 1500K color temperature and a factor of 5 for illuminance, out of the box?  I’d be interested to know if anyone else has a similar experience.

What I’m working on now is measuring the values given by the TCS3414 vs. a known accurate illuminance and color temperature meter, to tell if the deviation from true value is a constant, or a linear function, or what.  I’ve verified that the calculations are done correctly in the code per the datasheet.

But in the meantime, it seems like a shame to deprive everyone else of Tiuri De Jong’s complete and, might I add, lucidly written code, so it may be downloaded here:

2012-11-18 Light Meter Code Rev5

I’ve also posted the code in full after the jump.

Continue reading “Interfacing the Arduino to the Taos TCS3414 via I2C, continued” »


Jun 7 2012

Interfacing the Arduino to the Taos TCS3414 via I2C

By Max

Well, this was a productive night:  I’ve been working with the Taos TCS3414, which is a light and RGB color sensor.  It’s a tiny little guy, about 2.5 x 3.5 mm I would guess, and shown above is mounted on breakout boards.  I just had a breakthrough night with it, getting it to correctly return values from the sensors, so I thought I’d share my preliminary code for the benefit of all.

Update: better code here!

Helpful tips:

  • The TCS3414 is I2C, whereas the TCS3404 uses the similar SMBus.  The Atmega 328 can do both, but I2C is easier for reasons of both hardware and libraries, so get the TCS3414.
  • I2C is on analog pins 4 and 5, not digital pins 4 and 5.
  • It’s a 3.3V device, so make sure you power it via the 3V output on the Arduino, not the 5V output.  It draws 9ma max, so the 50ma capacity via Arduino is plenty.
  • Similarly, you’ll need to level shift 5V bidirectionally to 3V from the Arduino to the sensor, so google logic level converters.  I used a pair of NTE491 MOSFETs.

Here’s what my hardware looks like (note, my breakout board pins aren’t the same layout as the sensor):

That all being said, here’s my (working concept only) code!:

// 6 June 2012

#include

int ledPin = 13; // LED connected to digital pin 13

byte receivedVal = 0x00;

unsigned int clearLow = 0;
unsigned int clearHigh = 0;

void setup()
{
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);

// join i2c bus (address optional for master)
Wire.begin();

Serial.begin(9600);
Serial.write("Serial started" "\n");

digitalWrite(ledPin, HIGH); // set the LED on

Wire.beginTransmission(0x39);
Wire.write(0x80);
Wire.write(0x03); // Turn the device on and enable ADC
Wire.endTransmission();

Wire.beginTransmission(0x39); // Request confirmation
Wire.requestFrom(0x39,1);
receivedVal = Wire.read();
Wire.endTransmission();

if (receivedVal == 0x03) {
Serial.write("ADC Started" "\n");
}
else {
Serial.write("Connect to sensor failed with code: ");
Serial.println(receivedVal, DEC);
}

delay(50); // wait for a moment to allow ADC to initialize
digitalWrite(ledPin, LOW); // set the LED off
}

void loop() {
Wire.beginTransmission(0x39);
Wire.write(0xB8);
Wire.endTransmission();

Wire.beginTransmission(0x39); // Request confirmation
Wire.requestFrom(0x39,2);
clearLow = Wire.read();
clearHigh = Wire.read();
Wire.endTransmission();

clearHigh = (clearHigh * 256) + clearLow;

Serial.println(clearHigh, DEC);

delay(500);
}

If you’ve done it right, it should start spitting out meaningless numbers, that decrease when you hold your hand over the sensor!  More to come on this topic soon!


Jun 15 2011

Electricity Quick Reference Cards

By Max

These are some quick reference guides I made for my dad, for Christmas.  I am posting it now because June is the next month after December, clearly.  So my dad has been hampered in working on his classic cars and rental properties with their myriad electrical problems because he’s never been exposed to the fundamentals of electricity.  I figured that what he needed in lieu of a formal physics course was a quick reference that he could refer to as needed. Continue reading “Electricity Quick Reference Cards” »


Oct 13 2010

My Nixie Clock Build

By Max

It’s finally done, jesus. A few years ago, I bought some electronics components from a former Eastern Bloc country.  Nixie tubes are apparently still widely available over there, so since the largest line item in the order was shipping costs, I had them throw some Nixies in with the order.  They sat in my parts bin until, a few months ago, I decided to make a clock out of them. Continue reading “My Nixie Clock Build” »


Oct 9 2010

Rev15 of the Arduino DMX Reception Software Released

By Max

New in this version:

  • Tested and working with IDE version 0021.  I have not tested it with the new Arduino Uno hardware, but can’t think of any reason why it wouldn’t work.  If you have any success or otherwise with the new hardware, drop a line in the comments.
  • A bug has been fixed in the addressing routine caused by button debounce, and the addressing routine logic has been simplified and made clearer.  Big thanks to Ron Barber for pointing out the source of the bug and contributing new code.
  • There is now a check when the previously stored address is read from EEPROM to ensure that it is in the valid range of 1-511, to prevent a bad value being read in from uninitialized EEPROM.
  • Fixed a potential bug in the break detection routine that could cause the read values to be off by one in cases where the break from the microcontroller was exactly 88uS.

You can grab it here or mosey on over to the original post for the instructions.


Jul 10 2009

Rev13 of the Arduino DMX Reception Software Released

By Max

New in this version:

  • Tested and working with IDE version 0016.
  • The number of channels to receive is now easily user-configurable.
  • Replaced static variables with #define statements for RAM optimization (+48 bytes, woot!).

You can grab it here or mosey on over to the original post for the instructions.

Ed. Note: This is no longer the latest version.  Head to here for the latest.


Jun 20 2009

Arduino Theremin/Synth Final Walkthrough

By Max

P1000478DNG

It’s Done! I gave it to my sister last weekend and she really liked it.  If you’re just tuning in now, I have posts about the hardware development, waveform crafting, an early demonstration, and the software algorithm.  The final version has the following features:

  • Four octaves of continuous pitch variation by moving your hand nearer or farther from an ultrasound sensor
  • Digital volume control
  • Continuous waveform variation–can generate a pure sine tone like a classic theremin, or one with overtones, which sounds like an 80’s synth organ.
  • Spectral glide–similar to a Wah pedal or the instrument used in Peter Frampton’s ‘Do You Feel Like I Do’
  • Decay/Sustain–envelope shaping to play notes
  • Distortion–sounds like the guitar effect.

Listen to the Tone of the Future:

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

  1. 0:00-0:00 Pure tone, no effects
  2. 0:45 Waveform selection– no overtones
  3. 1:05 Decay effects
  4. 1:37 Wah
  5. 2:45 Distortion

And here is a video with me demonstrating the operation (and also explaining several key features completely incorrectly):

Continue reading “Arduino Theremin/Synth Final Walkthrough” »


Jun 4 2009

Arduino Theremin/Synth Update II

By Max

The Hardware, Oh the Hardware. I’ve been making some great progress on shaping the generated tone and getting some more musicality — I’ve programmed a decay function and that’s made a huge difference, depending on the input values I’ve got a pretty good harp simulacrum, and also something that sounds like an early 1980’s analog synth piano, which I <3.  I’ll try to get a demo up of where I’m at with tonality.  Mainly, I’ve been trying to figure out the analog inputs to control the tone sensing, as well as volume, attack, decay, echo, etc.  This is really two separate problems.  For the frequency control, I want to detect distance from 2″-3′ with good precision, stability, and ideally linearity.  For the volume and effects control, I want a 0-5V analog input over about 1-1.5″ of travel, that can be operated with a single finger.  Here’s what I’ve looked at: Continue reading “Arduino Theremin/Synth Update II” »


May 29 2009

Generate Real-time Audio on the Arduino using Pulse Code Modulation

By Max

TEK-434 1973-2009 RIP :(

TEK-434 1973-2009 RIP :(

So. There are a bewildering variety of options for generating sound via the Arduino, but I’m trying to make a real-time synthesizer, with the following features:

  • Arbitrary waveform shape, including the ability to add harmonics for a more musical sound
  • Generate any frequency dependent on sensor input
  • Efficient processor usage to allow for effects such as reverb, echo, envelope shaping, etc.
  • A minimum of external hardware

Audio output for the Arduino is pretty well-tilled soil, but surprisingly most of the previously published options are geared towards canned sound playback, or tone generation without a focus on musicality.  I’ve implemented an algorithm called Pulse Code Modulation, and I think it has a lot of potential.  Keep reading for an explanation of how it works and why it’s awesome.

Continue to page 2…