|
|
View previous topic :: View next topic |
Author |
Message |
JAM2014
Joined: 24 Apr 2014 Posts: 138
|
Question about EX_EXPIO.C |
Posted: Fri Jan 13, 2017 5:12 pm |
|
|
Hi All,
I am starting to write code for a project that will ready a fairly large quantity of digital signals connected to 74LS165 shift registers. There will be 32 '165's for a total of 256 bits that need to be read. I've looked at EX_EXPIO.C and 74165.C, and I think I pretty much understand how the data will be clocked out of the 32 '165 devices. What I'm not exactly clear about is how the multi bytes of data will be arranged. The comments in 74165.C say the code 'clocks bits into the 'ei' structure with ei defined as 'Byte *ei', and that 'acquire_expanded_inputs (&data);' is used to 'read the ei array from the chips'. So, does that mean that the bits are clocked in on 8 bit boundaries (Bytes), and that to access the individual bytes I'd do this:
Code: |
read_expanded_inputs (&data[n]);
|
IOW, with an index pointing to the desired byte in the ei array?
Thanks,
Jack |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9232 Location: Greensville,Ontario
|
|
Posted: Fri Jan 13, 2017 7:50 pm |
|
|
While I've never used the driver, it does mean that 8 bit( 1 byte) is read in at a time, so a complete 74165 is read.
Hopefully someone has played with this code.... when I google 74165, some hits said it'd been discontinued.
One thing to remember is that this is a serial 'chain' so you WILL have to do some 'math' to calculate the acquistion time delay. Worst case is getting data from 74165 #32 in the chain,the one furthest from the PIC. Now if you have 3 extra I/O pins , you can divide the 32 long chain into 2, 16 unit long chains, so access is faster. I did that 30 years ago. There is a trade of of time vs I/O pins
An option for you may be to use PICs as 'smart ,remote I/O' devices. You could easily replace 6 74165( or more) with 3 PICs and only require 3 I/O pins from the master PIC. A 40 pin PIC could have 32 inputs 'muxed' to one I/O line.
Several ways to get 256 inputs,what's best depends upon cost,parts availability,speed of scanning,type of inputs and overall project concept(1 off or 1000 units ?)
Jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 13, 2017 8:23 pm |
|
|
You first make an array with the required number of bytes:
Code: | int8 data_array[32]; |
Then you pass the array to the 74165.c driver routine:
Code: | read_expanded_inputs (data_array); |
Note there is no '&' in front of the array name.
JAM2014 wrote: | So, does that mean that the bits are clocked in on 8 bit boundaries
(Bytes) | Yes.
JAM2014 wrote: | and that to access the individual bytes I'd do this: |
To access individual bytes, you just read an array byte. For example,
to read the 1st byte in the array, you would read the value at index = 0.
Code: |
int8 value;
value = data_array[0];
|
To read the 6th byte, you would read the value at index = 5:
Code: | value = data_array[5]; |
Etc.
This is done of course, after you call the read_expanded inputs() function.
After that, the array has been filled with data from your inputs.
The real issue is how you are going to handle the fanout for the enable
line and the clock. You have 32 of those. You may have to put in
intermediate buffers, or I suppose you could use multiple PIC pins,
driving one bank of eight 74HC165 with two pins each (for clk and enable).
That's 8 PIC pins total. |
|
|
JAM2014
Joined: 24 Apr 2014 Posts: 138
|
|
Posted: Fri Jan 13, 2017 8:34 pm |
|
|
Hi,
Thanks for the clarification! That driver makes complete sense now, and appears to be very easy to use!
As for 'fan-out', the PIC will reside on a 'backplane' board with 4 pluggable 'daughterboards' connected, each with 8 74LS165's. The clock and enable lines on the input to each daughterboard are buffered, so the PIC pins will only be driving 4 'LS buffers.
Thanks,
Jack |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|