LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Relay control by PWM

Solved!
Go to solution

Hello everybody,

 

I'm developing a VI for controlling the temperature. I want to control the cooling with the fan with a relay, so I thought about doing it with a PWD. How can I generate it? I tried with the Simulate signal tool (0..1) and converting the signal into boolean values using the >0 comparison, but it doesn't work.

 

How can I generate this signal? Can I keep going this way or should I try another method?

 

I'm using cRio with the module NI9485.

 

Thank you very much in advance.

0 Kudos
Message 1 of 7
(4,612 Views)

Hi loewesh,

 

I'm using cRio with the module NI9485.

Are you using the ScanEngine or are you programming the FPGA?

 

How can I generate this signal? Can I keep going this way or should I try another method?

Did you read the datasheet of the NI9485? (Do that!)

- This module uses real relays and so is rather slow. It needs about 10ms to switch the relay (0.5ms open time, 9.0ms close time)!

- I recommend a loop set to iterate at 10ms (minimum!) and set the relay state as needed… The datasheet explicitely sets a switching rate of 1Hz!!!

- What kind of fan do you want to control? Which PWM frequency does it expect (if it is controlled by PWM like PC housing fans)? When you simply switch the fan on/off I would rather use a loop rate of (atleast) 1s…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(4,599 Views)

Glad I refreshed before I replied.

 

There is a Note to here on the published spec to account for faster switching rates.

 

However, this is not a device designed for PWM output.  You have the wrong hardware to accomplish what you think you want to do.  


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 7
(4,586 Views)

Hello GerdW,

 

I'm using the ScanEngine.

 

I missed that value on the datasheet. With a switching rate of 1 Hz I guess we agree there's no PWM posible using this module.

 

The fan is just a standard small fan.

 

My idea is to control the temperature with a PID control. I have as well an analog output module NI9263, which works with low-current. What system can I arrange so I control the fan (12V) with this output?

 

 

Many thanks again.

0 Kudos
Message 4 of 7
(4,585 Views)

Hi loewesh,

 

With a switching rate of 1 Hz I guess we agree there's no PWM posible using this module.

No, I don't agree.

I also have devices in our testbenches (bigger fans or medium-sized heating devices with upto 1kW power) where I apply a PWM with a frequency of 0.2 to 0.1 Hz (full cycle) - which would be possible with your relay module!

 

The fan is just a standard small fan.

So having a connector with just two pins: power supply voltage and COM/GND?

 

My idea is to control the temperature with a PID control. I have as well an analog output module NI9263, which works with low-current. What system can I arrange so I control the fan (12V) with this output?

Use a "slow" PWM with switching intervals of ~1s upto 10s…

 

It all depends on your system requirements!

Do you need to control the speed of the fan or is it sufficient to switch it on/off every few seconds?

How fast (or slow) does the system react on the fan air flow?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 7
(4,578 Views)

Thank you very much for your answers Jeff and Gerd,

 

Now I see it is possible. The system reacts quick, it doesn't take more than few seconds either to be warmed up too much or to be cooled down more than desired. Fortunately, it's not so important which one is the equilibrium temperature, 30º or 90º or any other, as long as the equilibrium can be reached using PID and PWM, and I think it can be accomplished with lower frequencies.

 

So, let's go further. What is the easiest way to implement the PWM control to the boolean output of the relay? Is the simulated signal a good approach?

 

Tank you again.

0 Kudos
Message 6 of 7
(4,533 Views)
Solution
Accepted by topic author loewesh

Hi loewesh,

 

to generate a PWM for such low frequencies I often use a simple approach:

- Have a loop running at a know interval, like 0.25s.

- Calculate a "ON" time from your PID value. Example: 63% of a cycle of 10s gives 6.3s ON-time and 3.7s OFF-time.

- Round these times to the loop interval and divide by the loop interval. Example: 6.25s ON, 3.75s off results in 25×ON, 15×OFF.

- In the loop you only need to count loop iterations: use a Q&R operation on the loop iterator and compare with the ON-limit. As long as the remainder is blow the ON-limit you swith the output on, else off…

check.png

This approach wil quantize the steps of the PWM, but is most often sufficient for such "slow" devices/control loops…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(4,528 Views)