How to add more I/O ports?

How can I add more I/O ports to my arduino duemilanove? If I use a serial connection through the two analogue ports will it be as fast as the I/O ports?

Thanks

Lots of ways please look in the playground for information.http://www.arduino.cc/playground/Main/InterfacingWithHardware

If I use a serial connection through the two analogue ports

How are you going to do that then? Software serial?

will it be as fast as the I/O ports?

No because you are sending serial data and that takes time. In a 9600 baud system it only sends 9600 bits per second and that has to come out of an I/O port so how could this possibly be as fast?

How fast is I2C? Is it noticeably slower then the built in I/O ports? I need to be able to send signals at most 10 times per second through this. What is the fastest method of I/O expansion? What would you recommend?

It of course depends on how many bytes of data you need to send 10 times a second.

But unless it is a lot i think that both serial and I2C will do the job.

It would be a lot easier to recommend a solution if you could tell a little about what it is you need the I/O expansion for.

Input ? Output only ?

Analog ? Digital ?

How many bytes and how frequently ?

pretty much just digital output but possibly a little digital input (temperature probe, or push buttons)

I need to tell about 24 N-Channel MOFSET transisitors to turn off/on about 10x per second.

Also, not really on topic but can I use logic level N-Channel mofset transistors for all 4 transistors in an H-Bridge?

about 10x per second.

This is considered to be a very slow rate so yes what ever method will do.

I use logic level N-Channel mofset transistors for all 4 transistors in an H-Bridge?

Most designs use 2 N-channel and 2 P-channel FETs. But it wouldn't supprise me to see one with all N-Channel, although you would need a few driver transistors or FETs as well.

If you just need to control 24 transistors + some "extra", then i would use 3 595 shiftregisters for the transistors, and the rest of >Arduinos ordinary pins for the "extra".

This is easy, cheap and well documented. Check the playground for example code for using the 595 shift register.

What is the difference between P-Channel and N-Channel? What is a drive transistor?
I miss typed the speed I will need the transistors to turn on/off with. About 180 times per second is what I would like. Can shift registers work fast enough for the 24 transistors?

About 180 times per second is what I would like.

Yes this is still very slow for a processor.

What is the difference between P-Channel and N-Channel?

Google it but basically P-channels pull up and n-channels pull down.

What is a drive transistor?

A transistor that is used to drive a load. Drive:- to power or to control.

Can shift registers work fast enough for the 24 transistors?

180 time a second for 24 outputs gives you 4320 pulses per second. So this is 231uS, one instruction on the processor takes about 0.625 uS (yes I know about it doesn't always) so that gives you in the order of 300 instructions executed for each output. What else do you want to do that is taking time? Without this information we can't tell if you have enough but I suspect you do.

Thanks for all the help. I don't plan on using anything more except for a potentiometer, and a push button. I am basically making a stator for a bldc motor. I planned on using a delta configuration, so each transistor needs to be able to be able to go before the electromagnet in the circuit then switch over to being after the electromagnet.
I tried running power to my N-channel logic level mofset transistor and then wiring that to an led and it controlled the led fine. Will N-channel work for both directions or is there another type of transistor necessary?

I needed to control 10 relays besides all my sensors, so I went for an extra Arduino and I2C for port expansion.
For this sort of application there is absolutely no perceivable delay, it just acts as a duemilanove with 30 I/O ports, and you can continue to add as many as you want.

Rod.

Google words
I2C i/o port expanders
SPI i/o port expanders
Serial i/o port expanders of a sort

I've used a serial in parallel out shift register to get more outputs which are easy to use

To get parallel in serial out shift registers to work requires either scanning and most likely missing a bit transition or using an IC that will output an interrupt trigger.

Your better bet is the available SPI chips with interrupt output. They can do input and/or output. The interrupt is a separate output from the chip that signals "Read my data now!" to the atmega processor on the arduino. There may be simpler chips that use a clocked serial but I could not find them with google.