<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tutorial Archive - CETONI GmbH</title>
	<atom:link href="https://cetoni.com/en/category/software-en/tutorial-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://cetoni.com/en/category/software-en/tutorial-en/</link>
	<description>Automatisierungs- und Mikrofluidiklösungen für das Labor</description>
	<lastBuildDate>Mon, 09 Feb 2026 14:29:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://cetoni.com/wp-content/uploads/2020/12/cropped-favicon-32x32.png</url>
	<title>Tutorial Archive - CETONI GmbH</title>
	<link>https://cetoni.com/en/category/software-en/tutorial-en/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Tutorial: Flow profile generation with QmixElements (CETONI Elements) &#8211; Part 2</title>
		<link>https://cetoni.com/en/tutorial-flow-profile-generation-with-qmixelements-part-2/</link>
		
		<dc:creator><![CDATA[CETONI]]></dc:creator>
		<pubDate>Tue, 08 Jun 2021 15:20:49 +0000</pubDate>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Software]]></category>
		<guid isPermaLink="false">https://cobomation.de/tutorial-flow-profile-generation-with-qmixelements-part-2/</guid>

					<description><![CDATA[<p>Der Beitrag <a href="https://cetoni.com/en/tutorial-flow-profile-generation-with-qmixelements-part-2/">Tutorial: Flow profile generation with QmixElements (CETONI Elements) &#8211; Part 2</a> erschien zuerst auf <a href="https://cetoni.com/en/">CETONI GmbH</a>.</p>
]]></description>
										<content:encoded><![CDATA[
		<div id="fws_69ba712396006"  data-column-margin="default" data-midnight="dark"  class="wpb_row vc_row-fluid vc_row top-level"  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-animation-delay="" data-bg-overlay="false"><div class="inner-wrap row-bg-layer" ><div class="row-bg viewport-desktop"  style=""></div></div></div><div class="row_col_wrap_12 col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding inherit_tablet inherit_phone "  data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" >
			<div class="wpb_wrapper">
				
<div class="wpb_text_column wpb_content_element " >
	<p>In the second part of this tutorial you will learn how to create sinusoidal flow profiles using JavaScript functions. To do this, you modify the script from the first part so that a sinusoidal profile is generated instead of a sawtooth profile. Before you start with this second part, you may want to read <a href="https://cetoni.com/en/tutorial-flow-profile-generation-with-qmixelements-part-1/">the first part of the tutorial here</a>.</p>
<p><span style="color: #4393e9;"><strong>Important</strong></span><br />For this tutorial, you need QmixElements version v20191121 or a newer version. If you are still using an older version, please update to the latest QmixElements version.</p>
<p><a href="#">Latest QmixElements Version</a></p>
<h3>Preparation</h3>
<p>Configure your system as described in the first part of the tutorial and then connect to your devices. If you do not have the appropriate devices, you are welcome to follow the tutorial with simulated devices. The QmixElements project with simulated devices and the script created in the first tutorial can be downloaded here.</p>
<p>Now open the script <strong>Tutorial_Sawtooth_Profile.qsc</strong> that you created in the first part of the tutorial and save it under a new name. You should then see the following program in script editor.</p>
<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-2304 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_FinalSawtoothScript.png" alt="" width="536" height="526" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_FinalSawtoothScript.png 536w, https://cetoni.com/wp-content/uploads/Flowprofile_FinalSawtoothScript-300x294.png 300w" sizes="(max-width: 536px) 100vw, 536px" /></p>
<h3>Part 2 &#8211; Script for generating a sinusoidal profile</h3>
<p>The goal of this script is to generate a flow profile in the form of a sine wave from 0 to the defined target flow rate with one pump and to supplement the flow of the first pump with the second pump in such a way that the sum of the two flows results in a constant flow with a defined flow rate.</p>
<p>To generate the profile, the flow rate of the pump must be changed step by step so that a sinusoidal profile is created over time. The number of steps for generating the sine profile, i.e. the resolution, should be set to 100 steps for one sine. In the previous sawtooth script you had set the number of steps to 20. Therefore change the value of the variable <strong>$GradientSteps</strong> to 100.</p>
<h3><img decoding="async" class="aligncenter wp-image-2306 size-full" src="https://cetoni.de/wp-content/uploads/ChangeGradientSteps.gif" alt="" width="1024" height="320"></h3>
<h3>Adjusting the resolution (number of steps) for a sine profile</h3>
<p>Now delete the two <strong>Generate Flow</strong> functions as shown in the figure below. To do this, select both functions and then delete them using the context menu (right mouse button) or by pressing the <strong>Delete key</strong>.</p>
<p><img decoding="async" class="aligncenter wp-image-2308 size-full" src="https://cetoni.de/wp-content/uploads/DeleteFlowFunctions.png" alt="" width="925" height="284" srcset="https://cetoni.com/wp-content/uploads/DeleteFlowFunctions.png 925w, https://cetoni.com/wp-content/uploads/DeleteFlowFunctions-300x92.png 300w, https://cetoni.com/wp-content/uploads/DeleteFlowFunctions-768x236.png 768w" sizes="(max-width: 925px) 100vw, 925px" /><br />Now insert a new variable before the two existing variables in the counting loop. Name the variable <strong>$Sinus</strong> and select <strong>JavaScript Expression</strong> in the <strong>Type</strong> field.</p>
<p><img decoding="async" class="aligncenter wp-image-2310 size-full" src="https://cetoni.de/wp-content/uploads/InsertGenerateFlowFunctions.gif" alt="" width="952" height="376"><br />The <strong>$Sine</strong> variable is used to store the calculation of the sine value for further processing. To calculate the sine value, use the JavaScript function <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin" target="_blank" rel="noopener">Math.sin()</a> together with the constant <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI" target="_blank" rel="noopener">Math.PI.</a> Enter the following into the input field for the JavaScript expression:</p>
<p style="text-align: center;"><strong>Math.sin</strong>(2 * <strong>Math.PI</strong> / (<strong>$GradientSteps</strong> &#8211; 1) * <strong>$i</strong>)</p>
<p>The loop counter <strong>$i</strong> runs from 0 to the number of <strong>$GradientSteps</strong> &#8211; 1. To calculate the current sine value, the period 2π is divided by the number of steps &#8211; 1 and then multiplied by the current step <strong>$i</strong>.</p>
<p><img decoding="async" class="aligncenter wp-image-2312 size-full" src="https://cetoni.de/wp-content/uploads/EnterSinusCalculation.png" alt="" width="1024" height="313" srcset="https://cetoni.com/wp-content/uploads/EnterSinusCalculation.png 1024w, https://cetoni.com/wp-content/uploads/EnterSinusCalculation-300x92.png 300w, https://cetoni.com/wp-content/uploads/EnterSinusCalculation-768x235.png 768w" sizes="(max-width: 1024px) 100vw, 1024px" /><br />To check the calculated value of the <strong>$Sine</strong> variable, you can display its value in the graphical logger. To do this, you have already created the virtual I/O channel <strong>Script Value 1</strong> in the first part of the tutorial and added it to the graphical logger. Now insert the function <strong>Write Device Property</strong> <span style="color: #4393e9;">❶</span> into the script. Then configure the function as shown in the figure below.</p>
<p><img decoding="async" class="alignleft wp-image-2332 size-medium" src="https://cetoni.de/wp-content/uploads/SinusWriteDeviceProperty-300x107.png" alt="" width="300" height="107" srcset="https://cetoni.com/wp-content/uploads/SinusWriteDeviceProperty-300x107.png 300w, https://cetoni.com/wp-content/uploads/SinusWriteDeviceProperty-768x273.png 768w, https://cetoni.com/wp-content/uploads/SinusWriteDeviceProperty.png 1024w" sizes="(max-width: 300px) 100vw, 300px" /><br />In the field <strong>Value to be written</strong> <span style="color: #4393e9;">❷</span> enter the variable name <strong>$Sinus</strong>. In the <strong>Device Property</strong> area <span style="color: #4393e9;">❸</span> select in the <strong>Device</strong>field the virtual channel <strong>Script Value 1</strong>. In the <strong>Property</strong> field select the property <strong>ActualValue</strong>. You can now read the function as follows:</p>
<p style="text-align: center;">Write the value of the variable <strong>$Sinus</strong> into the property <strong>ActualValue</strong> of the virtual channel <strong>Script Value 1</strong>.</p>
<p>Now delete all data from the graphical logger and activate automatic scaling. Now start your script. If you have entered everything correctly, you should see how the following sine function is generated in the graphical logger:</p>
<p><img decoding="async" class="aligncenter wp-image-2316 size-full" src="https://cetoni.de/wp-content/uploads/PlotLoggerVirtualChannelSinus.png" alt="" width="1076" height="241" srcset="https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus.png 1076w, https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus-300x67.png 300w, https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus-1024x229.png 1024w, https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus-768x172.png 768w" sizes="(max-width: 1076px) 100vw, 1076px" /><br />The sine oscillates between 1 and -1 as expected. For the sinusoidal flow profile to be generated, the flow rate should oscillate between 0 and the target flow rate. In a first step, the sine value should be adjusted so that it oscillates between 0 and 1. You can achieve this by shifting the sine on the Y-axis upwards by 1 and then halve the amplitude. To store the new value, we use the existing variable <strong>$Flow1</strong> <span style="color: #4393e9;">❶</span>. This can now be calculated like this:</p>
<p style="text-align: center;"><span style="color: #4393e9;">❷</span> <strong>$Flow1</strong> = (<strong>$Sine</strong> + 1) / 2</p>
<p><img decoding="async" class="aligncenter wp-image-2318 size-full" src="https://cetoni.de/wp-content/uploads/ShiftAdjustSinus.png" alt="" width="1024" height="313" srcset="https://cetoni.com/wp-content/uploads/ShiftAdjustSinus.png 1024w, https://cetoni.com/wp-content/uploads/ShiftAdjustSinus-300x92.png 300w, https://cetoni.com/wp-content/uploads/ShiftAdjustSinus-768x235.png 768w" sizes="(max-width: 1024px) 100vw, 1024px" /><br />Now change the <strong>Write Device Property</strong> function so that the value of the variable <strong>$Flow1</strong> is displayed instead of the value of the variable <strong>$Sine</strong>. Then delete the graphical logger and reactivate automatic scaling. You should now see the following function in the graphic logger &#8211; a sine function oscillating between 0 and 1:</p>
<p><img decoding="async" class="aligncenter wp-image-2320 size-full" src="https://cetoni.de/wp-content/uploads/PlotLoggerVirtualChannelSinus2.png" alt="" width="1075" height="246" srcset="https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus2.png 1075w, https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus2-300x69.png 300w, https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus2-1024x234.png 1024w, https://cetoni.com/wp-content/uploads/PlotLoggerVirtualChannelSinus2-768x176.png 768w" sizes="(max-width: 1075px) 100vw, 1075px" /><br />To make the sine oscillate between 0 and the target flow rate, you now only have to multiply by the target flow rate <strong>$TargetFlow</strong>. Extend the calculation of the variable <strong>$Flow1</strong> by this step:</p>
<p style="text-align: center;"><strong>$Flow1</strong> = (<strong>$Sine</strong> + 1) / 2 *<strong> $TargetFlow</strong></p>
<p>The flow rate <strong>$Flow1</strong> will now oscillate sinusoidally between 0 and the target flow rate. The flow rate <strong>$Flow2</strong> of the second pump should complement the first flow rate in such a way that a constant flow with a constant flow rate <strong>$TargetFlow</strong> is created. You can therefore calculate the flow rate of the second pump in the variable <strong>$Flow2</strong> as follows:</p>
<p style="text-align: center;"><strong>$Flow2</strong> = $TargetFlow &#8211; $Flow1</p>
<p>Now insert two <strong>Generate Flow</strong> functions in front of the <strong>Write Device Property</strong> function and then delete the <strong>Write Device Property</strong> function as it is no longer needed.</p>
<p><img decoding="async" class="aligncenter wp-image-2322 size-full" src="https://cetoni.de/wp-content/uploads/InsertGenerateFlowFunctions-1.gif" alt="" width="952" height="376"><br />The script should now look like the figure below <span style="color: #4393e9;">❶</span>. Configure the two <strong>Generate Flow</strong> functions to start the first pump at flow rate <strong>$Flow1</strong> <span style="color: #4393e9;">❷</span> and the second pump at flow rate <strong>$Flow2</strong> (see figure below). Make sure that the <strong>Run to completion</strong> option <span style="color: #4393e9;">❸</span> is disabled.</p>
<p><img decoding="async" class="aligncenter wp-image-2324 size-full" src="https://cetoni.de/wp-content/uploads/GenerateFlowSinus-1.png" alt="" width="917" height="359" srcset="https://cetoni.com/wp-content/uploads/GenerateFlowSinus-1.png 917w, https://cetoni.com/wp-content/uploads/GenerateFlowSinus-1-300x117.png 300w, https://cetoni.com/wp-content/uploads/GenerateFlowSinus-1-768x301.png 768w" sizes="(max-width: 917px) 100vw, 917px" /><br />Now delete all data from the graphical logger again and activate automatic scaling. Before starting the script, check that the syringes of both pumps are filled. Then start your script. If you have entered everything correctly, you should see how the following flow profiles are generated in the graphical logger:</p>
<p><img decoding="async" class="aligncenter wp-image-2326 size-full" src="https://cetoni.de/wp-content/uploads/SinusFlowProfile.png" alt="" width="1096" height="249" srcset="https://cetoni.com/wp-content/uploads/SinusFlowProfile.png 1096w, https://cetoni.com/wp-content/uploads/SinusFlowProfile-300x68.png 300w, https://cetoni.com/wp-content/uploads/SinusFlowProfile-1024x233.png 1024w, https://cetoni.com/wp-content/uploads/SinusFlowProfile-768x174.png 768w" sizes="(max-width: 1096px) 100vw, 1096px" /><br />You have now learned the basics of how to use JavaScript in the script functions &#8211; e.g. to perform mathematical calculations. Apply what you have learned, for example by programming a script that generates two sinusoidal flows, where the sine of the second flow has twice the period of the sine of the first flow. Use the graphical logger to check the results.</p>
<p>In the third part of the tutorial you will learn how to add an initialization routine to the script, how to wind up the syringes and get tips on how to improve the readability of your script and how to document your script.</p>
<p>The QmixElements project with simulated devices and the scripts created in the first and second part of the tutorial can be <a href="https://cetoni.de/downloads/Flowprofiles.qpr" target="_blank" rel="noopener">downloaded here</a>.</p>
</div>




			</div> 
		</div>
	</div> 
</div></div>
<p>Der Beitrag <a href="https://cetoni.com/en/tutorial-flow-profile-generation-with-qmixelements-part-2/">Tutorial: Flow profile generation with QmixElements (CETONI Elements) &#8211; Part 2</a> erschien zuerst auf <a href="https://cetoni.com/en/">CETONI GmbH</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Tutorial flow profile generation with QmixElements (CETONI Elements) &#8211; Part 1</title>
		<link>https://cetoni.com/en/tutorial-flow-profile-generation-with-qmixelements-part-1/</link>
		
		<dc:creator><![CDATA[CETONI]]></dc:creator>
		<pubDate>Mon, 07 Jun 2021 16:04:54 +0000</pubDate>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Software]]></category>
		<guid isPermaLink="false">https://cobomation.de/tutorial-flow-profile-generation-with-qmixelements-part-1/</guid>

					<description><![CDATA[<p>Der Beitrag <a href="https://cetoni.com/en/tutorial-flow-profile-generation-with-qmixelements-part-1/">Tutorial flow profile generation with QmixElements (CETONI Elements) &#8211; Part 1</a> erschien zuerst auf <a href="https://cetoni.com/en/">CETONI GmbH</a>.</p>
]]></description>
										<content:encoded><![CDATA[
		<div id="fws_69ba7123996e7"  data-column-margin="default" data-midnight="dark"  class="wpb_row vc_row-fluid vc_row"  style="padding-top: 0px; padding-bottom: 0px; "><div class="row-bg-wrap" data-bg-animation="none" data-bg-animation-delay="" data-bg-overlay="false"><div class="inner-wrap row-bg-layer" ><div class="row-bg viewport-desktop"  style=""></div></div></div><div class="row_col_wrap_12 col span_12 dark left">
	<div  class="vc_col-sm-12 wpb_column column_container vc_column_container col no-extra-padding inherit_tablet inherit_phone "  data-padding-pos="all" data-has-bg-color="false" data-bg-color="" data-bg-opacity="1" data-animation="" data-delay="0" >
		<div class="vc_column-inner" >
			<div class="wpb_wrapper">
				
<div class="wpb_text_column wpb_content_element " >
	<p>The QmixElements software has a powerful script system to automate processes and procedures quickly and easily. This tutorial will give you an insight and many useful hints on some of the advanced features of QmixElements. Techniques, such as the use of variables, the use of JavaScript and the use of virtual channels for recording values in the graphical logger.</p>
<p>In this tutorial, you will create two scripts that generate flow gradients or flow profiles based on mathematical functions.</p>
<h3>Preparation</h3>
<p>Before you can start programming the scripts, you must configure your system. If you do not have the appropriate devices, you are welcome to follow the tutorial with simulated devices. You can download the QmixElements project with simulated devices and the script created in the tutorial here.</p>
<p><span style="color: #4393e9;"><strong>Important</strong></span><br />
For this tutorial you need the QmixElements version v20191121 or a newer version. If you are still using an older version, please update to the latest QmixElements version.</p>
<p>Latest QmixElements Version</p>
<p>For this tutorial we used two neMESYS low pressure syringe pumps with 5 ml glass syringes <span style="color: #4393e9;">❶</span>. You can do this tutorial with other neMESYS syringe pumps or syringes, but you may have to adjust the flow rates. To switch the valves automatically during the generation of the flow profiles, activate the valve automation for both pumps <span style="color: #4393e9;">❷</span>. Please configure <strong>ml/min</strong> <span style="color: #4393e9;">❸</span> as the unit for the flow rate.</p>
<p><img decoding="async" class="aligncenter wp-image-2416 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_Configuration.png" alt="" width="993" height="559" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_Configuration.png 993w, https://cetoni.com/wp-content/uploads/Flowprofile_Configuration-300x169.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_Configuration-768x432.png 768w" sizes="(max-width: 993px) 100vw, 993px" /></p>
<p>To visualize calculated values from the script graphically, create a virtual channel <span style="color: #4393e9;">❹</span>in the list of I/O channels. A virtual channel is an I/O channel that can be used for entering and outputting values.</p>
<p>To record and visualize the generated flow profiles graphically in real time, use the graphical logger and configure it according to the figure below. The current flow rate of both pumps should be displayed as well as the current value of the virtual channel <span style="color: #4393e9;">❶</span>. As <strong>Log Interval</strong><span style="color: #4393e9;">❷</span> set a value of 0.1 seconds. Now you can start programming the first script.</p>
<h3><img decoding="async" class="aligncenter wp-image-2434 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_Loggerconfig.png" alt="" width="916" height="411" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_Loggerconfig.png 916w, https://cetoni.com/wp-content/uploads/Flowprofile_Loggerconfig-300x135.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_Loggerconfig-768x345.png 768w" sizes="(max-width: 916px) 100vw, 916px" /></h3>
<h3>Part 1 &#8211; Script for generating a sawtooth profile</h3>
<p>The aim of this script is to generate a flow profile in the form of a sawtooth with one pump and to supplement the flow of the first pump with the second pump so that the sum of the two flows leads to a constant flow with a defined flow rate but with a mixing ratio that changes over time.</p>
<p><img decoding="async" class="aligncenter wp-image-2440 size-full" src="https://cetoni.de/wp-content/uploads/sawtooth_function.png" alt="" width="617" height="233" srcset="https://cetoni.com/wp-content/uploads/sawtooth_function.png 617w, https://cetoni.com/wp-content/uploads/sawtooth_function-300x113.png 300w" sizes="(max-width: 617px) 100vw, 617px" /></p>
<p>The sawtooth is generated by increasing the flow rate stepwise in a fixed interval from 0 to the desired target flow rate. The following parameters can be identified for the script:</p>
<ul>
<li>Number of steps for a single sawtooth (<strong>$GradientSteps</strong>)</li>
<li>Duration of a step in milliseconds (<strong>$StepDuration</strong>)</li>
<li>Target flow rate (<strong>$TargetFlow</strong>)</li>
</ul>
<p>You create three variables for these parameters in your script. So you can change the parameters later quickly and easily in one place, without having to navigate through the complete script all the time. For each variable you assign a meaningful and unique name.</p>
<p><img decoding="async" class="aligncenter wp-image-2436 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_Variables.png" alt="" width="517" height="176" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_Variables.png 517w, https://cetoni.com/wp-content/uploads/Flowprofile_Variables-300x102.png 300w" sizes="(max-width: 517px) 100vw, 517px" /></p>
<p>For the gradient, use 20 steps (<strong>$GradientSteps = 20</strong>) with a duration of 100 milliseconds each (<strong>$StepDuration = 100</strong>). The resolution of 100 ms is a reasonably fast time base for many applications. You can change these values later at any time. You can enter a fixed value for the target flow rate, or you can calculate the target flow rate based on the maximum flow rate of the first pump. To do this, you can insert the device property (<strong>Insert device property</strong>) for the maximum flow rate of the pump into the JavaScript field and use it for calculations. In this example we want to dose with one tenth of the maximum flow rate and therefore simply divide it by 10. You can also use other values or your own calculations:</p>
<p style="text-align: center;"><strong>$TargetFlow</strong> = $neMESYS_Low_Pressure_1.MaxFlow / 10</p>
<p>To create a single sawtooth, you now need a <strong>Counting Loop</strong> <span style="color: #4393e9;">❶</span>. Two parameters can be configured for a counting loop: the number of <strong>Loop Cycles</strong> <span style="color: #4393e9;">❷</span> and the name of the variable (Counter Variable) in which the counter value for the current loop cycle is stored <span style="color: #4393e9;">❸</span>. The input field for the loop cycles <span style="color: #4393e9;">❷</span> is marked with an orange V, i.e. you can use variables in this input field. At this point you can simply enter the previously defined variable <strong>$GradientSteps</strong>.</p>
<p><img decoding="async" class="aligncenter wp-image-2418 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_CountingLoop.png" alt="" width="918" height="240" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_CountingLoop.png 918w, https://cetoni.com/wp-content/uploads/Flowprofile_CountingLoop-300x78.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_CountingLoop-768x201.png 768w" sizes="(max-width: 918px) 100vw, 918px" /></p>
<p>Within the loop you can now calculate the flow rate for the first pump and save it in a variable. The loop counter <strong>$i</strong> takes the values 0 &#8211; 19 for the 20 loop passes. You can therefore calculate the flow rate with the following formula:</p>
<p style="text-align: center;"><span style="color: #4393e9;">❶</span> <strong>$Flow1</strong> = $TargetFlow / ($GradientSteps &#8211; 1) * $i</p>
<p>I.e. the flow rate is 0 in the first loop pass and reaches the value <strong>$TargetFlow</strong> in the last loop pass. The sum of the flow rates of both pumps should give the value <strong>$TargetFlow</strong>. Therefore, in a second variable, you can calculate the flow rate of the second pump as follows:</p>
<p style="text-align: center;"><span style="color: #4393e9;">❷</span> <strong>$Flow2</strong> = $TargetFlow &#8211; $Flow1</p>
<p><img decoding="async" class="aligncenter wp-image-2428 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_FlowVariables.png" alt="" width="847" height="309" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_FlowVariables.png 847w, https://cetoni.com/wp-content/uploads/Flowprofile_FlowVariables-300x109.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_FlowVariables-768x280.png 768w" sizes="(max-width: 847px) 100vw, 847px" /></p>
<p>You can now use these two values to start the dosing of the two pumps with the function <strong>Generate Flow</strong> <span style="color: #4393e9;">❶</span>. To configure the Generate Flow function, simply select the appropriate pump and enter the calculated value <strong>$Flow1</strong> or <strong>$Flow2</strong> in the <strong>Flow field</strong> <span style="color: #4393e9;">❷</span>. It is important that the unit for the flow rate is set to the same value as configured for the pump &#8211; in this case <strong>ml/min</strong> <span style="color: #4393e9;">❸</span>. You have to deactivate the <strong>Run to completition</strong> checkbox <span style="color: #4393e9;">❹</span>. If this field is active, the next function will not be started until the pump has finished dosing. In the case of the Generate Flow function, this would be when the pump is fully wound or drained. Since this is not desired here, but the script is to be continued immediately, deactivate the field.</p>
<p><img decoding="async" class="aligncenter wp-image-2430 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_GenerateFlow.png" alt="" width="850" height="280" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_GenerateFlow.png 850w, https://cetoni.com/wp-content/uploads/Flowprofile_GenerateFlow-300x99.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_GenerateFlow-768x253.png 768w" sizes="(max-width: 850px) 100vw, 850px" /></p>
<p>To achieve the desired step duration for each loop cycle, add a <strong>Delay</strong>function <span style="color: #4393e9;">❶</span> as the last function in the loop. You can directly enter the variable <strong>$StepDuration</strong> in the configuration area of the function in the input field <strong>Milliseconds</strong> <span style="color: #4393e9;">❷</span>. The Delay function delays the further execution of the script for the configured time period.</p>
<p><img decoding="async" class="aligncenter wp-image-2420 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_Delay.png" alt="" width="1001" height="241" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_Delay.png 1001w, https://cetoni.com/wp-content/uploads/Flowprofile_Delay-300x72.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_Delay-768x185.png 768w" sizes="(max-width: 1001px) 100vw, 1001px" /></p>
<p>At the end of your short script, now add the <strong>Stop All Pumps</strong> <span style="color: #4393e9;">❶</span> to stop all pumps. To synchronize the recording of the flow rates in the graphical logger with the script flow, add the function to start the logger (<strong>Start Plot Logger</strong>) <span style="color: #4393e9;">❷</span> before the counting loop and the function to stop the recording (<strong>Stop Plot Logger</strong>) <span style="color: #4393e9;">❸</span> at the end of the script.</p>
<p><img decoding="async" class="aligncenter wp-image-2426 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_FirstTestRun.png" alt="" width="535" height="280" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_FirstTestRun.png 535w, https://cetoni.com/wp-content/uploads/Flowprofile_FirstTestRun-300x157.png 300w" sizes="(max-width: 535px) 100vw, 535px" /></p>
<p>When your syringes are completely filled, you can now start the first test run. If the script has run without errors, you should see the following graphs in the graphical logger.</p>
<p><img decoding="async" class="aligncenter wp-image-2424 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_FirstTestRun_Graph.png" alt="" width="926" height="260" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_FirstTestRun_Graph.png 926w, https://cetoni.com/wp-content/uploads/Flowprofile_FirstTestRun_Graph-300x84.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_FirstTestRun_Graph-768x216.png 768w" sizes="(max-width: 926px) 100vw, 926px" /></p>
<p>In the next step, extend the script to repeat the generation of the sawtooth cyclically until the user presses the <strong>Request Script Stop</strong> <span style="color: #4393e9;"><strong>❶</strong></span> button. To do this, insert a <strong>Conditional Loop</strong> <span style="color: #4393e9;">❷</span> in front of the sawtooth loop. In the configuration area of the function, switch to the JavaScript area <span style="color: #4393e9;">❸</span> and enter the following condition:</p>
<p style="text-align: center;"><span style="color: #4393e9;">❹</span> <strong>$StopRequested</strong> == false</p>
<p>This means that this loop is repeated continuously as long as the condition is fulfilled, i.e. as long as the global variable <strong>$StopRequested</strong> has the value false. The variable <strong>$StopRequested</strong> is a global script variable that is always present. After starting the script this variable always has the value false. Only when the user presses the button <strong>Request Script Stop</strong> <span style="color: #4393e9;">❶</span>, the value of the variable is set to true.</p>
<p><img decoding="async" class="aligncenter wp-image-2414 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_ConditionalLoop.png" alt="" width="817" height="251" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_ConditionalLoop.png 817w, https://cetoni.com/wp-content/uploads/Flowprofile_ConditionalLoop-300x92.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_ConditionalLoop-768x236.png 768w" sizes="(max-width: 817px) 100vw, 817px" /></p>
<p>Now you can insert the sawtooth loop into the conditional loop. Click on the <strong>Counting Loop</strong> <span style="color: #4393e9;">❺</span> and drag it to the <strong>Conditional Loop</strong> <span style="color: #4393e9;">❷</span>. The counting loop is then inserted into the conditional loop. Now restart the script. The generation of the sawtooth is now repeated until you press the button <strong>Request Script Stop</strong> <span style="color: #4393e9;">❶</span>.</p>
<p>After a few cycles, press the <strong>Request Script Stop</strong> <span style="color: #4393e9;">❶</span> button to end the script. If the script has run without errors, you should see the following graphs in the graphical logger.</p>
<p><img decoding="async" class="aligncenter wp-image-2432 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_GraphLog.png" alt="" width="963" height="258" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_GraphLog.png 963w, https://cetoni.com/wp-content/uploads/Flowprofile_GraphLog-300x80.png 300w, https://cetoni.com/wp-content/uploads/Flowprofile_GraphLog-768x206.png 768w" sizes="(max-width: 963px) 100vw, 963px" /></p>
<p>Your flow profile script is almost finished. To improve the clarity, you can combine the variables you declared at the beginning of the script in a variable group (<strong>Variable Declarations</strong>). Insert a <strong>Variable Declarations</strong> function as the first function in the script. Then select all variables. Click on the first <strong>Create Variable</strong> function and then click on the last <strong>Create Variable</strong> function while holding down the Shift key &#8211; just as you would select several files in your file explorer.</p>
<p>Afterwards you can move all marked variables with the mouse into the variable group. With this you have grouped the variables and improved the clarity and readability of the script. In addition, it is now easier to move this group of variables to another position. Your script should now look like this:</p>
<p><img decoding="async" class="aligncenter wp-image-2422 size-full" src="https://cetoni.de/wp-content/uploads/Flowprofile_FinalSawtoothScript-1.png" alt="" width="536" height="526" srcset="https://cetoni.com/wp-content/uploads/Flowprofile_FinalSawtoothScript-1.png 536w, https://cetoni.com/wp-content/uploads/Flowprofile_FinalSawtoothScript-1-300x294.png 300w" sizes="(max-width: 536px) 100vw, 536px" /></p>
<p>In the second part of the tutorial you will learn how to modify the script so that sinusoidal flow profiles can be generated with the help of JavaScript functions. You will also learn how to add an initialization routine to the script that pulls up the syringes and how to record calculated values using virtual I/O channels in the graphical logger. Finally, you will receive tips on how to improve the readability of your script and document your script.</p>
<p>The QmixElements project with simulated devices and the script created in the tutorial can be <a href="https://cetoni.de/downloads/Flowprofiles.qpr" target="_blank" rel="noopener">downloaded here</a>.</p>
</div>




			</div> 
		</div>
	</div> 
</div></div>
<p>Der Beitrag <a href="https://cetoni.com/en/tutorial-flow-profile-generation-with-qmixelements-part-1/">Tutorial flow profile generation with QmixElements (CETONI Elements) &#8211; Part 1</a> erschien zuerst auf <a href="https://cetoni.com/en/">CETONI GmbH</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
