I work with a s7-200 PLC CPU 224, Now I have a program downloaded in my PLC. I want to read and write to VW28 via a web page. Reading goes well with JavaScript and CGI but when I want to write a new value to VW28 it doesn’t work. Is there someone who has an idea how to go about the reading part? This is what I got so far:
Read: this reads the Variable Word: called Var0 and Var1
<script language="JavaScript">
<!--
var Interv = 5
function startClock() {
Interv = Interv - 1
var now = new Date()
var dummystr = parseInt(now.getTime() / 1000)
delete now
if (Interv < 0) {
document.ICUGTW.setNoVariables(2);
document.ICUGTW.setVariableName(0, "Var0");
document.ICUGTW.read();
document.myform.varWord0.value = document.ICUGTW.getValue(0);
document.ICUGTW.setVariableName(0, "Var1");
document.ICUGTW.read();
document.myform.varWord1.value = document.ICUGTW.getValue(0);
Interv = 5
} else {
document.myform.time.value = Interv;
}
timrID = setTimeout("startClock()", 1000)
}
// -->
</script>
To write to a bit in the PLC called Var2: This works
document.ICUGTW.writeVariable('Var2', '1'): // bit on
document.ICUGTW.writeVariable('Var2', '0'); // bit off
But how do I write a new value to Variable Word 28, VW28 = Var3
When I use the line below the value of Var3 (VW28 in the PLC) becomes 0
document.ICUGTW.writeVariable('Var3', '0');
When I use the line below the value of Var3 (VW28 in the PLC) becomes 256
document.ICUGTW.writeVariable('Var3', '1'):
Is there someone who has done this before? Thanks for reading my post.
Aafke
Read: this reads the Variable Word: called Var0 and Var1
<script language="JavaScript">
<!--
var Interv = 5
function startClock() {
Interv = Interv - 1
var now = new Date()
var dummystr = parseInt(now.getTime() / 1000)
delete now
if (Interv < 0) {
document.ICUGTW.setNoVariables(2);
document.ICUGTW.setVariableName(0, "Var0");
document.ICUGTW.read();
document.myform.varWord0.value = document.ICUGTW.getValue(0);
document.ICUGTW.setVariableName(0, "Var1");
document.ICUGTW.read();
document.myform.varWord1.value = document.ICUGTW.getValue(0);
Interv = 5
} else {
document.myform.time.value = Interv;
}
timrID = setTimeout("startClock()", 1000)
}
// -->
</script>
To write to a bit in the PLC called Var2: This works
document.ICUGTW.writeVariable('Var2', '1'): // bit on
document.ICUGTW.writeVariable('Var2', '0'); // bit off
But how do I write a new value to Variable Word 28, VW28 = Var3
When I use the line below the value of Var3 (VW28 in the PLC) becomes 0
document.ICUGTW.writeVariable('Var3', '0');
When I use the line below the value of Var3 (VW28 in the PLC) becomes 256
document.ICUGTW.writeVariable('Var3', '1'):
Is there someone who has done this before? Thanks for reading my post.
Aafke