I am Completely NEW to PICS and LOST PIC18f252


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Feb 2011
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: I am Completely NEW to PICS and LOST PIC18f252

    Thanks so far for the help.
    I have cleaned up the code, see below, and now i have a whole new list of errors.

    What does all of this mean? (errors are in the attachment)


    Code:
    Define OSC 4
    
    include "bs2defs.bas"
    
    Progress Var Byte
    Relay1 var PORTC.2
    Relay2 var PORTC.1
    Relay3 var PORTC.0
    StatLED var PORTA.0
    OptoPin var PORTB.0
    ADVar	var	byte	' A-to-D result: one byte.
    CS	var PORTB.2		' Chip select is pin 0. 
    AData VAR PORTB.7	' ADC data output is pin 1. 
    CLK	VAR PORTB.6  	' Clock is pin 2. 
    baud  	con   	16468 	' N9600
    i var byte
    A Var PORTA.6
    
    ' BASIC Stamp II Interface for the ADC0831 
    ' 8-bit analog-to-digital converter
    
     
    
    high CS			' Deselect ADC to start.
    Start:
      high CS			' Deselect ADC to start.
      progress = 0
      gosub One
      Gosub Two
      Gosub Three
      If Progress = 3 then 
      gosub  completegood
      Else
              high Statled
      endif
    
    
    One:  'This will test the output of relay 1 and check its value through the ADC
      High Relay1
      Pause 10
      gosub ADC'Run ADC code
      Low Relay1
    'Test ADC value to be within range 80-100
      If (ADVar>80) and (ADVar<100) then 
       i = 0
        REPEAT
         High StatLED
         Pause 500
         Low StatLED
         Pause 500
         i = i + 1
        UNTIL i > 7
      else 
       i = 0
        REPEAT   
         High Relay1
         Pause 500
         Low Relay1
         Pause 200 
         i = i + 1
        UNTIL i > 7  
      ENDIF   
     return
    
    Two:'This will test the output of relay 2 and check its value through the ADC
      High Relay2
      Pause 10
      Gosub ADC'Run ADC code
      Low Relay2
    'Test ADC value to be within range 105-140
      If (ADVar>105) and (ADVar<140) then 
      gosub BLEDG
      else 
        i = 0
       REPEAT   
         High Relay1
         Pause 500
         Low Relay1
         Pause 200 
         i = i + 1
       UNTIL i > 7  
      ENDIF   
     return
    Three:'This will test the output of relay 3 and check its value through the ADC
      High Relay3
      Pause 10
      gosub ADC'Run ADC code
      If Optopin = 1 then 
      gosub Optogood
      endif 
      Low Relay3
    'Test ADC value to be within range 200-260
      If (ADVar>200) and (ADVar<260) then 
      goto BLEDG
      else 
       i = 0
       REPEAT   
         High Relay3
         Pause 500
         Low Relay3
         Pause 200 
         i = i + 1
       UNTIL i > 7
       Progress = progress + 1   
      ENDIF   
     return
    
    BLEDG: 'Tested out good so we will let everyone know. 
     i = 0
      REPEAT
       High StatLED
       Pause 500
       Low StatLED
       Pause 500
       i = i + 1
      UNTIL i > 7
     return
    
    OptoGood: 'Tested out good so we will let everyone know.
      i = 0
      REPEAT
       High StatLED
       Pause 100
       Low StatLED
       Pause 100
       i = i + 1
     UNTIL i > 4
     return 
    
    CompleteGood: 'Tested out good so we will let everyone know.
     
       High StatLED
       Pause 100
       Low StatLED
       Pause 300
     end
    
    
     
    
    ADC:
      low CS		' Activate the ADC0831. 
      shiftin AData,CLK,msbpost,[ADVar\9]	' Shift in the data. 
      high CS		' Deactivate '0831.
      pause 500
      serout 3,baud,[ADVar]
      pause 1000
    Attached Images Attached Images  

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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