14.01.2015 Views

Report - Høgskolen i Telemark

Report - Høgskolen i Telemark

Report - Høgskolen i Telemark

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

To write to multiple channels, the C# code example below can be used:<br />

using (Task AnalogWrite = DaqSystem.Local.LoadTask(*task name*))<br />

{<br />

AnalogMultiChannelWriter writer = new AnalogMultiChannelWriter(AnalogWrite.Stream);<br />

writer.WriteSingleSample(true, *output array*);<br />

}<br />

When reading the sensors, the DAQ input needs to be converted before the values can be<br />

used. The 2 - 6 [V] input must be converted into 0 - 20 [cm] (tank height). This is done by the<br />

simple calculation below:<br />

Converted sensor value = (5 * sensor value) – 10<br />

When converting from 0 - 20 [cm] to 0 – 5 [V], only dividing by 4 is required (multiply by 4<br />

when going from volt to cm).<br />

5.1.5 Starting the control application<br />

When the control application is initialized (without errors), the application can be started by<br />

clicking the enabled ‘start’ button on the left side of the UI (User Interface), shown in Figure<br />

5-3.<br />

When the start button is clicked the control application will initialize the control algorithm<br />

class (ControlAlgorithm) with the configuration values needed and start two timers named t1<br />

(ControlTimer1) and t2 (ControlTimer2). A message confirming that the application is<br />

running will be shown in the status field, the stop button will be enabled and the start button<br />

will be disabled, this is shown in Figure 5-5.<br />

63

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!