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 ...

    Pplease post the whole code.

  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
    Pplease post the whole code.
    Code:
    '****************************************************************
    '*  Name    : 16F88_LM235.BAS                                   *
    '*  Author  :                                    *
    '*  Notice  : Copyright (c) 2020                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 04/04/2020                                        *
    '*  Version : 1.0                                               *
    '*  
    '****************************************************************
    '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
    
    
    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 B3
    
    
    DEFINE 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 ...
    '=========================================================================== 
        DATA @0,16  '   16 Tenp min.
        DATA @1,30  '   30 Temp Max.
    '=========================================================================== 
    
    
    '===========================================================================
    '*****  SETTAGGIO PORTE 
    
    
    '      VAR      PORTA.0     'LM235M            Pin 17  
    IncButton    VAR    PORTA.1     'SW          Pin 18
    DecButton    VAR    PORTA.2     'SW          Pin 1
    SetButton    VAR    PORTA.3     'SW          Pin 2     
    '      VAR    PORTA.4     '                  Pin 3     
    '      VAR    PORTA.5     '                  Pin 4
    Rele   VAR    PORTA.6     '                  Pin 15
    '      VAR    PORTA.7     '                  Pin 16 
    '-----------------------------------------------
    '       Var       PORTB.0   '                   Pin  6
    '       var    PORTB.1   '                   Pin  7
    l_rs    var       PORTB.2   'LCD  sig. RS       Pin  8
    l_en    Var    PORTB.3   'LCD sig. E         Pin  9
    l_d4    var       PORTB.4   'LCD 4              Pin 10
    l_d5    var    PORTB.5   'LCD 5              Pin 11
    l_d6    var    PORTB.6   'LCD 6              Pin 12
    l_d7    var    PORTB.7   'LCD 7              Pin 13
    
    
    '--------------------------------------------------------------
    
    
    '---------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
    '===========================================================================        
    CounterA    var byte    ' General purpose Variable
    CounterB    var byte    ' General purpose Variable
    CounterC    var byte    ' General purpose Variable
    temp        var word
    temperature var word
    samples     var word 
    Dummy       var word  
    sample      VAR BYTE  
    quanta      con 1250
    DatoEE      var byte
    Tmax        VAR Byte
    Tmin        VAR Byte
    Tcomp       VAR word
    Grade       var Byte
    TimeOut     var word    ' Variable for SetUp Menu Time-Out
    '===========================================================================
    
    
    
    
     
    START:
    '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
    '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
    
    
    ' --------  bit a bit controllo 0=output  1=input
    
    
    INTCON = 0           ' NO INTERRUPT
    ADCON1 = 001110   '
    ADCON0=  000101   'Disable Converter Module
    while !adcon0.0:wend ' Attende che il convertitore sia spento prima di fare il resto 
    ANSEL  = 000001   'Disable Inputs Tranne AN0
    OSCCON = 100000   'Internal RC set to 4MHZ
    CMCON  = 7           '
            '76543210 
    TRISA  = 111111   ' impostazioni INP/OUT
    TRISB  = 000000   ' delle porte  
    '----------------------------------------------------
    
    
    ' Per utilizare i pin RA6 ed RA7 come I/O bisogna impostare lo switch in fase 
    ' di programmazione Oscillotar come "INTRC_IO"
      PORTA.6=0  
    
    
    
    
    
    '    Leggi Dati dalla EEPROM
    '=========================================================================== 
     Read 0,DatoEE
     Tmin=DatoEE
    
    
     Read 1,DatoEE
     Tmax=DatoEE                                                                 
    '=========================================================================== 
        
    Lcdout $FE, 1           'Clear screen
    
    
    MAIN:
    
    
    'Subroutine to measure temp
    '----------------------------------------------------
    TEMP_READ:                          
    temp = 0                            'Clear temp register
    temperature = 0                     'Clear temperature register 
    sample = 0                          'Clear sample register 
    samples = 0                         'Clear samples register
    
    
    do
    sample = 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*10) */ quanta       
      
       
        Pause 200        ' Timeout for LCD to settle
        LCDOUT $FE, 1   ' cancella LCD   
        LCDOUT $FE, 2   ' ritorna al primo carattere  
        lcdout $FE, 2,   "Temp. ",dec2 (temperature/100),".", dec1 (temperature//100),$DF,"C "
        lcdout $FE, $C0, "Tmin ",#Tmin DIG 1,#Tmin Dig 0," Tmax ",#Tmax DIG 1,#Tmax Dig 0
        
    
    
    
    
        If temperature> TMax then 
          PORTA.6=1 
        else 
          PORTA.6=0 
        Endif
    
    
        'lcdout $FE, $C0, "Tmax ",#Tmax DIG 1,#Tmax Dig 0," Tco ",dec2 (Tcomp/100),".", dec1 (Tcomp//100)
    loop
    
    
    goto MAIN
    '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
    '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Compare value ...

    no, no. The problem why is the ADC reading high is the LM335 wiring. Cobuccit has wired a "pullup" resistor to LM335 from 5V and this shifting the output voltage to 3V at 30degC.

    My ADC settings on 16F690 is correct, I don't use settings for 16F88 on 16F690 of course.
    Anyway, I tried to figure out what's wrong with Cobuccit's setup and then I look at web and find the most popular LM335 wiring and then I got it. He has probably wired the sensor like this and that's the problem in cooperation with his posted code.
    Attached Images Attached Images  

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: Compare value ...

    i see no schematic anywhere and post 1 says a lm35, a pullup for a lm35 is not warranted.
    this has turned into a pointless exercise in guesswork.
    Warning I'm not a teacher

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: Compare value ...

    this won't work properly with those readings either

    670 */ 1250 = 3271 and would display as 27.1 deg with following code

    Code:
    temperature= temp */ quanta  ; this result is now 4 digits
    
    
    
    
    lcdout $FE, 2, "Temp ",dec2 (temperature/10),".", dec1 (temperature/10),"C"
    its just so wrong i give up
    Warning I'm not a teacher

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