Solved

How to write into data blok into Siemens PLC

Posted on 2009-07-08
6
642 Views
Last Modified: 2013-11-10
With next code i'm trying to write in the Data Blok 11 into first byte. But i have no sauces. Can you help me to resolve the error.

Best regards
function DB_write ( dbno:Integer;dwno:Integer;var amount:Integer;var buffer):Integer;stdcall;
 
 
function DB_write;external 'w95_s7m.dll' name 'db_write';
 
 
procedure Tform1.writePLC();
var
ammount1: Integer;
buffmy: Word;
begin
ammount1 := 1;
buffMY:= 1 ;
DB_read(11, 0, ammount1, buffmy);
end;

Open in new window

0
Comment
Question by:pr2501
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 28

Expert Comment

by:Bill Bach
ID: 24830469
Not my field, but I have an obvious suggestion:  Change DB_read to db_write.
0
 

Author Comment

by:pr2501
ID: 24837794
thank you

It's ok now.

Just..
Can you help me for the nexyt problem:
When i close app. And start agin i have next mesage:

First chance exception at $7C812AFB. Exception class EOleException with message 'Cannot expand named range'. Process Project1.exe (3248)

After clicking on continue, i get mesage error (attached picture) and after clicking on ok  it starts and it works normaly.
I need to avoid this interuption.

canexpand.JPG
0
 

Author Comment

by:pr2501
ID: 24840537
Some explanations more:

I need to close my app, because i'm  writeing new values into buffer by changing variables into Delphi IDE. After restarting my app again and with clicking on speed button i'm writing (calling procedure for write)  . And then that error appears:
Cannot expand named range
0
 
LVL 28

Accepted Solution

by:
Bill Bach earned 500 total points
ID: 24840797
Are you closing the application normally, or are you terminating it through the IDE?  Many data environments instance DLL's, create connections, and perform other tasks at startup that must also be properly shutdown when terminating.  In many cases, if you terminate an app from the IDE, these clean-up functions never get called, memory never gets released, etc., and problems can occur.  Check to see if you have to call some cleanup functions for this library, and just ensure that they are called before terminating the app in the IDE.
0

Featured Post

Webinar: Choosing a MySQL HA Solution

Join Percona’s Principal Technical Services Engineer, Marcos Albe as he presents Choosing a MySQL High Availability Solution on Thursday, June 29, 2017 at 10:00 am PDT / 2:00 pm EDT (UTC-7).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Progress
Starting up a Project

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question