Discussion:
Converting data stream for database insert
(too old to reply)
ControlAutomation
2008-08-09 23:40:04 UTC
Permalink
This might seam like a rudimentary question, but what is the simplest way to prepare the data stream coming out of the DAQ Assistant so that it can be inserted into a database using the DB Tools Insert Data vi?  I am trying to stream one voltage channel from a CompactDAQ voltage card into a database and keep getting a type mismatch error from the DB VI.  When I set the table create to true, the function runs but inserts the text "Long binary data" of type "OLE Object" inserted into the rows of the database.  From the examples it looks like I need to use an array or a bundle but I'm not quite sure how to do this.
 
 
 
 
MikeS81
2008-08-10 17:10:05 UTC
Permalink
Hi ControlAutomation,you can tranform your "dynamic data" into an array of waveforms, or an array of double values. Transform these values into string, this should work to insert it into your database.Hope it helps.Mike
ControlAutomation
2008-08-10 18:40:05 UTC
Permalink
Thanks Mike,
What function would I use to transform the output into an array of floats?  Would I use "build array"?  I'm not exactly sure what format the data stream coming out of the DAQ Assistant is.  I'm used to dynamically allocated and sized arrays in VB or C++.  All of the examples and tutorials I have looked at speak to fixed-sized arrays that are represented on the front panel.  Do you know of an example that takes the output from the DAQ Assistant and puts it into a database?
Mike V.
MikeS81
2008-08-11 07:10:05 UTC
Permalink
Hi Mike V.,
this should work for you.
 
<img src="Loading Image...">
&nbsp;
Mike


DAQ2Database1.PNG:
Loading Image...
ControlAutomation
2008-08-11 14:10:10 UTC
Permalink
Forgive my Labview ignorance, Mike.&nbsp; But could you indentify the functions in this bitmap?&nbsp; Also, will this work with more than one channel coming out of one DAQ Assitant block or do I need to create one DAQ Assistant for each channel that I want logged?
&nbsp;
Thanks,
Mike V.
MikeS81
2008-08-11 14:40:06 UTC
Permalink
Hi Mike V.,
it´s possible with more than one channel, i confogured to channels. The first vi is the DAQ assistent, convert dynamic data, number to fractional string and then to variant.
&nbsp;
Hope it helps.
Mike
ControlAutomation
2008-08-11 19:40:07 UTC
Permalink
This post might be inappropriate. Click to display it.
MikeS81
2008-08-11 19:40:08 UTC
Permalink
Hi Mike v., normally "2d Array..." should work. Please see the attached example.Hope it helps.Mike


DynamicData_LV71.vi:
http://forums.ni.com/attachments/ni/170/348418/1/DynamicData_LV71.vi
ControlAutomation
2008-08-11 20:10:06 UTC
Permalink
I tried the string conversion - same result in the database - "Long Binary Value".&nbsp; The attached VI inserts the timestamp fine (Column 0) and then shows "Long Binary Data" for each of the four channels (Columns 1-4).&nbsp; I must be missing something obvious.&nbsp; Any further ideas?


DB Logging with DAQmx.vi:
http://forums.ni.com/attachments/ni/170/348426/1/DB Logging with DAQmx.vi
ControlAutomation
2008-08-12 12:10:10 UTC
Permalink
Hi Mike,
Thanks ! You have been most helpful !&nbsp; I managed to get this working by splitting the DAQ Assistant output data stream into 4 channels, then converting each dynamic channel to a single scalar, then feeding each of these into an element of a bundle (with one node of the bundle coming from the real time clock) and then into the DB.Insert.&nbsp; This worked, however insertion speed was limited to about 200-300 records per second.&nbsp; This can't keep up with my 32KHz requirement so I have had to resort to using a TDMS file to buffer the incoming data.&nbsp; Now I want to read the TDMS file back into the database.&nbsp; I thought the output data stream from the TDMS read was the same as the DAQ Assistant output but when I perform the same conversions, my data is all zeros when it hits the database.&nbsp; Any idea what I might be missing?
Thanks,
Mike V.
ControlAutomation
2008-08-12 13:40:19 UTC
Permalink
Never mind Mike.&nbsp; All I had to do was put the read TDMS file outside the while loop.&nbsp; It seems to be working now.
Continue reading on narkive:
Loading...