Write a new value to VW through a web page

Aafke

Member
Join Date
Oct 2003
Posts
3
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
 
Looks like your setting the upper byte of the word
to one and not the lower byte i.e.

00000001 00000000 = 256

Make sure the variable your looking at is correctly addressed
when writing/reading back the data, with relevant byte ordering.

I'm not familier with the Siemens script functions writeVariable
etc, however I used to get similar problems with other packages
in the way they write to the byte order of the word.

DES
 

Similar Topics

hi i am using rs view32 in which i want to write value in tag through vb. for example i have a tag higest_value as a integer which is decleared in...
Replies
21
Views
30,339
Hello Everyone, Can somebody tell me how I can move a internal value ( word, int, float etc) to a external tag in C script or VBS or another...
Replies
3
Views
2,007
I have a site that I have recently commissioned using View SE 8.0 connected to a CompactLogix 1769-L30ER. The customer has View SE ver 8.0, so...
Replies
7
Views
4,659
Hi , I am having a set of data that has to be logged in database via kepserver datalogger using compact logix,,, I was able to write those data...
Replies
1
Views
3,037
hi. i have a problem. im using omron cx-programmer..how to write the program to find maximum and minimum value in ladder diagram using the...
Replies
4
Views
3,259
Back
Top Bottom