Author Topic: Problem writing on a OMRON CJ1W  (Read 1989 times)

xavi

  • Newbie
  • *
  • Posts: 5
    • View Profile
Problem writing on a OMRON CJ1W
« on: September 23, 2015, 06:30:36 AM »
Hi to all!

I'm quite new with this software so sorry if my question is superfluous, but, I'm able to read from the CJ1W on the address W0 and D0, but when I try to write (using the basicLabel keypad or my on button with a call to OmronEthernetFINSCom1.write("W0","1234") ) the value is not writed to the PLC. I'm also connected at the same time with the CXProgram so if i modify the value from there, I see it immediately on another component (gauge).

The parameter of the OmronEthernetFINSCom seem ok, I tryed 2 differents configurations that work for reading:
1.- Just setting the ipAddress
2.- Setting the ipAddress and the networkaddress and the nodeAddress.

I was debugging the program and seems to SEND the FINS Frame... I'm completely lost, any help?

Thanks!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Problem writing on a OMRON CJ1W
« Reply #1 on: September 23, 2015, 06:52:24 AM »
If you are seeing values on the controls, that verifies your communications are good.

I don't have a CJ1W to test with, but I tried this quick test on a CP1H and version 3.99:

- Add an OmronEthernetFINSCom driver and set the IPAddress
- Add a BasicLabel and set both PLCAddressValue and PLCAddressKeypad to W0
- Run the application
- Click the BasicLabel and enter a value of 123

The BasicLabel changed to the new value. I was also online with CX-Programmer and watched the value change there also. So everything work as expected on my tests.

Does your PLC possibly have some protection that would keep the values from changing? Try putting the PLC in program mode to see if it works. Could you do a WireShark capture during a write to W0 and post the capture? From that I will be able to see if the PLC returns an error code that AdvancedHMI is not displaying.


xavi

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem writing on a OMRON CJ1W
« Reply #2 on: September 23, 2015, 07:05:03 AM »
Hi Archie!

I tryed to put the PLC in Programm but nothing.

I'll try to install the wireshark and try to sniff those packages.

Thanks!

xavi

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem writing on a OMRON CJ1W
« Reply #3 on: September 23, 2015, 07:47:33 AM »
Here you have the WireShark capture, I made a read and then a write.

Thanks!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Problem writing on a OMRON CJ1W
« Reply #4 on: September 23, 2015, 09:27:38 AM »
The End Code is 0x1103

According to WireShark : First address in inaccessible area


Based on the Omron reference manual:

0x11 : Parameter Error
0x03 : Address Range Error
Probable Cause : The start address in command process is beyond the accessible area.
Check the area being processed and set the correct range.


I did a WireShark with my CP1H and did a side by side comparison. There are 2 differences I see:

Destination Network Address is 0 because I am directly connected to my controller
Destination Node Number is also 0. I'm not sure if the CP1H even uses this

You are getting a successful read, so those values must be correct.

The only thing I see that stands out is the Beginning Address bit. The AdvancedHMI driver sends 0xff. I wonder if the CJ doesn't like something about that. Tomorrow I will have access to a CS1 controller and will test to see if I can write to the W0 on that controller.

xavi

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem writing on a OMRON CJ1W
« Reply #5 on: September 23, 2015, 10:25:10 AM »
Whoaaam this WireShark is great.

I was analyzing the command data inside the FINS and I realized that the Basic label was sending a 0xff as the initial address for the writing, but for the reading it was 0x00.

Then I created a button for writing using the .write()  with the address modified to w0.0 in stead of w0 and then it works JUST for BITS obviously, so at least I know that I can write and there's no protection.

So, it seems that, as you also wrote (you answer while I was writing), that the problem is the initial address 0xff if we try to write the whole word, but is back to 0x00 when we try to read just one bit.
I also try to write bit 1, and it also worked, 0x01...

By now I can make a for loop to write 1 by 1 all the bits of the word, but I think there must be something more efficient to fix it ;)

Thanks!


xavi

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem writing on a OMRON CJ1W
« Reply #6 on: September 24, 2015, 04:52:56 AM »
Hi Archie!

Finally I kind of "fix it" for my application.

As I'll be only working with words I change my call to write, in stead of calling the write with the address in a string I make the call to the write that accepts an OmronAddress, so after the call to the constructor of the OmronAddress I check the value of bitnumber, if it is eq to 255 I overwrite it to 0. That's all.

       MfgControl.AdvancedHMI.Drivers.Omron.OmronPlcAddress address = new MfgControl.AdvancedHMI.Drivers.Omron.OmronPlcAddress(textBox4.Text);
   if (address.BitNumber == 255)
       address.BitNumber = 0;
   string[] arrayCadenes = { TextBox2.Text };
   omronEthernetFINSCom1.Write(address, arrayCadenes);

By now and for me is working ok.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Problem writing on a OMRON CJ1W
« Reply #7 on: September 24, 2015, 07:38:52 AM »
Thanks for the feedback. I will work this fix into the driver

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: Problem writing on a OMRON CJ1W
« Reply #8 on: September 24, 2015, 07:56:19 AM »
Try this to see if it fixes the problem.

- Open AdvancedHMIDrivers\Omron\FINS\FINSBaseCom.vb
- Go to line 880 and modify the code to this:
Code: [Select]
            dataPacket.Add(CByte((address.ElementNumber) And 255))

            '* 24-SEP-15 A 0xff was going in the bit position if no bit specified. This is so returned data doesn't think a bit was requested
            Dim BitNumberByte As Integer = Requests(CurrentTNS).BitNumber
            If Requests(CurrentTNS).BitNumber < 0 Or Requests(CurrentTNS).BitNumber > 64 Then
                BitNumberByte = 0
            End If
            dataPacket.Add(CByte(BitNumberByte))

            dataPacket.Add(CByte((address.NumberOfElements >> 8) And 255))