03-30-2020 12:49 PM
At what point would the changed values be inserted into the vi? When the binary file gets opened it configures the program with the bad values. How would I go about writing in the new values?
Sorry, I'm really new to this.
03-30-2020 12:50 PM
You have the code to read the file. Once you've read the file you have the existing data. The Write to Binary File is right next to the Read from Binary File in the palette.
Also, if you're new to LabVIEW then it would be beneficial to check out the training materials at the top of this forum. Also, NI is offering their online training courses free until the end of April. If you're charged with maintaining/developing LabVIEW code then the time spent in training will save you considerably more time in the long run.
03-30-2020 12:53 PM
@JayWW wrote:
At what point would the changed values be inserted into the vi? When the binary file gets opened it configures the program with the bad values. How would I go about writing in the new values?
Sorry, I'm really new to this.
You need to write a new program. Copy the read code from the old program. As BertMcMahan said you take the output from that Read from Binary File, modify the necessary values in it, and then write it back to file.
03-30-2020 01:13 PM
I think it's coming in as a single cluster, so you can use "Bundle By Name" on the wire going out. If it's an array you will need to choose which element, so use "Index Array".
Try this: first, make a copy of everything, because you risk overwriting your previous settings file.
Make a copy of the code you showed us, and remove everything except "Open file", "Read binary file", "Close file", and the cluster coming in to "Read". Right click on the output from Read file and select Create Indicator. Run the file, and see what that indicator says. It will give you the contents of the file. Show us a picture of that.
Probably the simplest way to do this would be to run the code I mentioned, then delete the wire between Read and the indicator, then right click the indicator and select "Change to Control" (so you can edit it), then wire THAT indicator into a Write to File function, then run the code again.
03-30-2020 01:15 PM
@johntrich1971 wrote:
@JayWW wrote:
At what point would the changed values be inserted into the vi? When the binary file gets opened it configures the program with the bad values. How would I go about writing in the new values?
Sorry, I'm really new to this.
You need to write a new program. Copy the read code from the old program. As BertMcMahan said you take the output from that Read from Binary File, modify the necessary values in it, and then write it back to file.
It might not even be necessary to do that. There should be VI in there to write the file in the first place (I am making an assumption here that it was at least somewhat modularly written). Just find that VI, update the front panel controls, point it to the file path you want to write, and run the VI. No coding or reading of the file necessary.
03-30-2020 01:49 PM
@BertMcMahan wrote:
I think it's coming in as a single cluster, so you can use "Bundle By Name" on the wire going out. If it's an array you will need to choose which element, so use "Index Array".
Try this: first, make a copy of everything, because you risk overwriting your previous settings file.
Make a copy of the code you showed us, and remove everything except "Open file", "Read binary file", "Close file", and the cluster coming in to "Read". Right click on the output from Read file and select Create Indicator. Run the file, and see what that indicator says. It will give you the contents of the file. Show us a picture of that.
Probably the simplest way to do this would be to run the code I mentioned, then delete the wire between Read and the indicator, then right click the indicator and select "Change to Control" (so you can edit it), then wire THAT indicator into a Write to File function, then run the code again.
Here's what the indicator outputted when looking at the output of the read binary file.
03-30-2020 02:25 PM
OK, buncha stuff there- I'd suggest doing what I said in my last post. Right click, convert to Control, wire to Write to File. Change the values on your screen then run the program.
03-30-2020 02:26 PM
@BertMcMahan wrote:
OK, buncha stuff there- I'd suggest doing what I said in my last post. Right click, convert to Control, wire to Write to File. Change the values on your screen then run the program.
How do I specify the output file path out of the "Output Digital File"?
03-30-2020 02:32 PM
You don't want "output digital file" you want "Write to Binary File". Mimic the same functions you used to Read the file, just swap the Read for a Write. Path is specified in the Open function. Right click on the terminal and select "Create constant" then you can edit the constant.
03-30-2020 02:59 PM
@BertMcMahan wrote:
You don't want "output digital file" you want "Write to Binary File". Mimic the same functions you used to Read the file, just swap the Read for a Write. Path is specified in the Open function. Right click on the terminal and select "Create constant" then you can edit the constant.
That worked! I saved the outputted file and replaced the old settings file with it and the new power supplies came alive! Thanks! There's no way I would have figured that out on my own. Still working on Core 1 of the Labview training. 😀