74HC/HCT166 shift register datasheet, error...?


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598

    Question 74HC/HCT166 shift register datasheet, error...?

    Hi,

    Wasn't sure where to ask this, figured I'd start here. NEWBIE ALERT! WOOT!

    I'm trying to shift bits in and out of a PIC 16F628 using a 74HC166 as input and a 74HC164 as output with little success.

    I don't understand the Function Table on p.4 of the datasheet for the 166. They mention Q0-6 registers, and yet there is only a Q7 mentionned in the Functional diagram at the top of that page, nor on the Logical diagram on the next page, nor on the Process diagram below that one. The only 0-7 pins are the D pins, not Q.

    I'm trying to figure exactly how it is I am supposed to initiate SHIFT IN and SHIFT OUT commands and I'm going nowhere. I've scoured the web for schematics using these 2 shift registers as well as BASIC code to go along with them and have come up 'basically' empty-handed.

    Any help would be greatly appreciated.

    Thanks, and have a nice day!

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    Does PIC BASIC Pro support the hardware requirements for SHIFT IN/OUT commands? Let me add a little more, does it take care of the communication protocol like MBASIC?

    MBASIC can process SPI communication with any I/O pin through software. It does not necessarily have to use a pin designated for SPI, like pins RC3,4 and 5 on the PIC 16F877; labelled as SCL, SDA and SDO respectively.

    I am having some serious problems trying to get a PIC 16F628 to perform SHIFT IN/OUT commands with PIC BASIC Pro and I was wondering if my problem was with my selection of chips.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Hi Robert, Glad to se i'm not the only one close to montreal here.

    MBASIC can process SPI communication with any I/O pin through software. It does not necessarily have to use a pin designated for SPI, like pins RC3,4 and 5 on the PIC 16F877; labelled as SCL, SDA and SDO respectively.

    I am having some serious problems trying to get a PIC 16F628 to perform SHIFT IN/OUT commands with PIC BASIC Pro and I was wondering if my problem was with my selection of chips.
    i'm about to think you're using the PORTA. Add this line to the top of your code

    CMCON=7

    This one disable the internal analog comparator.

    If it's not working, can you provide your code here. That way it will be more easy to see what you do.

    regards
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    Bonjour Steve!

    Yup, I thought of that, same with PAUSEUS. I also use a button to shift in new data after I've sent +5V DC to one of the input pins on the 74HC166. Here's all my code, I even left in the indicator LEDs I've been using to display results:


    INCLUDE "MODEDEFS.BAS" ' Serial I/O modes

    ASM
    LIST
    INCLUDE 'M16F62X.INC' ; PM header
    DEVICE PIC16F628, HS_OSC, WDT_OFF, PWRT_ON, MCLR_OFF, LVP_OFF, PROTECT_OFF
    XALL
    NOLIST
    ENDASM

    DEFINE OSC 20 ' Set oscillator speed
    DEFINE SHIFT_PAUSEUS 3 ' Slow down SHIFT in/out commands by 3uSECS
    CMCON = 7 ' Set PORT A pins to digital

    SHFTIQ7 VAR PORTB.0 ' Input data
    SHFTICP VAR PORTB.1 ' Input clock pulse
    SHFTICE VAR PORTB.2 ' Input clock enable
    SHFTIPE VAR PORTB.3 ' Input parallel enable

    BUTTONI VAR PORTA.4 ' Input user entry

    LED1 VAR PORTA.2 ' Bit active indicator
    LED2 VAR PORTA.3 ' Loop indicator

    LOOP VAR BYTE
    DATAI VAR BIT[16]
    HIBIT CON %1
    HIBYTE CON 1

    START: DATAI = 0 ' Initialize variables
    LOOP = 0

    GOSUB REQBUT ' Wait for user input

    LOW SHFTIPE ' Initiate parallel load of bits
    LOW SHFTICE
    GOSUB CYCCLK

    HIGH SHFTIPE ' Initiate serial shift of bits
    LOW SHFTICE
    GOSUB CYCCLK

    HIGH SHFTICE ' Initiate hold of shift registers

    SHIFTIN SHFTIQ7,_ ' Shift in bits from registers
    SHFTICP,_
    LSBPRE,_
    [DATAI\16]

    FOR LOOP = 0 TO 15 ' Check bits for a high bit
    GOSUB BITNUM
    IF DATAI = HIBIT THEN
    GOSUB HIFND
    ENDIF
    NEXT LOOP

    GOTO START ' Restart processing

    FINISH: END ' Terminate processing


    ' SUB-ROUTINES


    REQBUT: GOSUB FLASH ' Process user input
    IF BUTTONI <> HIBYTE THEN GOTO REQBUT
    RESUME

    FLASH: HIGH LED1 ' Indicate waiting for user input
    HIGH LED2
    PAUSE 250
    LOW LED1
    LOW LED2
    PAUSE 250
    RETURN

    CYCCLK: LOW SHFTICP ' Cycle clock pulse
    HIGH SHFTICP
    RESUME

    BITNUM: HIGH LED2 ' Indicate bit number within string
    PAUSE 250
    LOW LED2
    PAUSE 250
    RETURN

    HIFND: HIGH LED1 ' Indicate bit is high
    PAUSE 250
    LOW LED1
    PAUSE 250
    RETURN

    If I jst connect the input pins to the PIC to GND, all the bits are 0, if I connect to +5V DC, all the bits are 1, which is what I expect. I'm stumped.

    Robert
    Last edited by Demon; - 28th January 2005 at 21:12.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  5. #5
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Robert,

    I didn't have time to go through your code all the way, but one thing that I would add to the top...For safty sake.
    I can't remember but I think porta.5 is your MCLR so you are ok there.

    TRISB=%00001111
    TRISA=%00011111


    I must go... Works a calling.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    dwayne

    When you're using LOW or HIGH it make pin automatically as output. BUT i agree TRIS setting is always a safe practice.

    robert

    Code:
    DATAI VAR BIT[16]
    
    .
    .
    .
    .
    SHIFTIN SHFTIQ7,_ ' Shift in bits from registers
            SHFTICP,_
            LSBPRE,_
           [DATAI\16]
    what about if you change your variable DATAI as follow

    DATAI VAR WORD 'it's now 16bits

    and then change
    Code:
    FOR LOOP = 0 TO 15 ' Check bits for a high bit
         GOSUB BITNUM
         IF DATAI.0(LOOP) = 1 THEN
         GOSUB HIFND 
         ENDIF
    NEXT LOOP
    BUT using your code without changing VAR definition (was DATAI VAR BIT[16] )
    Code:
    FOR LOOP = 0 TO 15 ' Check bits for a high bit
         GOSUB BITNUM
         IF DATAI [LOOP] = 1 THEN
         GOSUB HIFND 
         ENDIF
    NEXT LOOP
    and also i see some RESUME that must be change to RETURN. RESUME are use for interrupts.

    for now, it's the only thing i can see. I didn't check the Datasheet for the shift register as now. Wait for your relply on that.

    A la prochaine
    Last edited by mister_e; - 28th January 2005 at 22:55.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    RESUME? ARGH!!! I meant RETURN.

    What a bobo...?

    Robert
    :lol:
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    Hi guys,

    I added the TRIS definitions, but no go. Also, although a pin like CP is referred to as the 'Input clock pulse', it remains an output pin since the PIC is sending this signal to the 74HC166. But no matter, that's not the problem either.

    I also put the [LOOP] back in when comparing the individual bits to %1, I lost that along the way with the multitude of changes, not that either.

    I've come up with an alternative method of achieving my goals. The other thread discussing QBASIC has given me an idea that could greatly improve my design, making it more flexible, less complicated and much more user-friendly. I'll explore that for a while and fall back on this if the other option doesn't pan out.

    Having graduated from Champlain College in 1983 in Data Processing, some water has flowed under the bridge since the last time I've used QBASIC. I've been a mainframe programmer using COBOL since then.

    Merci!

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Qbasic..... yukkk, well it's still working with some POKE and PEEK but in 2005, i'll prefer use VB or Visual C.

    Qbasic remind me those TI-99/4A, TRS80, Comodore VIC-20, Comodore 64 and 128, Zinclair Z81, Tandy 1000, CoCo 1 & 2 and how many more stone age stuff working with cassette tape to store program. Looks like we all become older

    BTW, tell us more about what you're going to expect with your code i.e what goes in and how, what you do at the end,

    In brief what is suppose to do. As we can have many solutions here, we can help you on that... for sure.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve,

    Yeah, I know I could post the basic steps of my project. But then someone with enthusiasm to burn might post the code to do it all and then I'd have to chose between accepting his code or doing it myself. I don't want to put myself in that position 'cause that would be SOOOOO tempting to speed up the process. LOL

    Seriously, I'm stuck at home and I'm trying to keep my mind active. That's why I try to post specific questions to parts I can't figure out after a while. I learn best when I research the material myself, I'm a trial & error kind of guy. It may take me longer to go forward, but at least the 'thinking' is helping me fight this medication that numbs the skull (temporarily sidelined).

    Thanks for that message about those LCDs, I hadn't seen any cheap 4x40s in the Montreal area. I'm holding back on the other idea now until I can go get a few at Madison. These PICs are so much more user-friendly when it comes to LCD displays.

    Don't worry, I should be stuck on something else soon enough...

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    These PICs are so much more user-friendly when it comes to LCD displays.

    Don't worry, I should be stuck on something else soon enough...
    AND MORE, they're addictive once you get the first project run. After that we forget the old CMOS/TTL logic IC combination stuff.

    That come more and more interesting to place a PIC in almost everywhere after that. What a time saving in most case.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    Just got back from Maddison with their last 4x20. I'm searching the web now for the specs for I can start playing with it.

    I also have 30 Seiko 2x40s coming within the next few weeks. I like the 4x20 more though. I'd really like to find a larger format, but I haven't been able to find anything.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Usually all the LCDs have the same pinout. Look in LCDOUT section of PBP manual.

    I'd really like to find a larger format, but I haven't been able to find anything.
    next step, use your home theater screen and display on it.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    Euh, I'm kinda short on the home theater front...

    What about monitors? Do we have the capability to output to CRTs? Or do we have to communicate to a PC to have it handle the graphic manipulation?

    PIC to 14" monitor would be even better for my application. I'd like to display menus with 10-12 items, LCDs are kinda small for my needs. Of course I'll do with what I have, but a 14" area would be greatly superior.

    What about the new flat screen technology, can we output to those?

    (just taking a survey of what is available to me with PIC chips)

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  15. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    it's easy to do BW stuff on TV. Have a look on this link

    That should be be enough to start and give food to your brain.

    i never do some test with computer screen but if you look to VGA specs... i'm sure you can do something with.

    Nothing is impossible.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  16. #16
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default

    "10 characters wide"

    Ugh, I'm better off with the LCDs with that sort of resolution. Interesting reading though. Shoot the LCD I bought today has 4 lines by 20 characters, with backlighting, and is supported by PICs.

    I've been thinking a lot about the LCDs and they are probably the most economical, easiest to implement, require the least amount of space, require little current, and give a modern look to any display.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. PIC16F877A pwm use for IR transmission
    By mcbeasleyjr in forum General
    Replies: 0
    Last Post: - 11th July 2009, 18:51
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 04:58
  5. Replacing shift register with PIC
    By TonyA in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 7th April 2008, 18:31

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts