Crimson 3.0 Modbus registers to string.

haakonk

Member
Join Date
Jan 2019
Location
norge
Posts
5
Hello,

I have a sensor attached to the data station plus, which has several modbus registers i read from.

Forexample register 40038 is a 32 bit floating point measuring value and the next register 40040 has the parameter ID, parameter id 20 = RPM.

I am sending those values to a RAM6000 using Modbus TCP/IP and setting up my webplatform as a MQTT broker and sending my measurement values to the webplatform I am using.

The problem with this is that the measurement values I am sending has no context, so what I am trying to do is to get both the measurement value and the parameter ID into the same string so I can identify what parameter the measuring value has.

I have managed to make strings from arrays using the raw serial port using this program:
// declare local variable
int port = 2;
int i;
int j;


// clear the port's buffer
//ClearRx();

// print stop out of Port 2
PortPrint(port, "do sample\r\n"); //NB!! Return carriage and linefeed


int in = PortRead(2, 255);
// loop while there is data in the buffer, populating the array
while(in != -1) {
Zpulse.Array[i++] = in;
in = PortRead(2, 255);
Rs232.String();

// if something was received, build a string with byte 0-25
if(i > 0) {
Zpulse.Response = "";
for(j =0; j<=25;j ++){
Zpulse.Response += Zpulse.Array[j];
}
}
}

But I am strugling to get two Modbus registers into the same string, is this doable when the modbus registers have two different data types?
 
Your question gave me a headache, but I think I can point you the right direction. Download the Crimson reference manual at the bottom of the page here:


http://www.redlion.net/red-lion-software/crimson/crimson-31


Then look at IntToText() and DecToText() functions.

Il try to explain it better.
I have 2 Modbus registers i read, one for the measurement value and one for the parameter ID.

When i read these two registers they are stored in two separate Modbus registers.

Lets say i store the measurement value in register 1 and the parameter ID in register 2. The parameter ID for RPM is 22.
So when the motor is running at 1000 RPM it would look like this.
Register 1: 1000
Register 2: 22

What I would like to do is to put these two registers into one string so it would read 1000 22, or preferably into a ascii string so when i display the string it would say: 1000 rpm (49 48 48 48 9 114 112 109)

Hope this made it clearer.
 
Code:
someString = IntToText(register1,10,4) + "rpm" + " Whatever you want in the string \n";
Assuming that register1 is an integer then the output would be "1000rpm Whatever you want in the string\n"
 

Similar Topics

All, I must write the same value to a modbus register using on a Graphite HMI. Crimson prevents this, but according to technical support, the...
Replies
1
Views
1,261
I need some help transferring some data from an Anybus Module to a SQL database. Here's what I have so far: I created a Modbus TCP/IP Master...
Replies
3
Views
2,467
Good Morning everyone, Working on the next phase of my Crimson Project. I need to send 4 different Modbus Commands off of one button push. I...
Replies
13
Views
4,339
Hello all- I have a project using a RL Datastation Plus where I may need to move some Allen Bradley REAL tags over to the customers Modbus TCP...
Replies
2
Views
1,912
Hello, I am new to using Crimson 3 with Modbus TCP/IP Master protocol. I have a register 47101 that is packed with 16 bits for various on/off...
Replies
6
Views
4,365
Back
Top Bottom