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:
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.
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.
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.
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.
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?
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.
Bit 1: Alarm 2 Interrupt Enable (A2IE). When set to logic 1, this bit permits the alarm 2 flag (A2F) bit in the status register to assert INT/SQW (when INTCN = 1). When the A2IE bit is set to logic 0 or INTCN is set to logic 0, the A2F bit does not initiate an interrupt signal. The A2IE bit is disabled (logic 0) when power is first applied. Bit 0: Alarm 1 Interrupt Enable (A1IE). When set to logic 1, this bit permits the alarm 1 flag (A1F) bit in the status register to assert INT/SQW (when INTCN = 1). When the A1IE bit is set to logic 0 or INTCN is set to logic 0, the A1F bit does not initiate the INT/SQW sig- nal. The A1IE bit is disabled (logic 0) when power is first applied.
Sorry, I've only ever used the Arduino IDE to load sketches or burn bootloader to Atmega chips. I guess avrdude is a program? It sounds like it might just be easier to use jumpers from my UNO's pins to my TFQP adapter when I want to program the Atmega328P -AU chips. I thought this usbasp. Thing would just show up as a serial port that I'd select when I want to burn a bootloader.
I got this TQFP32 programmer and have used it to boatload ATmega328P-AU chips by connecting the pinout to the appropriate pins on my UNO, and using my UNO as the ISP. Since these USBasp's from china were so cheap, I thought I'd try one. I just figured I could plug my TQFP adapter into it and viola! But maybe not. Is there a trick to using these on a macbook 10.7, or is it more trouble than it's worth? See the photo of what I have, and also a couple links of the items: http://www.ebay.com/itm/171201827956?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
To visualize my question, here is the schematic after I made these changes. Will this work? I'm wondering if the TX & RX pins are connected correctly, though. Do I need the FTDI's TX pin to connect to the Atmega328's RX pin?
I want to add an FTDI chip to my project so it can be connected via USB, rather than a separate FDTI cable. So I copied the schematic from the FTDI basic, from Sparkfun, and pasted it into my new project. Since I won't be using 3.3 volts, can I delete C1 and the net connected to pin 17 on the FTDI chip? And can I remove the solder jumper SJ2, and then connect pin 4 on the FTDI chip to 5V? I think this is right, but want to make sure. After doing this, the 2 schematics will just kinda merge together into one I believe, with the FTDI allowing the USB port to talk to the Atmega chip. Thanks.
ps. Also, I see CTS from the FTDI chip will not be connected to anything. It's ok to leave it unconnected? The DTR pin is what resets the Atmega chip during programming, right?