Pages: [1]   Go Down
Author Topic: shiftOut  (Read 390 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://arduino.cc/en/Reference/shiftOut

Dear all,
I read this tutorial and I was confused about the MSBFIRST/LSBFIRST. Can anyone provide me an example how to illustrate the difference between this two ? If my number is 00000001, then it will shift the 0 first if it is MSBFIRST ? If my LEDs are numbered 1 to 8 from left to right assuming the most right is the LSB. So, I am confuse here.

Thanks for help smiley
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26322
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"If my number is 00000001, then it will shift the 0 first if it is MSBFIRST ?"  Yes.

"If my LEDs are numbered 1 to 8 from left to right assuming the most right is the LSB." So number them 7 to 0 from left to right. Then they will match up with your data. The lowest place of anything should always be position 0.
Look at how the data goes thru the shift register as well - from Qa to Qh. So Qa is the LSB and Qh is the MSB.
So your example 00000001 will end with Qh-g-f-e-d-c-b-a as 0-0-0-0-0-0-0-1.

* 74hc595_TI.pdf (914.58 KB - downloaded 21 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 47
I'm a high schooler.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I get confused to.
what I usually do is just do it with either LSB or MSB first.
if that doesn't work right, just do the other one.
It's a 50 50 chance you'll end up with the right one
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"If my number is 00000001, then it will shift the 0 first if it is MSBFIRST ?"  Yes.

"If my LEDs are numbered 1 to 8 from left to right assuming the most right is the LSB." So number them 7 to 0 from left to right. Then they will match up with your data. The lowest place of anything should always be position 0.
Look at how the data goes thru the shift register as well - from Qa to Qh. So Qa is the LSB and Qh is the MSB.
So your example 00000001 will end with Qh-g-f-e-d-c-b-a as 0-0-0-0-0-0-0-1.
So if MSB first, suppose the sequence should be reverse ? Assuming the data shift from left to right. So MSB first means Qh first and Qh will get shifted to the LSB position isnt that ?

Thanks !
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26322
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, the shift register only goes one way, from Qa to Qh.
If you want to shift LSB first, then Qh would end up with the LSB.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay I think I get it now. The key is that 'it starts from Qa'

So if my example is 00000001, and order type is MSBFIRST, the 1 will be shift first ?

Thanks ! smiley
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 336
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I want to shift the number 00000001, then Qa will output 0 and be placed at MSB position and Qh will have value of 1 and position at the LSB ?

Is that what MSBFIRST/LSBFIRST means ?

Thanks !
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26322
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As written, MSB - 00000001 - LSB.

MSBFirst results in:
Qh-g-f-e-d-c-b-a are MSB - 0-0-0-0-0-0-0-1 - LSB with MSB/LSB referring to the shift register

LSBFirst results in:
Qh-g-f-e-d-c-b-a are MSB - 1-0-0-0-0-0-0-0 - LSB.

So MSBFIRST/LSBFIRST is a software thing, and you have to check to make sure that is in sync with your hardware.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: