Greetings all!  My shift registers seem to be working well as a cheap
and easy port expander!   Apologies for how long it took me to write it
up, but we are currently in the middle of the FIRST Robotics Challenge
build season, so I'm spending almost every evening mentoring high school
students.

I've attached a schematic of the circuit used.  Notice it creates 16
output and 16 input lines using only 3 output and 1 input pin on the
parallel port.

I also attached the .comp file to drive it.  It count base-thread ticks
for timing.  I have it configured to update every 1 ms with my system,
but this is configurable.  While 1 ms is too slow for micro-stepping, it
is plenty fast enough to detect the pulses from my cooling fan
tachometers, turning pumps on and off, reading control panel buttons,
and blinking status LEDs.

The complete write-up can be found here:

http://www.shafferhouse.org/linuxcnc/LinuxCNCShiftRegisters.pdf

It goes into a lot of detail that is probably too basic for most of the
readers of this list, but please let me know if there are things you
would like me to add.

Enjoy!
-Kip

On Thu, 2013-01-03 at 07:18 +0200, Marius Liebenberg wrote:
> That sounds impressive. I am looking forward to seeing it.
> 
> On 2013/01/02 10:03 PM, Kip Shaffer wrote:
> > Absolutely!  I just finished wiring up the real (non-prototype) interface
> > card yesterday.  As soon as I make sure everything is working, I'll post
> > the wiring diagram and the HAL module.  It appears that even the
> > high-latency (1ms) shift register lines are fast enough to directly read
> > the tachometer signal from my cooling fans (120 Hz)!
> >
> >
> >
> >
> > On Wed, Jan 2, 2013 at 2:11 PM, Marius Liebenberg 
> > <mar...@mastercut.co.za>wrote:
> >
> >> Kip,
> >> Would you be willing to share your module. I am in need of a similar
> >> solution.
> >> Marius
> >>
> >> On 2012/12/28 02:54 PM, Kip Shaffer wrote:
> >>> Gene,
> >>>      Not sure if you would be interested in the approach I'm using, but it
> >>> may help you or others who are in a similar predicament.
> >>>
> >>> You can use shift registers to add as many additional lines as you want.
> >>>    For example, you can take 3 output lines on your parallel port, and
> >> turn
> >>> them into 8, 16, 24 or more output lines.  Shift registers come in two
> >>> varieties: Serial-In Parallel-Out, which you would use to create more
> >>> output lines, and Parallel-In Serial-Out which you can use to create more
> >>> input lines.
> >>>
> >>> I wrote a HAL module to implement my setup, which uses 4 pins on the
> >>> parallel port to create 16 output and 16 input lines.  I use these lines
> >>> for higher-latency signals, since it takes about 1 ms to shift all the
> >> bits
> >>> in and out.
> >>>
> >>> There is a good article explaining it here:
> >>>
> >>>
> >> http://robots.freehostia.com/Software/ShiftRegister/ShiftRegisterBody.html
> >>> -Kip
> >>>
> >>>
> >>> On Fri, Dec 28, 2012 at 5:15 AM, MC Cason <farmerboy1...@yahoo.com>
> >> wrote:
> >>>> On 12/28/2012 03:10 AM, Steve Blackmore wrote:
> >>>>> On Fri, 28 Dec 2012 02:34:37 -0500, you wrote:
> >>>>>
> >>>>>
> >>>>>> Mainly the 3 weeks to a month it takes from mainland china for
> >> delivery.
> >>>>>> But since I've decided to sacrifice the one pin I was saving for a
> >> home
> >>>>>> pin, that is the path I'll take.
> >>>>> That seems a long time? I've had several packages from China most have
> >>>>> taken 4 or 5 days, none longer than 10 days from Shanghai to my
> >> doorstep
> >>>>> in UK. They are usually in the country within 48 hours, the delays are
> >>>>> always here!
> >>>>>
> >>>>> Steve Blackmore
> >>>>> --
> >>>>      Here in the Southern part of the US,  It regularly takes between 10
> >>>> days, and 2 weeks for items to arrive from Shenzhen, or Hong Kong,
> >>>> Longer, from Shanghai, or Guandong.  The latest set of boards I had
> >>>> made, were air flighted out of Hong Kong, on the 19th. According to the
> >>>> tracking number, they haven't landed yet...
> >>>>
> >>>> --
> >>>> MC Cason - Assocaite Developer - Eagle3D
> >>>> Created by: Matthias Weißer
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >> ------------------------------------------------------------------------------
> >>>> Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
> >>>> much more. Get web development skills now with LearnDevNow -
> >>>> 350+ hours of step-by-step video tutorials by Microsoft MVPs and
> >> experts.
> >>>> SALE $99.99 this month only -- learn more at:
> >>>> http://p.sf.net/sfu/learnmore_122812
> >>>> _______________________________________________
> >>>> Emc-users mailing list
> >>>> Emc-users@lists.sourceforge.net
> >>>> https://lists.sourceforge.net/lists/listinfo/emc-users
> >>>>
> >> --
> >> Regards / Groete
> >>
> >> Marius D. Liebenberg
> >> MasterCut cc
> >> Cel: +27 82 698 3251
> >> Tel: +27 12 743 6064
> >> Fax: +27 86 551 8029
> >> Skype: marius_d.liebenberg
> >> Skype Me^(TM)! <skype:marius_d.liebenberg?call>
> >> Get Skype <http://www.skype.com/go/download> and call me for free.
> >>
> >>
> >>
> >>
> >> ---
> >> avast! Antivirus: Outbound message clean.
> >> Virus Database (VPS): 130102-0, 2013/01/02
> >> Tested on: 2013/01/02 09:11:40 PM
> >> avast! - copyright (c) 1988-2013 AVAST Software.
> >> http://www.avast.com
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
> >> and much more. Keep your Java skills current with LearnJavaNow -
> >> 200+ hours of step-by-step video tutorials by Java experts.
> >> SALE $49.99 this month only -- learn more at:
> >> http://p.sf.net/sfu/learnmore_122612
> >> _______________________________________________
> >> Emc-users mailing list
> >> Emc-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/emc-users
> >>
> 

component lsrio16 "Latching Shift Register I/O";
author "Kip Shaffer";
license "GPLv2 or later";
description """Provides logic to drive latching shift registers, such as the "
  "74LS595 for output or the 74LS597 for input, to provide for many more "
  "physical I/O lines.  Data is read from the in-* pins, and sent serially "
  "out the ser_out pin.  Similarly, data is received on the ser_in pin and "
  "presented on the out-* pins. "
  "The following pins should be routed to the parallel port or similar "
  " input/output device: ser_out, clk, latch, ser_in""";
pin in  bit in-# [16]  "Parallel input line.";
pin out bit out-# [16] "Parallel output line.";
pin out bit ser_out "Serial data out.";
pin out bit clk "Serial clock pulse.";
pin out bit latch "Serial register latch.";
pin in bit  ser_in "Serial data input.";

param r unsigned shift_period = 3;
param r unsigned update_period = 300;

variable long elapsed;
variable int mode = 0;
variable int bitPosition = 0;

function _ nofp;
;;

#define MAX 16

FUNCTION(_) {
  elapsed++;

  if(elapsed > shift_period) {
    switch (mode) {
       case 0: //Idle
          if(elapsed > update_period) {
             mode = 1;
          }
          break;
       case 1: //Latch Input
          if(!latch) {
             latch = 1;
          } else {
             latch = 0;
             bitPosition = MAX - 1;
             ser_out = in(bitPosition);
             out(bitPosition) = ser_in;
             mode = 2;
          }
          elapsed = 0;
          break;
       case 2: //Toggle Data
          if(!clk) {
             clk = 1;
             if(bitPosition == 0) {
                mode = 3;
             }
          } else {
             bitPosition--;
             ser_out = in(bitPosition);
             out(bitPosition) = ser_in;
             clk = 0;
          }
          elapsed = 0;
          break;
       case 3: //Latch Output
          if(!latch) {
             latch = 1;
             clk = 0;
          } else {
             latch = 0;
             mode = 0;
          }
          elapsed = 0;
          break;
     }
  }
}

<<attachment: Latching Shift Register IO.gif>>

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to