+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Newbie level 2
    Points: 23, Level: 1

    Join Date
    Mar 2018
    Posts
    3
    Helped
    0 / 0
    Points
    23
    Level
    1

    74HC175, parallel to serial data conversion

    Hi dear friends,
    Thanks for providing the opportunity to interact with you experts!
    Here I want to perform parallel to serial data conversion. Therefore I am using 74HC165, 8-bit parallel-in/serial-out shift register.
    I need C code to read & store the fault status into Variable( say unsigned char). I tried below C code but its not working.
    Basically I have an 8 Window Annunciator product where I want to read the Eight different Fault status. These faults can be either Logic 0 or Logic 1. Now these Eight status shall be collected into a Variable(datatype: unsigned char, as value 0b00000000/ 0b11111111 is possible)
    Hardware logic is illustrated as shown in fig(A):
    D0 to D7 are eight fault status which can be either Logic 0 or Logic 1.
    C Code to read & store the status is as follows:

    Code C - [expand]
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    
    void CHK_FAULT_INPUT(void)
    {
        unsigned char a=0, Val=0;
     
        PL_ENABLE   = 1;
        SERIAL_CLK  = 0;
        CHIP_ENABLE = 1;    
     
     
            PL_ENABLE   = 0;        // PL
            asm("nop");     
            asm("nop");
            CHIP_ENABLE = 0;        // CE
            asm("nop");     
            asm("nop");
            
            SERIAL_CLK  = 0;        // CP
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
                                    // FAULT_PAT: Q7
     
            if((FAULT_PAT & 0b00000001) == 1) 
                FAULT_InP1 = 0b00000001;
     
            else FAULT_InP1 = 0b00000000;
            asm("nop"); 
     
            SERIAL_CLK  = 0;
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
     
            if((FAULT_PAT & 0b00000010) == 1) 
                FAULT_InP2 = 0b00000010;
     
            else FAULT_InP2 = 0b00000000;
            asm("nop"); 
     
            SERIAL_CLK  = 0;
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
     
            if((FAULT_PAT & 0b00000100) == 1) 
                FAULT_InP3 = 0b00000100;
     
            else FAULT_InP3 = 0b00000000;
            asm("nop"); 
     
            SERIAL_CLK  = 0;
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
     
            if((FAULT_PAT & 0b00001000) == 1) 
                FAULT_InP4 = 0b00001000;
     
            else FAULT_InP4 = 0b00000000;
            asm("nop"); 
     
            SERIAL_CLK  = 0;
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
     
            if((FAULT_PAT & 0b00010000) == 1) 
                FAULT_InP5 = 0b00010000;
     
            else FAULT_InP5 = 0b00000000;
            asm("nop"); 
     
            SERIAL_CLK  = 0;
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
     
            if((FAULT_PAT & 0b00100000) == 1) 
                FAULT_InP6 = 0b00100000;
     
            else FAULT_InP6 = 0b00000000;
            asm("nop"); 
     
            SERIAL_CLK  = 0;
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
     
            if((FAULT_PAT & 0b01000000) == 1) 
                FAULT_InP7 = 0b01000000;
     
            else FAULT_InP7 = 0b00000000;
            asm("nop"); 
     
            SERIAL_CLK  = 0;
            asm("nop");     
            asm("nop");
            SERIAL_CLK  = 1;
            asm("nop");     
            asm("nop");
            if((FAULT_PAT & 0b10000000) == 1) 
                FAULT_InP8 = 0b10000000;
     
            else FAULT_InP8 = 0b00000000;
            asm("nop"); 
     
            FAULT_InP = FAULT_InP1 + FAULT_InP2 + FAULT_InP3 + 
                                      FAULT_InP4 + FAULT_InP5 + FAULT_InP6 + 
                                      FAULT_InP7 + FAULT_InP8;
     
            SERIAL_CLK  = 0;
            CHIP_ENABLE = 1;
            PL_ENABLE   = 1;
    }


    So kindly suggest the correct C code to read & store the fault status into Variable.
    Thanks!
    Regards,
    Santosh Bhat
    Sr. Engg, Bangalore
    Last edited by bassa; 6th March 2018 at 12:44. Reason: add code tag

    •   Alt6th March 2018, 12:31

      advertising

        
       

  2. #2
    Super Moderator
    Points: 71,480, Level: 65
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    11,701
    Helped
    3871 / 3871
    Points
    71,480
    Level
    65

    Re: 74HC175, parallel to serial data conversion

    Just for clarification - are you referring to the 74HC175 as in the title or the 74HC165 as in the text?

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   Alt6th March 2018, 13:49

      advertising

        
       

  3. #3
    Super Moderator
    Points: 60,444, Level: 60
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    12,339
    Helped
    2858 / 2858
    Points
    60,444
    Level
    60

    Re: 74HC175, parallel to serial data conversion

    Hi,

    aren´t 24,800 google results for "HC165 C code" enough?

    there are a lot of discussion, code, circuits... what else do you need?

    ****
    Your given circuit is useless, because it doesn´t show the microcontroller connections.
    Your given code is not complete.
    What does the simulation say? Do the waveforms meet the specifications of the datasheet?

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   Alt6th March 2018, 14:11

      advertising

        
       

  4. #4
    Newbie level 2
    Points: 23, Level: 1

    Join Date
    Mar 2018
    Posts
    3
    Helped
    0 / 0
    Points
    23
    Level
    1

    Re: 74HC175, parallel to serial data conversion

    Yes sir, my apology!

    Its 74HC165

    Regards,
    Santosh



  5. #5
    Newbie level 2
    Points: 23, Level: 1

    Join Date
    Mar 2018
    Posts
    3
    Helped
    0 / 0
    Points
    23
    Level
    1

    Re: 74HC175, parallel to serial data conversion

    I am using PIC16F1938 microcontroller in which PL, CE, CP & Q7 outputs of 74HC165 are given as I/P to microcontroller. So microcontroller Port pins are configured as INPUT and other functions of the port( ANSEL, O/P, LATCH etc. are disabled)
    As I mentioned, I need to read 8 different Fault status and store it into any variable/register. So micocontroller i/p pin details were not shown.

    I am trying my best to understand the 74HC165 logic and doing google search as well!
    I am testing it with hardware, there is no compilation error as code is building! But when I am debugging it then the expected responses are not coming, as PL bit is abruptly becoming high etc.



    •   Alt7th March 2018, 06:58

      advertising

        
       

  6. #6
    Super Moderator
    Points: 60,444, Level: 60
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    12,339
    Helped
    2858 / 2858
    Points
    60,444
    Level
    60

    Re: 74HC175, parallel to serial data conversion

    Hi,

    You need to read the HC165 datasheet.

    PL, CE, CP & Q7 outputs of 74HC165
    What datasheet do you refer to? Your pin naming is different to the TI datasheet.

    You talk about 4 outputs, but a HC165 only has 2 outputs. --> read datasheet.

    Microcontroller output --> HC165 input.
    The microcontroller software needs to control / write the outputs to generate the signal for the HC165 inputs.
    But this all has been discussed very often and very detailed.

    All you need to know is given in the datasheet.
    * generate the HC165 input signals
    * and read in the HC165 output signals
    Follow the waveform and the timing informations given in the datasheet.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



--[[ ]]--