Author Topic: Shift Registers  (Read 3313 times)

0 Members and 1 Guest are viewing this topic.

Offline SmurfKiller

  • Contributor
  • Posts: 12
  • Country: be
Shift Registers
« on: January 04, 2017, 02:21:55 pm »
Hi, Is there such a thing as a, for lack of a better word, reverse shift register?

I am trying to build an Arcade console based around the I-PAC 2 and RetroPi using standard arcade buttons/joysticks.

My problem is i would like to have a sort of head unit containing the I-Pac/RaspberryPi and then 2 controllers with the buttons/joysticks, which will mean i would have to have 15 wires + ground for each controller. which is just nuts.

So my idea was to use some sort of "reverse shift register" which will check if a button is pressed as quickly as possible, send it down some sort of serial interface then split it back out again on the other side.which i would think that it would allow me to easy upgrade it to a wireless interface later on down the track.

I hope that makes sense, I come from a computer science background, only just starting to get back into electronics well since i was a kid and this project seemed like a good way to get a toes wet.

Any tips on how this could be done would be great.

Thanks  :)
 

Offline plazma

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: fi
    • Homepage
Re: Shift Registers
« Reply #1 on: January 04, 2017, 02:28:01 pm »
Build the controls with inexpensive zero delay encoders. Then the cable is USB only.
 

Offline SmurfKiller

  • Contributor
  • Posts: 12
  • Country: be
Re: Shift Registers
« Reply #2 on: January 04, 2017, 02:36:25 pm »
Build the controls with inexpensive zero delay encoders. Then the cable is USB only.

after doing some googleing, that looks similar to the I-Pac controller, which i don't think will really do the job as they do not allow me to easily modify the controllers to make them wireless.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 2111
  • Country: de
Re: Shift Registers
« Reply #3 on: January 04, 2017, 03:04:02 pm »
Search for SPI or serial peripheral interface, which is a standard feature on most microcontrollers.
 

Online darrellg

  • Supporter
  • ****
  • Posts: 94
  • Country: us
Re: Shift Registers
« Reply #4 on: January 04, 2017, 05:45:15 pm »
Hi, Is there such a thing as a, for lack of a better word, reverse shift register?
Yes. It's called a shift register. There is more than one type. The Wikipedia article may shed some light:
https://en.wikipedia.org/wiki/Shift_register
 
The following users thanked this post: SmurfKiller

Offline SmurfKiller

  • Contributor
  • Posts: 12
  • Country: be
Re: Shift Registers
« Reply #5 on: January 04, 2017, 05:57:22 pm »
Ah Cool! :) So Parallel-in Serial-out on the controller, Serial-in parallel-out on the console :) I didn't know that shift registers could be used in that way.

So i am guessing that i could use a 555 timer to drive the clock line.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 9917
  • Country: us
  • DavidH
Re: Shift Registers
« Reply #6 on: January 04, 2017, 06:25:16 pm »
Look for a shift register with parallel load capability.  For serial controlled I/O expansion, the 74165 was commonly used for inputs and the 74164 or 74595 for outputs.  The 74595 has a registered output so shifting can occur without disturbing the outputs.

 

Offline SmurfKiller

  • Contributor
  • Posts: 12
  • Country: be
Re: Shift Registers
« Reply #7 on: January 04, 2017, 07:14:32 pm »
Look for a shift register with parallel load capability.  For serial controlled I/O expansion, the 74165 was commonly used for inputs and the 74164 or 74595 for outputs.  The 74595 has a registered output so shifting can occur without disturbing the outputs.

Thanks for that, searching on digikey was getting a little overwhelming.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 2111
  • Country: de
Re: Shift Registers
« Reply #8 on: January 04, 2017, 09:18:38 pm »
Intersil had a series of SPI interface ICs, don't know if they are still available.
The CDP68HC68P1 was an 8-bit I/O port and will do what you want.
http://www.alldatasheet.com/datasheet-pdf/pdf/87734/INTERSIL/CDP68HC68P1E.html
« Last Edit: January 04, 2017, 09:20:15 pm by Benta »
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 5692
  • Country: nl
Re: Shift Registers
« Reply #9 on: January 04, 2017, 09:34:16 pm »
Still you need some protocol: pre-amble, data, checksum ......
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 2111
  • Country: de
Re: Shift Registers
« Reply #10 on: January 04, 2017, 10:12:07 pm »
Still you need some protocol: pre-amble, data, checksum ......

Not really. SPI is super-simple, it's pure bit-banging in hardware.
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 3812
  • Country: ro
  • .
Re: Shift Registers
« Reply #11 on: January 04, 2017, 10:15:31 pm »
You can replace shift registers with a simple microcontroller ... you could get a PIC32 or something like that with lots of I/O pins.. you could read the state of the buttons a few hundred times a second and send the state through SPI or i2c or you could fake a USB keyboard and send the buttons as a series of key presses ...

Some microcontrollers also have interrupt on i/o pin state change which means your code would be able to know right away when a button was pushed and send the data to other device, instead of the regular way where you code would wait for a particular amount of time, read the state of all buttons, send the states and then wait again (for example for 100 updates a second, the code would wait 10ms between each read)
A microcontroller would be more expensive (maybe 2-4$) plus you'd need a programmer but it would be a great learning experience
 

Offline pyroesp

  • Regular Contributor
  • *
  • Posts: 170
  • Country: be
    • Nicolas Electronics
Re: Shift Registers
« Reply #12 on: January 04, 2017, 10:18:14 pm »
Why not use a 16 bit GPIO expander like the MCP23017 (SPI) from microchip ?
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 3355
  • Country: gb
  • M0UAW
Re: Shift Registers
« Reply #13 on: January 04, 2017, 10:35:41 pm »
Why not use a 16 bit GPIO expander like the MCP23017 (SPI) from microchip ?

precisely what I was thinking but the MCP23S017 for SPI, also has Interrupt on change facility IIRC.

*additional info*
(doesn't read quite how I meant it to, both the I2C and SPI versions of the chip have interrupt on change capability, not just the SPI version but the SPI version is capable of operation up to 10MHz)
« Last Edit: January 05, 2017, 12:03:16 pm by CJay »
M0UAW
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 9917
  • Country: us
  • DavidH
Re: Shift Registers
« Reply #14 on: January 05, 2017, 02:13:32 am »
Why not use a 16 bit GPIO expander like the MCP23017 (SPI) from microchip ?

precisely what I was thinking but the MCP23S017 for SPI, also has Interrupt on change facility IIRC.

If I was not using the 74164, 74165, and 74595, I would prefer mariush's suggestion of using a cheap microcontroller because of availability even if it took several.  I have used PICs for this type of application and I regret that there is not an equally inexpensive ARM option for this.

For a cascaded string of 74164, 74165, and 74595 shift registers, the chip select signal can be used to drive both load and latch on alternate edges so only 3 signals are needed and loads and latches happen with a minimum of dispersion which may be necessary in some applications whereas a microcontroller or I/O expander cannot do this.

Several smaller expanders may be preferable to one large one to minimize the routing distance of the I/O signal lines.  Socketed DIP packages may be preferred where the I/O extenders are exposed to hostile conditions.
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 5692
  • Country: nl
Re: Shift Registers
« Reply #15 on: January 05, 2017, 09:46:54 am »
Not really. SPI is super-simple, it's pure bit-banging in hardware.
Yeah but the software doesn't know which bit is what if there is no start of frame (pre-amble) etc. in your protocol. But I think we are talking about different layers here.
I would just use two simple 8 bit micros for this task one for encoding and sending, one for receiving and decoding. If you make it a "one wire" and ground protocol, you can simply replace it later on with any wireless solution even a cheap $2 433MHz Tx and Rx set.
« Last Edit: January 05, 2017, 09:51:26 am by Kjelt »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 9917
  • Country: us
  • DavidH
Re: Shift Registers
« Reply #16 on: January 05, 2017, 10:35:46 am »
Not really. SPI is super-simple, it's pure bit-banging in hardware.
Yeah but the software doesn't know which bit is what if there is no start of frame (pre-amble) etc. in your protocol. But I think we are talking about different layers here.
I would just use two simple 8 bit micros for this task one for encoding and sending, one for receiving and decoding. If you make it a "one wire" and ground protocol, you can simply replace it later on with any wireless solution even a cheap $2 433MHz Tx and Rx set.

If microcontrollers are used on both ends, then an asynchronous interface will allow getting rid of the clock and possibly the chip select signals.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 2111
  • Country: de
Re: Shift Registers
« Reply #17 on: January 05, 2017, 01:14:52 pm »
Quote
Yeah but the software doesn't know which bit is what if there is no start of frame (pre-amble) etc. in your protocol. But I think we are talking about different layers here.

SPI is simply:

Assert CS
Send 8 clock pulses with associated data bits (2 wires).
Deassert CS

Done, you've transferred a byte.

 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 5692
  • Country: nl
Re: Shift Registers
« Reply #18 on: January 05, 2017, 02:44:29 pm »
Quote
Yeah but the software doesn't know which bit is what if there is no start of frame (pre-amble) etc. in your protocol. But I think we are talking about different layers here.
SPI is simply:
Assert CS
Send 8 clock pulses with associated data bits (2 wires).
Deassert CS
Done, you've transferred a byte.
I know what SPI is  ;)
My point is your receiving device powers up and receives a byte, which byte was this, which switches or joystick position does it represent? You don't know.
It is even worse, there are slave implementations were you can clock all you want, if a transmitting spi device is powered down in the mid of the transmission and powers up and returns transmitting you end up with two nibbles from different bytes. You need a higher level protocol to check if you received the entire message (bytes/packets of data) and if the message was received correctly. Else you have a risk of running out of sync and ending up with loosing the mame game you are playing  :)
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 2111
  • Country: de
Re: Shift Registers
« Reply #19 on: January 05, 2017, 05:01:08 pm »
I think you are making a mountain out of a molehill.
We are talking simple 74AC/HC type shift registers with a master and a number of slaves. It's not for downloading "Titanic".
If your CS signal doesn't work, it's back to the drawing board.

Let's leave it there. Cheers.
 

Offline CJay

  • Super Contributor
  • ***
  • Posts: 3355
  • Country: gb
  • M0UAW
Re: Shift Registers
« Reply #20 on: January 05, 2017, 06:29:24 pm »
I think you are making a mountain out of a molehill.
We are talking simple 74AC/HC type shift registers with a master and a number of slaves. It's not for downloading "Titanic".
If your CS signal doesn't work, it's back to the drawing board.

Let's leave it there. Cheers.

There is a tendency to go down a rabbit hole when this sort of discussion happens but my reasoning for suggesting the MCP23x017 was the simple fact that those chips are very well supported on Raspberry Pi (many, many 'extender' boards use either the SPI or I2C version of them) and there are many software libraries and guides which remove the burden of having to develop your own.
M0UAW
 

Offline SmurfKiller

  • Contributor
  • Posts: 12
  • Country: be
Re: Shift Registers
« Reply #21 on: January 16, 2017, 11:22:33 am »
Thanks for all the useful information, I Have decided to go for a atmega328p-pu with some 74hc165n's and a NRF24L01 module in the controller. Found all the parts really cheep on ebay.

I attached the schematic i came up with if anyone wants to look/ criticize :)

Hopefully all the parts will arrive in a week or so, and i can start breadboard it all up and test it.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 2111
  • Country: de
Re: Shift Registers
« Reply #22 on: January 16, 2017, 12:58:10 pm »
Looks good. Remember to connect CLK/INH on the 'HC165s, don't leave them floating.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf