element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Tying two shift registers together to communicate 8 bits between them
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 8 replies
  • Subscribers 393 subscribers
  • Views 1156 views
  • Users 0 members are here
  • shift
  • register
  • communication
Related

Tying two shift registers together to communicate 8 bits between them

screamingtiger
screamingtiger over 10 years ago

I have two microcontrollers one of which is an arduino mini.  I need to output 8 digital pins from one from one to the other.  I need this "data" to be fast and reliable so I am shying away from serial (I2c, ISP etc).  I am wondering though about a shift register, I think these would still be fast enough but I wondered if this makes sense:

 

Microcontroller A shifts out 8 bits to shift register A, then microcontroller B uses shift register B to shift in the bits.  Shift register A and B are connected in parallel through their shift bits.


So basically I will have of two registers directly connected so I can shift bits in with one side and shift bits out with the other.  Saving a lot of pins but maintaining speed at the same time.

 

Is this necessary or can I just use 1 register where once micro controller can shift in and the other can shift out on the same register?

 

I am going to be using ISP anyways for another controller that is attached to all of this, but this specific connection I want to be rock solid.  I may just end up using a bus but am curious if registers are used this way?

 

Thoughts?  Thanks in advance!


  • Sign in to reply
  • Cancel

Top Replies

  • clem57
    clem57 over 10 years ago +2
    Let me see if I got this: send bit's serially to shifter. shifter sends bits parallel (how far?) Another shifter converts back to serial receiver gets bits Points to realize: A shifter will go one direction…
  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago in reply to screamingtiger +2
    So, on the receiving side, the SPI/I2C works the same basic way as the Serial Has a message arrived ?, if so read it and put in a variable, update whatever your going to based on this value now do other…
  • mcb1
    mcb1 over 10 years ago in reply to screamingtiger +2
    Joey The guys at Wyolum created an arduino slave that interfaced with a GPS. (called I2GPS) The idea was it sat as a I2C device (addr 88) and you polled it for an update. You might be able to see what…
Parents
  • clem57
    clem57 over 10 years ago

    Let me see if I got this:

    1. send bit's serially to shifter.
    2. shifter sends bits parallel (how far?)
    3. Another shifter converts back to serial
    4. receiver gets bits

     

    Points to realize:

    • A shifter will go one direction only. Serial to parallel is one and parallel to serial is another.
    • There is a finite time to shift added to the serial out.
    • Serial can always have errors! This design does not take that into account.
    • Distance on parallel is always shorter because of attenuation. Serial much better.

     

         I will let you ponder these and then answer why go to this trouble?

    Clem

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago in reply to clem57

    Hi screamingtiger

     

    Actually, the parallel or Serial distance is not relevant, a parallel bus is simply a number of serial channels image, attenuation would be the same or not relevant in the compare , this is a physical limitation not a protocol one, you can line drive a parallel bus as easily as a serial one

     

    I2C, SPI and UART (Old School TTL version of RS232) are all reliable and as much as a parallel is, the built in hardware of the devices makes using it as simple as parallel, if not simpler, there are many techniques you can use to ensure integrity of the passed message including sending the byte then the inverse, or a check sum, or a parity bit (See RS232), if these where not reliable then pretty much every automotive system (New ones), medical devices, laptops, automation systems would be unreliable... there not, also you do not specefy the speed at which you need to transfer data, these serial protocols go easily up to 10Mbit if needed which equates to perhaps 1MByte/Second, more than most microcontrollers could handle so the serialization is or should not be an issue

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • screamingtiger
    screamingtiger over 10 years ago in reply to Robert Peter Oakes

    clemm

    Robert Peter Oakes

     

    The more I think about this the more I need to experiment.  Thanks for your information and thoughts and if you bear with me maybe you can understand my crazy thought process.

     

    Originally I had the receiver requesting 1 byte of information over and over again from the sender.  Every request required work on the sender's part to get the information and send it.  What I noticed is that for the most part, the information doesn't change that much.  Lets say it changes on average 1 time per second, but the receiver will request 100 times per second just in case, because you never know when it will change.

     

    So the receiver is requesting over and over and the sender sends the exact some byte over and over.  So my thought is the sender could set a shift register and then only change it when necessary.  This means the receiver can read it 100 times per second without any work needed by the sender until it changes.  This can greatly relieve the load on the sender right?


    Why two shift registers?  Well originally I thought I would wire 8 GPIO pins together to send this information.  So between two pics, that is 16 pins being used up!

     

    Then I realized two shift registers can be run by 4 pins each so I would only use 8 pins total between the two.  the registers are just there to save pins.

     

    Does that make sense?  Keep in mind I have the mindset the receiver "asks" for the information.  The receiver's only job is to get this information and do something with it.  The sender's job is much more than just to send, it has 10 other things to do and cant be bogged down just sending information.

     

    I now realize the analogy I need to think about.  A button being pushed.  I can check to see if the button is pressed in a loop over and over, OR I can setup an interrupt to only check it when it is pushed.


    The concept in this case is that the receiver should not request information, but rather the SENDER SENDS information only when it changes.  I think I see my flaw.

     

    Now need to try to work this out.  Perhaps SPI is the way to go over all.  I can send my byte of information and then the next byte can be some sort of XOR value to check validity.  I don't see that step needed with a shift register since I can read the pins in order and cant miss a bit.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • clem57
    clem57 over 10 years ago in reply to screamingtiger

    Okay, now you set forth the problem, the solution is more obvious. If you have a case where the data may change, setup an interrupt from the sender to the receiver. Interrupts allow less processing and are more efficient. The interrupt is like a shoulder tap to receive new data. A SPI is a master (could be sender) and slave(could be receiver). The only rule is master shall control clock and initiate talk.Data can be returned from slave only when master send something even dummy data. I hope that helps and not muddies the water for you.

    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago in reply to screamingtiger

    So, on the receiving side, the SPI/I2C works the same basic way as the Serial

     

    Has a message arrived ?, if so read it and put in a variable, update whatever your going to based on this value

     

    now do other stuff but check the receivers on each loop to check for any updates, if you get a new byte, compare to the current, if there different then do whatever you do with the data, if it is the same, just ignore it

     

    Job done

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • screamingtiger
    screamingtiger over 10 years ago in reply to clem57

    Thanks, I have to use I2C from the Pi to the arduino as I want the Pi to be master but the Arduino I2c library  doesn't support being a slave.

     

    The reason I was trying to avoid this is I have to use SPI to communicate with a sensor as well so I will be using Ic2 and SPI at the same time in the Pi.

     

    I'm going to figure this out tomorrow and if it wont work I'll have to used the shift registers.

     

    Thanks for your information!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 10 years ago in reply to screamingtiger

    Joey

    The guys at Wyolum created an arduino slave that interfaced with a GPS. (called I2GPS)

    The idea was it sat as a I2C device (addr 88) and you polled it for an update.

     

    You might be able to see what they did and replicate it to allow the Arduino to be a I2C slave.

     

    Mark

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • screamingtiger
    screamingtiger over 10 years ago in reply to mcb1

    I'm not sure how I messed my post up.  Ardunio is fine as a slave for I2C.  It doesn't support being a  slave for SPI.

     

    I got it all working now for the most part.  Thanks!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • screamingtiger
    screamingtiger over 10 years ago in reply to mcb1

    I'm not sure how I messed my post up.  Ardunio is fine as a slave for I2C.  It doesn't support being a  slave for SPI.

     

    I got it all working now for the most part.  Thanks!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube