ArdIU - Open source flight computer w/ ATMega328

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

LithosphereRocketry

Pining for the Fjords
Joined
Feb 19, 2017
Messages
882
Reaction score
93
So, as well as rockets, I also dabble in programming and electronics. Of course, that means that I'm required to make my own flight computer... I'm under 18, so I can't do dual deploy, but I can still stage composites. (Can I use A10's as separation motors for dual deploy?) I'll build it with 4 pyro channels and a barometer in case I end up selling it. I've also considered active stabilization with canards, so I'll throw in 4 servo channels & an accelerometer/gyro breakout. Datalogging is nice... Throw in an 8k nonvolatile FRAM board...

Oh wait, I'm out of pins. Throw in a shift register and put all 4 pyros, 3 LEDs, and a buzzer on 3 pins... Sounds good to me. Program via separate USB serial adapter...

There won't be any possibility of GPS or telemetry.:sigh: I'm out of pins (again) and I can't put any sensors on shift registers.

Current parts list:
-ATMega328 processor
-74HC595 shift register
-BMP280 barometer breakout
-MPU6050 accel/gyro breakout
-8kB SPI FRAM breakout
-SOT-223 size MOSFETs (4)
-5V regulator
-100uF power supply stabilizing capacitors (2)
-22pF oscillator capacitors (2)
-Crystal for processor clock
-Piezoelectric buzzer
-LEDs (4)
-330 ohm resistors (4)
-10k resistor
-Reset pushbutton
-Lots of headers
-Screw terminal blocks (6 2-pin)

I probably forgot something and will need to redesign completely... But I do have everything tentatively routed out, because I was bored...
ardiu_1_0_pcb.jpg

More will come... at some point...
 
Looks like a fun project. Just watch out for maxing out the 6050's G readings & do some good planning on what you want to record in that 8k of memory. Have fun with it!
 
Thanks!

The 6050 can read 16 G max, but I'll be using it mostly for the gyro. I'm planning on adjusting the record rate based on the flight profile- probably 10 bytes per sample means 1:20 at 10hz or 8 seconds at 100hz.

Sent from my LGL44VL using Rocketry Forum mobile app
 
If that's your entire parts list let me suggest some additions.

Decoupling caps 0.1uf (2) on the AT328P.
Gate resistors (~1K) 2 ea on your MOSFET gates.

The BMP280 and MPU6050 are 3V devices, you need to run the AT328P on 3 or 3.3V not 5V.
 
If that's your entire parts list let me suggest some additions.

Decoupling caps 0.1uf (2) on the AT328P.
Gate resistors (~1K) 2 ea on your MOSFET gates.

The BMP280 and MPU6050 are 3V devices, you need to run the AT328P on 3 or 3.3V not 5V.

I think he's planning on using breakout boards with on-board regulators, that takes care of the 5V issue for them. However, running the processor on 5V and the other silicon at 3.3V creates a voltage mismatch on the interface side (SPI and I2C), so he either needs to either match the voltages by running the processor at 3.3v, or add some interface circuitry to match them. It's much easier just to run everything at 3.3V.
 
If that's your entire parts list let me suggest some additions.

Decoupling caps 0.1uf (2) on the AT328P.
Gate resistors (~1K) 2 ea on your MOSFET gates.

The BMP280 and MPU6050 are 3V devices, you need to run the AT328P on 3 or 3.3V not 5V.

Can you clarify where to put the capacitors? The two 100uF capacitors are meant to stabilize voltage spikes (there's one on each side of the regulator).

Yes, I'm using breakout boards (I don't want to deal with microscopic ICs). I've tested my boards with a stadard Arduino at 5V on all logic and they work perfectly.

CErving- I'd love to run everything at 3.3V so I can use 1S LiPos. However I've never used 3.3V in anything so I'd rather keep it at 5V- I want this to use as much of what I already know as possible.
 
Can you clarify where to put the capacitors? The two 100uF capacitors are meant to stabilize voltage spikes (there's one on each side of the regulator).

Yes, I'm using breakout boards (I don't want to deal with microscopic ICs). I've tested my boards with a stadard Arduino at 5V on all logic and they work perfectly.

However I've never used 3.3V in anything so I'd rather keep it at 5V- I want this to use as much of what I already know as possible.

Decoupling capacitors: Refer to the datasheet on the AT328P or look at the reference schematic for an Arduino. The 328P has 2 Vcc pins. Right next to each Vcc pin is a ground pin. Place at 0.1uf ceramic capacitor across these pins as close to the chip as you can. That is not a suggestion but a requirement for this chip to work reliably.

Voltage level: You need to make sure the CS and SPI pins on the BMP280 and MPU6060 are 5V tolerant. That info should be in the datasheets.

Good luck!
 
Decoupling capacitors: Refer to the datasheet on the AT328P or look at the reference schematic for an Arduino. The 328P has 2 Vcc pins. Right next to each Vcc pin is a ground pin. Place at 0.1uf ceramic capacitor across these pins as close to the chip as you can. That is not a suggestion but a requirement for this chip to work reliably.

Voltage level: You need to make sure the CS and SPI pins on the BMP280 and MPU6060 are 5V tolerant. That info should be in the datasheets.

Good luck!

I see the capacitors you're talking about on the Arduino datasheet. However, I can't seem to find anything about them in the ATMega datasheet. My guess is that they just make sure the power supply stays stable at 5V to try to avoid brownouts/surges. Everything shares the same VCC- I can't imagine it's different from one place to another. The extra board in between is essentially a very inefficient capacitor, so that shouldn't make a difference.

I've used both the BMP280 and MPU6050 boards at 5V numerous times before. The breakout boards are designed with Arduino in mind, so I'm good on that front.

Besides, I'll test out the whole thing on a breadboard in the exact same configuration before using it.
 
CErving- I'd love to run everything at 3.3V so I can use 1S LiPos. However I've never used 3.3V in anything so I'd rather keep it at 5V- I want this to use as much of what I already know as possible.

It's easy... just swap the 5V regulator for a 3.3V one. There are a few minor issues with the breakout boards that I won't go into, but it should work fine.
 
Good work there. Very Impressive for someone at your age.
I have been using the same components for a recording altimeter as well as using an additional pyro board for dual deployment.
I did not have a nicely printed board so I soldered everything together on a circuit board and connected things together, kind of a mess.
I have used two of these (One with a Nano and one with bare bone ATMega328P) in my two rockets and they worked fine for several flights as long as you don't peg the accelerometer at 16G (no Warp or Vmax motors).
Bryan Sparkman (see his award winning NARAM report) used similar setup and was kind enough to share his Arduino code so I could modify it for my purposes.
Now I have added an ADXL78 70G single axis chip with an ADC but it's a pain to calibrate and I always have to fly it to figure out the calibration values (it seems to be off by a couple of Gs so I have to add it in the code).
The MPU-6050 is a lot easier to calibrate, always on the money. By the way, I only use 3.3V voltage regulator for the BMP-180 (or newer 280) and the MPU-6050 and run it through the I2C even with 5V logic, with no problem.
These are on breakout boards and so they already come with the decoupling capacitors and circuitry as recommended in the data sheet.

-John

P.S. Does anyone know where I can get some Arduino code to read values from the AIS1120SX accelerometer? It only uses SPI.
 
" For devices with multiple pairs of power and ground pins, it is essential that there is a decoupling capacitor for every pair of pins. "

https://www.atmel.com/Images/Atmel-...ign-Considerations_ApplicationNote_AVR042.pdf

OK, thanks- that was the datasheet I was missing. Those capacitors shouldn't be a big deal to add.

It's easy... just swap the 5V regulator for a 3.3V one. There are a few minor issues with the breakout boards that I won't go into, but it should work fine.

I don't think it's necessarily that easy- I think I remember seeing a penalty in clock speed at lower voltage in one of the datasheets. If I remember right, my 16MHz clock gets me down to 4V-ish. The 5V isn't a big deal- all of my breakout boards are 5V ready and I'll rarely be trying to cram this into small spaces.
 
Hello Lithosphererocketry. Firstly, good luck with your project. It looks like you will have a lot of enjoyment (and challenges :wink:) along the way.

Decoupling caps. As others' have said check the data sheet and put enough of the required small ones (100n or thereabouts) close to the parts that need them, and the large ones can generally go anywhere on the board (within 6" is usually a reasonable rule-of-thumb).

Consider putting some form of RF filtering on any lines that go off the board. This can help with EMC (electromagnetic compatibility) when near RF sources. A small cap to GND can help there, just to dump the RF to ground before it can weasel its way into the circuitry.

If you are doing your own firmware, be careful as there are a lot of corner-cases to consider. Try to leverage off somebody else's code for ideas that you have to consider on this. Might save some trashed airframes.

Two layer or four layer PCB? Here is a great site for getting them made. Cheap and relatively quick. Great quality. No need for Gerbers if you are using Altium. www.pcbwell.com

Consider using a four-layer PCB if you want to improve decoupling and make routing a little easier. The internal layers become power and GND, and form a very effective low inductance and low ESR decoupling capacitor. The price difference might not be worth worrying about.

Have fun :)
 
Last edited:
Hello Lithosphererocketry. Firstly, good luck with your project. It looks like you will have a lot of enjoyment (and challenges :wink:) along the way.

Decoupling caps. As others' have said check the data sheet and put enough of the required small ones (100n or thereabouts) close to the parts that need them, and the large ones can generally go anywhere on the board (within 6" is usually a reasonable rule-of-thumb).

Consider putting some form of RF filtering on any lines that go off the board. This can help with EMC (electromagnetic compatibility) when near RF sources. A small cap to GND can help there, just to dump the RF to ground before it can weasel its way into the circuitry.

If you are doing your own firmware, be careful as there are a lot of corner-cases to consider. Try to leverage off somebody else's code for ideas that you have to consider on this. Might save some trashed airframes.

Two layer or four layer PCB? Here is a great site for getting them made. Cheap and relatively quick. Great quality. No need for Gerbers if you are using Altium. www.pcbwell.com

Consider using a four-layer PCB if you want to improve decoupling and make routing a little easier. The internal layers become power and GND, and form a very effective low inductance and low ESR decoupling capacitor. The price difference might not be worth worrying about.

Have fun :)

Thanks!

I'll be ordering through OSH Park- they're very reasonably priced, and I've never had a problem with them. That said I've ordered all of 2 things from them...

I'll be sticking with 2-layer because of a) the lower cost and b) I use the free version of Eagle, which doesn't allow them (4 layer boards).

I'll be using my own software based on the Arduino Diecimilia (standard) firmware. Part of the fun here is designing my own software...

I don't think I'll have any problem with being within 6"- my board is currently only 4" long. However I'm thinking about rerouting a bit.

What lines need the filter capacitors? I have 8 different offboard lines (4 pyros and 4 servos). I'm guessing the pyros don't need them as they're "behind" a MOSFET, but I can throw on some on the servos.

Again, thanks for all the advice, everyone! I'm looking forward to getting this put together!
 
Last edited:
Your crystal and associated capacitors should be loacated as close as possible to the controller chip. In the document jderimig gave you the link to it describes the layout requirements of the oscillator section. You should follow those requirements as closely as possible.


Everything shares the same VCC- I can't imagine it's different from one place to another.
This is a poor assumption to make especially where you are not using ground planes and power planes. You are not dealing with just DC here. You will have AC noise being induced into your Vcc due to the fact that current draw isn't constant but tends to be drawn in pulses as the controller performs different tasks. In addition each trace has resistance, inductance and stray capacitance. Getting good clean power to each component is not a trivial task.
 
Your crystal and associated capacitors should be loacated as close as possible to the controller chip. In the document jderimig gave you the link to it describes the layout requirements of the oscillator section. You should follow those requirements as closely as possible.
I'm going to re-layout the board anyway, so I'll take this into consideration.


This is a poor assumption to make especially where you are not using ground planes and power planes. *snip*
I am using power and ground planes- sort of. My Vcc takes up all free space on the top of the board and ground is all free space on the bottom. I realize that they act as inductive loads, so I can get voltage spikes. I'll be using the recommended 0.1uF capacitors on the ATMega power pins as well as a 100uF anti-brownout capacitor.
 
What lines need the filter capacitors? I have 8 different offboard lines (4 pyros and 4 servos). I'm guessing the pyros don't need them as they're "behind" a MOSFET, but I can throw on some on the servos.
I would consider putting them on them all. The RF getting in on the MOSFET lines can get rectified by the MOSFETS and end up on the supply rail. Same happens with digital inputs or outputs, with the protection diodes on the chip providing the rectification typically. Outputs are less susceptible as they are lower impedance.

I don't think I'll have any problem with being within 6"- my board is currently only 4" long. However I'm thinking about rerouting a bit.
The position of the large capacitors is not likely to affect operation on your size PCB.
 
Bump!

Got back to work on this a bit. I decided to start with a smaller board as "proof of concept" using an ATTiny85 with baro & 1 pyro channel (the Mercury board), then if that works, move up to an ATTiny84 with another pyro channel and recording (the Gemini version). The '85 version should be pretty nice for cable cutter type setups that only need one pyro channel or MPR staging where you can run motor deployment but need an ignition line for the second stage.

The full version will be re-christened ArdIU Apollo. (Notice a theme?)

Here's my PCB for the ATTiny85:
Capture.jpg

The drills are 1.75" apart, and the entire board should fit in a 29mm tube.

OTT, on filter capacitors: I don't think they'll be necessary on the MOSFET lines. A FET isn't like a normal transistor- there is zero current between the gate and other parts, instead it acts as a small capacitor, and conducts when it is charged. If you're worried about spikes to VCC while the FET is on, that won't be a problem either as the pyro channel(s) are connected directly to the battery, so it would have to go "through" the regulator.

The one worry I might have is the continuity LED as it runs off logic VCC. It's a diode, though, so it shouldn't allow any voltage to make its way back "upstream".

I will ground test everything thoroughly before flying.
 
Where are your gate resistors on the Mosfet? You should have 2, one to pull down the gate to ground and one series resistor to limit the inrush current due to the gate capacitance. Why don't you post your schematic?
 
OTT, on filter capacitors: I don't think they'll be necessary on the MOSFET lines. A FET isn't like a normal transistor- there is zero current between the gate and other parts, instead it acts as a small capacitor, and conducts when it is charged.

Every power MOSFET includes a diode between drain and source.
 
Where are your gate resistors on the Mosfet? You should have 2, one to pull down the gate to ground and one series resistor to limit the inrush current due to the gate capacitance. Why don't you post your schematic?

The FETs shouldn't need gate resistors. The ATTiny85 datasheet says that it can source and sink current, and gives a constant current limit but gives no limit for "transient current". The FET should charge in 10 picoseconds, in which time light will travel 0.3 mm. I'd call that transient.

I'm not posting my schematic frankly because it's a mess. If and when I get it cleaned up I'll be happy to.

Every power MOSFET includes a diode between drain and source.

That shouldn't be an issue- neither one can get at sensitive electronics. I'd be worried about a standard bipolar transistor where the gate can draw current.


I appreciate that everyone's trying to help, as there are some things I genuinely missed- like the decoupling capacitors and oscillator location. But I *think* I'm fine on these points.
 
The FETs shouldn't need gate resistors. The ATTiny85 datasheet says that it can source and sink current, and gives a constant current limit but gives no limit for "transient current". The FET should charge in 10 picoseconds, in which time light will travel 0.3 mm. I'd call that transient.


How are you planning to keep the MOSFET off while the ATTiny's outputs are in the indeterminate or high-impedance state during power-up, initialization and power-off?
 
Last edited:
The FETs shouldn't need gate resistors.
The gate resistor helps with keeping the MOSFET from oscillating and ringing. I have been bitten by this before. The internal parasitics can do some strange things at times.

As others have said, you also need pulldowns to turn them off before the IO ports are intiialised.
 
Presumably the MOSFET source is connected to the circuit ground just like all of your sensitive electronics.

How do you propose I fix this? I can't put a capacitor on it since a capacitor from ground to ground really doesn't do much... The ground voltage changes all the time anyway. Mount your altimeter on a sled? You just changed the ground voltage with all the static charge on the sled.

Everything sensitive has a decoupling capacitor attached to it.

How are you planning to keep the MOSFET off while the ATTiny's outputs are in the indeterminate or high-impedance state during power-up, initialization and power-off?
As others have said, you also need pulldowns to turn them off before the IO ports are intiialised.

That's a good point. However, on the ArdIU Apollo's shift register the same problem crops up, and a simple pulldown won't fix it- the shift register will genuinely try to fire the ematches if they were firing at shutdown. My solution was a separate interlock for the pyros: No connection, no fire.

The advantage of this setup is that if the processor browns out due to a power-hungry ematch it'll continue firing.

The gate resistor helps with keeping the MOSFET from oscillating and ringing. I have been bitten by this before. The internal parasitics can do some strange things at times.

Can you clarify how such an oscillation would happen, and what the effects would be? I'm not picturing how this would occur.
 
You can get additional parasitic components adding into the circuit, both internally within the components, and externally with things like long wires and circuit traces. The MOSFET devices have internal parasitic capacitances which can help form a Colpits (tapped-capacitor) oscillator in the high MHz range typically. I have seen this several times in voltage-follower mode, even though the gain is technically less than unity and it should not oscillate :). Outcome is usually a circuit that gives really strange results, and sometimes mysteriously starts behaving itself when you start probing with a scope.
https://en.wikipedia.org/wiki/Colpitts_oscillator

I have heard of strange behaviours in common source mode also. It is always something that comes up at design reviews if they are left out.
 
You can get additional parasitic components adding into the circuit, both internally within the components, and externally with things like long wires and circuit traces. The MOSFET devices have internal parasitic capacitances which can help form a Colpits (tapped-capacitor) oscillator in the high MHz range typically. I have seen this several times in voltage-follower mode, even though the gain is technically less than unity and it should not oscillate :). Outcome is usually a circuit that gives really strange results, and sometimes mysteriously starts behaving itself when you start probing with a scope.
https://en.wikipedia.org/wiki/Colpitts_oscillator

I have heard of strange behaviours in common source mode also. It is always something that comes up at design reviews if they are left out.

After reading that Wikipedia article I'm still completely baffled. I can add a gate resistor, I'd just like to understand why it would help- if this is an issue I don't really see what a resistor is going to do about it.
 
After reading that Wikipedia article I'm still completely baffled. I can add a gate resistor, I'd just like to understand why it would help- if this is an issue I don't really see what a resistor is going to do about it.

Trust me. I have had to fix up other peoples' circuits with this problem. It provides some damping at very high frequencies I think.

I would add the pulldown while you are at it :wink:

Thanks for posting the circuit. Depending on which 1117 regulator you are designing for be careful you have enough output capacitance. The LM1117 needs a minimum of 10uF. The REG1117 (also by TI) suggests a 10uF cap on the output and also specifies it to have an ESR (effective series resistance) of less than 0.5 ohm. These things are important around regulators, especially LDO (low dropout), to keep them stable and not oscillating.

Also be careful of miniature ceramics of this value. The dielectric is quite voltage dependent and although a cap might be marked 10uF it may actually be half of that at the full rated voltage. Y5V dielectrics are pretty bad. Not sure what you have used.

Here is a good article on the voltage dependence of the ceramic dielectrics.
https://www.maximintegrated.com/en/app-notes/index.mvp/id/5527
 
Back
Top