Pages: [1]   Go Down
Author Topic: 5v project not working on 3.3v  (Read 1795 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I wonder if there must be made any softwaresided changes in order to make my atmega328p-pu work on 3.3v with 8mHz crystal, which is programmed being plugged into an arduino UNO (on 5v of course) and then clipped to a breadboard.

This chip works fine if I power the breadboard with 5v (still using 8mHz crystal with 22pF decoupling capacitors), i.e. the pwm signal on pin 6 tested with the code below varies between 0 and 5v, but if i power it with 3.3v (another arduino as source, or my iPod), my multimeter shows only 0,1v, all the time.

What am I doing wrong? I really don't want to use a step-up booster and - for sure - the used 3.3v source has enough power (logical considering that it works on 5v).

My breadboard installation doesn't matter in this case, because this behavior is apparently related to the atmega itself.

Any help is greatly appreciated, I am still new to Arduino!

Greets,
Flok3r

Code:

int out_A_pwm = 6;
int out_A_in_1 = 7;
int out_A_in_2 = 8;

int i = 1;
int pwm = 0;


//----------------------------------
void setup() {

  // Motor part ----------------
  pinMode(out_A_pwm,OUTPUT);
  pinMode(out_A_in_1,OUTPUT);
  pinMode(out_A_in_2,OUTPUT);
  digitalWrite(out_A_in_1, HIGH); //setting direction of the motor
  digitalWrite(out_A_in_2, LOW);

}
//------------------------------------
void loop(){
  if (pwm == 255) i = -1;
  else if (pwm == 0) i = 1;
 
  pwm = pwm + i;
  analogWrite(out_A_pwm, pwm);
  delay(5);
 
}

Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4086
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Boy that's a tough one, seems like it should just work. Should not be related to the ATmega. When you power the breadboard with 3.3V, you have verified that it is indeed supplying 3.3V under load, right?

Edit: Timings will be off. Programming the chip in an Uno assumes a 16MHz clock. When the chip is then moved to the breadboard running at 8MHz, delay(1000) will actually result in a two second delay, etc. Not entirely sure about PWM, should probably work, although I'd think the PWM frequency would be halved as well. Still, it ought to run.

Your sketch is pretty simple, but when faced with a conundrum like this, I always back off to the simplest thing possible, i.e. the Blink sketch.
« Last Edit: October 02, 2011, 08:44:54 am by Jack Christensen » Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the used 3.3v source has enough power (logical considering that it works on 5v).
How much current is your circuit drawing?

It is possible that your 3.3V sources don't have enough current capacity for your circuit.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Of course, yea. And this is the really weird thing, why does it perfectly work on 5v and not at all at 3.3v?
So, i suppose, it doesn't matter.. shouldn't matter if the atmega is programmed using an 5v/16mHz Uno and then moved on a 3.3v/8mHz breadboard?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Jamed C4S

This i ment with the quoted line:
The 3.3v source provides enough power, actually more when using my iPod, otherwise i simply power it with the 5v or the 3.3v pin of another arduino.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Edit: Timings will be off. Programming the chip in an Uno assumes a 16MHz clock. When the chip is then moved to the breadboard running at 8MHz, delay(1000) will actually result in a two second delay, etc. Not entirely sure about PWM, should probably work, although I'd think the PWM frequency would be halved as well. Still, it ought to run.

Your sketch is pretty simple, but when faced with a conundrum like this, I always back off to the simplest thing possible, i.e. the Blink sketch.
Yes, thought about that too, but doesn't explain this behavior. I believe having read somewhere that sketches will run equally on 16 and 8 mHz, because these frequencies are supported by the default bootloader, only things like 10 or 20 mHz require a reconfigured one.

Yes, I just made this simple sketch to figure out what is going wrong, the real code doesnt work either of course.
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The 3.3v source provides enough power, actually more when using my iPod, otherwise i simply power it with the 5v or the 3.3v pin of another arduino.

You repeated the same line that doesn't make sense.  I'm confused what an iPod has to do with your Arduino.  The reason something works at 5V and not at 3V is because the sources are different.  You are probably using a 5V source that is able to supply several hundred milliamps; while the 3V3 regulators on the Arduino are only rated for 50mA.

Measure how much current your circuit is using at 5V.  This will give you an idea of how much current it will draw at 3V3.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry if that wasn't clear enough.
Its not a source problem for sure. The current draw of the test installation is below the rated 50mA for the 3.3v pin of an UNO, but my iPod (used as source in my project, providing regulated 3.3v) provides even more.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4086
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The test sketch you posted refers to motors. Are they actually hooked up?
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It could be that the brownout detector voltage set by the extended fuse byte is too high. You can check this by using avrdude to read the fuse bytes, and then using http://www.engbedded.com/fusecalc to decode them. Bear in mind that the brownout detector is referenced to the internal 1.1v reference, which has a tolerance of around +/-9%.

Can you confirm that you have at least one 100nF decoupling cap between and close to the Vcc and ground pins of the mcu? Also that you have connected Avcc to +5v and Agnd to ground even if you aren't using the ADC?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think so, because it is one of the chips being delivered together with the arduino board, factory settings should work, or not?
But thanks for the advice, I learned something again smiley-grin
Anyway, I'll test that when I have time, meanwhile I use a step-up booster for the mcu circuit and the 3.3v to power the motor.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6619
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think so, because it is one of the chips being delivered together with the arduino board, factory settings should work, or not?

The standard extended fuse byte in the boards.txt file (used when you use the IDE to burn a bootloader into an atmega328p) is 0x05, which sets the brown-out level to 2.7v typical, 2.9v maximum. That should be OK on 3.3v. However, if your chip has the fuse programmed as 0x04, the brownout level would be 4.3v typical, 4.5v maximum.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12205
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry if that wasn't clear enough.
Its not a source problem for sure. The current draw of the test installation is below the rated 50mA for the 3.3v pin of an UNO, but my iPod (used as source in my project, providing regulated 3.3v) provides even more.

The 3.3V supply from an Arduino is (for some boards) rated at 50mA absolute max.   On connecting the load it will try to draw much more current briefly to charge the decoupling capacitors, which could cause problems?

The standard configuration of a 328 for Arduino is with brown-out threshold set to 2.7V, which is a little too close to 3.3V for comfort - perhaps the brownout detector is kicking in before the 3.3V supply has stabillised?

It is essential that AVcc and Vcc are within 0.3V of each other, BTW, someone's already hinted at this.

If you run at 3.3V you must ensure that no pin goes above 3.6V or below -0.3V at any time.
Logged

[ I won't respond to messages, use the forum please ]

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3488
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Double check if your power supply is really delivering 3.3V to the chip. Measure at the chip.

If there are 3.3V and it still doesn't work, maybe you should drop the frequency further. If you setup would be fine with a lower frequency then this would be a solution. The point is that lower frequency implies lower admissible voltage for stable operation.
Logged

Check out my experiments http://blog.blinkenlight.net

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sooooo,
First of all: Thanks for all your great advices, they help me understand the mcu-world a bit more!
I can't exactly determine the mistake i made, but after re-organizing the breadboard components and changing some cable it somehow worked suddenly, so probably a lack of electrical connection somewhere, which is weird, because I had already removed / moved some stuff in order to minimize testing configuration and localize the mistake.
Though not everything works perfectly now ("fake" gnd and vc on analog pins have only 2.7v), it works!
Since I am really very new to all this, it also could have been a decoupling mistake.
Thanks, solved!
« Last Edit: October 03, 2011, 12:16:09 pm by flok3r » Logged

Pages: [1]   Go Up
Jump to: