Issue moving to standalone board

Hi, I'm currently working on a project that will control 12V output, and I can't get it to function when I move the atmega328 chip to the stand alone board.

The short version is, when the atmega chip is on my Uno R3 and I use the pinouts from the arduino, it runs fine. Everything behaves as it should(I have only tested the outputs). When I move the chip, the outputs don't work, and I read .40V at the output pins. Oddly, I have 5v at pin 14, for a reason I can't really explain because the arduino code just has my 4 output pins, digital pins 6, 9, 10, 11 (atmega pins 12, 15, 16, 17).

I have a 16mhz crystal hooked up (would wrong capacitor values possibly cause this?). Verified ground at atmega pins 8, 22. Verified 5.03V at atmega pins 7, 20.

What's the deal? Can someone help me out? Rookie mistake? The 12V and 5V source have a shared ground, but the 5V source is a regulated source that only touches the arduino/atmega. The rest is controlled with NPN modulation to P-Channel Mosfets so that they are the only components 'touching' the 12V source without level shifting. There are input pins but they are level shifted and I haven't tested those yet.

Thanks in advance. I'm glad I didn't finish school as an electrical engineer(or am I?).

A schematic and/or photo of your actual setup, not a generic breadboard Arduino schematic/photo, and the code that you are using, would make this much easier to troubleshoot.

Make sure your connections are as per here, http://arduino.cc/en/Main/Standalone

Don't forget the 0.1uF capacitor across vcc and ground of the atmega. I also had a hard time making it run standalone without the capcaitor. For best results, put a big capacitor (10uF) and a smaller one (1nF) across the vcc and ground and as close to the atmega chip as possible.

Make sure your connections are as per here, http://arduino.cc/en/Main/Standalone

Don't forget the 0.1uF capacitor across vcc and ground of the atmega. I also had a hard time making it run standalone without the capcaitor.

You are absolutely correct about the need for the capacitors so what you are really saying is "Make sure your connections are NOT EXACTLY as per here".

It is too bad that it is apparently impossible to get things like this corrected. It seems that any time we see the word 'standalone' in the topic heading we have to bring up the need for these capacitors.

Don

Here are the modifications I will make are:

connect .1uF across pin 22 and pin 20. connecting 5V to VREF on pin 21. (I was under the impression it wasn't needed, but I will try these modifications one at time)

I will report back with the findings.

Jaxx: Here are the modifications I will make are:

connect .1uF across pin 22 and pin 20. connecting 5V to VREF on pin 21. (I was under the impression it wasn't needed, but I will try these modifications one at time)

It is not needed to have 5v connected to Vref, and it can create problems in some situations and its best to leave this pin unconnected unless you have a specific reason to use an external voltage source as your ADC reference value. If you are utilizing analog read commands in your standalone programs then just wire a .1ufd cap from the vref pin to ground to gain a little noise filtering for the analog to digital functions. Lefty

I will report back with the findings.

I added a "104" .1uF cap to pin 20 and 22.

Oddly my powersource is now spitting out 7V, pin 14 on the atmel chip has raised from 4V to 5.6V and the pins that are supposed to be high are at .5V instead of the .4 they were before.

I'm so lost. I don't understand what I've done that transferring it to this board doesn't perform the way it is supposed to.

Oddly my powersource is now spitting out 7V

Have you put the recommended (by the manufacturer) capacitors across the input and output pins of the voltage regulator.

Also: Reread Reply #1.

Don

I haven't added the capacitors. The cap values I was a little confused about, as well as which was applicable for my application. http://www.scribd.com/doc/82734831/KA78R05-Low-Dropout-Voltage-Regulator-Data-Sheet It is listed on page 5 of the datasheet, but I don't know what Ci or Co is.

A photo of the design wouldn't help much. There's a bit much going on, but I have confirmed the connections as I have gone.

Here is a quick schematic, forgive me as I am inexperienced with TinyCAD and couldn't find a 28 pin chip. I also might have put the p-Channel MOSFET incorrectly, or the NPN. You get the idea, however.

Here is the code, but it has been swapped out, and a few different versions have been burned to confirm that the code wasn't the issue. As I stated, the issue isn't with the code, it's the transfer from the Arduino board to the standalone perf board. I've tried multiple pieces of code on and off the board. I'll post two versions of what I've tried. There are 4 output pins as I stated in my original post.

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 9;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

This was used for testing purposes, but had no outputs high as they should be. As I mentioned, pin 15 on the atmel chip was .4V. (or .5V in the latter case)

Here was the original code to test the chip while it was attached to the arduino(or something similar... I might just written a similar program to set all to high) The code is not finished, so don't worry about that.

//This is the flasher circuit for the e30 flasher.
//Jackson de Oliveira 2012.07.23
//jacksonde.com
//LF is left front
//RF is right front
//LR is left rear
//RR is right rear
//****************
//OUTPUTS
//pin 6 is LF
//pin 9 is RF
//pin 10 is LR
//pin 11 is RR
//
//Due to requirement to power P Channel FETs, NPNs control gates. In order to enable 12v output, output pin must GO HIGH.
//****************
//INPUTS
//pin 7 is hazard switch button (goes high)
//pin 8 is park signal (goes high)
//pin 12 is left flasher (goes high)
//pin 13 is right flash (goes high)

const int LF = 6;           // pin definitions
const int RF = 9;
const int LR = 10;
const int RR = 11;

const int hazardIn = 7;
const int parkIn = 8;
const int leftIn = 12;
const int rightIn = 13;

int brightness = 128;    // how bright the LED is in "park" mode, out of 255. 0 is off, 255 is on 100%.
long previousMillis = 0;  //last update of loop

long blinkInterval = 1000; //milliseconds blink period

int hazardState = 0; //int to hold what mode the hazard state is in.
//0 is off
//1 is regular hazard
//2 is 4-in-1-sec alternating flash
//3 is 4-in-1-sec continunious
//4 is demo/full cycle

// the setup routine runs once when the chip is power cycled
void setup()  { 
  pinMode(LF, OUTPUT);
  pinMode(RF, OUTPUT);
  pinMode(LR, OUTPUT);
  pinMode(RR, OUTPUT);
  pinMode(hazardIn, INPUT);
  pinMode(parkIn, INPUT);
  pinMode(leftIn, INPUT);
  pinMode(rightIn, INPUT);
}

// the loop routine runs over and over again forever:
void loop()  { 
  //CHECK FOR INPUTS
  int hazard = digitalRead(hazardIn);
  int park = digitalRead(parkIn);
  int left = digitalRead(leftIn);
  int right = digitalRead(rightIn);
  unsigned long currentTime = millis();
  
  
  //troubleshooting code, set all outputs to ON
  digitalWrite(LF, HIGH);
  digitalWrite(RF, HIGH);
  digitalWrite(LR, HIGH);
  digitalWrite(RR, HIGH);
  
  if(hazard == HIGH)
  {
    //hazard is currently pressed
    //start a counter for long vs short presses and debounce.
    
    //check for debounce and press length. if press length is >50, increment state. if press length >1000, nullify state.
    
  }
  else
  {
    //hazard is no longer pressed
    if(hazardState -= 0)
    {
      //hazard currently not active!
      //check for park
      
      //check for left
      
      //check for right
      
    }
  }
}

Does anyone have any input?

More than one person using this forum has failed to get a standalone Arduino working because the capacitors attached to the crystal pins were the wrong value. Check that they really are 10pF, not 10nF or something else. Actually, 10pF is rather low, 18pf or 22pF is usually recommended. I normally use a 3-terminal ceramic resonator instead, which has these caps built-in.

...also you MUST have a capacitor between the regulator input and ground. The datasheet doesn't give a value. I suggest 100uF electrolytic in parallel with 0.1uF ceramic.

Thank you for the useful feedback. I have ordered the necessary parts for the amendments and I will report back if the issues aren't solved.

I have made all the changes you suggested, a 100uF and .1uF across Vin and ground, the voltage regulator's Vout is still 7.3xV, and there is no functional change on the atmel chip from changing the crystal caps to 22pF.

Unless I'm missing something painfully obvious, I'm giving up on this project for the time being. I'm not sure what I did wrong, but I would guess it is something to do with the voltage regulator (a KA78R05 ldo 5v) or an issue of my pin configuration on the dip socket.

Do you have a schematic of the standalone system your trying to setup as it would make finding the problem a lot easier.

Riva:
Do you have a schematic of the standalone system your trying to setup as it would make finding the problem a lot easier.

It is in reply 8, the top section of the schematic shows all pins that would have an active connection.

edit: Do I need a pullup resistor on pin 1?

are all your ground pins attached to ground? Curious, why is the base of the npn connected to the 5v output? Is it supposed to have a constant power or is it triggered? Also, and I dunno if this makes much difference, but when I throw my 328s on their own, I use 10uf caps with the regulator, and if it's not using its internal crystal, I use 22pf on the crystal pins. Also for standalone, I use a 10k pull down resistor in conjunction with a reset button (according to the standalone schematic on the website). Other than that, from a noobs pov, I would he as lost as you are :(. Best of luck, though! Also, if it's not too much trouble, do you have a detailed pic of the circuit on a breadboard?