16F877 and 4094 please help


Closed Thread
Results 1 to 19 of 19
  1. #1
    Join Date
    Sep 2009
    Posts
    23

    Default 16F877 and 4094 please help

    Hello friends
    I have manufactured this circuit with 16F877
    3 switches of entry that them portray the situation of entry in the 4094
    This code work good .my problem is always sees the last entry
    that I can see the all entries simultaneously be portrayed in the 4094



    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            alarm var word
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
            alarm=0
           
    start:
    
           IF PORTB.0=0 THEN
           alarm=%10000000
    	   ENDIF
    	   IF PORTB.1=0 THEN
           alarm=01000000
    	   ENDIF
    	   IF PORTB.2=0 THEN
           alarm=%00100000
    	   ENDIF
           gosub print
           goto start      
    
    print:
            
            ShiftOut data_pin,clock,0,[alarm]                              
            strb = 1  : PAUSEUS 100 :  STRB = 0
            return
    
    end
    Attached Images Attached Images  

  2. #2
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    i didnt understand what you mean ;

    i think this will help you if i understood right.

    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            alarm var byte
            flag   var byte
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
            alarm=0
            flag  = 0
           
    start:
    
           IF PORTB.0=0 THEN
                    alarm=%10000000
                    flag.0 = 1
           ELSE
                    flag.0 = 0
           ENDIF
    	   
           IF PORTB.1=0 THEN
                    alarm=01000000
                    flag.1 = 1
           ELSE
                    flag.1 = 0
           ENDIF
    	   
           IF PORTB.2=0 THEN
                   alarm=%00100000
                   flag.2 = 1
           ELSE
                   flag.2 = 0
           ENDIF
    
           IF flag = 0 THEN alarm = 0
           
           
           
           gosub print
           goto start      
    
    print:
            
            ShiftOut data_pin,clock,0,[alarm]                              
            strb = 1  : PAUSEUS 100 :  STRB = 0
            return
    
    end

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            alarm var byte
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
            alarm=0
           
    start:
    
           IF PORTB.0=0 THEN
    	    alarm = alarm + $80      ' add the bit
           ELSE
                alarm = alarm & $7F      ' remove the bit
           ENDIF
    
           IF PORTB.1=0 THEN
    	    alarm=alarm + $40
           ELSE
                alarm = alarm & $BF      ' remove the bit
           ENDIF
    
           IF PORTB.2=0 THEN
                alarm=alarm+$20
           ELSE
                alarm = alarm & $DF      ' remove the bit
           ENDIF
           gosub print
           goto start      
    
    print:
            
            ShiftOut data_pin,clock,0,[alarm]                              
            strb = 1  : PAUSEUS 100 :  STRB = 0
            return
    
    end
    Last edited by Jerson; - 17th October 2009 at 14:09.

  4. #4
    Join Date
    Sep 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Sorry for my English is not good
    I want he permanently remains turned on corresponding led (TOGGLE led)
    For each button that is activated
    Last edited by dovegroup; - 18th October 2009 at 07:03.

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    This will leave your last action ON.

    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            alarm var BYTE
            Flag   var BYTE
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
            alarm=0
            Flag = 0
    
    start:
    Pause 10
    
           IF PORTB.0=0 THEN
           alarm=%10000000
    	Flag=1   
    ENDIF
    	   IF PORTB.1=0 THEN
           alarm=%01000000
    	Flag = 1   
    ENDIF
    	   IF PORTB.2=0 THEN
           alarm=%00100000
    	Flag = 1   
    ENDIF
     
    If Flag = 1 Then  gosub print
           goto start      
    
    print:
            
            ShiftOut data_pin,clock,0,[alarm]                              
            strb = 1  : PAUSEUS 100 :  STRB = 0
            Flag = 0
    return
    
    end
    Al.
    Last edited by aratti; - 18th October 2009 at 08:14.
    All progress began with an idea

  6. #6
    Join Date
    Sep 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Thank you very much for the answers
    But does not function the circuit,When I have in 3 inputs 0, (ΡΒ0=0,ΡΒ1=0,ΡΒ2=0)
    Do not turn on 3 led but always only 1

  7. #7


    Did you find this post helpful? Yes | No

    Default

    This code only has shiftout....the leds are on your shiftin receive side...right?

    What you need to do is save your previous LED status. Currently every time you receive data from a button press it resets the other LED's so only 1 LED will be on.

  8. #8
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    But does not function the circuit,When I have in 3 inputs 0, (ΡΒ0=0,ΡΒ1=0,ΡΒ2=0)
    Do not turn on 3 led but always only 1
    To have also two or three leds on at the same time you have to add more code (in red):


    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            alarm var BYTE
            Flag   var BYTE
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
            alarm=0
            Flag = 0
    
    start:
    Pause 10
    
    IF PORTB.0=0 THEN
    alarm=%10000000
    Flag=1   
    ENDIF
    
    IF PORTB.1=0 THEN
    alarm=%01000000
    Flag = 1   
    ENDIF
    	   
    IF PORTB.2=0 THEN
    alarm=%00100000
    Flag = 1   
    ENDIF
     
    IF PORTB.0=0  and PORTB.1 =0 THEN
    alarm=%11000000
    Flag=1   
    ENDIF
    
    IF PORTB.1=0  and PORTB.2 =0 THEN
    alarm=%01100000
    Flag=1   
    ENDIF
    
    IF PORTB.0=0  and PORTB.2 =0 THEN
    alarm=%10100000
    Flag=1   
    ENDIF
    
    
    IF PORTB.0=0  and PORTB.1 =0 AND PORTB.2 = 0 THEN
    alarm=%11100000
    Flag=1   
    ENDIF
    
    If Flag = 1 Then  gosub print
           goto start      
    
    print:
            
            ShiftOut data_pin,clock,0,[alarm]                              
            strb = 1  : PAUSEUS 100 :  STRB = 0
            Flag = 0
    return
    
    end
    Very likely you will need also a reset, in this case add the following code:
    Code:
    IF PORTB.0=1  and PORTB.1 =1 AND PORTB.2 = 1 and alarm>0 THEN
    alarm=%00000000
    Flag=1   
    ENDIF

    You can also try the following code which is a lot shorter and should work as well.
    Code:
    INCLUDE "modedefs.bas"
    DEFINE SHIFT_PAUSEUS 100
    
    
            
            TRISB = %00000111 
            
            Alarm   var BYTE
            Flag    var BYTE
            B0      var Byte
    '****************************************************************
            symbol clock=portc.4
            symbol data_pin=portc.2
            symbol strb=PORTc.3
    '****************************************************************
    alarm = 0
    Flag = 0
    B0 = 0
    
    start:
    
    Pause 10
    
    B0 = PortB & %00000111
    Alarm = (7 - B0) * 32
    If Alarm <> Flag then gosub Print
    goto start      
    
    Print:
    
    ShiftOut data_pin,clock,0,[alarm]                              
    strb = 1  : PAUSEUS 100 :  STRB = 0
    Flag = Alarm
    return
    
    end
    Al.
    Last edited by aratti; - 19th October 2009 at 08:30.
    All progress began with an idea

  9. #9
    Join Date
    Sep 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default

    Yes it works irreproachably
    Thank you very much friend aratti
    Thank you very much all friends for the answers

  10. #10
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Glad to hear that! You are welcome.

    Al.
    All progress began with an idea

  11. #11
    Join Date
    May 2014
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    Hi,
    I am inexperienced still in picbasic but I try
    Reading her user guide, and studying examples of code

    I noticed in this post the code from aratti, It is exactly what I need (thank you very much aratti)
    I used him as a basis, and I made changes so that him I adapt in my work

    Here I would want your help, so that I use also port C from the 16F876, so that I increase the inputs (push button) circuit in 16

    Thank you in advance
    regards

    Here it is the code and the circuit, that works perfect
    Code:
    DEFINE OSC 10
    DEFINE SHIFT_PAUSEUS 100
    
    
    TRISA = %00000000
    TRISB = %11111111 
    TRISC = %00000000
    ADCON1 = 7
    '************************************        
    alarm var BYTE
    Flag   var BYTE
    bleg   var word
    B0      var word
    '************************************
    Symbol data_pin=PORTA.0
    Symbol clock=PORTA.1
    Symbol strb=PORTA.2
    Symbol oe=PORTA.3
    '************************************
    alarm=0
    Flag = 0
    B0 = 0
    bleg= 900
    portC = %00000000
    
    '************************************
    
    
    start:
    
    oe= 0:pause bleg
    
    B0 = PortB & %11111111
    Alarm = (0 + B0) * 1
    If Alarm <> Flag then gosub Print
    oe= 1:pause bleg
    goto start      
    
    '************************************
    Print:
    
    ShiftOut data_pin,clock,1,[alarm]                              
    strb = 1  : PAUSEUS 100 :  STRB = 0
    Flag = Alarm
    return
    
    end
    Name:  alarm-sch.png
Views: 1220
Size:  10.7 KB

  12. #12
    Join Date
    Sep 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    Hi Anatoli

    I am not guru in picbasic I will try to help you, with those who I know
    It tryed these changes

    Code:
    DEFINE OSC 10
    DEFINE SHIFT_PAUSEUS 100
    
    
    TRISA = %00000000
    TRISB = %11111111 
    TRISC = %11111111
            
    alarm var word
    Flag   var BYTE
    bleg   var word
    B0      var word
    C0      var word
    '************************************
    Symbol data_pin=PORTA.0
    Symbol clock=PORTA.1
    Symbol strb=PORTA.2
    Symbol oe=PORTA.3
    '************************************
    alarm=0
    Flag = 0
    B0 = 0
    C0 = 0
    bleg= 500
    portC = %00000000
    ADCON1 = 7
    '************************************
    
    
    start:
    
    oe= 0:pause bleg
    
    B0 = PortB & %11111111
    C0 = PortC & %11111111
    Alarm = (0 + C0) * 1  & Alarm = (0 + B0)
    If Alarm <> Flag then gosub Print
    oe= 1:pause bleg
    goto start      
    
    '************************************
    Print:
    
    ShiftOut data_pin,clock,1,[alarm\8]   
                           
    strb = 1  : PAUSEUS 100 :  STRB = 0
    Flag = Alarm
    return
    
    end

  13. #13
    Join Date
    May 2014
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    Hi dovegroup

    I thank you for your help, him I tryed
    the second IC-4094 works rightly, but the first IC-4094 does not works any output

  14. #14
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    It looks like you're using Proteus and simulating the project. If so, and maybe not, you've assigned D9 to two chips which I'm assuming are the 4094. Change one or the other to something else and hook something up to the lower chip. Then see what you've got.

  15. #15
    Join Date
    May 2014
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    Friends Dovegroup and AvionicsMaster1

    Connecting a logic analyzer in line CLOCK and DATA
    I discovered that the DATA that are directed to the IC-4094 are only 8bit, would not be supposed were 16bit
    8bit for the first IC and 8bit for the second IC

    See the snapshot from the analyzer

    Name:  analyser.png
Views: 1393
Size:  26.4 KB
    Last edited by Anatoli; - 20th May 2014 at 15:23.

  16. #16
    Join Date
    Sep 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    Very rightly Aнатолий
    8bit for the first 4094 and 8bit for the second 4094
    I do not know to answer you how it will become this, I suppose that thus

    ShiftOut data_pin,clock,1,[alarm_1,alarm_2]

  17. #17
    Join Date
    May 2014
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    I will try with this
    Thank you .Я благодарю товарища

  18. #18
    Join Date
    May 2014
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    Товарища dovegroup

    Even if you are not guru in the picbasic as you report in initial your post
    Your help was very big, so that I complete my work

    See the changes that I made

    Alarma = (0 + C0) * 1
    Alarme = (0 + B0) * 1

    ShiftOut data_pin,clock,1,[Alarma,Alarme]

    Thank you very much
    Aнатолий (Anatoli)


    Name:  ALARM-END.png
Views: 1147
Size:  43.3 KB

  19. #19
    Join Date
    Sep 2009
    Posts
    23


    Did you find this post helpful? Yes | No

    Default Re: 16F877 and 4094 please help

    Anatoli good the knowledge guru my friend, but when doesn't exist appetite in order to you help ?
    I am cheerful that I even helped little So that you will complete your work

    привет товарищ Анатолий
    алексей или иным dovegroup

Similar Threads

  1. 4094 Please Help
    By dovegroup in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 10th September 2009, 12:11

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