. .
  1. #1
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 3 Days Ago Forum Superstar, has done so much to help others, they deserve a medal. Has been a member for 9-10 years. Has a total post count of 2,908. Received thanks 360 times, giving thanks to others 8 times.
    I'm pulling my hair out trying to get a KFlop to read the correct register in a Click PLC.

    The KFlop sample code uses the following line to read the input register and store the input statuses into virtual bits-
    Tx:01;04;e0;00;00;01;06;0a;.

    01 is the device ID, 04 the Function Code, e000 the register address, 0001 the number of registers, with the 060a being the CRC code (the sample script generates the CRC code so I don't have to worry about that).
    The input statuses are accessed via the Click's X register at hex address 0000.
    (I'm not sure how the e000 translates to 0000, but it works!)

    Now I want to read the Click's Holding Register DS1, which also has the hex address of 0000.
    According to the manual, the preceding function code should control what registers are read, so swapping the 04 for 06, should mean DS1 gets read, but it doesn't. I still end up with the contents of X register.

    Anybody got any suggestions?
    Even if it is to tell me I've missed something stupid!

    Here's the Click help extract covering the addressing-
    Attachment 10761

  2. #2
    Maybe you could post the code here.

  3. #3
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 3 Days Ago Forum Superstar, has done so much to help others, they deserve a medal. Has been a member for 9-10 years. Has a total post count of 2,908. Received thanks 360 times, giving thanks to others 8 times.
    The code is over 400 lines worth, and it does work for reading and writing the main PLC inputs and outputs.

    I have figured out my problem though, and answered my own questions.
    The E range of hex addresses point to the Input and Output holding registers, which store the values in hex blocks, which are what the sample code use. Being new to PLCs, I had no idea about the extra registers, it wasn't until I went through all the registers in the Address Picker, that I found the E addresses, and everything slotted into place.

    I've been out this morning and a command of 01;03;00;00;00;01;..;.. reads DS1, and I've also got the KFlop writing a new value to DS2, so all that's left is to code the KFlop to store the DS1 value where I can read it in Mach, and get it to read a new value from Mach and write it into DS2.

  4. #4
    That's good then, I've not used the Click PLC before but you are correct in that they use defined sets of registers for different tasks, some are retentive memory, some are general purpose, etc.
    They are generally called 'tables' and that's a good way to think of them.

    This is old hat now but it shows the principle, e.g. G tables are registers for general use, R tables are retentive following power down, etc.
    GEM Driver > GEC GEM80 PLC > Data Types
    Last edited by EddyCurrent; 15-11-2013 at 02:07 PM.

  5. #5
    m_c's Avatar
    Lives in East Lothian, United Kingdom. Last Activity: 3 Days Ago Forum Superstar, has done so much to help others, they deserve a medal. Has been a member for 9-10 years. Has a total post count of 2,908. Received thanks 360 times, giving thanks to others 8 times.
    There's no G or R in a Click, but there are various registers that handle different data types.

    This was my first ever attempt at using a PLC, and it's not been too painful considering. Hardest part was getting my head around ladder logic, as what could be done in a couple lines of more normal programming code, takes umpteen rungs and switches. It took me a few attempts to get the logic for the tool changer working how it should.

    The Click is reasonably priced, and I'll probably look at using them in the mill for the toolchanger, but it'll be another couple months before I get anywhere near starting that project.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. hitachi wj200 vfd and modbus
    By iamspuddy in forum Spindles & Drive Motors
    Replies: 0
    Last Post: 27-09-2013, 07:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •