Jump to content

Recommended Posts

Posted

Hi there!

i'm new in the forum. I start to work with S7 1200 CPU1214AC/DC/RLY firmware 4.4 i create my HTLM pages and download in to PLC. Everything work well i can read dat from DB or tags but if i try to write from my HTML dose't work. I find on line a tutorial from SIEMES i copy a couple of examples but dosen't work  i use a password but nothing. If i modify the variable from the SIEMENS page gave me when i type the IP i can change the variable.

Please some one can help me because i diden't know what my problem is 

 

Thank you soo much 

Sergio


Posted

Have you declare your variable with awp in you web page? 
In your plc, the tag checkbox Visible in HMI engineering must be checked.

 

Here is a demo web page which include few write option. Just cut/paste in a text file, rename it *.html

 

regards

 

<!DOCTYPE html>
<html lang="en">
<head>
<!-- Web page must use utf-8 charct set -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="styles/MainStyle.css" />
<link rel="stylesheet" href="styles/Write.css" />
<script src="scripts/MainFunction.js"></script>
<script src="scripts/PLCTagFunction.js"></script>

<title>Siemens 1200 web demo</title>

<!-- this block is used in case of internet explorer version <9 is used. Only v9 include HTML5 -->
<!--[if lt IE 9]>
		<script type="text/javascript">
	    document.createElement("header")
		document.createElement("footer")
		document.createElement("section")
		document.createElement("aside")
		document.createElement("nav")
		</script>
		<![endif]-->
		
</head>

<body>
<header>
	<img src="images/Unit.jpg" alt="S7-200 unit" />This is a <b>SIEMENS</b> 1200 demo.</header>
<hr>


<div id="MainDiv">
	<h4>Different syntax could be use for read and write variable</h4>
	Counter value is :=MW102:<br>
		<!-- *************** Use push button as variable input************* -->
	<!-- AWP_In_Variable Name="bResetPB" -->
	<form method="post">
		<input name="bResetPB" type="hidden" value=1>
		<input id="ResetOnePB" type="submit" value="Reset counter">
	</form><br/>
	
	<!-- *************** Use select list as variable input ************** -->
	<!--  AWP_In_Variable Name="bResetPB" -->
	<form method="post">
		<select name="bResetPB">
			<option value=1>Reset to zero</option>
			<option value=0>Do not reset</option>
		</select>
		<input type="submit" value="Send request">
	</form><br/>
	
	<!-- *************** Use radio pb as variable input *************** -->
	<!--  AWP_In_Variable Name="bResetRequest" [Use="bResetPB"] -->
	<form method="post">
		<label for="bResetRequest">Do you want to reset counter?</label>
		<input type="radio" name="bResetRequest" value="1" checked="checked">yes
		<input type="radio" name="bResetRequest" value="0">no<br/>
		<input type="submit" value="Send request"/>
	</form><br/>
	
	<!-- *************** Use text for enter numeric value *************** -->
	<!-- CSS style is applied to input field for validate numeric value
	<!-- AWP_In_Variable Name="iSpeed" -->
	<form id="NumFieldForm" method="post">
		<label for="iSpeed">Speed reference: </label>
		<input name="iSpeed" type="number" min="10" max="1800" step="10" value="900" title="enter a value between 10 and  1800." required> RPM<br/>
		<input type="submit" value="Send new speed">
	</form><br/>
	
	<form id="NumFieldFormwText" method="post">
		<label for="iSpeed">Speed reference: </label>
		<input name="iSpeed" type="text" value=":=MW100:" required> RPM<br/>
		<input type="submit" value="Send new speed">
	</form><br/>
	
	<!-- *************** Use cursor for enter numeric value *************** -->
	<!-- AWP_In_Variable Name="iSpeed" -->
	<form method="post">
		<label for="iSpeed">Speed reference: (:=MW100:) </label>
		<input name="iSpeed" type="range" min="10" max="1800" value=":=MW100:">
		<input type="submit" value="Send new speed">
	</form>
</div>

<footer>
	Snapshot take at <script>WriteDate();</script>
	<div id="FooterDiv">
		Created by slcman
	</div>
</footer>
<script>PageLoad()</script>
</body>
</html>

 

 

Posted (edited)

Hello!

Follow these steps:

Possible Reasons & Solutions:

1. Check PLC Web Server Settings

Make sure that Write Access is enabled in the PLC web server settings. To check:

Open TIA Portal → PLC Web Server Settings

Ensure that:

"Allow Write Access" is enabled

"Allow JavaScript & WebSockets" is enabled.
 

2. Verify User Permissions

Since you mentioned using a password, ensure that the user account has write permissions:

In TIA Portal → Go to User Management

Check if the user is assigned the "Full access (Read/Write)" role

Try using the default admin account to test the write function.
 

3. Correct HTTP Request Method (POST vs GET)

When writing data, ensure you’re using the correct HTTP method (POST, not GET).
Here’s an example of how to properly send data using JavaScript (AJAX with fetch API):

fetch("http://<PLC-IP>/plcdata", {
    method: "POST",
    headers: {
        "Content-Type": "application/json"
    },
    body: JSON.stringify({
        tagName: "DB1,DWORD0",  // Replace with your actual DB variable
        value: 1234  // Replace with the value you want to write
    })
})
.then(response => response.json())
.then(data => console.log("Write Success:", data))
.catch(error => console.error("Error writing to PLC:", error));
 

Ensure that PLC-IP is replaced with the actual IP address of your S7-1200.

Also, check the correct tag name format for your variables.

 

4. Check Firewall & Network Issues

Try disabling firewall on your PC temporarily and test the write operation.

Ensure that the PLC and PC are in the same subnet.

Use WireShark to check if the request is being sent but blocked.

5. Test Write Function via Siemens Web Interface

Open your browser → Enter http://<PLC-IP>

Go to Variables → Try to manually change a variable.

If this works, the issue is likely in your HTML/JavaScript request syntax.

Final Steps:

1️⃣ Confirm Web Server Settings & User Permissions
2️⃣ Use Correct POST Method & JSON Format
3️⃣ Test via Siemens Web Interface
4️⃣ Disable Firewall & Use Wireshark for Debugging
5️⃣ Check TIA Portal Security Settings (Read/Write Access)
 

Master Siemens S7-1200 with Iqra Technology! 🚀

Facing issues with S7-1200 PLC, HMI, or web-based control? At Iqra Technology, we provide expert training, troubleshooting, and hands-on support for Siemens automation. Learn PLC programming, TIA Portal, SCADA, and IoT from industry professionals.

Expert Guidance | Hands-on Training | 24/7 Support

🔗 Visit Iqra Technology and take your automation skills to the next level!

Edited by khanzain
Posted

Hi Sergio,

It sounds like you're making good progress with your S7-1200 and HTML interface! Since you're able to read data but not write, a few things might be causing the issue:

User Permissions: Make sure the PLC web server settings allow write access. In TIA Portal, go to Web Server Settings and check if "Enable Write Access" is activated.

JavaScript & HTTP Requests: If you're using JavaScript to send data, verify that your POST/GET requests are correctly formatted and that you're targeting the correct tag addresses.

Cross-Origin Restrictions: Some browsers block certain types of requests. Try running your HTML file directly from the PLC or adjust security settings.

PLC Security Settings: Since you mentioned using a password, double-check that your authentication headers are correctly handled in your request.

Firewall/Network Issues: Ensure that your PLC is not being blocked by a firewall or network setting.

If you’re short on time while troubleshooting this, you might want to Hire Someone To Take My Online Class so you can focus on getting your S7-1200 working without falling behind on coursework. Hope this helps, and let us know how it goes!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...