Pages: [1] 2   Go Down
Author Topic: how to use 8 of the digital i/o pins at same time?  (Read 1326 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley
Logged

Berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 181
Arduino rocks your socks off
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

SW Scotland
Offline Offline
Edison Member
*
Karma: 13
Posts: 1327
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

[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
« Last Edit: June 13, 2010, 04:29:28 am by bhags21 » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 241
Posts: 24480
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
is called parallel processing
No, parallel processing is something quite different.
Logged

"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.

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 8
Posts: 1992
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
No, parallel processing is something quite different.

Just what I was thinking.....
Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 516
Posts: 31579
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

B0100111001000011, USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1503
I'm confused.  Wait, maybe not..
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

SW Scotland
Offline Offline
Edison Member
*
Karma: 13
Posts: 1327
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

B0100111001000011, USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1503
I'm confused.  Wait, maybe not..
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 516
Posts: 31579
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

No.
Logged

B0100111001000011, USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1503
I'm confused.  Wait, maybe not..
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-razz.
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 516
Posts: 31579
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1] 2   Go Up
Jump to: