Project3: 32 extra io expansion on a uno/nano board with shiftregisters.

In this project we expand the io range off the arduino by using 6 original io's from the arduino and 2 pieces of 8bit parrallel to serial inputregisters cd4021 and the output to 2 pieces of 8bit serial to parrallel output registers cd 4094
We don't need to have special libraries to read and write from and trough the registers.
The program uses the bitread an bitwrite functions to read or set the data.
In this example we read the full 16bit from te 2 input registers , read the state of bit 0 and send the bit to the output registers.
With some adaptions in the program you can do anything you want to send the data to the output.
Basically we read the value as an integer from 0-65535 and than we read the bitstate of a  particular bit.
After that you can choose what you want to do with it, but in this example we read the bitstate (0/1) of bit0.
now we set this bitvalue to the sendword who can has every value from previous calculations you made, but in this case sendword was 0 so if bit0 from the inputs is 1, we send this bit to the bit posistion 0 of the sendword, so the sendword will get the integer value  1 or 00000000 00000001.
The maximum number of registers you can use is basically infintly but, the more registers you use the slower the system will be. If you use clock rates of 1ms , the delay for reading 1 registers will be approximatly 20ms.
So for reading and sending together, is this about 40ms/registergroup so in this project it took about 80ms for 32 io's.
You can speed up the clock rate in ÁS but than we have the risk of loosing data through EMC and wiring, 
By decreasing the clock delay speeds the system go's faster but that's something you need to test in your own project depending on how its made up.
You can download the cpp program and circuit details in following zip file.
In the drawings you will find an extra expansion on the outputs with the ULN2803 so these chips can directly control relays.
cd 4094
cd 4021
the circuits
Sitecsolutions
Your partner in automation solutions
Webdesign : Sitecsolutions