is it possible?


Results 1 to 2 of 2

Thread: is it possible?

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    O.K that's not strange and i see one improvement that should be done first to make it simple.

    About those LCDs, you can control more than 1 LCD with the same PIC, you just need few external parts. see the following thread, everything is really well explain. code and schematic are included
    http://www.picbasic.co.uk/forum/showthread.php?t=626
    so now you save one PIC, code, money, time....

    Now, about the other 16F628... what will be his purpose, do you want to have bidirectional communication, i mean, do you want that the master send a command then receive the according answer from the 16F628???
    If so, kepp the HSERIN/HSEROUT for your PC communication and use SERIN/SEROUT/SERIN2/SEROUT2 to talk to that device.

    Code:
        '    This is the snip of the Master PIC16F877 
        '
        '    This will send a byte to the PIC16F628 and 
        '    waiting for a reply.  If there's no reply
        '    after 2 second it will display an error 
        '    message to the LCD.
        '    
        SerialOUTToPIC16F628  var PORTC.0
        SerialINFromPIC16F628 var PORTC.1
        
        SentByPIC16F628       var byte
        
        SendMeBeer            con 0    ' command bytes 
        SendMeFruit           con 1    '     to be 
        SendMeCash            con 2    '     send
                                       '
        T2400                 con 396  ' used for baudrate=2400 
        TimeoutDelay          con 2000 ' used for timeout=2000 mSec=2 Sec
        
        HIGH SERIALOUTTOPIC16F628      ' For safety sake and avoid to send 
                                       ' garbage at the first time
    
    start:
        pause 2000   ' LCD start-up delay AND future LCD message duration
        lcdout $fe,1 ' Clear LCD screen
        
        serout2 serialouttopic16f628 ,T2400,_       ' send command byte to
                [sendmebeer]                        ' the external PIC16F628
        
        serin2  serialinfrompic16f628,T2400,_       ' waiting for  
                timeoutdelay, DisplayErrorMessage,_ ' the external
                [sentbypic16f628]                   ' PIC16F628 answer
        
                ' jump to different routine 
                ' depending of the 
                ' SentbYPIC16F628 value     
                '
                branch sentBYpic16f628,[Budweiser,_ ' when = 0 
                                        MolsonDry,_ ' when = 1
                                        SmirnoffIce]' when = 2
                goto start
                                                                            
                ' Timeout occur, display 
                ' the error message
                '
                DisplayErrorMessage:
                                    lcdout         "Looks like my",_
                                           $fe,$c0,"buddy sleep!!"
                                    
                                    goto start
          
    BudWeiser:
        lcdout "Let's drink a ",$fe,$C0,_
               "Budweiser Barrel"
               
        goto start
              
    MolsonDry:
        Lcdout "lezzz dwwwwrank",$fe,$c0,_
               "a MolsonDry pot"
               
        goto start
              
    SmirnoffIce:
        lcdout "ZZZzzzzzzZZ i i",$fe,$c0,_
               "loowve you....."
               
        goto start
    Code:
        '    This is the code snip for the PIC16F628
        '
        '    This will wait for a PIC16F877 command request
        '    and return a byte value.
        '
        SerialOUTToPIC16F877  var PORTB.0
        SerialINFromPIC16F877 var PORTB.1
        
        SentByPIC16F877       var byte
        SendToPIC16F877       var byte
                              
        Budweiser             con 0    ' command bytes 
        MolsonDry             CON 1    '     to be
        SmirnoffIce           CON 2    '      send
                                       '
        T2400                 con 396  ' used for baudrate=2400 
        
        high SERIALOUTTOPIC16F877      ' For safety sake and avoid to send 
                                       ' garbage at the first time
    
    start:
        serin2  serialinfrompic16f877,t2400,_ ' waiting for  
                [sentbypic16f877]             ' the external
                                              ' PIC16F877 answer    
                                              '
        branch sentbypic16f877,[SendMeBeer,_  ' =0
                                SendMeFruit,_ ' =1                                                 
                                SendMeCash]   ' =2
        
        goto start
        
    SendMeBeer:
        sendtopic16f877=budweiser ' open the fridge and choose your beer
        goto SendData             ' send it to master
        
    SendMeFruit:           
        ' do according stuff 
        goto SendData    
                               
    SendMeCash:            
        ' do according stuff 
        goto SendData
    
    SendData:
        serout2 serialouttopic16f877,t2400,[sendtopic16f877]
        goto start
    Above are just rough example. Should be enough to start.

    For the PC communication you can use the internal USART module or still use SERIN/SEROUT stuff. As i remind, that part you already know how to play with in PIC amd in VB.

    for your keyboard... hard to know wich kind you use but if it's a matrix one, you can find code example almost everywhere... Click here to download the Melabs keyx.bas file
    Last edited by mister_e; - 12th June 2005 at 12:43.
    Steve

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

Members who have read this thread : 0

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