Show Posts
Pages: 1 [2] 3 4 ... 44
16  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
17  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.
18  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
19  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!
20  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
21  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.
22  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
23  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.
24  Using Arduino / Motors, Mechanics, and Power / Fly back diode for small relay on: March 29, 2014, 09:42:33 pm
I have this tiny SMD relay:
http://www.digikey.com/product-detail/en/IM03DGR/PB1172CT-ND/1828462


Would this diode work well to put across the coil for the fly back voltage?
http://www.digikey.com/product-detail/en/BAT54KFILM/497-5561-1-ND/1207053

I've been using a much larger SMD one, it's more like the typical  1N4001, but if I could find one in a smaller package that'd be great. This one I found it a schottky, which I've read is good for fly back voltage?
Thanks.
25  Using Arduino / Motors, Mechanics, and Power / Re: Motor fly back or something else? on: March 28, 2014, 02:24:49 pm
The 47uF cap for the 2N3904 transistors -- does it just go from 5V to Gnd, near the 2N3904?
26  Using Arduino / Motors, Mechanics, and Power / Re: Motor fly back or something else? on: March 27, 2014, 12:16:49 am
Add something like 47uF electrolytic decoupling close to the relay switching transistors -
the current pulses from turning on/off the relays is probably triggering reset.  The
ATmega should have 0.1uF caps on each supply pin, not just one of them.

Any wiring connected to the reset pin needs to be routed away from all the high-current
paths to the relays and motors, or perhaps change the 10k pull-up on it to 1k.

I just discovered I don't even have pin 6 (Vcc) of the Atmega328P-AU connected to anything! That could be causing a problem?  Pins 4 & 6 are Vcc, pins 3 & 5 are GND.  One cap in there would be as close to one Vcc as the other, but maybe that's what you meant-that you saw I didn't even have the one pin connected?  What about pins 18 & 21? They are AVcc & AGnd.  I have them tied to Vcc & Gnd, respectively.  Should I add a 0.1uF cap by them?

The 47uF cap for the 2N3904 transistors --I'm not sure where to put them.  Check out my picture, They are C7 & C8.  I'm guessing C7 is the right way to do it, but I don't understand transistors well enough to visualize how they work.
27  Using Arduino / Motors, Mechanics, and Power / Re: Motor fly back or something else? on: March 25, 2014, 09:41:02 pm
https://www.dropbox.com/s/m3ykh9c3pykipqj/Version%204.0.pdf
Here a PDF file of my schematic.   I can't seem to get a photo uploaded tonight.
28  Using Arduino / Motors, Mechanics, and Power / Re: Motor fly back or something else? on: March 25, 2014, 08:19:32 pm
Sorry about the poor photo. I'll upload a better one when I get home. The grounds are connected because they are the same. I have two 3 D cell battery packs wired in series. 4.5 + 4.5 volts. The Arduino is powered off one, the motor off both for 9 volts.   I wouldn't put a diode across the terminals, but rather 4 of them, 2 tying each motor terminal to gnd and 9 volts, to take care of fly back voltage, but I'm not sure that's the problem. Fly back should be affecting the 4.5 volt should it? It seems more like when the motor starts it drops the voltage for a split second. I didn't put any polarized caps in the system like I do when using a voltage regulator, I thought battery voltage would be constant, but I wonder if it's dropping out sometime when the little motor starts.
29  Using Arduino / Motors, Mechanics, and Power / Motor fly back or something else? on: March 25, 2014, 05:41:38 pm
My Atmega controls my motor via 2 double throw relays, to give me forward and reverse. The whole thing is battery powered, no voltage regulators.  (6) C batteries. The atmega runs on 4.5 volt, the motor on 9 volt. When the motor cuts on and off sometimes it resets my Atmega. I have a fly back diode on the relays' coil, but that is all. Do I need it on the motor, too?  I put a 0.1 uF cap across the motor terminals like someone suggests to help noise, and now my Atmega resets every time the motor turns on. I put a 1000uF cap across gnd and 9 volts, and that fixed my issue.  I'm just wondering if that's the appropriate fix?  Would the motor diodes fix this problem, or would I still need a large cap in the picture?
30  Using Arduino / General Electronics / Re: DS3234; Deactivating an alarm on: March 21, 2014, 09:35:19 am
Thanks!  I see how that works again.  I've tried wrapping my brain around it but it doesn't stick.  After rereading the arduino reference page on bitwise, I see that you are just adding the binary digits together.  I couldn't figure out how it knew what those things were, like DS3234_INTCN, and  DS3234_A2IE , but I found in the library's .h file that their defined, as 1, 2 4, etc, representing binary numbers.  So just putting in the INTCN will 'take out' the alarm values.  Kinda neat when you understand it!  Thanks again.
Pages: 1 [2] 3 4 ... 44