How to swap a variable?


Results 1 to 6 of 6

Threaded View

  1. #4


    Did you find this post helpful? Yes | No

    Default

    Hi Jessey,

    I noticed in your 1st subroutine "Select_A_Sensor_To_Read:" you are swapping your variables before the gosub to "Check_Temperature:" . What happens if you read the temperature first
    right before the swap statement. The last sensor reading will now be in the temp variable. It can now be stored in Radiator_Temp or Block_temp. The way you have it now it reads the temperature to temp and exits the subroutine.

    Try this
    Add a new variable Old_temp

    If I = 0 Then''''''''''''''''''''

    Sensor_Select = Radiator_Sensor' This is a little convoluted to say the
    GOSUB Check_Temperature ' it should work then the program switches
    SWAP Old_temp, Radiator_temp ' least but it works, how and why I have no
    Radiator_temp = temp ' idea. If I uncomment the commented out code


    Endif ' sensors around i.e. instead of reading the
    ' Radiator_Sensor on pin 15 it then reads
    If I = 1 Then ' the sensor on 33 even though it's declared
    Sensor_Select = Block_Sensor ' on pin 15 and vice versa for the
    GOSUB Check_Temperature ' it should work then the program switches
    SWAP Old_temp, Block_temp ' DS1820 Block_Sensor. So it switches the
    Block_temp = temp ' two sensors, very confusing! It must be in


    Endif
    Return''''''''''''''''''''''''''''''
    Last edited by mark_s; - 18th June 2010 at 19:11.

Members who have read this thread : 0

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