Code Monkey home page Code Monkey logo

Comments (11)

cmseaton42 avatar cmseaton42 commented on August 11, 2024 1

Also, I recommend doing the following as it will limit the number of payloads to the PLC though I don't think it will fix your issue.

const { Controller, Tag, TagGroup } = require("ethernet-ip");
const fs = require("graceful-fs");

const delay = require("delay");

const PLC = new Controller();

const voltajeLineaAN = new Tag("TDLOW_PQMII.VOL_VAN");
const voltajeLineaBN = new Tag("TDLOW_PQMII.VOL_VBN");
const voltajeLineaCN = new Tag("TDLOW_PQMII.VOL_VCN");

const voltajeFaseAB = new Tag("TDLOW_PQMII.VOL_VAB");
const voltajeFaseBC = new Tag("TDLOW_PQMII.VOL_VBC");
const voltajeFaseCA = new Tag("TDLOW_PQMII.VOL_VCA");

const energiaReal = new Tag("TDLOW_PQMII.ENY_POS_REAL");

// Use Tag Group
const group = new TagGroup();
group.add(voltajeLineaAN);
group.add(voltajeLineaBN);
group.add(voltajeLineaCN);
group.add(voltajeFaseAB);
group.add(voltajeFaseBC);
group.add(voltajeFaseCA);
group.add(energiaReal);

console.log("Tablero - TD_LOW_1");

const fecha = new Date().toISOString();
const fila = `VOLTEJE-AB;VOTEJE-BC;VOLTEJE-CA;VOLTAJE-AN;VOLTEJE-BN;VOLTAJE-CN;ENERGIA\n`;

fs.appendFileSync(`${__dirname}/archivos/${fecha}.txt`, fila);

PLC.connect("172.30.0.85", 0).then(async () => {
    while (true) {
        try {
            await PLC.readTagGroup(group);

            let fila = `${voltajeFaseAB.value};${voltajeFaseBC.value};${voltajeFaseCA.value};${
                voltajeLineaAN.value
            };${voltajeLineaBN.value};${voltajeLineaCN.value};${energiaReal.value}\n`;

            await fs.appendFile(`${__dirname}/archivos/${fecha}.txt`, fila);
        } catch (error) {
            console.log("error", error);
        }

        await delay(100);
    }
});

from node-ethernet-ip.

guillermoLeon26 avatar guillermoLeon26 commented on August 11, 2024 1

The incorrect values were produced by a fault in the sensor that is connected to the PLC, now it works perfectly, I am also testing it in another PLC and so far everything works fine

from node-ethernet-ip.

cmseaton42 avatar cmseaton42 commented on August 11, 2024

Can you post a snippet of your code?

from node-ethernet-ip.

guillermoLeon26 avatar guillermoLeon26 commented on August 11, 2024
const { Controller, Tag } = require('ethernet-ip')
const fs = require('graceful-fs')

const delay = require('delay')

const PLC = new Controller()

const voltajeLineaAN = new Tag('TDLOW_PQMII.VOL_VAN')
const voltajeLineaBN = new Tag('TDLOW_PQMII.VOL_VBN')
const voltajeLineaCN = new Tag('TDLOW_PQMII.VOL_VCN')

const voltajeFaseAB = new Tag('TDLOW_PQMII.VOL_VAB')
const voltajeFaseBC = new Tag('TDLOW_PQMII.VOL_VBC')
const voltajeFaseCA = new Tag('TDLOW_PQMII.VOL_VCA')

const energiaReal = new Tag('TDLOW_PQMII.ENY_POS_REAL')

console.log('Tablero - TD_LOW_1')

const fecha = new Date().toISOString()
const fila = `VOLTEJE-AB;VOTEJE-BC;VOLTEJE-CA;VOLTAJE-AN;VOLTEJE-BN;VOLTAJE-CN;ENERGIA\n`

fs.appendFileSync(`${__dirname}/archivos/${fecha}.txt`,fila)

PLC.connect('172.30.0.85', 0).then(async () => {
  while (true) {
    try {
      await PLC.readTag(voltajeLineaAN)
      await PLC.readTag(voltajeLineaBN)
      await PLC.readTag(voltajeLineaCN)
      await PLC.readTag(voltajeFaseAB)
      await PLC.readTag(voltajeFaseBC)
      await PLC.readTag(voltajeFaseCA)
  
      await PLC.readTag(energiaReal)

      let fila = `${voltajeFaseAB.value};${voltajeFaseBC.value};${voltajeFaseCA.value};${voltajeLineaAN.value};${voltajeLineaBN.value};${voltajeLineaCN.value};${energiaReal.value}\n`

      await fs.appendFile(`${__dirname}/archivos/${fecha}.txt`, fila)

      // console.log('Voltaje AN', voltajeLineaAN.value)
      // console.log('Voltaje BN', voltajeLineaBN.value)
      // console.log('Voltaje CN', voltajeLineaCN.value)
      // console.log('Voltaje AB', voltajeFaseAB.value)
      // console.log('Voltaje BC', voltajeFaseBC.value)
      // console.log('Voltaje CA', voltajeFaseCA.value)
  
      // console.log('Energia Real', energiaReal.value)
    } catch (error) {
      console.log('error', error) 
    }

    await delay(100)
  }
})

from node-ethernet-ip.

jhenson29 avatar jhenson29 commented on August 11, 2024

Have you verified that the values in the PLC aren’t actually doing this?

from node-ethernet-ip.

guillermoLeon26 avatar guillermoLeon26 commented on August 11, 2024

I am comparing the values with those that scada cimplicity throws at me, and that does not happen there.

Maybe it's because the scada cimplicity is already getting information

from node-ethernet-ip.

cmseaton42 avatar cmseaton42 commented on August 11, 2024

does the spike happen consistently, say after every 8th scan? or is it random? Also, is simplicity scanning at roughly the same rate you are?

from node-ethernet-ip.

kyle-github avatar kyle-github commented on August 11, 2024

The value you get is very suspicious: 16187392r10 = F70000r16. The underlying protocol just reads the bytes in the tag. I am not familiar with how node-ethernet-ip is handling those. JavaScript is not the most fun language in which to handle binary data.

Based on the value in hex, I would be looking at the PLC program or the sensors first.

from node-ethernet-ip.

guillermoLeon26 avatar guillermoLeon26 commented on August 11, 2024

Thanks for answering

The peak occurs randomly and of varying magnitude. And yes I scan at the same speed as simplicity, but when I slow down the scan the same thing happens

I'm going to try another plc with a slower scan speed, I think that plc has problems because by checking I found that there are some memory overflows but I don't know exactly where they are, I'm going to keep investigating

from node-ethernet-ip.

cmseaton42 avatar cmseaton42 commented on August 11, 2024

What are the underlying datatypes of the tags? PLC scan time shouldnt matter I dont think but overflowing memory in the PLC could be your issue. If you are using COP or CPS anywhere in your PLC program, then you may be overrunning whatever you are copying data to and writing to the value of your target tag.

from node-ethernet-ip.

cmseaton42 avatar cmseaton42 commented on August 11, 2024

Awesome, glad you got it figured out. I'm gonna go ahead and close this issue. :)

from node-ethernet-ip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.