Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

DPO4104 Oscilloscope - Saving .csv Multiple Times in C#

Post Reply
Jonathon Vinsko
Posts: 5
Joined: April 19th, 2018, 1:14 pm
Country: United States

DPO4104 Oscilloscope - Saving .csv Multiple Times in C#

Post by Jonathon Vinsko » June 11th, 2018, 10:23 am

Hello,

I have been working on a program in C# (Visual Studio 2017) that can save a .csv file multiple times. This CSV needs to include x-axis data as well as data from Channel 1 and Channel 2. The current issue I am running into is that I am unable to run the program more than one without power cycling my Oscilloscope.

I run my code and, when it goes to save Channel 2, the response from the first query (in my case, YMULT) seems to be coming back incorrectly. My code crashes at the parsing of the response, saying "System.FormatException: 'Input string was not in a correct format.'" Upon looking into Response, it is an empty string. I am unsure why I cannot communicate with the Oscilloscope multiple times. Do I need to reset it in some way?

As a side note, the same thing happens after I save Channel 1, crash, and re-run the code. The second time through, it does not save channel one, crashing with the same error.

I have attached my Visual Studio Solution zipped in a .rar file. Please let me know if you have any advice for my code or if more information is needed!

EDIT: I have realized that, upon zipping and attaching my file, my first query says 'TVA.Write("DATA:SOU CH1, CH2");' This was a form of the code that I was testing, and not how I have been running it. It should just say 'TVA.Write("DATA:SOU CH1");'

Regards,
Jon
Attachments
Test_TekVISANet.rar
(1.19 MiB) Downloaded 510 times

Dave W
Tektronix Applications
Tektronix Applications
Posts: 267
Joined: April 26th, 2010, 12:01 pm
Country: United States

Re: DPO4104 Oscilloscope - Saving .csv Multiple Times in C#

Post by Dave W » June 14th, 2018, 9:18 am

Hi Jonathan,

When you query the data from the scope with the CURVE? query, the data gets sent back with the block header (#45000 for example) followed by the raw data itself. After you have read all the data you will need to do one more read to read the return line character "\n" that the instrument outputs after the data. If you do this, you should be good the next time you go to read from the scope.

Jonathon Vinsko
Posts: 5
Joined: April 19th, 2018, 1:14 pm
Country: United States

Re: DPO4104 Oscilloscope - Saving .csv Multiple Times in C#

Post by Jonathon Vinsko » June 14th, 2018, 9:43 am

Hi Dave,

I am running a TVA.Read(out response); directly after my TVA.ReadBinary(out rawwave1); to clear the '/n' character. This does not fix the issue. The queries return an empty string "".

I am unsure if it is an issue with my oscilloscope or my software. Could someone maybe try running this on their own oscilloscope?

Regards,
Jon

Dave W
Tektronix Applications
Tektronix Applications
Posts: 267
Joined: April 26th, 2010, 12:01 pm
Country: United States

Re: DPO4104 Oscilloscope - Saving .csv Multiple Times in C#

Post by Dave W » June 14th, 2018, 1:34 pm

Hi Jonathan,

On line 43 of your code it says

Code: Select all

TVA.Write("DATA:SOU CH1, CH2");
This is invalid. While on Windows based scopes you may set DATA:SOURCE to more than one item at a time, on the DPO4104 you cannot. Change it to

Code: Select all

TVA.Write("DATA:SOU CH1");
The rest of it looks pretty good. I don't have a scope available to try it on though.

Jonathon Vinsko
Posts: 5
Joined: April 19th, 2018, 1:14 pm
Country: United States

Re: DPO4104 Oscilloscope - Saving .csv Multiple Times in C#

Post by Jonathon Vinsko » June 14th, 2018, 1:57 pm

Hi Dave,

I had previously posted an edit to my original post saying that I had accidentally left in a feature that I was trying out, and that was the attempt to save both channels. It is currently not working for me with the change that you asked me to make as that is what I originally had.

Regards,
Jon

Post Reply

Return to “Programming Support”

Who is online

Users browsing this forum: No registered users and 4 guests