AndreasW

MrPLC Member
  • Content count

    69
  • Joined

  • Last visited

Community Reputation

20 Excellent

2 Followers

About AndreasW

  • Rank
    Sparky

Profile Information

  • Country Germany
  1. GOT HMI - Enable/Disable Serial Port

    Hi MarkusR, don't know if this will work but maybe you can use the Chanel Shutdown Controls GS539 to disable the corresponding chanel. The Special Registers are described inside the Screen Design Manual inside Chapter 12/GOT special registers
  2. MELSEC-L PID Control

    Hi Neverov, you can find this manual at https://dl.mitsubishielectric.com/dl/fa/document/manual/plc/sh080040/sh080040s.pdf for a list of other manuals for L-Series: https://www.mitsubishielectric.com/app/fa/download/search.do?kisyu=/plcl&mode=manual    
  3. Subtraction with GX Works 3

    looks strange, but i think this is because PlsMem is now saved between the fb calls like it was intended. I think you have a problem with your PlsAct value: 1.) you wrote that the difference of PlsAct and PlsMem should be less than 500 (pulse) , but if i look at the both temporary values: PlsAct (Temp1) = - 903.443.592 (currente value) PlsMem(Temp2)= - 930.792.352 (last value) => PlsAct was increased by 27.348.760 between the fb calls, and PlsAct isn't changed inside the FB   2.) PlsAct gets negative, so i think that your actual Pulse counter exceeds the DWORD Range of +2.147.483.647 and then the values will be negative. And if your PlsAct value changes within the range of 27.348.760 this can happens easily after a short while. You can check/detect the overflow of PlsAct with the Carry-Flag (SM700), that will be set if addition or substraction exceeds the range limit, but this will only work if you use DADD or DSUB instructions to modify PlsAct, if you use D+/D- instruction to change PlsAct the Carry-Flag won't be set. I would check: - are all variables of type DoubleWord (Signed) ? - is the FB called only once per scan ? - check the calculation of PlsAct          
  4. Subtraction with GX Works 3

    i still think that "PlsActMemory" is always Zero when the function block is called, and that the value of PlsActMemory isn't stored between the functions calls, because this seems to be the only way that  "DeltaPls" is always calulated to the same value as "PlsAct". PlsDelta = PlsAct - PlsActMemory ([D- PlsAct PlsActMemory PlsDelt]) => PlsDelta = PlsAct - 0 => PlsDelta = PlsAct Maybe you can save the current value of "PlsAct" and "PlsActMemory" to some temporary variables before the [D- PlsAct PlsActMemory DeltaPls] instruction to see what values both variables have before the substraction takes place e.g.: ---|  SM400 | -------------------------------[DMOV PlsActMemory Temp1] ---|  SM400 | -------------------------------[DMOV PlsAct Temp2] as i wrote before PlsActMemory will be Zero when its defined as IN/OUT parameter and the the value is not passed again to the input signal of the function block. In this case the current value (PlsAct) first is stored in PlsActMemory by the [DMOV PlsAct PlsActMemory] but will be reset to zero with the next call of the function block.    
  5. Subtraction with GX Works 3

    looks like that your PlsActMemory is zero when the FB is called? if this FB is called and PlsActMemory is zero, your delta will be equel to PlsAct : "DeltaPls= PlsAct - 0 => DeltaPls= PlsAct"; like in your video if PlsActMemory is an IN/OUT variable do you set the saved output value of the FB to the input when calling your FB? if you don't set it, then PlsActMemory will set to zero when the fb is called
  6. Subtraction with GX Works 3

    hi Simo99, can you post a screenshot of your program and what values do you want to substract?  
  7. Subtraction with GX Works 3

    hi Simo99, just some thoughts: - did you use the DSUB/ D- instruction? if you use SUB/- instruction with DWORD the result is wrong? - is the second value realy smaller the first one?  you can check the Carry, Zero and Borrow Flag  ( SM700, SM8022 Carry When the operation result exceeds the upper limit of the data setting range, the carry flag is turned ON.,   SM8020 Zero When the operation result is 0, the zero flag is turned ON.   SM8021 Borrow When the operation result is less than the lower limit of the data setting range, the borrow flag is turned ON. ) - did you select DWORD inside your monitoring window ?  
  8. Table of Special Registers and Special Relays

    you can find several manuals for different PLC Types (Q/L/FX-serias)  at https://www.mitsubishielectric.com/app/fa/download/search.do?mode=manual&kisyu=/plcq for a list of the special special register have a look at the Appendix inside the hardware design manual, eg. for Q-Series CPU https://dl.mitsubishielectric.com/dl/fa/document/manual/plc/sh080483eng/sh080483engax.pdf see Appendix 2 and Appendix 3.    
  9. Byte to Word

    instead of shifting the bits you can use the swap instruction 1.) MOV HighByteValue  D1                 // move the High-Byte to D1 (this will be stored in the lower 8 Bit of D1) 2.) SWAP D1                                        // swap Hi/Lo of D1 (High-Byte-Value will stored in the upper 8 Bit of D1) 3.) WOR LowByteValue D1                  // OR the value of the Low-Byte of D1     
  10. FX5U Shift Dword

    Hello BL, do you really want to shift the bits of the counter in D0 or is it about reading multiple counter values and store them block by block? If you need to shift the bits of the counter (D0), this can be done with the SHL or SHR instruction, but I can't understand why you should shift bits of a counter. How many bits do you want to shift? If you need to swap high/low byte of the read counter you can use the DSWAP instruction. If you want to store multiple values (each after reading with dhcmov) you don't need a shift instruction. In this case you can the use the BMOV instruction. Alternatively you could use an index register e.g. Z1 and read the values after D0Z1.  
  11. Mitsubishi FX5 read/write from PC with nodejs

    hi david ott,   you wrote: My Test(Wrandom Write) would be as on page 133 and as I thought: new Buffer.from([0x05(subheader), 0xFF(PC No.), 0x0A, 0x00 (monitoring time in 2 parts), 0x04(number of devices?), 0x00 (fixed value),0x16, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 part), 0x00, 0x22 (input1 in 2 parts), 0x17, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 parts), 0x00, 0x40 (input2 in 2 parts), 0x18, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 parts), 0x00, 0x04(input3 in 2 parts),0x1F, 0x4E, 0x00, 0x00 (head dev.# in 4 parts), 0x20, 0x52 (device name in 2 parts), 0x00, 0x01(machineUsed in 2 parts),]);   this should be Ok except for the data values, but should write R19990- R19992 and R19999. i think for the inputvalues you have to switch the order of the High and the Low Byte: e.g. input1 = 22 (dec) = 16 (hex)  --> 0x16, 0x00 (input1 in 2 parts) input2 = 40 (dec) = 28 (hex)  --> 0x28, 0x00 (input2 in 2 parts) input3 = 04 (dec) = 04 (hex) --> 0x04, 0x00 (input3 in 2 parts) ... new Buffer.from([0x05, 0xFF, 0x0A, 0x00, 0x04, 0x00  ,0x16, 0x4E, 0x00, 0x00 , 0x20, 0x52 , 0x16, 0x00 , 0x17, 0x4E, 0x00, 0x00, 0x20, 0x52, 0x28, 0x00,  0x18, 0x4E, 0x00, 0x00 , ....   If your input is a decimal number and if you don't want to convert it to a hex number you also can use the decimal number as input for the buffer, then just leave out the "0x" at the beginning. input1 = 22 (dec) =  22, 0 (input1 in 2 parts) input2 = 40 (dec) = 40, 0 (input2 in 2 parts) input3 = 04 (dec) = 4, 0 (input3 in 2 parts) new Buffer.from([0x05, 0xFF, 0x0A, 0x00, 0x04, 0x00  ,0x16, 0x4E, 0x00, 0x00 , 0x20, 0x52 , 22, 0 , 0x17, 0x4E, 0x00, 0x00, 0x20, 0x52, 40, 0,  0x18, 0x4E, 0x00, 0x00 , ....     regarding the value 255: that was only a hint, which is about the High Byte. If the value is in the range 0-255 (dec) the high byte is 0 and the low byte is equal to the value, therefore it can be written in the buffer as [VALUE, 0] as above. For values > 255 (dez) it is easier to represent the number hexadecimal, because you can directly see the high/low byte. e.g. 16589 (dec) = 40CD(hex) => Low-Byte= 0xCD, High-Byte= 0x40        
  12. Mitsubishi FX5 read/write from PC with nodejs

    Hello David Ott, if there are only 10 registers you can of course simply write zero to the other registers (R19993-R19998) if these registers are not used in the PLC. If you do this, you should mark the registers as used/written in the device comments of the PLC, so that they are not accidentally used later. Alternatively you can use the function Test(Wrandom Write) to write only the selected registers, see page 133 in the SLMP manual https://dl.mitsubishielectric.com/dl/fa/document/manual/plcf/jy997d56001/jy997d56001j.pdf In both cases the values written are 16 Bit, that mean you have to write two bytes for each value (high byte and low byte, in the order LOW, HIGH). i.e. if the value to write is <= 255 (decimal) => High-Byte= 0x00, "var writeBuffer = new Buffer.from([0x03, 0xFF, 0x0A, 0x00, 0x16, 0x4E, 0x00, 0x00, 0x20, 0x52, 0x03, 0x00, input1format, 0x00, input2format, 0x,00, input3format, 0x00]);" if the value is > 255 the corresponding high byte must be written e.g. 16.589 (dec) = 40CD(hex) => 0xCD, 0x40  
  13. Mitsubishi FX5 read/write from PC with nodejs

    hi david ott, if you receive 192, 86 (81h, 5Bh) this is the error code, because the send request is wrong, i forgot that the send buffer also need the data in high order, to receive R20000 and following register use the following send buffer: let sndBuff= new Buffer([0x01, 0xFF, 0x0A,0x00, 0x20,0x4E,0x00,0x00,  0x20,0x52,   0x09,0x00]); 0x01 ... command: batch read word units 0xFF ... pc-no 0x0A, 0x00 .... timeout (000Ah) 0x20, 0x4E, 0x00, 0x00 .... start adress (00004E20h .... = 20000) 0x20, 0x52 .... register type (5220h = R-Register) 0x09 .... number of register to read 0x00 ... endcode inside the receive function you have to convert/combine the received bytes to an 16 bit value (signed/unsigned, depending on the data type used in the plc) Therefore you can use an Int16 Array or an UInt16 Array.   client.on('data', function(data) {     let buff= Buffer.from(data);     console.log('Received: ');     console.log(buff);     const int16array = new Int16Array(         buff.buffer,         buff.byteOffset,         buff.length / Int16Array.BYTES_PER_ELEMENT);     console.log(int16array);     const uint16array = new Uint16Array(         buff.buffer,         buff.byteOffset,         buff.length / Uint16Array.BYTES_PER_ELEMENT);     console.log(uint16array);     let value1= (buff[3] << 8 ) | buff[2];     let value2= (buff[5] << 8 ) | buff[4];     console.log('value1=' + value1);     console.log('value2=' + value2);     client.end(); });  
  14. Mitsubishi FX5 read/write from PC with nodejs

    hi David Ott, the response 91,16 (5Bh, 10h) is an error code, i think this is because the request you send to plc is wrong; -> could you show me the Request you send to PLC (for binary)? for your request string "01FF000A522000004E200900" (in ASCII) this should be something like: let sndBuff= new Buffer([1,255,0,10,0,0,78,32,82,32,9,0]); client.write(sndBuffer, ()=>{                 timeout= setTimeout(()=> {                     console.debug('error: timeout occured, no data received for last ReadRequest');                     EndConnection();                 }, 1500);   be aware that the position of the device code and the head device are switched in the binary version, see page 124 in the SLMP manual https://dl.mitsubishielectric.com/dl/fa/document/manual/plcf/jy997d56001/jy997d56001j.pdf    
  15. Mitsubishi FX5 read/write from PC with nodejs

    hi david ott, i think the problem is that you send the wrong request. If you set the data code to BINARY, you have to change the nodejs and the Request you send to the plc. The request has to be send as Bytre-Array and not as a string. Also the response data from the plc can't be interpreted as string all you recieve are bytes. The response is no longer the string "8100" (4 bytes) but only 2 bytes with the value 81h and 00h, and if you use console.log to visualize/show these two bytes are interpreted as utf-8 characters and console.log will show the corresponding symbols to see the received bytes you can use an Buffer object, so in your nodejs program change the client.on function to show the received bytes.   ///// nodejs (OLD) works for ASCII //////////////////////////////////// client.on('data', function(data) {     console.log('Received: ' + data);    <--- received data are ASCII coded so console.log can show them as STRING     client.end(); }); ///// nodejs (NEW) //////////////////////////////////// client.on('data', function(data) {     let buff= Buffer.from(data);     console.log(buff);                            <--- Buffer object hold the received Bytes, console.log show the received Bytes     client.end(); });