Form app based upon example code doesn't always work

Post your .Net discussions here
Post Reply
TimOster
Newbie
Posts: 0
Joined: Mon Dec 01, 2014 5:36 pm

Form app based upon example code doesn't always work

Post by TimOster » Fri Jul 13, 2018 7:03 pm

I took the BlockGui example code and used it as a template to build a vb.net form app. My app allows you to select any available v/div, AC or DC coupling, timebase, numsamples....all the various trigger parameters...all the signal generator parameters. Pretty much everything. I then use the example for a Block collection. The only thing extra is that I output the data to a csv file, in the same portion of code the example puts it into the textbox.

The problems I'm having, are: First, the adc to mV conversion doesn't seem to be correct. Scope captures using the Pico app show the correct amplitudes, but when I use the app, they are not correct at all. The second problem is that sometimes it collects the data as expected, but other times I either get garbage, or the data seems to have large amounts of pretrigger data in the set.

I need some help on these issues, which I'm sure are in how I wrote the code. The purpose immediately of learning to write code using the PicoScope 2205A, is to capture the response of a sensing coil. We use the sig gen to output a squarewave, 1V at 1KHz, into an induction coil. The sense coil under test sits inside this induction coil, and senses the field we induce. We only need to look at one cycle, which shows the charge as an induced voltage, and when the squarewave drops, the induction coil decays and we see the discharge on the sense coil.

We've been doing this manually, using a Pico 2204, but I'm trying to make this an automatic test so I can dump the data into our Production Database. That and people who don't know anything other than how to read instructions, can run the tests for us. I attached a png file showing the response. In my app, I don't need all the data before the rise time.

I'd be happy to email all the code I've been using to you, as well as captured data, both good and bad and screen shots of the settings I'm using. I also have the ...psdata and ...pssettings files we are currently using.

Regards,
Attachments
freecoildata.png

Hitesh
Site Admin
Site Admin
Posts: 2805
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Form app based upon example code doesn't always work

Post by Hitesh » Mon Jul 16, 2018 8:00 am

Hi Tim,

It might be useful to send your code to support@picotech.com so we can investigate further.

For the millivolts conversion, it might be useful to know example ADC counts and the resulting output for you (the channel range will be required for this).

From the screenshot, I can see that you are using an auto trigger, which triggers automatically after one second. This could be one of the reasons why you sometimes see 'garbage data' if the trigger condition has not been made in that time.

Regards,
Hitesh

Technical Support Engineer

TimOster
Newbie
Posts: 0
Joined: Mon Dec 01, 2014 5:36 pm

Re: Form app based upon example code doesn't always work

Post by TimOster » Mon Jul 16, 2018 3:50 pm

I've tried sending the code via email but everything I could think of was getting rejected. Zip files, the actual code, I even renamed the files as .txt.

The last attempt I copied the code into the email text. So far I haven't gotten a rejection, actually I just got the response from your site, so I guess it got through.

Sorry for doing it that way. I guess in the future I might try setting up a GitHub account and posting it there. I did that when I was taking course work online via edX.org.

Thanks.

TimOster
Newbie
Posts: 0
Joined: Mon Dec 01, 2014 5:36 pm

Re: Form app based upon example code doesn't always work

Post by TimOster » Mon Jul 16, 2018 5:58 pm

I think I figured out my trigger problem. I didn't read the reference well, I was telling the scope to trigger at 100 as in mV, but I see I needed to use the adc counts. My bad.

I'm still having trouble with the amplitude results though. I don't seem to be getting the correct answer from the adctomv function.

I've tried passing in the index of the VoltageRange structure and the verbal range, VoltageRange = 3 or VoltageRange.PS2000_500MV. I still get the wrong answer for amplitude. I'm seeing roughly 1/2 what I should see.

I'm also confused by the range selection in general. The signal is about 175mV peak, but if I use the 200mV range I see the results clipped. Isn't the +/-200MV range from -200mV to +200mV? I'm having to use the +/-500MV range to not see the waveform clipped.

TimOster
Newbie
Posts: 0
Joined: Mon Dec 01, 2014 5:36 pm

Re: Form app based upon example code doesn't always work

Post by TimOster » Mon Jul 16, 2018 6:47 pm

Mystery solved. I'm not sure if this is an error in your example code or not. In the Imports class you have a line as follows:

Public inputRanges() As Integer = New Integer(12) {10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000} ' ranges in mV

That array contains voltage ranges that do not exist in the 2205A. I edited it as follows:

Public inputRanges() As Integer = New Integer(8) {50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000} ' ranges in mV

That gets the ranges limited to those that exist, however in the function to convert adc to mV lower in the code, you are using range, when it should be range - 1 to account for zero.

After editing those two spots, I get the same results from my code and from the PicoScope 6 software.

The array might be due to the example being for more models, however the range - 1 part is probably something that is needed regardless.

Cheers.

Hitesh
Site Admin
Site Admin
Posts: 2805
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Form app based upon example code doesn't always work

Post by Hitesh » Tue Jul 17, 2018 8:04 am

Hi Tim,

Thanks for the update.

The enumeration range is to ensure it is in line with other product ranges (PicoScope 6 uses the same API functions).

With regards to the millivolt conversion, I'll contact you via the support ticket you have with us.

Regards,
Hitesh

Technical Support Engineer

Post Reply