02-27-2020 03:55 PM
As usual cbuthers comments are spot on. The only addition I have is that I often find it useful to use a third party serial communication software to check the message structure. It also gives you a sanity check on whether it is your LabView software/serial cable or hardware which isn't working.
I'd recommend Putty, you will have to manually add the line feed and carriage return characters (<LF><CR>), see the link below.
02-28-2020 02:07 AM - edited 02-28-2020 02:08 AM
Good morning everyone.
@Henrik: Your example works as well. Very nice to see the real time change in a graph. This could come handy later. Attached you will find the screenshot.
@cbutcher:
Thanks a lot for the files. I think (hope) I can start playing around now. First I want to see if I am able to read out two different values (Plant Temp and maybe Set Temp) in one VI with your code. I think if I manage to do this I am a huge step further.
Unfortunately, I don't have much time today. And 0 over the weekend. But I promise I will be back next week and work on this script. So you won't get rid of me that easy 🙂
@Niatross:
I will have a look into this later. It's a valid point I guess.
Thanks again to all of your suggestions here. This is a tremendous help and I couldn't have done any of it without you guys. Much appreciated.
02-28-2020 02:26 AM
@Torracc wrote:
Good morning everyone.
...
@cbutcher:
Thanks a lot for the files. I think (hope) I can start playing around now. First I want to see if I am able to read out two different values (Plant Temp and maybe Set Temp) in one VI with your code. I think if I manage to do this I am a huge step further.
So I'd suggest (and you can feel free to disagree) that you'd be best off trying to first setup simple VIs (in the style of the Read Plant Temperature.vi I sent) that do a single command from your list in the first post.
After that, you can test them in the manner of the example VI, to check they work in a reasonable fashion.
Then, you probably want some sort of "Main" VI to combine them and trigger them based on button presses etc. I'd suggest reading about Event Structures and using one in a While loop to handle button presses and call subVIs (the simple ones you create in the first step) based on which button is clicked, then updating indicators or reading controls as appropriate.
You can also use Value Change events on numeric controls (e.g. "Setpoint" control or something) to call a VI like "Set Setpoint Temperature.vi" (I just made this name up, but whatever you call your Writing subVIs)). Or you can stick with boolean events, and read the numeric control values inside those cases of the Event Structure.
Good luck and feel free to post more questions here as you find them.
02-28-2020 02:39 AM - edited 02-28-2020 02:40 AM
SO it took me some tries but I figured how to read out 2 things in one VI. Not sure if you would do it like that. I tried to make them parallel (I guess that was intuition?) but then it only showed just one of them (either set or plant) and never both. I guess I kind of "stole" a path with the wiring in parallel and so I only got one value. I also needed to save two sub VIs, because when I changed the parameter in the set point read out to "S", it automatically changed the parameter "T" in the plant temp read out to "S" as well. I guess there is a better way than saving multiple sub VIs just for one different parameter. However, it kind of works.
Of course it is silly to read out the set point temperature. But I figured there are only two commands for a simple read out in the manual and that is set point and plant temperature. There is this option to read out the full status of the chiller with "R" but I guess this needs some fixing as it is multiple lines and not just one string to number.
02-28-2020 03:01 AM - edited 02-28-2020 03:03 AM
@Torracc wrote:
I also needed to save two sub VIs, because when I changed the parameter in the set point read out to "S", it automatically changed the parameter "T" in the plant temp read out to "S" as well. I guess there is a better way than saving multiple sub VIs just for one different parameter. However, it kind of works.
Hmm. Actually, that's exactly what I'd probably do.
My reasoning would be something like the following:
Does that make any sense?
Essentially, this is now beyond "how can I make this work" and into "how should I make this look/feel/work"?
You're now talking about the design of your driver, and making it "nice" for a "user" (even though probably the user is also the same person as the developer, i.e. you).
02-28-2020 03:04 AM
@cbutcher wrote:Does that make any sense?
100%
02-28-2020 04:18 AM
Okay so with Henriks VI I was able to identify some parts of the read out of the chiller. When I use "R" as a command I will get a weird output.
I THINK that I was able to identify the parts to the actual "values" of the chiller. So both the 070X are the Plant and Set Temperatures. I was able to cross check with the output of the "T" and "S" commands and they fit. So I figured the other ones need to be for the Control Flags, the Alarm Flags and the Pressure.
The values for Control Flags and Alarm Flags are always constant (A5 and 00), which makes sense I guess. The value for the pressure varies, which also makes sense.
Now how to convert these lines into real strings? That is the questions. For the Temperatures we convert hex string into numbers. So I figured that we would now need to convert hex string into "real" string. But I couldn't find anything simple for that when I googled it. So I guess that there is not a pre-set function for that?! Because then I would be able to read out the other parameters of the chiller as well (the pressure would be interesting, not sure what control and alarm flag really is).
edit: With just changing the offset to a high number (19 or 20) and changing the 100 to 1 I was able to read out the pressure! So with the offset I can just "cut" parts of the string, right? Maybe not the smoothest way of handling problems but it works 🙂
02-28-2020 05:57 AM - edited 02-28-2020 06:02 AM
@Torracc wrote:
Now how to convert these lines into real strings?
No, you convert them into actual values. Personally, I am a fan of the Scan From String function. You can define your entire response and pull out the values you care about. See Format Specifier Syntax for more information on building the format string.
02-28-2020 09:31 AM
@crossrulz wrote:
@Torracc wrote:
Now how to convert these lines into real strings?
No, you convert them into actual values. Personally, I am a fan of the Scan From String function. You can define your entire response and pull out the values you care about. See Format Specifier Syntax for more information on building the format string.
That is great advice. This safes so much space and I get all the needed information with just one function. I implemented that into my code. I was wondering about the two Flags though. In the manual they say
"Control Flags Status in Bit encoded Byte (2 chars)" and "Alarm Flags Status in Bit encoded Byte (2 chars)"
So does that mean that there is more information saved in the "10100101" and "00000000"? Because that would actually be the next part. To figure out if there are alarms.
I can read out the temperatures and the pressure now. That already makes 1/4 of my problem. So the 3 points missing would be:
- set the temperature (so don't just read it out)
- check for alarms (just for Alarm Flags like low flow or low level alarm)
- turn on/off the chiller (I think that's the "W" parameter)
02-28-2020 09:44 AM - edited 02-28-2020 09:53 AM
For the flags you can use Number to Boolean Array and optionally Array to Cluster (guide) to create an array or cluster of values.
The cluster is nice because you could create 8 boolean indicators and set their labels to the appropriate element of the alarms.
They'll be in order of the flags described in the manual (or perhaps reverse order, in which case you could list the booleans indicators in opposite order, or you could use Reverse 1D Array).
To set the plant temperature, the manual specifies a command of the format: ^JP xxxx^M where xxxx is degrees C * 100 as an ASCII representation of hexadecimal characters 0-F.
So to set the value to 25 degrees C, you'd want to give the value as the hex value for 2500, which is 09C4.
You can do this in LabVIEW like follows:
Here the format string specifies a hexadecimal string with 4 characters and 0 padding (with %4x you only get 9C4, which might not be sufficient).