Go Down

### Topic: Multiple Port Manipulation (Read 1 time)previous topic - next topic

#### danb121

##### Oct 10, 2012, 11:28 am
Hi All

I need to be able to change 10 outputs at exactly the same time; I'm aware of port manipulation but this only work for 8 I/O pins could I use something like the && statement?

Code: [Select]
`void loop(){  (PORTB = B11111111 &&  PORTD = B11111111);  delay(1000);  (PORTB = B00000000 &&  PORTD = B00000000);  delay(1000);}`

Any advice would be helpful.

Thanks in advance

Dan

#### fungus

#1
##### Oct 10, 2012, 11:56 am

Hi All

I need to be able to change 10 outputs at exactly the same time; I'm aware of port manipulation but this only work for 8 I/O pins could I use something like the && statement?

Code: [Select]
`void loop(){  (PORTB = B11111111 &&  PORTD = B11111111);  delay(1000);  (PORTB = B00000000 &&  PORTD = B00000000);  delay(1000);}`

Any advice would be helpful.

No, the && operator doesn't do that, you need to do this:
PORTB = B11111111;
PORTD = B11111111;

The timing difference will be one clock cycle.  Normal Arduino clock speed is 16mHz.

If that's too much difference you'll have to add an external 16-bit shift register.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### retrolefty

#2
##### Oct 10, 2012, 02:52 pm
Quote
I need to be able to change 10 outputs at exactly the same time;

For anyone to be really helpful you need to put a number on how close to 'exactly' you mean. What is the maximum skew rate between output pins that you can live with, 1 millisec, 1 usec, 1 nanosec ? A lot of time beginners have not yet gained a feel for how fast a arduino clock cycle is in the real world.

If you cannot put a metric to 'exactly' then perhaps if you could describe what the output pins are going to be wired to and the function they will be performing.

Lefty

#### Graynomad

#3
##### Oct 10, 2012, 03:01 pm
Doesn't matter what you do there's no way to change 10 pins at exactly the same time using the processor IO unless you move to a 16- or 32-bit chip.

Use fungus's solution.

Do you really need exactly? Why?

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

#### danb121

#4
##### Oct 10, 2012, 05:02 pmLast Edit: Oct 10, 2012, 05:06 pm by danb121 Reason: 1
Cheers for the replies.

I'm using the arduino and circuit for highspeed photography, the flash guns have to have a low light output to minimise motion blur so to get the correct exposure I need to use multiple flash guns...
In answer to your question ideally the outputs would be changed at exactly the same time as firing flash guns at different times will also cause motion blur.  My aim is to build a box that I can use for a number of different situations and enviroments; having said that the extra 2 outputs are just for contingency so I could live without them

I'll also do some tests to see if firing 2 outputs with a slight delay will cause a problem

Thanks again

Dan

#### retrolefty

#5
##### Oct 10, 2012, 05:32 pm

Cheers for the replies.

I'm using the arduino and circuit for highspeed photography, the flash guns have to have a low light output to minimise motion blur so to get the correct exposure I need to use multiple flash guns...
In answer to your question ideally the outputs would be changed at exactly the same time as firing flash guns at different times will also cause motion blur.  My aim is to build a box that I can use for a number of different situations and enviroments; having said that the extra 2 outputs are just for contingency so I could live without them

OK, but that doesn't answer the maximum timing skew between output changes allowed. There has to be a value which is fast enough to not cause detection, and it might be that even some microseconds is fast enough.

I'll also do some tests to see if firing 2 outputs with a slight delay will cause a problem

Now that is something constructive to try. delayMicroseconds() is available for that testing effort, I believe that command has a 4 microsecond resolution.
Lefty

Thanks again

Dan

Go Up

Please enter a valid email to subscribe

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy