Temperature Controller Problem - Page 4


+ Reply to Thread
Page 4 of 4 FirstFirst ... 234
Results 31 to 39 of 39

Thread: Temperature Controller Problem30 days old

  1. #31
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    470
    Thumbs Up
    Received: 38
    Given: 7
    Total Downloaded
    2.88 GB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    Quote Originally Posted by amod View Post
    Code for peak hold which I tried.

    Dim value as word 'raw ADC value
    Dim newvalue as word. ' peak hold value

    Main:
    If newvalue > value then
    This is not very helpful as we have no idea of where you are getting you newvalue from, consequently it is difficult to determine if your comparison is the correct way around. To me it looks like you are asking if your peak value is greater than the new ADC reading whereas you need to ask if the new ADC reading is higher than your current peek value. But as I said it is difficult to tell and there is not enough code to determine the source of the values and in which order they are being updated. You need to post full compilable code if you expect people to find errors.

    Personally I would rename value and newvalue as something like ADC_raw and Peak_Value, it will make much more sense to others trying to read you posted code (and possibly yourself later) as it does what it says it is, whereas value and newvaule could relate to anything.

    Either preload a value into Peak_Value at creation, i.e. DIM Peak_Value as word = $00 or on your first ADC read Peak_Value = ADC_raw, you have to have an inital value for comparison.
    The after every ADC read you have...
    If ADC_raw > Peak_Value then Peak_Value = ADC_raw 'Peak_Value = highest reading until cleared

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #32
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    49
    Thumbs Up
    Received: 14
    Given: 0
    Total Downloaded
    144.28 MB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    Amod, assuming VALUE is an A/D raw reading then these two lines are all that's needed. To clear the peak values call the routine RESET_PEAK.

    IF VALUE > HIGHTEMP THEN HIGHTEMP = VALUE 'store positive peak value
    IF VALUE < LOWTEMP THEN LOWTEMP = VALUE 'store negative peak value


    RESET_PEAK: 'routine to reset +- peak values
    HIGHTEMP = 0
    LOWTEMP = 9999
    RETURN

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #33
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    98
    Thumbs Up
    Received: 102
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    Thanks Dave.I will try it after one week.Iam out of the city for a week.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #34
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    98
    Thumbs Up
    Received: 102
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    I have made peak hold.thanks.
    One thing I was thinking that currently iam using a toggle switch for peak hold.toggle switch on then peak hold ,when off then normal values.Can this work will work with push button? When pushbutton pressed then peak hold , pressed again then normal values.please guide.I was trying with branch command.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #35
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,415
    Thumbs Up
    Received: 102
    Given: 24
    Total Downloaded
    5.09 GB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    Yes, it can be done.
    Regards

    Joseph

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #36
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    98
    Thumbs Up
    Received: 102
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    How? Please give example

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #37
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    470
    Thumbs Up
    Received: 38
    Given: 7
    Total Downloaded
    2.88 GB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    First it depends on...
    a) If you are using a double pole or single pole switch connected or a single pole with a pull up/down resistor.
    b) If a latching or momentary switch will be used and
    c) How quickly you are sampling the switch and accounting for switch bounce.

    De-bounce can be handled several ways, CR time constant, SR latch or reading the input at intervals of every 100ms or longer, you may get away with 50mS but some switches can bounce for nearly that long. It took about 10 seconds on Google to find this for some examples.
    If the input is in the pressed state then simply toggle a bit variable and use either an If-Then or Select-Case statement to determine if the normal or peak data is sent to the display depending on if the bit variable is 1 or 0.
    Last edited by Stephen Moss; 24th June 2019 at 11:22.

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #38
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    98
    Thumbs Up
    Received: 102
    Given: 5
    Total Downloaded
    10.35 MB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    Stephen Moss,
    Please give me proton basic example.In your link it is in c language.As iam new to proton basic programming an example will be helpful.Iam using a push to on tact switch with pull-up resistor.

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #39
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,229
    Thumbs Up
    Received: 372
    Given: 131
    Total Downloaded
    1.58 GB

    0 Not allowed!

    Default Re: Temperature Controller Problem

    Here's a demo program I wrote a few days ago to illustrate Peak hold and its decreasing peak for display purposes, as used in power level meters for audio. It may show you how simple Peak hold actually is with the Proton language. It uses an ADC channel to create the value and comparisons and timings for the peak hold.

    Code:
    '
    '   /\\\\\\\\\
    '  /\\\///////\\\
    '  \/\\\     \/\\\                                                 /\\\          /\\\
    '   \/\\\\\\\\\\\/        /\\\\\     /\\\\\\\\\\     /\\\\\\\\   /\\\\\\\\\\\  /\\\\\\\\\\\  /\\\\\\\\\
    '    \/\\\//////\\\      /\\\///\\\  \/\\\//////    /\\\/////\\\ \////\\\////  \////\\\////  \////////\\\
    '     \/\\\    \//\\\    /\\\  \//\\\ \/\\\\\\\\\\  /\\\\\\\\\\\     \/\\\         \/\\\        /\\\\\\\\\\
    '      \/\\\     \//\\\  \//\\\  /\\\  \////////\\\ \//\\///////      \/\\\ /\\     \/\\\ /\\   /\\\/////\\\
    '       \/\\\      \//\\\  \///\\\\\/    /\\\\\\\\\\  \//\\\\\\\\\\    \//\\\\\      \//\\\\\   \//\\\\\\\\/\\
    '        \///        \///     \/////     \//////////    \//////////      \/////        \/////     \////////\//
    '                                  Let's find out together what makes a PIC Tick!
    '
    ' Calculate the peak value from a sensor
    ' For display purposes decrease the peak value over time
    ' until it matches the current sensor value. i.e. Damping
    ' 
        Device = 18F25K20
        Declare Xtal = 64 
        Declare Hserial_Baud = 9600
    '
    ' Define ADC parameters
    '
        Declare Adin_Res = 10               ' 10-bit result required
        Declare Adin_Tad = cFRC             ' RC OSC chosen
        Declare Adin_Stime = 50             ' Allow 50us sample time
    '
    ' Declare variables
    '
        Dim wPeakValue As Word              ' Holds the Peak value
        Dim wSensorValue As Word            ' Holds the value from the sensor
        Dim bPeakTimeout As Byte            ' The count before the peak starts to decrease
        
    '--------------------------------------------------------------------------
    ' Get an ADC reading suitable for the serial terminal and the Rep modifier
    '
    Proc ADC_Read(), Word
        Result = ADIn  0 
        Result = Result /  20 
        If Result = 0 Then Result =  1 
    EndProc
    
    '--------------------------------------------------------------------------
    ' Setup the program
    '
    Proc Setup()    
        ANSEL =  1                            ' Set AN0 as analogue
        ADCON2 = 128                          ' Right justify the ADC for 10-bit
        bPeakTimeout = 0
        wPeakValue = 0    
    EndProc
    
    '--------------------------------------------------------------------------
    ' Take ADC readings and calculate the peak value
    ' Display on a serial terminal the peak
    ' Then decrease the peak value over time for display and a damping effect
    '   
    Main: 
        Setup()                                     ' Setup the program
      
        Do                                          ' Create a loop
            wSensorValue = ADC_Read()               ' Take a reading from the ADC       
            If wSensorValue > wPeakValue Then       ' Is the sensor value greater than the peak value?
                wPeakValue = wSensorValue           ' Yes. So make the peak value the same as the sensor value
                bPeakTimeout = 0
            EndIf
            '
            ' This creates a timer so that the peak decreases over time (if required)
            '
            Inc bPeakTimeout                        ' Increment the timer for the peak to decrease
            If bPeakTimeout >= 20 Then              ' Has the timer gone over the set iterations?
                bPeakTimeout = 0                    ' Yes. So reset it
                Dec wPeakValue                      ' Decrement the peak value
                If wPeakValue <= wSensorValue Then  ' Has the peak value reached the sensor value?
                    wPeakValue = wSensorValue       ' Yes. So hold the peak at the sensor value
                EndIf
            EndIf
            '
            ' Display on a serial terminal the sensor reading and the gradual fall of the peak
            '
            HRSOutLn "Sensor ", Dec3 wSensorValue,_
                     Rep " "\wPeakValue, "* Peak ", Dec wPeakValue
            DelayMS  20 
        Loop
    Last edited by top204; 24th June 2019 at 21:44.

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Temperature Sensor
    By chuckieboy in forum The Lounge
    Replies: 9
    Last Post: 26th May 2012, 06:17
  2. Replies: 4
    Last Post: 23rd September 2010, 13:33
  3. temperature sensor
    By chuckieboy in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 30th June 2010, 20:10
  4. Temperature Controller using PIC16F628A
    By bentech4u in forum Proton Plus Compiler v3
    Replies: 9
    Last Post: 29th October 2008, 17:39
  5. Operating temperature...
    By Hans Chr in forum The Lounge
    Replies: 3
    Last Post: 8th August 2006, 12:16

Posting Permissions

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