ps6000SetExternalClock Error

Post your .Net discussions here
Post Reply
cjmorcom
Newbie
Posts: 0
Joined: Mon Mar 22, 2021 2:03 pm

ps6000SetExternalClock Error

Post by cjmorcom »

I am trying to synchronise a 6404C (firmware V1.7.5.0) with an external 10MHz clock signal connected to the AUX input.

I first setup a trigger on channel C using ps6000SetSimpleTrigger and then run ps6000SetExternalClock:

Code: Select all

Imports.SetSimpleTrigger(_handle, 1, Imports.Channel.ChannelC, threshold_lsb, Imports.ThresholdDirection.Falling, 0, 0);

uint ires = Imports.setExternalClock(_handle, externalSyncFrequency, threshold_lsb);

with the two functions defined as follows:

Code: Select all


[DllImport(_DRIVER_FILENAME, EntryPoint = "ps6000SetSimpleTrigger")]
internal static extern UInt32 SetSimpleTrigger(
        	short handle,
        	short enabled,
        	Channel channel,
        	short threshold,
        	ThresholdDirection direction,
        	uint delay,
        	short autoTriggerMs);
                        
[DllImport(_DRIVER_FILENAME, EntryPoint = "ps6000SetExternalClock")]
internal static extern UInt32 setExternalClock(
		short handle,
		ExternalSyncFrequency frequency,
		short threshold);
			
However, the call to ps6000SetExternalClock returns error 86, which I understand to be: PICO_TRIGGER_AND_EXTERNAL_CLOCK_CLASH

I can understand I would get this error if I was attempting to use the AUX input as both a trigger and external clock. However, the trigger is defined as channel C so it's not clear to me why I am seeing this.

Please can anyone suggest where I might be going wrong or what this error really means?

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: ps6000SetExternalClock Error

Post by Martyn »

Can you try issuing the ps6000SetExternalClock immediately after the ps6000OpenUnit call.

Please note that once set the external clock will be used until the unit is power cycled.
Martyn
Technical Support Manager

cjmorcom
Newbie
Posts: 0
Joined: Mon Mar 22, 2021 2:03 pm

Re: ps6000SetExternalClock Error

Post by cjmorcom »

Thanks, will try when I’m back in the office on Friday…

cjmorcom
Newbie
Posts: 0
Joined: Mon Mar 22, 2021 2:03 pm

Re: ps6000SetExternalClock Error

Post by cjmorcom »

I've modified my code so that ps6000SetExternalClock is called immediately after ps6000OpenUnit, but ps6000SetExternalClock still returns error 86: PICO_TRIGGER_AND_EXTERNAL_CLOCK_CLASH.

Any other thoughts as to what the problem might be?

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: ps6000SetExternalClock Error

Post by Martyn »

Can you post your code, then I can check it against a unit when in the office on Monday.
Martyn
Technical Support Manager

cjmorcom
Newbie
Posts: 0
Joined: Mon Mar 22, 2021 2:03 pm

Re: ps6000SetExternalClock Error

Post by cjmorcom »

Here is the code:

Code: Select all

internal uint picoSyncTest()
{
	string[] devices = { "" };		
	uint status = 0;			

	try
	{
		//Enumerate devices
		short serialNumLength = 255;
		StringBuilder sb = new StringBuilder(serialNumLength);
		status = Imports.EnumerateUnits(out short deviceCount, sb, ref serialNumLength);
		if (status != StatusCodes.PICO_OK)
		{
			throw new ArgumentException($"EnumerateUnits: {status} = {StatusMessage.Text[status]}");
		}
		devices = sb.ToString().Split(',');
				
		//Try to open the first unit
		sb = new StringBuilder(devices[0]);
		status = Imports.OpenUnit(out _handle, sb);
		if (status != StatusCodes.PICO_OK)
		{
			throw new ArgumentException($"OpenUnit({devices[0]}): {status} = {StatusMessage.Text[status]}");
		}
		
		//Try to sync the picoScope to an external 10MHz clock, threshold = -0.5V
		Imports.ExternalSyncFrequency externalSyncFrequency = Imports.ExternalSyncFrequency.PS6000_FREQUENCY_10MHZ;
		short threshold_lsb = Convert.ToInt16(-0.5 * Imports.MaxValue);
		status = Imports.setExternalClock(_handle, externalSyncFrequency, threshold_lsb);
		if (status != StatusCodes.PICO_OK)
		{
			throw new ArgumentException($"setExternalClock: {status} = {StatusMessage.Text[status]}");
		}
	}
	catch (Exception ex)
	{
		Console.WriteLine($"Picoscope:{ex.Message}");
	}

	return status;
}
This runs, but function Imports.setExternalClock() returns 86 which according to StatusMessage.Text[86] is "PICO_TRIGGER_AND_EXTERNAL_CLOCK_CLASH"

In case its relevant, the sync signal is sequence of negative going pulses running from 0V (the baseline) to -0.8V (when terminated). Each pulse is 5ns in duration and the pulse frequency is 10MHz.

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: ps6000SetExternalClock Error

Post by Martyn »

You have picked up the wrong error code as decimal 86 is 0x56 PICO_EXTERNAL_FREQUENCY_INVALID which means the scope can't sync to your clock signal.
Martyn
Technical Support Manager

cjmorcom
Newbie
Posts: 0
Joined: Mon Mar 22, 2021 2:03 pm

Re: ps6000SetExternalClock Error

Post by cjmorcom »

Thanks for pointing out I'd picked the wrong error message and that the proper status code is PICO_EXTERNAL_FREQUENCY_INVALID.

However, I now believe the issue is not the frequency, but the duty cycle of our reference clock that at the root of our sync problem.

I have tested the PS6000 using a different 10MHz clock source that delivers a square wave and confirmed it syncs to this correctly.

However, the PS6000 will not sync to our high precision 10MHz reference clock which has a duty cycle of 5% (or 95% depending upon signal polarity).

To help us decide what to do next, please can you confirm the allowable duty cycle limits for the external sync clock?

Martyn
Site Admin
Site Admin
Posts: 4499
Joined: Fri Jun 10, 2011 8:15 am
Location: St. Neots

Re: ps6000SetExternalClock Error

Post by Martyn »

The issue may be due to the AC coupling used for the external clock signal. We haven't specifically tested anything other than 50% duty cycle however would expect that 60:40 would work but beyond that may cause difficulties.
Martyn
Technical Support Manager

cjmorcom
Newbie
Posts: 0
Joined: Mon Mar 22, 2021 2:03 pm

Re: ps6000SetExternalClock Error

Post by cjmorcom »

Thanks for the useful info - I hadn’t realised the input was AC coupled. We’ll look at other options to sync the scope.

Post Reply