Compare value ...


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Compare value ...

    I think, You want this:


    Here is a Richard's corrected and tested code. I hope it will be works:
    Code:
    '****************************************************************'*  '*  Name    : 16F88_LM235.BAS                                   *
    '*  Author  :                                    *
    '*  Notice  : Copyright (c) 2020                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 04/04/2020                                        *
    '*  Version : 1.0                                               *
    '*  
    '****************************************************************
    #CONFIG
      __config  _CONFIG1, _INTRC_IO & _WDT_ON & _PWRTE_OFF & _MCLR_ON & _BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF & _CCP1_RB0 & _CP_OFF
      __config  _CONFIG2, _FCMEN_ON & _IESO_ON
    #ENDCONFIG
    'PIC 16F88
    '    Hardware Assignments
    '    --------------------
    ' LCD circuitery
    '01     - Vss (GND)
    '02     - Vdd (+5V)
    '08 RS  - PORTB.2
    '09 E   - PORTB.3
    '10 DB4 - PORTB.4
    '11 DB5 - PORTB.5
    '12 DB6 - PORTB.6
    '13 DB7 - PORTB.7
    
    
    adcon1.7=1
    ANSEL = %000001 'Disable Inputs Tranne AN0
    OSCCON = %01100000 'Internal RC set to 4MHZ
    TRISA = %10111111 ' impostazioni INP/OUT
    TRISB = 0 ' delle porte
    '----------------------------------------------------
    DEFINE LCD_DREG PORTB       'Porta B DATA OUT 
    DEFINE LCD_DBIT 4           '0 --> Bit 0-3 : 4 --> Bit 4-7 
    DEFINE LCD_RSREG PORTB      'LCD register select port - Porta B --> RS
    DEFINE LCD_RSBIT 2          'LCD register select bit  - Pin RS B2
    DEFINE LCD_EREG PORTB       'LCD enable port - Porta B --> EN
    DEFINE LCD_EBIT 3           'LCD enable bit - Pin EN B3DEFINE LCD_BITS 4           'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2          'Number lines on LCD DEFINE LCD_COMMANDUS 2000   'Command delay time in us 
    DEFINE LCD_DATAUS 50        'Data delay time in us
    
    
    '    EEPROM Locations Codice ASCII es. a=97 b=98 c=99 ...
    
    
    '===========================================================================
    '*****  SETTAGGIO PORTE 
    
    
    Rele   VAR    PORTA.6     '                  Pin 15
    '--------------------------------------------------------------
    '---------Define ADCin Parameters   
    DEFINE ADC_BITS 10      'set number of bits in result
    DEFINE ADC_CLOCK 3      'set clock source (3=rc)
    DEFINE ADC_SAMPLEUS 50  'Set sampling time in uS
    
    
    '    RAM Assignments and Variables
    '=========================================================================== 
    temp var word
    temperature var word
    samples var word
    sample VAR BYTE
    quanta con 1250
    Tmax VAR byte
    Tmin VAR byte
    '===========================================================================
    Tmin=16
    Tmax=30
     
    START:
    Lcdout $FE, 1           'Clear screen
    rele=0
    
    
    main:   
    sample = 1
    samples= 0
    FOR sample = 1 TO 20 'Take 20 samples
    ADCIN 0, temp 'Read AN0 into temp variable
    samples = samples + temp
    PAUSE 50 ' Wait 1/4 seconds per reading
    NEXT sample
    temp = samples/20 'Average over 20 samples (Every 5 seconds)
    temperature= temp */ quanta
    
    
    LCDOUT $FE, 2 ' ritorna al primo carattere
    lcdout $FE, 2, "Temp ",dec2 (temperature/10),".", dec1 (temperature/10),"C"
    lcdout $FE, $C0, "Tmin ",#Tmin, " Tmax ",#Tmax
          
    If temperature > (Tmax*100) then
    rele=1
    else
    rele=0
    Endif
                                    
    goto main

  2. #2
    Join Date
    Apr 2020
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: Compare value ...

    Quote Originally Posted by louislouis View Post
    I think, You want this:
    Here is a Richard's corrected and tested code. I hope it will be works:
    Code:
    '****************************************************************'*  '*  Name    : 16F88_LM235.BAS                                   *
    '*  Author  :                                    *
    '*  Notice  : Copyright (c) 2020                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 04/04/2020                                        *
    '*  Version : 1.0                                               *
    '*  
    '****************************************************************
    #CONFIG
      __config  _CONFIG1, _INTRC_IO & _WDT_ON & _PWRTE_OFF & _MCLR_ON & _BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF & _CCP1_RB0 & _CP_OFF
      __config  _CONFIG2, _FCMEN_ON & _IESO_ON
    #ENDCONFIG
    'PIC 16F88
    '    Hardware Assignments
    '    --------------------
    ' LCD circuitery
    '01     - Vss (GND)
    '02     - Vdd (+5V)
    '08 RS  - PORTB.2
    '09 E   - PORTB.3
    '10 DB4 - PORTB.4
    '11 DB5 - PORTB.5
    '12 DB6 - PORTB.6
    '13 DB7 - PORTB.7
    
    
    adcon1.7=1
    ANSEL = 0001 'Disable Inputs Tranne AN0
    OSCCON = 100000 'Internal RC set to 4MHZ
    TRISA = 111111 ' impostazioni INP/OUT
    TRISB = 0 ' delle porte
    '----------------------------------------------------
    DEFINE LCD_DREG PORTB       'Porta B DATA OUT 
    DEFINE LCD_DBIT 4           '0 --> Bit 0-3 : 4 --> Bit 4-7 
    DEFINE LCD_RSREG PORTB      'LCD register select port - Porta B --> RS
    DEFINE LCD_RSBIT 2          'LCD register select bit  - Pin RS B2
    DEFINE LCD_EREG PORTB       'LCD enable port - Porta B --> EN
    DEFINE LCD_EBIT 3           'LCD enable bit - Pin EN B3DEFINE LCD_BITS 4           'LCD bus size 4 or 8 
    DEFINE LCD_LINES 2          'Number lines on LCD DEFINE LCD_COMMANDUS 2000   'Command delay time in us 
    DEFINE LCD_DATAUS 50        'Data delay time in us
    
    
    '    EEPROM Locations Codice ASCII es. a=97 b=98 c=99 ...
    
    
    '===========================================================================
    '*****  SETTAGGIO PORTE 
    
    
    Rele   VAR    PORTA.6     '                  Pin 15
    '--------------------------------------------------------------
    '---------Define ADCin Parameters   
    DEFINE ADC_BITS 10      'set number of bits in result
    DEFINE ADC_CLOCK 3      'set clock source (3=rc)
    DEFINE ADC_SAMPLEUS 50  'Set sampling time in uS
    
    
    '    RAM Assignments and Variables
    '=========================================================================== 
    temp var word
    temperature var word
    samples var word
    sample VAR BYTE
    quanta con 1250
    Tmax VAR byte
    Tmin VAR byte
    '===========================================================================
    Tmin=16
    Tmax=30
     
    START:
    Lcdout $FE, 1           'Clear screen
    rele=0
    
    
    main:   
    sample = 1
    samples= 0
    FOR sample = 1 TO 20 'Take 20 samples
    ADCIN 0, temp 'Read AN0 into temp variable
    samples = samples + temp
    PAUSE 50 ' Wait 1/4 seconds per reading
    NEXT sample
    temp = samples/20 'Average over 20 samples (Every 5 seconds)
    temperature= temp */ quanta
    
    
    LCDOUT $FE, 2 ' ritorna al primo carattere
    lcdout $FE, 2, "Temp ",dec2 (temperature/10),".", dec1 (temperature/10),"C"
    lcdout $FE, $C0, "Tmin ",#Tmin, " Tmax ",#Tmax
          
    If temperature > (Tmax*100) then
    rele=1
    else
    rele=0
    Endif
                                    
    goto main

    Your video is OK!
    and the code is similar to mine, except for the initial strings.

    Code:
    #CONFIG
      __config  _CONFIG1, _INTRC_IO & _WDT_ON & _PWRTE_OFF & _MCLR_ON & _BODEN_ON & _LVP_OFF & _CPD_OFF & _WRT_PROTECT_OFF & _DEBUG_OFF & _CCP1_RB0 & _CP_OFF
      __config  _CONFIG2, _FCMEN_ON & _IESO_ON
    #ENDCONFIG

    without too much hesitation, however, I did copy and paste of your source in my compiler
    Microcode Studio Plus 3.0.0.5
    and as soon as I tried to issue the compile command it gave me errors.

    Code:
    ERROR Line 11: Syntax error. (louislouis.pbp)
    ERROR Line 12: Syntax error. (louislouis.pbp)
    ERROR Line 13: Redefiniton of LABEL __config. (louislouis.pbp)
    ERROR Line 13: Syntax error. (louislouis.pbp)
    ERROR Line 14: Syntax error. (louislouis.pbp)
    What are all those strings? why won't my compiler accept them?
    Thanks

Similar Threads

  1. How to compare two temperatures
    By SKOLS1 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th April 2012, 09:07
  2. how to hserin compare with known value?
    By aa222k in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd November 2010, 18:48
  3. Is there a faster way to compare?
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 8th February 2010, 19:48
  4. how to compare data
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 1st November 2009, 22:30
  5. Compare Data
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 14th February 2008, 20:40

Members who have read this thread : 7

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