Turn on output pin


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302

    Default Turn on output pin

    I have two sensors to control one rele.
    One for volt and one for temperature.
    When the temperature (Vout) exceed the limit (P3) turn on the rele
    and if the temperature is below the limit turn of the rele.
    I want now , if the volt (value2) exceed the limit (P5) turn on the rele
    and stay on for forever, but i don't know how


    Code:
        If Vout >= P3 then                'Temp
            PORTA.0=1
            Pause 1000
                else
            PORTA.0=0
        endif
        		            
        If value2 >= P5 then  PORTA.0=1    'Volt
    P3 and P5 is the limit

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,569


    Did you find this post helpful? Yes | No

    Default

    Hi,
    How about this:
    Code:
    Relay var PortA.0                       'Relay connected to PortA.0
    Latch var bit
    
    ON CON 1                                'Constant for relay ON
    OFF CON 0                               'Constant for realy OFF
    
    Latch = 0
    
    Start:
      If Value2 >= P5 then Latch = 1        'Remember that Value2 has exceeded limit
    
      If (Vout >= P3) OR (Latch = 1) then   'Relay ON if Vout is over limit OR Value2 is or have been.
        Relay = ON
      ELSE
        Relay = OFF
      EndIf
      Pause 1000
    Goto Start
    Once Value2 is bigger than (or equal to) P5 the relay will turn ON and stay ON forever. Otherwise the state of the relay depends on Vout.

    /Henrik Olsson.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    How about this:
    Code:
    Relay var PortA.0                       'Relay connected to PortA.0
    Latch var bit
    
    ON CON 1                                'Constant for relay ON
    OFF CON 0                               'Constant for realy OFF
    
    Latch = 0
    
    Start:
      If Value2 >= P5 then Latch = 1        'Remember that Value2 has exceeded limit
    
      If (Vout >= P3) OR (Latch = 1) then   'Relay ON if Vout is over limit OR Value2 is or have been.
        Relay = ON
      ELSE
        Relay = OFF
      EndIf
      Pause 1000
    Goto Start
    Once Value2 is bigger than (or equal to) P5 the relay will turn ON and stay ON forever. Otherwise the state of the relay depends on Vout.

    /Henrik Olsson.
    Thank you
    If i want to add two more value

    If value >= P1 then PORTA.0=1
    If value1 >= P2 then PORTA.0=1

    how to make this;

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi Savnik,
    Looks like a job for select case - see page 129 in . . dare I say . .the manual.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hi Savnik,
    Looks like a job for select case - see page 129 in . . dare I say . .the manual.
    I read the select case in page 129 , but i cann't understand how to write the code , because i have many variables

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 14:55
  2. Help changing CCP3 output pin
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th July 2008, 03:30
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  4. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 18:07

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