DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Dasylab via RS232

Solved!
Go to solution

Good morning!

 

I am going to use dasylab for a small controll. I would like to controll 3 adjustable transformers. The pc with the NI USB-6210 is near the transformer. Via RS232 I would like to controll the transformers from the control room. I connected the two pc´s (One near the transformer and one in the controll room)  with a RS232 cable. Is it possible to use the RS232 input in dasylab for this purpose? I am just at the beginning of this project, and I am glad about all informations and advices you can give.

 

Thanks a lot and have a nice day

 

Hilby

0 Kudos
Message 1 of 9
(7,631 Views)

You would need the output model in DASYLab for sending data out and input module for receiving data.

 

Are both computers going to use DASYLab?  Because you could use and create the application in DASYLab in the computer by the transformer and then use an app like TeamViewer to remote controll it.

This would also allow you to controll it from any other computers as long as the control computer is connected to the INternet.  This would also save you a second DASYLab license

 

Tom Rizzo
InSyS Corp.
www.insyscorp.com
Your DASYLab integrator
0 Kudos
Message 2 of 9
(7,626 Views)

I haven't tried it, but possibly... you will need a "Null modem" type of cable.

 

Alternately, if you have  network, you can use the DataSocket Server to store and serve data between two computers. This DataSocket server is installed with DASYLab.

 

One DASYLab can write to it, the other can read from it. Expect update rates to be 1-10 seconds, depending on the network configuration.

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
0 Kudos
Message 3 of 9
(7,625 Views)

Hallo again!

 

I have tried the rs232 configuration. Another dazylab configuration is not possible for me. Also there is no internet connection at the second PC.

 

I can now send decimal as ASCII values per HyperTerminal to my dazylab configuration.

 

What I now tried is a bit more complicated. I wish I could have some kind of verification. Some kind of message type declaration at the beginning.

 

For example: I would like to send an ASCII string like:

 

"New transformer Voltage: 300 \r\n"

 

Then I want dasylab to find out that the string starts with New transformer Voltage. If this is true, than Dasylab should save the 300 as an value in a global variable.

This is how it would look in cpp (The content of new_message is "New transformer Voltage: 300 \r\n"):

 

int i=0;
while (new_message[i]!=':')  //do this untill you reach ":"
{
my_message[i]=new_message[i]
i++;
}
if (strcmp(mymessage,"New transformer Voltage")==0)  //compare the foiund string with the expected string
{
i=i+2;  //go two steps forward
while(new_message[i]=!'\r')  // do this untill you reach CR
{
temp[i-24]=new_message[i];  //save Voltage value in temp
i++;
} newvoltage=atoi(temp); //convert string to integer }

 

I did not tested this code, This was just what comes in my mind when thinking about this problem. I just want to prevent that the value for the transformer is changed when something wrong is comming through my rs232 connection. Another thing is that I have three different transformers and I have to declare which Transformer I want to change. Is there some kind of programming possible in dazylab? Do I have other possibilities?

 

I hope the code is okay, and that you can understand my issue.

 

I even have another problem: How can I write text which is coming through rs232 into global strings?

 

Thanks a lot and have a nice day.

 

Hilby

 

 

 

0 Kudos
Message 4 of 9
(7,594 Views)

Ok, two questions, maybe two answers...

 

the data format command for the voltage will be a quoted search string, followed by the format strings.

 

New transformer Voltage: 300 \r\n

 

Use: "New transformer Voltage: " a\r\n

 

DASYLab will search for that string and when it finds it, it will interpret the characters after the string as numbers until it sees <CR><LF>

 

To write text coming in from the serial port you have to dedicate a channel, and you cannot use that string for data, too.

 

Use $1\r\n to put a whole line into ${STR_1}

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
0 Kudos
Message 5 of 9
(7,591 Views)

Okay, I will try that!

 

Thank you and i will reply tomorrow!

 

Hilby

0 Kudos
Message 6 of 9
(7,585 Views)

Hi cj!

 

I have tried your solution. Works fine! Thank you. What I cannot realise until now is saving a string from rs232 in a global string, maybe you can explain your solution a bit?

 

I also have to controll if the target value is between 0V and 300V. I used the math box with a trigger (math box: In(0) > 0 AND In(0) < 300, trigger: value greater than 0.5, because the math box returns 1 if the expression is true). Is there a more comfortable solution?

 

 

Thanks a lot,

 

Hilby

0 Kudos
Message 7 of 9
(7,553 Views)
Solution
Accepted by topic author Hilby

For the RS232 string... we expect that the string must be delimited - for example, it ends with a <CR>. When you use the notation

 

$1\r

 

DASYLab will start at the current location, and put all characters into the Global string number 1 (${STR_1} in other modules) up to the \r (the <CR> character). It does not put the delimited into the global string.

 

If you use the store into global string, then it grabs everything on the line. If you need to anchor it better, use the quoted string to search for a unique header before the $1

 

"Unique text" $1\r

 

will interpret this line

 

Unique text can be stored into the global string<CR>

 

and store " can be stored into the global string" into the Global string 1. It anchors on the "Unique text" and terminates at the <CR>.

 

For the trigger... use the Pre/Post Trigger ... it's more reliable and outputs 0 or 5. 

 

 

 

Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.
Message 8 of 9
(7,551 Views)

Hey!

 

You are so great, thanks a lot!

 

Have a nice day!

0 Kudos
Message 9 of 9
(7,547 Views)