diff --git a/templates/BaseJavaIDL.tmpl b/templates/BaseJavaIDL.tmpl
index 4ea7de1dbb86fd1dbe82d7a07a11b0c559d779a9..ffee13e62cad572017bfda0bd1accc8169e2a579 100644
--- a/templates/BaseJavaIDL.tmpl
+++ b/templates/BaseJavaIDL.tmpl
@@ -416,7 +416,26 @@ public class ${Assembly}BaseImpl extends TCSHardwareDeviceImpl implements ${Asse
 	}
 	@Override
 	public void ${x.SetSheet["Name of command"][$idx]}($($y[$type][4]) arg0) throws IllegalParameterErrorEx,INACTErrorEx {
-		baciH.set$(($y[$type][4]).capitalize())ValSync(${x.SetSheet["Short name"][$idx]},arg0);
+#if str($x.SetSheet["Alarm high"][$idx]) !="nan" and str($x.SetSheet["Alarm high"][$idx]).strip() !="NA" and str($x.SetSheet["Alarm high"][$idx]).strip() !="" and $y[$type][1] != "S"
+   #if $type[0]=="I" or $type[0]=="U"
+         	$y[$type][4] maxval=str($x.SetSheet["Alarm high"][$idx]).split(".")[0];
+   #else
+		$y[$type][4] maxval=$x.SetSheet["Alarm high"][$idx];
+  #end if
+ #end if
+#if str($x.SetSheet["Alarm low"][$idx]).strip() !="nan" and  str($x.SetSheet["Alarm low"][$idx]).strip() !="NA" and  str($x.SetSheet["Alarm low"][$idx]).strip() !="" and $y[$type][1] != "S"
+#if $type[0]=="I" or $type[0]=="U" 
+		$y[$type][4] minval=str($x.SetSheet["Alarm low"][$idx]).split(".")[0];
+#else
+		$y[$type][4] minval=$x.SetSheet["Alarm low"][$idx];
+#end if
+#end if
+		if (arg0>=minval && arg0<=maxval){
+			baciH.set$(($y[$type][4]).capitalize())ValSync(${x.SetSheet["Short name"][$idx]},arg0);
+		} else {
+			m_logger.log(Level.SEVERE, "Value outside range for:"+"$x.SetSheet["Short name"][$idx]");
+			throws new IllegalParameterErrorEx();
+		}
 		
 	}
 #end if
diff --git a/templates/CDBInstance.tmpl b/templates/CDBInstance.tmpl
index 525cd2ff948d9850331f6c5edb3b8701c71686ce..0b0dfe23409e60e735fa651e38f9ecd7c013b74a 100644
--- a/templates/CDBInstance.tmpl
+++ b/templates/CDBInstance.tmpl
@@ -107,8 +107,9 @@
  #else
 	units=""
 #end if
+
         min_timer_trig="0"
-    #if $y[$type][1] != 's'
+    #if $y[$type][1] != "S"
         min_delta_trig="0"
         min_step="1"
     #end if
diff --git a/test/myDeviceInterfaces.xls b/test/myDeviceInterfaces.xls
new file mode 100755
index 0000000000000000000000000000000000000000..e4347e05c0609eed8c8488035519464e57c5a5a2
Binary files /dev/null and b/test/myDeviceInterfaces.xls differ