Sunday, May 3, 2009

SPI interfaces

My classes have been keeping me busy this week. Rather than doing more research on my own time for this blog, I'm just going to write up everything that I've learned about SPI interfaces for my embedded systems course.

The serial peripheral interface, or SPI, was created to allow multiple embedded devices to be networked together on a common bus. It's much like I2C in this respect. Unlike I2C, SPI can operate in full duplex mode, which means that one device can send and receive data at the same time. It accomplishes this using two separate lines for send and receive. 

There are generally three lines on the bus: one each for transmit and receive and a third line for the clock. The clock line is controlled by the master node in the network, and allows the master and slave to remain synchronized. In order for more than one slave to be used at a time, each slave must have a slave select input. This input, generally active low, determines which slave is listening and talking. This means the master will have a number of outputs to allow it to control each slave. This caused me a number of headaches over the weekend because the PIC I'm using for my current project was already running short of output pins. Inactive slaves will almost always put their output pin into tri-state. There are apparently a few exceptions to this.

When transferring data, the master will send a clock signal to the slave. At each clock signal, one bit will be sent and one received by each device. If data only needs to be transferred in one direction, the data going the other way can be discarded when it arrives. It is important to note that data is sent no matter what. 

For the PIC that I've been using, the transmission of data is performed using shift registers. Each device has an eight bit shift register that will shift on each clock cycle. Received data gets shifted in as sent data is shifted out, and after eight clock cycles the data can be read from the shift register. To transmit a value, the shift registers are preloaded with that value and then the clock cycles eight times.

The observant among you may have noticed a problem with this. If data is shifted in and out on the same clock cycle, how do you account for data rise and fall times? Basically, how do I know that a the change I've made on my slave's output port has propagated to the master before the master reads? The answer is that reads might happen on a rising edge of the clock and writes might happen on the falling edge of the clock. There are other ways to organize this, but they all revolve around reading and writing on different parts of the clock cycle. These different ways of organizing the SPI read and write functions are often called the modes of transmission.

Once you have your master and slave talking to each other, you may decided you want to add another slave or six. This is actually pretty simple to do. The new slaves can be put on the same bus as the original slave as long as the master has a separate select pin for each of the slaves (or a counter that can be decoded). 

Overall, SPI is a fairly simple method of transmitting data between embedded devices. It can send and receive data at the same time (i.e. it's full duplex). It also gets rid of the need for sophisticated PLL circuitry to synchronize master and slave. The number of output pins is also much smaller than the amount needed for parallel communication, which is very useful. Problems with SPI include a lack of acknowledgment from slaves, short communication distance, and more pins required than I2C.

Information about SPI was found at wikipedia and in the datasheet for the PIC 16F877. 




Sunday, April 26, 2009

A survey of avionics

In order for me to learn everything I need to know about avionics, I need to first know what there is to know. From there I can get an idea of what to focus on first. Thus, my first major post here is going to be about what avionics actually is and what disciplines it encompasses.

Avionics, or aviation electronics, is comprised of all of the electronic systems on everything from satellites to planes. The main electrical systems on an aircraft or spacecraft are the control systems used to orient and maneuver the craft, the navigation systems, and the systems that convey information to and from the people that use the craft. In addition to these main components, any other electrical systems on the craft also qualify as avionics. All components that may be placed on a spacecraft may also serve a purpose on land, so the difference between avionics and electronics is mainly the requirements the design has to meet in terms of power, radiation hardening, resistance to vibration, reliability, and the like. These lead to a system that is much more difficult to design, and the final product can often cost as much as ten times more than a terrestrial analogue.

Unfortunately, many of the constraints are interrelated, so a gain in one area may result in a loss in another area. A more robust system may weigh more or have a larger volume, for example. Surprisingly, weight savings carry almost a ten to one benefit, in that if you can drop the weight of a system by a kilogram you can carry almost ten kg more. This is due in large part to the added frame weight that is necessary to support heavier components, which in turn requires more lift, which leads to larger and more powerful engines.

Environmental factors also have a large impact on design. Components may be subjected to temperatures from -40 to 70 degrees Celsius, extreme and rapid pressure changes, large accelerations, and vibrations. This means that many components used in commercial products are not suitable for aviation applications. The standard 74LS parts I've been using in school are simply not robust enough for an aerospace environment. Military spec'd parts will fair better, but the design of the system itself will have to take into account vibration and acceleration. All of the circuit boards I've manufactured have used solder as a mechanical support, but large acceleration or too much vibration could rattle those parts off the board. Potting compound and better solder practices will be required to ensure a robust design. There are probably other things that can be done to improve resistance to vibration, which I'll be looking into later.

Lastly, robustness is a key issue in avionics equipment. A failure in your cell phone may be an annoyance, but a failure in the communications systems of a spacecraft or aircraft could be deadly or result in the loss of millions of dollars worth of equipment. Even if a problem is found before launch, it could still result in missing the launch window if it is severe enough. All avionics systems need to take this into account.

For the near future, I'm going to focus on the main electronics areas of navigation, communication, human-machine interface, flight control systems, and spacecraft state sensors. Each of these covers a very large area by itself, so I've got a lot of work to do. I think what I'm going to do is make a post on each of these that outlines the basics of what each encompasses. After that I'll focus on learning about each area in turn. At this point I find flight control systems the most interesting, so I'll probably start with that after my overview posts.

For the most part, my investigation into these subsystems will probably focus on terrestrial applications for similar devices. The majority of textbooks about these subjects deal with them in the abstract, and not specifically for spaceflight or other aerospace applications. In order to take that into account, I'll have to constantly be thinking about the many restraints that avionics systems face.


Things to Come

I'm currently a senior in electrical engineering at the University of Washington. I'm graduating this Spring, and I don't know what's coming next. Now that I've spent four years learning about electronics, there's one thing I know for certain: An undergrad degree in engineering doesn't teach you nearly enough to build your own spacecraft. This is a problem.

I've been interested in spaceflight since I was just a lad. Like most boys, I wanted to be an astronaut when I grew up. The more I learned about spaceflight, the less I wanted to be an astronaut. That's not to say I don't want to go to space, because I do. I just want to wait until it's more convenient and doesn't cause such serious health problems. Not only that, I want to be able to go to space on my own terms. I like the idea of doing research in space, but I'm also attracted to the romance of it. I want to go to space, the Moon, even Mars, for the long term. 

It seems to me that becoming an astronaut isn't the best way to make that a reality. There are a lot of engineering problems that need to be solved before people will be able to do more than just visit space. I'd like to try solving those directly. The first main challenge to human space flight is just getting there. Space isn't really that far away, only about the distance from Seattle to Olympia, but it takes far more effort to safely get there than an afternoon drive. 

In order to safely get to space, we have to have some pretty impressive technology. There are a lot of companies currently working on this problem, and a lot of them are interested in electrical engineers. That said, as a newly graduated engineer, I don't have enough experience to even be considered by some of them. I talked to Blue Origin, and they told me to try back in five years, once I had more experience. After some prodding, it was suggested that I focus on avionics if I really want a job in the field. 

That's where this blog comes in. I don't currently know very much about avionics, but I am going to change that. There are a lot of resources on the subject, and school has done me the favor of teaching me how to learn. The only risk is that I'll get lazy and not study hard enough to become able to solve the hard problems spaceflight faces. By blogging my research and tracking my learning progress, I hope to give myself some added motivation to succeed here.

My large scale goal is to use this blog to make me a better, more knowledgeable engineer who is an expert at avionics. Most of the posts are going to reflect that. I plan to mainly post discussions of various technologies that I need to know about. I also plan to do many personal projects that encapsulate many of the areas I need to know about, and I'll post about those projects here as well. In addition to all of that, I'll also write about spaceflight in general. I'll hopefully average about one post a week here, but I haven't come up with a schedule yet.

At this point, my plans for the immediate future are to write up a survey of the current avionics industry. I'll focus on the many technologies that are commonly used, and come up with a list of things that I need to learn. Expect that post soon.