Show Posts
Pages: [1]
1  Using Arduino / Microcontrollers / Re: Embedding Arduino in a Project on: January 04, 2012, 08:16:01 pm
Agreed, I'm not sure why you want to use the USBTinyISP.  If you already have a bootloader on your atmega then you can just use something like this
http://www.arduino.cc/en/Main/Standalone.  I do this all the time on small circuit boards.  It's really quite simple.  Then you just add a 6 pin header and use an FTDI friend (I use something like this https://www.adafruit.com/products/70).

-Zeke
2  Using Arduino / LEDs and Multiplexing / Re: Parsimony, ShiftOut and Bleedthrough on: January 04, 2012, 02:31:20 pm
Thanks Mike.  That clarification helps a lot.  I did remove the capacitor from the latch pin, but I haven't added decoupling capacitors on the supply of all of my chips.  I did put one on each side of my voltage regulator.

Decoupling capacitors is one of those things that I understand in theory, but not in practice.  I'm using 9 ICs in my design (4 shift registers, 4 darlington arrays, one atmega).  Does that mean that I need 11 caps (two for the 7805 plus one for every IC) or does only the atmega need a decoupling cap?  Also does it go on the power pin or the data pin?  I assume power pin.  Does it need to cross the power and GND pins directly or can it go to a common ground?  Can you point me to a good discussion of decoupling caps for beginners?

-Zeke


corrected code:


void shiftOut(byte outputData) {
  // This shifts 8 bits out MSB first, on the rising edge of the clock, clock idles low

  // loop over the bits in outputData and send them to the shift register
  for (int i=7; i>=0; i--) 
  {
    bitClear(PORTB, clockPinPortB);

    //Sets the pin to HIGH or LOW depending on pinState
    if (bitRead(outputData,i))
    {
      bitSet(PORTB, dataPinPortB);
    }
    else
    {
      bitClear(PORTB, dataPinPortB);
    }

    //register shifts bits on upstroke of clock pin 
    bitSet(PORTB, clockPinPortB);
  }

  // the clock pin likes to idle at LOW
  bitWrite(PORTB, clockPinPortB, 0);
}


-Zeke
3  Using Arduino / LEDs and Multiplexing / Parsimony, ShiftOut and Bleedthrough on: January 04, 2012, 09:24:01 am
I'm currently working on a project with a bunch of 74HC595 shift registers and ULN2003AN darlington arrays.  I'm PWMing the light and like many people have been searching for ways to improve the performance of manual bit banging.

Since I've started the project I've learned about SPI, but my current board is using other pins and more importantly, I feel like I'm really starting to understand shift registers (after using them for a few years mostly with blind copy and paste).

The first thing I discovered was writing to PORTB directly instead of using digitalWrite.  Wow, that's so much faster it's really quite nice.  The deeper I get into microcontrollers the more I appreciate the hard work the arduino folks have put into making this stuff so much easier.  That said, there are times to get closer to the metal and I'm there now.

Now, what most of the sample code on the net does is something like this:

1. set latch to low (disable the outputs while shifting bits)
2. clear data pin
3. set clock to low
4. loop over the bits in a byte and for each bit
  4a. set the clock to low
  4b. set the data pin high or low
  4c set the clock high (triggers a read from the shift register)
  4d. set the data pin low
5. set the clock to low
6. set the latch to high (enable the outputs

What I don't understand is why we would need to do 2, 3 and 4d.  If I'm going to set the clock to low at 4a then 3 seems redundant and if I'm setting the value of the data pin at step 4b then step 2 seems redundant.

The only theory I have is that some folks are worried that if there's data on the data bit when I hit step 4a then that will get shifted onto the registers but of course I'm sending 32 bits down the pipe anyway and so that bit will 'fall out the end' of the shift register before I enable the latch.

What am I missing?

Thanks,

-Zeke

Here's my current shiftOut if my pseudocode is too pseudo.


void shiftOut(byte outputData) {
  // This shifts 8 bits out MSB first, on the rising edge of the clock, clock idles low

  //clear everything out just in case to prepare shift register for bit shifting  
  bitClear(PORTB, dataPinPortB);
  bitClear(PORTB, clockPinPortB);

  // loop over the bits in outputData and send them to the shift register
  for (int i=7; i>=0; i--)  
  {
    bitClear(PORTB, clockPinPortB);

    //Sets the pin to HIGH or LOW depending on pinState
    if (bitRead(outputData,i))
    {
      bitSet(PORTB, dataPinPortB);
    }
    else
    {
      bitClear(PORTB, dataPinPortB);
    }

    //register shifts bits on upstroke of clock pin  
    bitSet(PORTB, clockPinPortB);
    //zero the data pin after shift to prevent bleed through
    bitClear(PORTB, dataPinPortB);
  }

  // the clock pin likes to idle at LOW
  bitWrite(PORTB, clockPinPortB, 0);
}
4  Using Arduino / Motors, Mechanics, and Power / Measuring Power, 12v RGB LED strips, 7805, atmega328 and 8 AA's on: August 16, 2011, 03:47:13 pm
This is a repost from the general electronics section, but this seems like it might be a more appropriate forum.

I've been playing with electronics for a few years now and have build a lot of things that I like, but I'm still a self taught rank amateur and could use some advice.

I'm building a battery powered RGB LED display (for a bike).  It consists of 4 strands of 12v RGB LEDs, a 7805 voltage regulator an atmega328 running the UNO bootloader and some transistors.

It currently drains 8 AA's (1.5v*8=12v) in about 2 hours and I want it to last at least 8, or ideally 12 hours.  

Each alkaline AA should be 2700mah or 21 Ah for the 8 AA's.

So, now I'm learning about power.  I've never tried measuring power and so I think I'm doing something wrong.

I placed my multimeter between the battery and my circuit board and with the lights plugged in I'm getting a .6 reading when the meter is set to 10A and a 2.8 reading when it's set to 20m.  Does that mean that I should multiply .6 * 10A to get 6 Amps or is at .6 A or 600 mAh.  Most people think that it should be .6 amps which makes some sense to me since the light should use about 115 mA per color per meter and I have about four meters and one color is on at a time (on average).  

If that were true then I my lights should last for days instead of hours (21600 Ah / .6 = 36 hours)

To move things further along when I measured without my lights the circuit (the 7805, 16 mhz atmega and a bunch of transistors switching nothing frenetically) is using .25 * 10A).  I thought that an arduino should use something like 25 ma while it's running so I'm off by a factor of 10 or 100 depending on how my meter is reading.

That leads me to think that I should remove the 7805 and give the Arduino it's own power source.  Is that recommended for minimizing battery drain.

Summary:
* 4 meters of 12 RGB LED strip @ 114 mA / meter (http://tinyurl.com/12vrgbled)
* 16 mhz 'breadboard arduino' (on a protoboard)
* 7805 giving the arduino 5v (and the bypass to get the lights 12v)
* 8 AA batteries (21600 mAh)

Power reading
@ 10A .6 with lights, .25 without lights
@ 20m 2.8 with lights 1.15 w/o lights

Battery life
* 1.5 -> 2 hours with 8 alkaline AA's

Questions:
1. How do I read my ammeter (is .6 @ 10A setting .6 amps or 6 amps)?
2. How long would you predict the circuit would last?
3. Should I avoid the 7805 and power the arduino from a separate power source?
4. How much would I gain if I did that?

Thanks again, your struggling friend,

Zeke
5  Using Arduino / General Electronics / Re: Measuring current, 12v, 5v, 7805, Arduino on: August 16, 2011, 02:29:43 pm
That's what's confusing me.  When the multimeter is set at 20ma I'm getting a reading of "2.8", but when I set it at 10A I get ".6".

Maybe my multimeter is broken...  I'm using a GB-220 (Gardner Bender)
6  Using Arduino / General Electronics / Measuring current, 12v, 5v, 7805, Arduino on: August 16, 2011, 11:24:10 am
I'm building a battery powered RGB LED display (for a bike).  

It consists of 4 strands of 12v RGB LEDs, a 7805 voltage regulator an atmega328 running the UNO bootloader and some transistors.

It currently drains 8 AA's (1.5v*8=12v) in about 2 hours and I want it to last at least 8, or ideally 12 hours.  

Each alkaline AA should be 2700mah or 21 Ah for the 8 ones.

So, now I'm learning about power.  I've never tried measuring power and so I think I'm doing something wrong.

I placed my multimeter between the battery and my circuit board and with the lights plugged in I'm getting a .6 reading when the meter is set to 10A and a 2.8 reading when it's set to 20m.  Does that mean that I should multiply .6 * 10A to get 6 Amps or is at .6 A or 600 mAh.  

.600 A makes some sense to me since the light should use about 115 mA per color per meter and I have about four meters and one color is on at a time (on average).  If that were true then I my lights should last for days instead of hours.

To move things further along when I measured without my lights the circuit (the 7805, 16 mhz atmega and a bunch of transistors switching nothing frenetically) is using .25 * 10A).  I thought that an arduino should use something like 25 ma while it's running so I'm off by a factor of 10 or 100 depending on how my meter is reading.

That leads me to think that I should remove the 7805 and give the Arduino it's own power source.  Is that recommended for minimizing battery drain.

Summary:
* 4 meters of 12 RGB LED strip @ 114 mA / meter (http://tinyurl.com/12vrgbled)
* 16 mhz 'breadboard arduino' (on a protoboard)
* 7805 giving the arduino 5v (and the bypass to get the lights 12v)
* 8 AA batteries

Power reading
@ 10A .6 with lights, .25 without lights
@ 20m 2.8 with lights 1.15 w/o lights

Battery life
* 1.5 -> 2 hours with 8 alkaline AA's

Questions:
1. How do I read my ammeter (is .6 @ 10A setting .6 amps or 6 amps)
2. How long would you predict the circuit would last?
3. Should I avoid the 7805 and power the arduino from a separate power source
4. How much would I gain if I did that.

Thanks again, your struggling friend,

Zeke


Pages: [1]