Quentin

Members
  • Posts

    24
  • Joined

  • Last visited

Posts posted by Quentin

  1. New issue, the if loop control the relay will only run once per for loop. 

    i.e. it will iterate through the for loop run the if loop once and then wait for the delay to be completed.

    for (private i = 0, i < numrows(tempSPs), i++)
       curSP = tempSPs[i]
       if(Out < 0)
          Relay_control[0] = 0
          delay(0.02)
       else
          Relay_control[0] = 1
          delay(0.02)
       endif
       delay(tempDuration[i])
       ?tempSPs[i]
       ?tempDuration[i]
    endfor

    What is required is for the if loop to actually run continuously during the whole delay of the for loop, would this work?

    for (private i = 0, i < numrows(tempSPs), i++)
       curSP = tempSPs[i]
       private startTime = systime()
       private elapsedTime = 0
       while (elapsedTime < tempDuration[i])
          if(Out < 0)
             Relay_control[0] = 0
             delay(0.02)
          else
             Relay_control[0] = 1
             delay(0.02)
          endif
          elapsedTime = systime() - startTime
       endwhile
       delay(tempDuration[i])
       ?tempSPs[i]
       ?tempDuration[i]
    endfor


     

  2. Great!

    Like this then? Or do i need to setup globals first?

    while(1)
       for (private i = 0, i < numrows(tempSPs), i++)
          curSP = tempSPs[i]
             if(Out < 0)
                Relay_control[0] = 0
                delay(0.02)
             else
                Relay_control[0] = 1
                delay(0.02)
             endif
          delay(SPduration[i])
       endfor
    endwhile

    image.png.f980785d921abd2b033708953307c268.png

  3. Great, thank you!

    Two follow up questions:

    1/     Where do I write this script? Sequence (which thread priority... PID?) or PID loop/ event tab?

    global tempHyst = 1
    while(1)
       if (TC[0] > curSP)
          relay_control = 0
       endif
       if (TC[0] < curSP - tempHyst)
          relay_control = 1
       endif
       delay(1)
    endwhile

     

    2/     Where can I read in the temperature setpoints from the page0 button/ set to as you suggested? How can IU communicate with the blue box/ "set point" input or do I have to add these directly from a sequence loop? If so can the button create a variable or I would have to create a distinct channel to store all of these values like in the exemple below? 

     

    global tempSPs = {Temp1[0],Temp2[0],Temp3[0],Temp4[0],Temp5[0]}
    global tempDuration = {time1[0],time2[0],time3[0],time4[0],time5[0]}
    
  4. Thank you for the clairifications. Sorry I am very new to this...

    I confirm that I am using an SSR relay. 

    Would it be possible to read in those setpoints and durations from the page0? And then how could I communicate with my relay to ask it to stop/restart when it has reach the setpoint in question. 

     

    Would I write the script in the sequence or in the PID loop - event script? 

     

    Example:

    Trying to reach 115 degrees and stay there for 2min, then 125 degrees and stay there for 3 min, then 135 degrees and stay there for 4min, then back to 120 and stay there for 5min and back to 110degrees and stay there for 5min with the minimum amount of overshoot.

     

    I have attached my .ctl

    Test2.ctl

  5. I have a relay connected to my digital I/O (FIO0) on my labjack, I have created a channel (Dig Out) called relay_control to switch on/off this relay with a daqfactory page0 - descriptive text component (expression: relay_control[0], action: toggle between). for some reason when i click on the page component it does send a signal but then the relay switches back off because the signal is not sustained... I though that was the whole point of a "toggle". Do you know how I can fix this? 

  6. I am trying to setup a PID loop with 5 different temperatures setpoints and 5 distinct durations for each setpoint. How do you suggest I proceed? 

    The goal is to basically have a 5 setpoint entries on the page0 and 5 duration entries. The PID is controlling a relay that truns On/Off a heat pad. I am reading the temperature from a K-type thermocouple. 

    I am using a labjack U6