Test and Measurement Forum

ps5000SetChannel

Post your VB and VBA discussions here

ps5000SetChannel

Postby Jay H » Thu Apr 15, 2010 2:27 pm

I gather this function should be called whenever I change a particular Channel (a,b,c,d, etc...)'s voltage range (i.e. the Vertical scale) or turn a channel off?

I actually store a default value (I use '99') as the Range index for each channel when the channel is off (i.e. unit.channelSettings( 'channelindex').range Obviously, this is out of the range of the inputRanges array.... I also turn the boolean flag .enabled to false.

Both of these values are passed to ps5000SetChannel.. I notice that the function returns "INVALID VOLTAGE RANGE" as expected. Not knowing the code in that function, I assume because the channel is off (i.e. enabled = False or 0 in terms of what I pass to the C DLL), this has no side effect does it? The function returns that non-0 status value whenever this happens although I have NOT noticed any problems with it.

Jay
Jay H
Newbie
 
Posts: 0
Joined: Wed Mar 31, 2010 2:13 pm

Re: ps5000SetChannel

Postby Robin » Fri Apr 16, 2010 11:28 am

I'm not sure if this will cause problems, but you should avoid doing it. Generally, the first thing that API functions do is check that the input parameters are in range. If one is found to be out of range, then the function may return immediately.

So in your case, you may not be disabling the channel.

Robin
Robin
Zen Master
Zen Master
 
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Re: ps5000SetChannel

Postby Jay H » Fri Apr 16, 2010 12:51 pm

OK, thanks, I changed it to some default value...
Jay H
Newbie
 
Posts: 0
Joined: Wed Mar 31, 2010 2:13 pm

Re: ps5000SetChannel

Postby Jay H » Fri Apr 16, 2010 1:54 pm

Ah, now I remember why I didn't 'fix' this initially.

I think your example may exhibit this strange result too as well as I played with it also.

I check to see whether the channel is enabled, if not, I pass it PS5000_5V which is what I initialize the channel too in the beginning.

I've noticed that if both channels are off and a valid value is passed to ps5000SetChannel, the loop in blockdatahandler that gets the timebase via calls to ps5000GetTimebase gets stuck in an infinite loop.

I tried it with the C code and it does the same thing. But, when I send ps5000SetChannel the value of '99' I get the bad Status report but it works fine. I get no data, but then again, the channels are off, so this is what I think would be expected. However, no infinite loop to ps5000GetTimebase though...

Jay
Jay H
Newbie
 
Posts: 0
Joined: Wed Mar 31, 2010 2:13 pm

Re: ps5000SetChannel

Postby Jay H » Fri Apr 16, 2010 3:17 pm

Well, I played with the code some more and I just don't do anything in BlockDataHandler if both channels are turned off, works. probably don't even need to go that far if the channels are off. Not going to collect much of anything anyway. :-)

Jay
Jay H
Newbie
 
Posts: 0
Joined: Wed Mar 31, 2010 2:13 pm


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests