Solved

How to write into data blok into Siemens PLC

Posted on 2009-07-08
6
623 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to split this in C++ 4 77
wordappend challenge 8 85
Data center mess 4 47
Modify a small python script 19 44
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Read about achieving the basic levels of HRIS security in the workplace.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now