Host Engineering Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
February 07, 2012, 08:35:03 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Help : PC monitoring (reading/writing) DL205 via ECOM  (Read 2304 times)
marc.turcotte
Jr. Member
**
Posts: 13


« on: May 20, 2009, 04:24:24 pm »

Hi,

I am studying in mechanical engineering and i would like to do the following....

I have couple of PLCs (DL205) with ECOM 10BASE-T boards on the network. Here is the summary of what i want the Java program to be able to do...

1- PC writes (sets) Cxxxx to 1 every loop on every online PLC.
2- PC reads every PLC value Cyyyy (which is the same value for every PLC).
3-a) if PC reads Cyyyy = 0 , PC does nothing
3-b) if PC reads Cyyyy = 1 , PC reads another value from PLC : Vzzzzzz.

At that point , Vzzz will be a recipe name, example : Broadway .

The PC now has to look in a certain folder for a txt file called Broadway. In that txt file, there will be a list of "C" and "V" addresses with values to upload to the PLC memory. The PC will have to write all theses values to the PLC memory. Once again, all via ECOM.

I am not asking for anyone to do everything and sent it to me, i also doubt anyone would... but i want to learn how to do this. I am relatively good with PLC Ladder programming, but i have no clue regarding Java, C+, VB...

Thanks for your time and i would really appreciate any of your help!
« Last Edit: May 20, 2009, 04:31:04 pm by marc.turcotte » Logged
MikeS
Host Moderator
*****
Posts: 170



WWW
« Reply #1 on: May 21, 2009, 09:20:07 am »

marc,

the ethernet sdk available for download from our web (www.hosteng.com) has a vb6 - named etherccm - program that demonstrates all how to interact with ECOMs to move data between a PLC and a PC.

I'd start there and get familiar with the process of locating the ECOM on the network, establishing a connection to it, then exchanging data. It's pretty easy stuff if you have any VB6 programming background.

Once you have the example working for you, please come back and ask any specific questions you have about the interaction with the PLC, I'm not much help on working on the PC side with VB, but I can get you through using the ethernet sdk function calls that move the data into and out of the PLC.
Logged

Good design costs a lot. Bad design costs even more.
marc.turcotte
Jr. Member
**
Posts: 13


« Reply #2 on: May 22, 2009, 03:46:29 pm »

Thanks for the reply,

i took the time to check the program carefully, and hopefully, i will be able to do all i want with functions included in that program... The only problem is that this program is, to me, way to complex to filter....

I am now building my interface and my scan functions in VB, but what i would really like is pretty much straight forward.... I have a list of PLCs IP/Mod that are on the network that i will input at the beggining of the program....

-I want to program to read C1003 value on every PLC
-I want to program to set C1001 = 1  (write to plc)

If you guys could highlight me these functions, if they do exist in a simplified form, i would be able to do everything i want...!

Thanks again
Logged
marc.turcotte
Jr. Member
**
Posts: 13


« Reply #3 on: May 26, 2009, 12:54:22 pm »

Anyone??

Here is an informal summary of the program i am building... If you guys could only explain what is the way to read / write data to the PLC i'd be all set!

Code:
Do Until running = 0
For i=1 to plc_qty Step 1
If ReadPlcCoilValue_C1000_plc_ip(i) = 1
plc_ip_status(i) = 1
WritePLCCoilValue_C1003_plc_ip(i) -> 1
plc_ip_recipe(i) = ReadPLCRegisterValue_V2100_plc_ip(i)
plc_ip_request_recipe(i) = ReadPLCCoilValue_C1002_plc_ip(i)
Else
End
Next
Loop

Thanks
  
« Last Edit: May 26, 2009, 03:26:20 pm by marc.turcotte » Logged
marc.turcotte
Jr. Member
**
Posts: 13


« Reply #4 on: May 27, 2009, 02:41:27 pm »

I tried writing 1 to C1003 with the utility without success....

I've also used the writing code to adapt it to my needs without succes...


Code:
 
                Dim DataType As Byte
                DataType = &H33

                Dim DataAddress As Integer
                DataAddress = StringToHexInt(203)
                
                Dim CCM_SizeData As Integer
                Dim DataLength As Integer
                CCM_SizeData = 1
                DataLength = CCM_SizeData
                
                Dim bWrite As Long
                Dim ByteBuffer(255) As Byte
                Erase ByteBuffer
                    
                bWrite = True
                Rc = StringToByteArray(True, ByteBuffer)
            
                Rc = PASCAL_HEICCMRequest(aDevices(tDevice), bWrite, DataType, DataAddress, DataLength, ByteBuffer(0))
                If Rc <> 0 Then
                    DisplayList.AddItem "Error " + Hex(Rc) + " (" + ShowHEIErrorText(Rc) + ") performing CCM writing Request"
                
                Else
                    Dim j, k As Integer
                    DetailLine = ""
                    Dim l As String
                    DisplayList.AddItem "Successfully wrote" + Str(CCM_SizeData) + " BYTE(s) of data"
                End If

I get the "Successfully wrote 1 byte of data" message, but its not writing to the PLC at all...?!

Just to make sure i tried the right thing with the Host Ethernet CCM Transaction program... here is what i entered for C1003 writing:

-Write checked
-Data type : Output
-Size : 1
-Start Address (Hex) : 203
-Data to write : well i tried 1, 01, 11, 10 just in case...


Thanks for your help!
« Last Edit: May 27, 2009, 02:47:02 pm by marc.turcotte » Logged
MikeS
Host Moderator
*****
Posts: 170



WWW
« Reply #5 on: May 28, 2009, 09:30:56 am »

V memory addresses are 0-based (V0, V1, V2, etc.), but CCM addresses are 1-based, so V1003 = CCM offset 204, not 203. The formula to get from a V address to a CCM offset is : convert octal V address to Hex, and add 1. Reverse this process to go from CCM offset to V memory address.
Logged

Good design costs a lot. Bad design costs even more.
marc.turcotte
Jr. Member
**
Posts: 13


« Reply #6 on: May 28, 2009, 09:35:17 am »

I am trying to write to C and not V..

so, for example, if i want to write to C0000 , i look up in the control relay bit map, which tells me that C0000 is V40600.

i convert V40600 to hex, which is 4180, add 1, 4181. Since its the 1st location of the 16 on address 40600, i type in "01" , (1 byte)

C0000 successfully changes to 1 ...

That works, but as soon as i want to change another value, such as C1000, which is 41A0, 41A1 (after adding 1), it doesnt work. (and yup, C1000 is the first bit of the address....

Logged
marc.turcotte
Jr. Member
**
Posts: 13


« Reply #7 on: May 28, 2009, 01:17:58 pm »

Ok found it...

i had to write to Registers instead.

I have another question...

what if the currently active state of a V address has some C relays set to true... it'll get messed up if i write just another value..

Ex: V40600 contains C0000 to C0017. If C0000,C0002, C0007 are on, the value would be 0085 at address 4181 . If i want the program to set the variable C0003 to true, i cannot have it simply write 0008 @ add 4181.

I have to read the whole bunch of values of the V address, tranform it, add them, retransform , write?

And what if i want to know the value of a specific C value??? If like in the previous example, 0/2/7 are on, and i just want to know if C0002 is on, how do i do that?

Thanks
Logged
MikeS
Host Moderator
*****
Posts: 170



WWW
« Reply #8 on: May 28, 2009, 01:38:37 pm »

glad you found the answer to your previous question.

the smallest amount of data that the CCM (DirectNET) protocol can manage is a BYTE, so you cannot access a single CR, you must read the BYTE that contains that CR.

and this brings us to your other question about overwriting data already in registers.  you're going to have to read the BYTE, change the approptiate BITs and write the BYTE back to the PLC. the danger here is that the PLC may be changing the BITs while your application is modifying the BYTE, and when you write your new data back the PLC's data would be lost. there are a couple of ways around it but they all involve some type of token handling. it's a bit tedious, but that's what's required since the protocol cannot write to single BITs.
Logged

Good design costs a lot. Bad design costs even more.
marc.turcotte
Jr. Member
**
Posts: 13


« Reply #9 on: June 01, 2009, 09:55:00 am »

Hi,

thanks for your help, im actually doing pretty good as of now...

i've been able to read if a particular CR. is on or off with the following.

You have to input a and b as Hex (for example, a = 0008 (C3 true ) and b = 524F (which set true:C0/1/2/3/6/11/14/16))
which a is the C to read , and B the "current status of surrounding bytes".

Code:
Dim a, b, c, d As String

a = CLng("&H" & Text1.Text)
b = CLng("&H" & Text2.Text)
c = Hex$(a Or b)
d = Hex$(CLng("&H" & c) Xor b)

'c = a Or b
If CLng("&H" & a) = CLng("&H" & d) Then
    Text3.Text = "Value was OFF"
Else
    Text3.Text = "Value was already on"
End If


this compares with OR a and b to get C. Then D = C Xor B to reset values that were already on because of B...

and then if D = A, it means that the value was off. else it was already on.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM