Go Down

Topic: how to use 8 of the digital i/o pins at same time? (Read 1 time) previous topic - next topic

bhags21

Hi i want to know how to use 8 of the digital i/o pins at the same time?

e.g. pins 1,2,3,4,5,6,7 and 8 has output value of
             1,0,1,0,0,1,0 and 1 (which will be keep changing)

How can i output this data [glow]simultaneously[/glow] without any delay between two output signals??

the command
int pin1 = 1 ;
pinMode(pin1, OUTPUT);
digitalWrite( pin1, HIGH);
will drive only one pin at a time. So how to drive multiple pins at the same time?

thanks in advance  :)

Otacon2k

You will have to use direct port manipulation (google the term). With direct port manipulation all pins of the port you are switching are switched simultaneously, but the code will get a bit more complicated.

jackrae

It depends on what you mean by "the same time"
Surely any processor can only operate on one instruction at a time (and that includes the best proecssor of all  -  the human brain) and as such no two events can occur simultaneously.
This "drawback" is used effectively in programmable control systems to ensure "simultaneous" sequences occur in the correct order
However you can surely produce a routine to set up and then switch outputs on a single given command - but even then events will not be exactly simultaneous
jack
jack

bhags21

#3
Jun 13, 2010, 11:26 am Last Edit: Jun 13, 2010, 11:29 am by bhags21 Reason: 1
[glow]@jackrae :[/glow] yes you can run multiple pins/ outputs simultaneous and is called parallel processing! (my be a minor delay in nano seconds)

[glow]@Otacon2k:[/glow]  Thanks a lot mate! That's what i needed to know!
i'm checking this

[glow]http://www.arduino.cc/en/Reference/PortManipulation[/glow]

it seems to address the issue..
Thank for you help!!!!! ;D

AWOL

Quote
is called parallel processing

No, parallel processing is something quite different.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

pluggy

Quote
No, parallel processing is something quite different.


Just what I was thinking.....
http://pluggy.is-a-geek.com/index.html

Grumpy_Mike

You can only change bits of the same port at the same time. Even then they don't actually change sanctimoniously.
In fact it is part of Einstein's theory of relativity that these is no such thing as a simultaneous event.
This is why in electronics things are often synchronised by a clock pulse or strobe signal which indicates all the relevant data lines have stable data on them.
Parallel processing involves more than one CPU, in practice they never have access to the same i/o address space so it is on no help in getting things to happen simultaneously.

You will probably find that you don't need to have things happening simultaneously.

TchnclFl

What about quantum computing?  Can't they do an infinite number of operations at the same time? ;D

jackrae

But the question related to Arduino - not some device that might stretch our personal (or national) budgets.
Basic question still stands - what do you mean by simultaneous
"exactly so or just about so"
jack

TchnclFl

Quote
But the question related to Arduino - not some device that might stretch our personal (or national) budgets.
Basic question still stands - what do you mean by simultaneous
"exactly so or just about so"
jack


Agreed.  I was just being a bit of an @$$ haha :).

Grumpy_Mike

Quote
What about quantum computing?  Can't they do an infinite number of operations at the same time?


No.

TchnclFl

Really?  I swear I saw a special somewhere saying the quantum mechanics stated that any individual atom has an infinite number of states in which it exists at the same time.

Perhaps not :P.

mowcius

Quote
Really?  I swear I saw a special somewhere saying the quantum mechanics stated that any individual atom has an infinite number of states in which it exists at the same time.

An individual atom can exist in multiple states but it does not mean that you can perform multiple events at the same time...

Mowcius

Grumpy_Mike

Quote
An individual atom can exist in multiple states

But when you measure what state it is in the other states collapse and you end up with just one state. Therefore there is no way to extract information about the state. It's called Heisenberg uncertainty principle.
http://en.wikipedia.org/wiki/Uncertainty_principle

mowcius

Quote

But when you measure what state it is in the other states collapse and you end up with just one state. Therefore there is no way to extract information about the state. It's called Heisenberg uncertainty principle.

Indeed. Reminds me of learning about wave-particle duality at school... Oh the joys of physics :p

Mowcius

Go Up