Pages: [1]   Go Down
Author Topic: Multiple Port Manipulation  (Read 953 times)
0 Members and 1 Guest are viewing this topic.
Stevenage
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
void loop()
{
  (PORTB = B11111111 &&  PORTD = B11111111);
  delay(1000);
  (PORTB = B00000000 &&  PORTD = B00000000);
  delay(1000);
}

Any advice would be helpful.

Thanks in advance

Dan
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 144
Posts: 5348
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Stevenage
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley

Thanks again

Dan
« Last Edit: October 10, 2012, 10:06:08 am by danb121 » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley

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
Logged

Pages: [1]   Go Up
Jump to: