Compare value ... - Page 2


+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 41 to 69 of 69
  1. #41
    Join Date
    Apr 2020
    Posts
    30

    Default Re: Compare value ...

    [QUOTE = louislouis; 145048] OK, si prega di registrare questo esadecimale e dire quale numero mostrato sul display. Quindi riscaldare il sensore con le dita o il saldatore. I numeri devono essere intorno a 600 per 30 ° C e 700 per 35 ° C e coś via.
    Questo test la lettura ADC sul PIC. [/ QUOTE]


    Prima di installare questo firmware il display mostrava 25,5 ° C.
    Con questo firmware sul display della legge 665.
    Tenendo il sensore tra le dita puoi vedere il valore salire 670, 674, 677.679 ... ecc.

  2. #42
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    That's confirms the ADC readings is OK.

    If you program this HEX (thermometerNOrele.hex), the rele must be allways switched OFF. Yes or No?

    Then program this HEX (thermometerTEST.hex), probably this should be working proper. Yes or No?
    Attached Files Attached Files

  3. #43
    Join Date
    Apr 2020
    Posts
    30

    Default Re: Compare value ...

    Quote Originally Posted by louislouis View Post
    That's confirms the ADC readings is OK.

    If you program this HEX (thermometerNOrele.hex), the rele must be allways switched OFF. Yes or No?
    OK, the rele allways switched OFF

    Quote Originally Posted by louislouis View Post
    Then program this HEX (thermometerTEST.hex), probably this should be working proper. Yes or No?
    after the display appears, the relay goes ON and remains there regardless of the temperature.

    NOTA

    As soon as I turn on, there is a quick initial CLICK-CLACK. I believe the PIC port is set. he always has. Then he shows me the numbers on the display and the relay goes ON and does not move anymore, whatever the temperature.

  4. #44
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    That's weird behaviour. I don't had on hand 16F88, I run it on 16F690, but it doesn't matter.
    OK, one more chance try this:
    Attached Files Attached Files
    Last edited by louislouis; - 9th April 2020 at 22:33.

  5. #45
    Join Date
    Apr 2020
    Posts
    30

    Default Re: Compare value ...

    Quote Originally Posted by louislouis View Post
    That's weird behaviour. I don't had on hand 16F688, I run it on 16F690, but it doesn't matter.
    OK, one more chance try this:

    OK ! NOW WORK !

    Where was the problem ?
    Can you explain to me ?

    can you also show me how you managed to show the hexadecimal value 665 on the display?

    I am truly grateful to you for taking the time. Thank you very much.

  6. #46
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    I'm just curious, can you please try this hex, is It working OK?
    Attached Files Attached Files

  7. #47
    Join Date
    Apr 2020
    Posts
    30

    Default Re: Compare value ...

    Quote Originally Posted by louislouis View Post
    I'm just curious, can you please try this hex, is It working OK?
    No, it doesn't work, the relay goes ON as soon as I see the display and then it doesn't move anymore

  8. #48
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    Here is the code. Look at the comments, and modify the RAW number to number when the display show 30.0degC.
    Code:
    define osc 4
    adcon1.7=1
    ANSEL = %000001 'Disable Inputs Tranne AN0
    ADCON1 = %10001110 
    OSCCON = %01100000 'Internal RC set to 4MHZ
    TRISA =  %00000001 ' impostazioni INP/OUT
    TRISB =  %00000000 ' 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
    
    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
    
    low rele
    
    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
    
    if temp > 675 then high rele  'Instead 675 write the correct RAW number for 30degC 
    if temp < 675 then low rele   'Instead 675 write the correct RAW number for 30degC 
    
    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            FOR NORMAL OPERATION UNCOMMENT LINE 
    lcdout $FE, $C0, "RAW:",dec temp 'this show the ADC value  FOR NORMAL OPERATION COMMENT OR DELETE THIS LINE
    
    'When the display show 30,0 degC look at the RAW number on LCD and rewrite it in lines: if temp > 675 then high rele
    'and if temp < 675 then low rele . 
    
    goto main

  9. #49
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    not sure whats going on here

    my LM35 has a 0.3 volt output @30c, adc value 61 [10mV/deg]

    an adc read of 675 would need 329 deg
    This is more entertaining than Free to Air TV

  10. #50
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    on 10bit adc?

  11. #51
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    correct 10 bit 1024 counts @5v vcc
    Last edited by richard; - 10th April 2020 at 00:34.
    This is more entertaining than Free to Air TV

  12. #52
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    i get same result from proteus

    Name:  frm_on.jpg
Views: 168
Size:  370.2 KBName:  frm_off.jpg
Views: 165
Size:  367.1 KB

    Code:
    '****************************************************************'*  
    '*  Name    : 16F88_LM35.BAS                                   *
    '*  Author  :                                    *
    '*  Notice  : Copyright (c) 2020                                *
    '*          : All Rights Reserved                               *
    '*  Date    : 04/04/2020                                        *
    '*  Version : 1.0                                               *
    '*           PIC 16F88
    '****************************************************************
    #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
    
    
    adcon1.7=1
    ANSEL  = %00000001 '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 
     data @0,16,30
    '===========================================================================
    '*****  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 1249
    Tmax VAR byte
    Tmin VAR byte
    '===========================================================================
    pause 500
    START:
        read 0,tmin,tmax
        Lcdout $FE, 1           'Clear screen
        rele=0
    main:
        samples=0
        FOR sample = 1 TO 10 'Take 10 samples
            ADCIN 0, temp 'Read AN0 into temp variable
            samples = samples + temp
            PAUSE 40 ' Wait 1/4 seconds per reading
        NEXT sample
        temp = samples/10 'Average over 10 samples 
        temperature= temp */ quanta
        LCDOUT $FE, 1 ' cancella LCD
        lcdout "Temp ",dec2 (temperature/10),".", dec1 (temperature//10),$DF,"C"
        lcdout $FE, $C0,"temp ", dec temp 
        If temperature > (Tmax*10) then
            rele=1
        else
            rele=0
        Endif                           
    goto main
    This is more entertaining than Free to Air TV

  13. #53
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    not sure whats going on here

    my LM35 has a 0.3 volt output @30c, adc value 61 [10mV/deg]

    an adc read of 675 would need 329 deg
    i think i see the problem, if louis is using a 16f690 then the adc settings used are totally inappropriate
    adc control on a 16f690 is quite different to a 16f88

    define osc 4 ;there is no define called osc
    adcon1.7=1 ;bit 7 is unimplemented
    ADCON1 = %10001110 ;fosc/2 adc clk bits 0:3 and 7 are unimplemented


    should be
    define OSC 4 ;OSC = 4
    adcon0.7=1 ;right justify result
    adcon1= %00110000 ; frc adc clk
    Last edited by richard; - 10th April 2020 at 05:05.
    This is more entertaining than Free to Air TV

  14. #54
    Join Date
    Mar 2016
    Posts
    83

    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  

  15. #55
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    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.
    This is more entertaining than Free to Air TV

  16. #56
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    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
    This is more entertaining than Free to Air TV

  17. #57
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    Yea lm35, I overlooked that. You have right. I had no info about Cobuccit's setup, wiring, etc. Difficult to gave correct advice. If he use your posted schematic, and code it must be run whitout problems.

  18. #58
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    yes its a good reminder.
    code snippets for debugging are a pointless exercise
    code without a config section or at least in some way describing the config settings is a waste of time
    code without a schematic leads to pointless speculation and wasted time and resources
    if you are using a version of pbp that noah had in the ark at least tell us.
    gigo garbage in garbage out
    lucky covid has us all trapped inside bored shitless
    This is more entertaining than Free to Air TV

  19. #59
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    if your lm335 setup was used you need to subtract the offset
    eg

    main:
    samples=0
    FOR sample = 1 TO 10 'Take 10 samples
    ADCIN 0, temp 'Read AN0 into temp variable
    samples = samples + temp
    PAUSE 40 ' Wait 1/4 seconds per reading
    NEXT sample
    temp = (samples/10) -558 'subtract 2.73 v offset count
    temperature= temp */ quanta
    LCDOUT $FE, 1 ' cancella LCD
    lcdout "Temp ",dec2 (temperature/10),".", dec1 (temperature//10),$DF,"C"
    lcdout $FE, $C0,"temp raw ", dec temp
    If temperature > (Tmax*10) then
    rele=1
    else
    rele=0
    Endif
    goto main
    Last edited by richard; - 10th April 2020 at 08:29.
    This is more entertaining than Free to Air TV

  20. #60
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    I'm pretty sure, He has incorrectly wired the lm35 and that caused the weird behaviour. Tested in proteus, working firmware with wrong lm35 wiring causes relay always on.
    Conclusion, I need a drink Richard's code and schematic is the correct one. Please use it, it works.

    Just in case, here is the schematic and code for lm335:
    Attached Images Attached Images   
    Attached Files Attached Files
    Last edited by louislouis; - 10th April 2020 at 10:20.

  21. #61
    Join Date
    Apr 2020
    Posts
    30

    Default Re: Compare value ...

    Hello gentlemen forgive me, I think I put you in trouble. As I explained in some previous posts I pulled out an old "BreadBoard" to play on in this time of "Corona Virus".


    You are right, I looked at it for the good end I do not have an LM35, I have an LM235H recovered who knows where.
    its pattern is the current:

    Name:  scheme.jpg
Views: 145
Size:  28.8 KB

  22. #62
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,908

    Default Re: Compare value ...

    Oh dear... come on now!

    Ioannis

  23. #63
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    guess its my fault , should have launched into defensive mode on first reply
    like this
    it looked too easy.

    http://www.picbasic.co.uk/forum/showthread.php?t=24035

    questions to ask

    what have you tried ?
    what are you measuring ?
    where is your schematic ?
    your code is incomplete what is in your config section ?
    i see an incompletely described pgm with no config settings
    in an unspecified circuit
    no OSC statement in pbp code and still not a clue about the config settings used
    it just occurred to me that the op may be a troll and we have just been played.
    there is no way that the the op's code would ever have shown a realistic temp display with a lm335/lm235
    because multiplying the reading with an offset would yield meaningless results.
    it could have displayed a lm35 result as it was .
    at no time did op ever say the displayed temp results were also wrong
    i wonder.
    Last edited by richard; - 10th April 2020 at 12:16.
    This is more entertaining than Free to Air TV

  24. #64
    Join Date
    Mar 2016
    Posts
    83

    Default Re: Compare value ...

    Do you think the op just troll us?

  25. #65
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    Do you think the op just troll us?
    seems likely when you analyse it a bit

    how many newcomers can use the */ operator properly
    temperature= (temp*10) */ quanta
    or format a lcd line
    lcdout $FE, 2, "Temp ",dec2 (temperature/100),".", dec1 (temperature//100),$DF,"C"

    yet cannot use an if else block to set/clear a pin from a simple comparison
    This is more entertaining than Free to Air TV

  26. #66
    Join Date
    Apr 2020
    Posts
    30

    Default Re: Compare value ...

    Quote Originally Posted by richard View Post

    it just occurred to me that the op may be a troll and we have just been played..
    ...

    But please, thank you very much but don't make up stories.

    What does this phrase mean, which I pretended not to know how to do?
    A long time ago I was a more practical programmer and I certainly do not miss old preserved codes on which I went to browse to retrieve pieces of code here and there.

    I had the working object and could not find the source. Since I had noticed a bug I wanted to correct it. Not finding the source I thought to rewrite it. From there the adventure began.

    I am dusting off, I would love to start being a programmer again but times run like the wind.

    I hope to get back on track.

    I hope it is clear what I write, I use google translator.

  27. #67
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Compare value ...

    But please, thank you very much but don't make up stories
    i feel no shame , if it looks like a duck and it walks like a duck i'm prepared to say it could be a duck.

    you misled us with the sensor type, provided code that really can't display a meaningful result for the actual sensor in use
    yet provide no indication of that problem at all. you go on to describe a problem that's actually not relevant as if that's the main issue.
    worse still the code provided could very well have displayed proper temperature data with the bogus sensor.
    a troller would have been proud of the effort and result.
    its not a good look for a new user.
    This is more entertaining than Free to Air TV

  28. #68
    Join Date
    Apr 2020
    Posts
    30

    Default Re: Compare value ...

    Quote Originally Posted by richard View Post
    you misled us with the sensor type, provided code that really can't display a meaningful result for the actual sensor in use
    yet provide no indication of that problem at all. you go on to describe a problem that's actually not relevant as if that's the main issue.
    worse still the code provided could very well have displayed proper temperature data with the bogus sensor.
    a troller would have been proud of the effort and result.
    its not a good look for a new user.
    Well I'm sorry. I don't know why you like to make all these insinuations.
    But I can guarantee you that I had no bad intention. And I don't think it's fair to judge a person like that, but what I've done wrong?
    But every time I have to post something, I have to be afraid of being investigated in this way.
    Richard, maybe you see too many detective films.
    Well I'm sorry. I don't know why you like to make all these insinuations.
    But I can guarantee you that I had no bad intention. And I don't think it's fair to judge a person like that, but what I've done wrong?
    But every time I have to post something, I have to be afraid of being investigated in this way.
    Richard, maybe you see too many detective films.
    In any case, I think, it is going off topic. I was here to learn and get advice, not to be charged.

  29. #69
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,908

    Default Re: Compare value ...

    Calm everybody please.

    End of story.

    Seems that our lockdown makes everybody more sensitive!

    Ioannis

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

Posting Permissions

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