Show Posts
Pages: [1] 2 3 ... 44
1  Using Arduino / Storage / Atmega328P-AU interfacing with an SD Card at 3.3 V system voltage on: July 24, 2014, 02:11:27 pm
I've never made anything except 5 volt projects, but trying to connect an SD card, I think it might be time to test out a 3.3 volt system. I think the answer is yes to all these questions, but I just want to be sure:
If my Atmega328P-AU runs at 3.3 volts, I can just connect pins 10-13 (SPI) directly to the SD socket?.
If I run it at 3.3Volts, I'll need to flash a different Bootloader on the Atmega328P-AU than the one I use for 5volt?
I will need to use an 8Mhz crystal instead of a 16Mhz one?
I have an FTDI board I use to program my projects that has a 3.3V/5V switch, so I can use that to program it?
Thanks
2  Using Arduino / General Electronics / Re: resistor placement for Atmega328P-AU on: July 19, 2014, 11:30:31 am
Yes.
Don't forget  a cap on Avcc also.
Thanks, for verifying that for me.
3  Using Arduino / General Electronics / resistor placement for Atmega328P-AU on: July 19, 2014, 09:31:45 am
I've started using 2 decoupling caps for the AU version, since there's Vcc/GND on 2 opposite sides of the chip.  To try to keep them as close to the chip as possible had to run the Aref grounding cap through the one.  I guess this is ok.  See the photo.  The cap on the cap side of the Atmega is a Vcc/gnd decoupling cap, and the cap right above it is the Aref cap that goes to GND.  Does this layout look suitable?
thanks.
4  Using Arduino / Project Guidance / Re: disabling a MAX16910 with a DS3234 on: July 03, 2014, 03:21:11 pm
I really would like to be able to power up a project using the alarm from the DS3234 RTC, so as to have ultra low quiescent current.   The DS3234 only uses about 1.5uA when running off the coin cell, and the MAX16910 regulator only uses 1.6uA when in shutdown. I see 2 problems I'm not sure how to overcome.

1) The data sheet says the INT pin on the DS3234 needs a pull-up resister.  But if it's connected to 5V like in my schematic, there isn't 5V because the regulator will be powered off.

2) Enable on the regulator needs to be pulled high (2.4V or more, from the data sheet) to start up the regulator. But when the RTC chip's alarm is triggered, the INT pin goes LOW.

    I've drawn up these 2 components with their recommended schematics from the data sheets.  See the attached photo or pdf file.
thanks for the help!
5  Using Arduino / Programming Questions / Re: #ifdef doesn't seem to be working on: July 02, 2014, 08:07:51 am
WHEW! Thanks again.  I thought I was in big trouble, but you are right:

Code:
#include <EEPROM.h>
#include "writeAnything.h"
#include <math.h>
//#define PCB_Version_2.0
//#define PCB_Version_4.0
#define PCB_Version_4.2

int CenterDebounce = 15;  //+- this much is still considered center on the joystick
int motorUpPin = 6;   
int motorDownPin =11;
int LEDpin;
int analogPin;
int buttonPin;
char splashScreen[50];
struct config_mySettings { //these are stored in EEPROM
  unsigned long center;    //center reading of axis on joystick
  unsigned long up;        //upper limit of axis on joystick
  unsigned long down;        //lower limit of axis on joystick
}
joystick;

I will touch up my code, putting them back the way they should be.  I had moved them to setup(), trying to solve that initial problem.
thanks again.
6  Using Arduino / Programming Questions / Important Concern on: July 01, 2014, 09:56:06 pm
I have finished a project and have a few motor controllers ready to ship out to friends.  But I see now that my sketch does what you said not to do.  But it works, so I don't understand why.  I declared my variables in setup(), but use them in loop().  But my controllers work perfect, so will they ever stop working because of this?  The variables in question don't actually change, they are just defining pin numbers.  see my setup and loop below:

Code:
void setup(){
    Serial.begin(9600);
#ifdef PCB_Version_2.0
  LEDpin = A1;        //power indicator
  analogPin = A2;     //joystick connected to A2
  buttonPin = A5;     //program button on digital pin 2
#endif

#ifdef PCB_Version_3.0
  LEDpin = A1;        //Power indicator
  analogPin = A3;     //joystick connection pin
  buttonPin = A5;     //program button
#endif

#ifdef PCB_Version_4_0
  LEDpin = A5;        //Power indicator
  analogPin = A3;     //joystick connection pin
  buttonPin = 2;      //program button
#endif

#ifdef PCB_Version_4.2
  LEDpin = A5;        //Power indicator
  analogPin = A2;     //joystick connection pin
  buttonPin = 2;      //program button
#endif
  
  pinMode(buttonPin, INPUT);  //set pin as input
  pinMode(motorUpPin, OUTPUT);
  pinMode(motorDownPin, OUTPUT);
  pinMode(LEDpin, OUTPUT);
  digitalWrite(LEDpin, HIGH); //power indicator
  digitalWrite(buttonPin, HIGH);  //turn on pullup resistor
  digitalWrite(motorUpPin, LOW);  //be sure motor is off
  digitalWrite(motorDownPin, LOW);  //be sure motor is off
  analogWriteSAH_Init();  //this initiates the PWM timer to run on 20Khz
  EEPROM_readAnything(50, joystick);     //load settings from EEPROM
}

void loop(){
  if (buttonPressed()) {  //has the program button been pushed?
    Serial.println("The button has been pressed.");
    Serial.println("Entering program mode.");
    programMode();  //enter program mode if so
  }
  int reading = analogRead(analogPin);  //get a reading from the analogPin
  if (reading < 100 || reading > 900) error(); //the reading is way out of range (connector failure??)

  int offset = reading - joystick.center; //how far the reading is from the center value
  offset = abs(offset);
  //Serial.print("THE READING:  ");
  //Serial.println(reading);
  if (offset < CenterDebounce) { //we'll allow for the center reading to float a little
    motorIdle();  //turn off motor if it's this close to center
  }
  else if (reading > joystick.center) motorUp(reading);   //motor up in this range  ( center + 35 < reading < 900 )
  else if (reading < joystick.center) motorDown(reading); //motor down in this range ( center - 35 > reading > 100 )
  delay(10);
}

I can change them all if need be, but it will envolve a great deal of unpackaging.  They work now.  Will they ever NOT work because of this problem?  What I've read online says a variable declared in setup is NOT available to use in the loop.
7  Using Arduino / Programming Questions / Re: #ifdef doesn't seem to be working on: July 01, 2014, 09:40:07 pm
Ok, thanks for solving that mystery!
cheers.
8  Using Arduino / Programming Questions / #ifdef doesn't seem to be working on: July 01, 2014, 11:11:00 am
I've seen people use this in code, and thought I'd try it.  I have different PCB version, which use different pins from the Arduino.  So I can uncomment the version I need when uploading, but I get the redeclaration error. Is there something wrong with the way I'm using #ifdef?


Code:
//#define Version_3.0
//#define Version_4.0
//#define Version_4.1
#define Version_4.2

int CenterDebounce = 15;  //+- this much is still considered center on the joystick

struct config_mySettings { //these are stored in EEPROM
  unsigned long center;    //center reading of axis on joystick
  unsigned long up;        //upper limit of axis on joystick
  unsigned long down;        //lower limit of axis on joystick
}
joystick;


void setup(){
#ifdef Version_3.0
  int motorUpPin = 6;     //pin 6
  int motorDownPin = 11;  //pin 11
  int LEDpin = A5;        //Power indicator
  int analogPin = A2;     //joystick connection pin
  int buttonPin = 2;     //program button
#endif

#ifdef Version_4.1
  int motorUpPin = 6;     //pin 6
  int motorDownPin = 11;  //pin 11
  int LEDpin = A5;        //Power indicator
  int analogPin = A2;     //joystick connection pin
  int buttonPin = 2;     //program button
#endif

#ifdef Version_4.2
  int motorUpPin = 6;     //pin 6
  int motorDownPin = 11;  //pin 11
  int LEDpin = A5;        //Power indicator
  int analogPin = A2;     //joystick connection pin
  int buttonPin = 2;     //program button
#endif
9  Using Arduino / Microcontrollers / Re: Atmega328P-AU is working, but won't take an upload on: June 20, 2014, 10:41:39 pm
I figured it out.  I had to change to board to Arduino Pro Mini, instead of Uno.  On Atmega328P-AU chips I've bought with the boot loader already on them, I just just UNO as the board, but when I loaded the boot loader on mine, I used Pro Mini as the board.  The ones I've bought must have had a different boot loader on them.
10  Using Arduino / Microcontrollers / Atmega328P-AU is working, but won't take an upload on: June 20, 2014, 04:36:14 pm
I burned the boot loader on these, and then uploaded a sketch that blinks D13, and sends a Serial String out every second, so it is easy to test them when installing them on new boards.  I uploaded this sketch on them via arduino's boot loader, not the ISCP header, so that I'd know for sure the bootload went ok.
So now, I have two of these new boards, and and after populating them, they both send out the serial string when I connect them with my FTDI breakout, but neither will take an upload.   Being that they send out the serial, that means the power supply is connected to the chip correctly thru the FTDI breakout, and that the TX is connected.  I check the continuity of the DTR pin, and the 0.1uF cap on it, which checked correctly at 100nF.  
Any ideas why this would be.  I even took off a few components like a Pololu SW and a remote RF receiver from one of them, but that didn't help.
I've cleaned them 3 times with alcohol and a toothbrush. I've also connected 12v to it's powered supply which feeds the board thru a 5 volt LM1117, and it would light up the onboard LED and continue to send the Serial string...

edit: I'm sorry these photos are upside down! also, I've tried my FTDI cable with a different project, and it works fine loading sketches on it.  It's also the Atmega328P-AU version.

Oh, the issue is, I get the message  avrdude: stk500_getsync(): not in sync: resp=0x00
11  Using Arduino / General Electronics / Re: running traces under the crystal on: June 17, 2014, 09:57:02 pm
Quote
4.6 PCB layout
Finally, the importance of the physical location of the resonator in relation to the AVR should be stressed. Always place the resonator as close to the AVR as possible and shield the resonator by surrounding it with a ground plane.
...I found this in that pdf you mentioned.  Thanks, that's a nice little PDF file.  It's not quite as intimidating as the data sheet on the ATmega328P!
12  Using Arduino / General Electronics / running traces under the crystal on: June 17, 2014, 09:38:59 pm
Does it hurt to run a trace under my SMD crystal, for my Atmega328P-AU?  See the photo, the trace that is highlighted is the reset signal that the FTDI header uses to program the Arduino.
Thanks
13  Using Arduino / General Electronics / Re: Interference of 2 Bluetooth Modules, top and bottom of PCB on: June 17, 2014, 07:32:11 pm
Thanks, good to know.  I don't have 2 yet, so I couldn't test it out, but I figured it'd work okay.
14  Using Arduino / General Electronics / Interference of 2 Bluetooth Modules, top and bottom of PCB on: June 15, 2014, 08:36:28 pm
If I have 2 bluetooth mates that SPARKFUN sells, one on the top of my custom PCB, the other on the bottom side, so that their chip antennas are located opposite one another, will they still function fairly well?  I only need about 15 feet of distance from both of them.

https://www.sparkfun.com/products/12576
15  Using Arduino / Motors, Mechanics, and Power / Adding PID to my Segway on: April 04, 2014, 11:41:04 am
this 20 second video clip shows my trouble:
My segway code uses an IMU (the MPU-6050) and comes up with the angle of the platform.  It then just maps the angle from about plus or minus 20 degrees to plus or minus 0-100 percent motor speed.  It works well with a rider, but when it's empty it is way to sensitive.  I don't have any kind of PID control, but the PID library looks very hopeful!
    Right now, I only use the IMU to figure out the angle, and that's it.  But I think I also need to use the raw gyro reading as the key number in the PID.  If the gyro reading is very high (or very low for the backward movement), than I could use it to tell the PID not to react as fast/severe.  Does this sound good?  I see the PID library has the setTunings() function to change the 3 values as it's running.  Kp, Ki, & Kd.  I'm not sure which of these I need work my gyro reading into:
Quote
Kp: Determines how aggressively the PID reacts to the current amount of error (Proportional) (double >=0)
Ki: Determines how aggressively the PID reacts to error over time (Integral) (double>=0)
Kd: Determines how aggressively the PID reacts to the change in error (Derivative) (double>=0)

Does anyone have any help on this.  I've search quite extensively on the web, but haven't come up with anything.
thanks.
Pages: [1] 2 3 ... 44