Logging from Chromatograph


JohnyQuick

Recommended Posts

I want to use ODBC to get chromatograph data, that gets written to an escel file, after every chromatogram.

After I set up DSN ODBC in system administrator, then what?

Do I open db.open(file name)//

Select cell #(that I need in the file)???

Please!! can you supply some example code, and tell me where in Daqfactory do I put this sequence, as this is data that needs to be logged continuously, while the "document" is open.

B)

Link to comment
Share on other sites

Reading from an excel file using ODBC is going to be questionable at best since Excel is really a spreadsheet, not a database. Any chance you can get your chromatograms written to a csv file or some other text or binary format? Then it would be much easier to read using the File. functions. As for db.open(), you specify the data source, not the file name. DAQFactory never deals with file names when using the db. functions, only data sources.

Link to comment
Share on other sites

Thanks for helping.

Yes, I already have a macro that grabs what I need from the chromatograph's excel file, and writes to a text file.

So, using the file command, opens the file, but then what? How do I match the information from the file to different channels in DF?

Link to comment
Share on other sites

OK, I have somewhere to start , thanks again.

I see in the user manual page 255, about "read a file and set an output channel from its data"

I will probably write a new macro to format into a .CSV file for the stuff I need.

The example in the manual isn't exactly what I need, but close enough I guess., to get the ball rolling for today.

:rolleyes:

Link to comment
Share on other sites

Well,

After much frustration I got your , 9.10.1 Write data to a file from a sequence

from the help file to work, but only after adding a "\" into the sequence. The create file, and read file examples do not work, and I can't get them to work. From your help file-they don 't work, when copied word for word.

I need to log data from a text file, that will get from an excel spreadsheet, via a macro that makes a text file.

If , the examples would work, I might find out what format my text file needs to be.

For now, the text file, I use, is line-per line to send to a wits level 0 OPC server, but I can change that:

Here's the current text file that I need to log.

&&

01400

121230

12130

12145

12150

12180

!!

These have witts codes concantenated to the values that I want to log into DF, so obviously, my text file for DF, will be different.

These channels, top to bottom are,

totalgas

c1

c2

c3

c4

c5

except for the &&, and !! lines, that go together with wits level 0.

So. everything is 0, except for c1, in my example.

Can you provide an example of logging from a text file, into DF, that works?

I don't care if its comma deliminated or not, just something that works, which the help file doesn't show me.

Link to comment
Share on other sites

9.10.1 is for writing to a file (i.e. logging to a file). You are trying to read from a file, not write to it, so this is the wrong section to look at anyway. As for the need for \, I'm guessing its because you copied the script out of the help and there was word wrap and it inserted a carriage return.

What you want is section 9.10.2, specifically step #3 is the script to read the file. This is for a csv file, however, and to know how to process your file, I'd really need the actual file and not just a cut/paste into the forum. You can attach the file to your post.

Link to comment
Share on other sites

Ok, I'm just a beginner here, take pity, and I'm thinking I do need to READ this file:

PacificSystems.txt--attached

This is tha data I need from Excel-scrubbed using a macro. It is a text file-non comma deliminated.

First line is total gas

second line is c1

third line is c2

4th=c3

5th=c4

6th=c5

In my example file, c1=30, c3=5, and everything else is 0

Now, I'm guessing the obvious, I need to LOG these in DF as Variables , right?

Or can I LOG these as Channels? Probably not channel outs thought, like the example in Help. Right?

I don't know what I'm doing, can you write some lines for me?

I did get the readfile example to work, but I can't tell, and I don't think its what I need anyway.

I am thinking I need to read my file and set the lines as variables.

PacificSystems.txt

Link to comment
Share on other sites

"LOG" is the wrong term. Log means storing the value on the disk. Putting it into a channel or variable is not logging the value.

The sample code in 9.10.2 is actually almost exactly what you want. Use an output channel just like the example, though name it something more appropriate for your application. The only difference in your code (besides the file and channel name) will be the 2 lines that put the data into the channel. In the sample, they are:

MyChannelNameOut_0 = StrToDouble(Parse(strIn,1,","))

MychannelNameOut_1 = StrToDouble(Parse(strIn,2,","))

All you need is:

MyChannelNameOut_0 = StrToDouble(strIn)

OK, well its more complicated than that. Let's assume you created output channels named c1 through c5 and one called TotalGas. The script to completion will read:

// Opens the file sets the variable FileHandle
Private FileHandle = File.Open("C:\PacificSystems.txt",1,0,0,1)
Private string strIn
strIn = File.Read(FileHandle)
if(strIn == "")
   file.close(filehandle)
   return  // no data
endif
TotalGas = strToDouble(strIn)
private count = 1
while (count < 6)
   // read the next line
   strIn = File.Read(FileHandle)
   // This checks for an empty string
   if(strIn == "")
	  // Breaks out if empty string
	  break
   endif
   execute("c" + count + " = strToDouble(strIn)")
   count++
endwhile
// Closes the file
File.Close(FileHandle)

Its largely the same thing. First I read the first line and put it into TotalGas. Then I loop through the next 5 lines. The execute() function simply builds a line that looks something like:

c1 = strToDouble(strIn)

but changes for c2, c3, etc each iteration (which corresponds to a line coming in from the file).

Link to comment
Share on other sites

Ok,

Thanks,

I copied the code you supplied and made a sequence, and made a button to start the sequence, but when I

put a "Variable Value Component" on page0 for total gas, c1,c2,c3,c4,c5, all I see is the voltage alternating for the test channel. I don't see my values from my example file.

I'm missing something , but don't know what's wrong.

My channels for total gas through c5 are set up:

device type=test

device#=empty

I/O type =A to D-Does I/O type cover my bases for channel out??

channel numbers are 9 to 14

timing is 1.0

conversion=none

Is there anything special for output channels, that I'm forgetting to do?

When I start the read sequence, there are no error messages, in the command /alert window.

Any Ideas for what's wrong?

I want to display the values from my file, onto a DF page, and then connect to daqconnect, so the Boss can see his chromatograph readings from the field, while he connects from the office.

My example file: "pacificSystems.txt" will get updated, through a macro, about every .5 minute.

So new chromatograph data gets displayed in DF.

I also want to set up a Logging of these "output" channels

This is just one of many DF problems that I am trying to accomplish, and this is the first.

Link to comment
Share on other sites

A to D means analog to digital and is an Input, not an output. You need D to A. You can tell its an input because it has non-zero Timing and allows you to change it. Output channels always have 0 timing and you can't edit it.

Link to comment
Share on other sites

1st off, where do you find a chromatograph that takes samples in 30 seconds??!! That's crazy fast!!

But as for your needs, yes, AzeoTech is correct (as he is the Guru!) when he says you need the File. functions...

I do similar things with our singles (pipe sizes) so I can keep a tally...I am though reading from a .csv file created from with-in DF...

You could take on the challenge of making your own chromat, as we are fiddling in, but it gets hairy!

(We run an SRi FID 8610C currently, customizing a driver, and manipulating the graphs to read areas can be a pain!...AzeoTech, do you still script-for-hire? We really want to get this part finished.)

Glad you found this place, and welcome JohnyQuick!!

Link to comment
Share on other sites

Thank you Azeotech!

It is working now, and I may just need your script for hire offer. I have all the usual problems for mudloggers, like depth-rop-lag depth-lag gas, OPC client for WITS, and others.

I want to set up two options for ROP. They both are A to D channels, where one runs off a pressure transducer, and the other will grab its data from an encoder on the draw-works.

I almost have something to show the Boss, as far as the chromatograph goes. I need to fiddle with network settings, as the excel file, will be running on a separate computer, and DF will have its own computer as well-probably a runtime version.

If anyone wants to show some script for a bristol ROP, I'm all ears, Beehay. :rolleyes:

Link to comment
Share on other sites

If you find lag depth, there is no reason for lag gas!

Do you use LogPlot? If so, you need seperate mulit-curves, one for straight across depth, rop, and spm, and the other multi-curve would be lag depth and gasses...

:rolleyes:

Well as for Bristol ROP, you're not necessarily calc'ing ROP from it, but counting Depth and then getting DRate from the time of each foot...

Do you have your pressure transducer scaled showing the Kelly movement?

You most definitely need a "zero" and "span" (much like the screw heads that are on most transducers and the coarse/fine adjustment in the Bristol housing) to scale your "digital bristol pen".

Once you can see the bristol in a time based chart, moving up and down, that is half the battle...

It can get rather intense in counting depth with the bristol, there are many variables involved and more than one sequence to get drate from it...

That being said, I use a "high set" and "low set" for my logic on "connection made" and "kelly down"...That also depends on what size rig it is...Is it a double? Triple? The high set must be something that wont "click" while they are wiping, so usually you can set it to a number if you watch your bristol variables number when they make a connection...(high set)

I usually set my low set variable to 0.25 of a foot and add it back at the end of the loop. I set it high enough to catch the depth loop and end it, but low enough to not miss too much...(I've seen a few bones at the end of a single and it miss a little on a slow drate...)

So if your bristol travels above the high set number, you know it is making a connection, and time to begin the depth counting sequence -

   
if(Kelly > KellyHighSet)
   beginseq(Depth)
endif

I can't really just copy and paste my depth sequence in here, because I've been modifying, brainstorming, creating that sequence for years now! It is kind of a custom sequence I'd rather not share...It is fairly basic though, a few things involved off the top of my head are - a number to start counting from (last kelly down), use a variable to hold pipe sizes, use your bristol movement to make things happen...High set = connection, (if bristol <= next pipe size, move forward)...Like I said, there are many things to make depth counting with a bristol happen..

:D

The issues I'm encountering now are, On/Off Bottom with the bristol...It's too jumpy when they brake on it, making it look like its moving upwards (minus depth) too much, need a WOB sensor...Kelly down to new connection to back on bottom time...I need to count the time from kelly down to back on bottom with a new pipe, and remove it from the drates time...It makes the 1st new foot look slooooow! :P Have to touch up the log at the end.

Hope this helps and ask away, and I'll help as much as I can...

BeeHay

Link to comment
Share on other sites

Here are a few screenshots if you are more of a visual person like me!

1st pic is a pop-up to control the bristol...Notice the zero and span!

2nd pic is an area where you can "override" the depth numbers..(if it gets off track!)

3rd pic is an older graph with the bristol in brown, spm in green, catalytic gas in blue, petroleum vapors in black, and thermal gas in red...See how when a connection is made, the spm and gasses go down? Working as it should!

:rolleyes:

post-222-1306517222_thumb.jpg

post-222-1306517231_thumb.jpg

post-222-1306517235_thumb.jpg

Link to comment
Share on other sites

Thanks BeeHay,

I've come up with a similar logic for the sequences,

While bristol[0] < bristol high

do rop sequence

do also depth sequence

Span=bristol high/bristol low-done in a calibration sequence.

I haven't thought about zeroeing the transducer, since span is what I'm after to calculate

depth, and rop, in different sequences.

I have not connected my transducer to labjack, as I don't have labjack yet.

It's 4-20 mamps so I'll use a precision resistor to get the voltages right.

Whatever bristol low is from the calibration, will be kelly down.

Not even close to graphing anything yet.

But you're right, stopping and starting during a single, opens a can of worms. I'll have to think about the

logic for that. Don't want to rig up wob sensors.

I'll start a bristol thread, when I get started.

Thanks again for your help.

Link to comment
Share on other sites

Right on JohnyQuick!

Sounds like you're on the right track!!

About the LabJack, I would recommend the U6 Pro for the high resolution, and the LJTick-CurrentShunt for your mA devices -

Current Shunt

U6 Pro

Cole Parmer makes some nice voltage transducers if you ever think about switching that up...

About finding DRate, you'll need to find 1 foot increments first, so you'll need a variable to place the depth number in to compare it to the newer depth number -

private depthvar = Depth[0]

while(Depth.Running)
   waitfor(depthvar &lt; Depth[0], 1)
   depthvar = Depth[0]
   //do a bunch more stuff here
endwhile

Do you use a 96 minute Bristol clock? Do you have a chart showing the differrent rates for different minutes and feet?

A key thing to remember is decimal seconds and DF uses seconds since the first day of 1970 in all of its variables times...

So if you can find your 1 foot increments, and then get the time from each of those marked feet, Drate comes easily!

To get time from a variable, use .Time - Depth.Time[0]

Anyway, there is a TON of stuff to accomplish! If you get stuck, you are at the right place for questions!!

AzeoTech, it looks like your forums are becoming more popular for the drilling field!! Woo hoo!! :rolleyes:

Have a good one JohnyQuick!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.