I need help with 16F877A


Closed Thread
Results 1 to 5 of 5
  1. #1
    valerij's Avatar
    valerij Guest

    Default I need help with 16F877A

    I need help with PIC 16F877A
    I am new to PIC BASIC.
    In attachment is my Flow Chart and Conections.
    Thanks
    Val
    [email protected]
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Thumbs down

    Anything else????
    IF You = Know THEN
    Share it
    ENDIF

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Talking

    No kidding...
    I'll write the whole program, put it on a circuit board, test it, and deliver it to your house for $1,000 -- complete with a free pizza.

    NOT!!!!

    Why not show us an attempt...no matter how feeble...then maybe, just maybe, somebody around here will help you...myself included.

    Until you've done some of the legwork, forget it...
    JDG

  4. #4
    valerij's Avatar
    valerij Guest


    Did you find this post helpful? Yes | No

    Default I wrote CODE

    I try to wrote code and for sure do a lot of mistakes.
    Can you check code in Att. and help me.
    Thanks
    Attached Files Attached Files

  5. #5
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Let me post it here for you.


    Code:
    '****************************************************************
    '*  Name    : TEST_Example.BAS                                  *
    '*  Author  : VAL                                               *
    '*  Notice  : Copyright (c) 2006                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 11/27/2006                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
     program TEST_Example
    
    'Project name:
    '    TEST_Example
    ' * Description:
    '    This project simulate real environment and test PLC response
    ' Configuration:
    '    MCU:   PIC16F877A
    '   Oscillator:  HS, 8 MHz
    '   Ext. Modules:  ADC(MCP3204),Switches,LED Diodes
    ' * Notes:
    ' ADC on PORTC
    ' 2x16 LDC on PORTB (4-bit)
    ' LED Diodes on PORTA
    ' Switches on PORTD and PORTE
    ' 1000=1 second
    PBP -p16F877A TEST_Example
    
     DEFINE OSC 8
     DEFINE ADCON1=7
     DEFINE intcon=0
     DEFINE LCD_DREG  PORTB
     DEFINE LCD_DBIT     0
     DEFINE LCD_RSREG    PORTB
     DEFINE LCD_RSBIT    4
     DEFINE LCD_EREG     PORTB
     DEFINE LCD_EBIT     5
     DEFINE LCD_BITS     4
     DEFINE LCD_LINES    2
     DEFINE LCD_COMMANDUS  2000
     DEFINE LCD_DATAUS   50
     
     TRISB=0
     LCD_Init(PORTB)
     LCDOut $FE,$80+6,"TEST"  'I want to show TEST in the midle of first line on the display
     LCDOut $FE,$0C+6,"START" 'I want to show START in the midle of second line 
     
     'Here I need code for ADC connected to PORTC
     'CLK(SCK) to PORTC.3
     'Dout(MISO) to PORTC.5
     'Din(MOSI) to PORTC.4
     'ADC is MCP3204 and I want To use CH0 and CH1
     'CH0 will be var MODV and CH1 will be var CURRV
     'Range is From 5 V to 0 V
     
     TRISA=0
     AA VAR PORTA.0       'PORTA is Output
     BB VAR PORTA.1
     CC VAR PORTA.2           'I connect diodes(AA,BB,CC,MM,NN,MDEF) to specific Pins
     MM VAR PORTA.3
     NN VAR PORTA.4
     MDEF VAR PORTA.5
     
     TRISD=1
     ALARM VAR PORTD.0            'PORTD is Input
     HEAT VAR PORTD.1
     INRANGE VAR PORTD.2     'Togle switches are connected to specific Pins
     DEFROST VAR PORTD.3
     EVAL VAR PORTD.4
     CF VAR PORTD.5             'Togle switch is RELAY that is ON or OFF
     SSV VAR PORTD.6
     COOL VAR PORTD.7   'ON=1 and OFF=0
     
     TRISE=1
     RET VAR PORTE.0         'PORTE same like PORTD
     CM VAR PORTE.1        
     
     
     main:
     
     ALARM1=ALARM             'Read status of PINA.0 (Can be GND or Vcc-0 or 1)
     IF ALARM1=0 Then        'If ALARM1=0(Pin ALARM is GND) I want to show this on LCD
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 1"
     Else
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 1"
     High CC     'Set CC to 1(Vcc) and rest to 0(GND)
     Low BB
     Low AA
     Low MM
     Low NN
     Low MDEF
     Pause 360000  'Keep that setings for 6 min
     
     
     
     Count CF,360000,CF1      'During this 6 min read status of CF and SSV
     Count SSV,360000,SSV1
      
     IF CF1<2 OR SSV<2 Then    'During this 6 MIN check does CF AND SSV change
     LCDOut $FE,$80+6,"TEST"    'they status min 2 times
     LCDOut $FE,$0C+6,"FAIL 2"
     Else
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 2"
     ALARM1=ALARM
     HEAT1=HEAT
     INRANGE1=INRANGE        'Read status of inputs
     DEFROST1=DEFROST
     EVAL1=EVAL
     COOL1=COOL             'I also need to read value of ANALOG INPUTS
     RET1=RET      'CURRV must be betwen 2.5 V and 5 V
     CM1=CM
     
     IF EVAL1=0 OR CM1=0 OR INRANGE1=0 OR ALARM1=0 OR RET1=1 OR DEFROST1=1 OR HEAT1=1 OR COOL1=0 OR MODV1=0 OR CURRV1<2.5 Then
      
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 3"
     Else
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 3"
     
     High CC    'Change status of output and keep that status 2 min
     High BB
     Low AA
     Low MM
     Low NN
     Low MDEF
     Pause 120000
     
     Count CF,120000,CF1
     IF CF1<2 Then
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 4"
     Else
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 4"
     
     IF EVAL1=0 OR INRANGE1=0 OR CM1=0 OR MODV1>0 OR HEAT1=1 OR SSV1=1 OR DEFROST1=1 OR RET1=1 OR ALARM1=0 OR COOL1=1 OR CURRV1<2.5 Then
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 5"
     Else
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 5"
     
     High AA
     LOW BB
     HIGH CC
     LOW MM
     LOW NN
     LOW MDEF
     PAUSE 180000
     
     COUNT IR,180000,IR1
     IF IR1=0 THEN
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 6"
     ELSE
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 6"
     
     IF EVAL1=0 OR HEAT1=0 OR CF1=1 OR CM=1 OR SSV1=1 OR DEFROST1=1 OR ALARM1=0 OR RET1=1 or COOL=1 OR HEAT1=0 OR MODV1>0 OR 0.9<CURRV1<1.8 THEN
      LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 7"
     ELSE
     
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 7" 
      
      LOW AA
      HIGH BB
      HIGH CC
      LOW MM
      LOW NN
      LOW MDEF
      PAUSE 30000
      
      LOW AA
      HIGH BB
      HIGH CC
      HIGH MM
      LOW NN
      LOW MDEF
      PAUSE 15000
      
      LOW AA
      HIGH BB
      HIGH CC
      LOW MM
      HIGH NN
      LOW MDEF
      PAUSE 1000
      
      LOW AA
      HIGH BB
      HIGH CC
      LOW MM
      LOW NN
      LOW MDEF
      PAUSE 120000
      
      IF EVAL1=0 OR CM1=0 OR SSV1=0 OR HEAT1=1 OR DEFROST1=1 OR ALARM1=0 OR RET1=1 OR COOL=0 OR MODV1<2.5 OR CURRV1<2.5 THEN
      LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 8"
     ELSE                  
       
     LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"PASS 8"
     
     LOW AA
     HIGH BB
     HIGH CC
     HIGH MM
     HIGH NN
     LOW MDEF
     PAUSE 15000
     
     LOW AA
     HIGH BB
     HIGH CC
     LOW MM
     HIGH NN
     LOW MDEF
     PAUSE 1000
     
     LOW AA
     HIGH BB
     HIGH CC
     LOW MM
     LOW NN
     LOW MDEF
     PAUSE 30000
     
     LOW AA
     HIGH BB
     HIGH CC
     LOW MM
     LOW NN
     HIGH MDEF
     PAUSE 1000
     
     LOW AA
     HIGH BB
     HIGH CC
     LOW MM
     LOW NN
     LOW MDEF
     PAUSE 60000
     
     IF DEFROST1=0 OR HEAT1=0 OR ALARM1=0 OR MODV1>0 THEN
      LCDOut $FE,$80+6,"TEST"
     LCDOut $FE,$0C+6,"FAIL 9"
     ELSE   
      LCDOut $FE,1,"I AM GOOD"
     LCDOut $FE,$0C,"TO GO"
     
     Endif
      ENDIF
       ENDIF
        ENDIF
         ENDIF
          ENDIF
           ENDIF
            ENDIF
             ENDIF
       END

    I just posted your code.
    I did not change anything in it.


    --------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. 16F877 vs. 16F877A
    By DavyJones in forum General
    Replies: 12
    Last Post: - 11th April 2009, 18:22
  2. help my bluetooth and PIC 16F877A?
    By slimpeng in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th March 2008, 06:52
  3. Read the newbee threads, 16F877A no go.
    By BobbyA in forum mel PIC BASIC Pro
    Replies: 39
    Last Post: - 31st December 2006, 03:09
  4. Clock connection to DS1802 from 16F877A
    By coyotegd in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd January 2006, 18:52
  5. 1st 16F877A program in PICBasic
    By Borisw37 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th January 2005, 04:46

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