How to seperate values from msg.payload?

Hi all,

I am currently working on a project where I am using a Modbus-Read and a Modbus-Response node in order to receive information from an external equipment.

The equipment is outputting pulses which are then read by the Read node.

Here I have two issues, the first one being able to get a Gauge working with proper values.
What I want here is to read the RPM of an engine, so I want the gauge to display how many revolutions per minute the engine is having. What I am stuck with so far is that it only displays a total amount of counts since it has started, so instead of showing for instance 1500 RPM, it is showing the total value of 30000 revolutions / pulses since it started counting.

Is there any way to change the msg.payload to show the value as pulses per minute instead of the total count?

My string is currently:

With the Change node set up like this:
image

My gauge is currently showing:
image

But even thou the engine is active, it still does not show me the current RPM.
The Modbus-Response node receives all the pulses, but does not pass on this info to the gauge.

My second issue is that the engine sends out two pulses for every revolution, so the value would need to be downscaled by a factor of two. For instance, if my engine is running steadily at 2000 RPM, it would send out 4000 pulses per minute.

Appreciate all and any help with these issues.

Best regards,
Alexander

From what I can tell from the Debug node I am unable to read the values due to it being undefined:
image

How can I define the value of the pulses received?

What is the debug showing? The error is indicating that msg.payload.Value does not exist

In fact we need to see the output from a debug node showing what is going into the Change node.

As posted above: "TypeError: Cannot read property 'Value' of undefined"
I am fairly new to using Node-RED, so I am uncertain of which nodes to use to be able to convert my pulses / msg.payload into something readable, and in this case the pulses showing up at all on the Gauge node.

connect another debug to the bottom output of the modius node and show what is coming from it.

Now connected the debug node to the switch node:
image
Payload steadily increasing but not giving any values to the Gauge.

Update. Currently showing:
image

So the issue is that there is no msg.payload.Value' you could try msg.payload[0] in the change node.

image
Like this?

Or do you mean that I should Set msg.payload to msg.payload[0] ?

that is right, after all there is no msg.payload.Value and that was causing the error

1 Like

In that situation I prefer to use Move rather than Set, it is less confusing. So Move msg.payload[0] to msg.payload.

1 Like

Oh great! Now we're getting somewhere atleast:
image

Now I need to get it to show up as current RPM instead of total counts since it started up.
Is there a way to change it in a matter that makes it reads x-pulses per minute instead of total count?

As mentioned earlier this is all new for me, so thank you for bearing with me here!

how would you manually change that value to rpm?

As of now the engine sensor is connected to a barrier which converts 0-100Hz signals to 24V digital input pulses. So for every revolution the engine has, the Brainbox ED-008 (equipment I use to communicate with Modbus TCP) / Modbus node receives two pulses.

In example: engine running steady at 1500 rpm will send out 3000 pulses every minute to the modbus read / response.

So I would need some parameters defining the pulses to be read as x-counts per minute instead of x-counts in total. Does this make sense? Else I'll try to explain the issue in another way.

Can/what happens if the motor is running at 1500 rpm for an hour and it is pushed to 3000 rpm for the next hour?

If the RPM is always constant, tehn # pulses/ number of minutes should be the rpm...right?

If so, you could get the start time and count the pulses. Then, when you want to display the RPM's subtract start time (in minutes) from current time (in minutes) and devide the pulses by that value.

The motor will not be running at constant revolutions. It has a span from 0 revolutions per minute (rpm) and up to 4500 rpm. So I need something that converts the pulses to rpm instantly.

I understand that this might be hard. It should be simple enough to convert the pulses to revolutions, the tough part is to get these pulses as counts per minute since the values are constantly changing.

Any ideas?

Suppose the values were coming in slowly enough that you could work the value out by hand, how would you do it? Once you know that then we can work out how to do it in node red.

1 Like

Why does it send two pulses and is there a constant time or a variable amount of time between pulses? I.E. could you firugr out the rpm based on the time between the two pulses?

My drawing skills are rather poor:


But the principle is that the engine is connected to a "flag". The flag has two read points which is picked up by the sensor, telling the sensor how fast the engine is turning around. Since it has two read points, it sends out two signals/pulses for every full rotation.

The time between the pulses will be variable since the rpm will vary depending on what resistance the engine occurs during operations.

The engine is working kind of like a mixmaster / kitchen mixer, and it will process various liquids ranging from water - concrete, so the harder the liquid, the more resistance the engine will have -> jumps in rpm regarding to what it is processing.

What I am thinking of that could be a solution by hand, is to manage to get the engine running at a constant speed, and from there count x-pulses in a given amount of time and from there multiply it up to a minute.
Say for instance that I get 50 pulses in a 10 second span, then I could multiply it by a factor of 6 to get an average rpm. But this value will only work for that given rpm / speed of the engine.

Another way to approach this is by doing "future" predictions based on previous readings. Say for instance that the last 10 seconds I have had a reading of 88 pulses, this could predict what the next 10 seconds should read. Having a hard time trying to wrap my head around this myself. Have been working for 14 hours straight now and should probably call it a day soon.

I'll be working with this project forward, so any suggestions would be greatly appreciated. I'll check in again tomorrow morning (20:32 here in Norway now).