I'm a bit confused as to how you can make a XOR trigger using SetTriggerChannelConditions. If I'm not mistaken, the function can either AND several inputs by calling it once, or OR several functions by calling them separately in a row. Condition structures can be used to invert logic as well.

But in order to make a XOR, you need to store at least 1 logical operation result. IE: (A AND B) need to be stored in order to (A AND (RESULT of FIRST OPERATION)). I'm relatively new to LabVIEW, but is there a way to do this with the SDK functions, or is it possible through LabVIEW itself?

Any information would be helpful, thanks.

## XOR Logic Trigger on the 4000A

### Re: XOR Logic Trigger on the 4000A

Hi Kapton.

Sorry for the delay.

Actually, you don't just use ps6000SetTriggerChannelConditions to create an XOR condition (and XOR is just a combinatorial Logic function of inverted, ANDed, and ORed functions, as shown in the diagram below, so no storage is needed). So, ps6000SetTriggerChannelConditions is performing the ANDing and or inverting the inputs, while PS6000_TRIGGER_CONDITIONS is performing the ORing and or inverting the outputs.

We have Digital Triggering in PicoScopes, so the logic is implemented in an FPGA, and the Logic fabric of an FPGA is based upon Karnaugh Maps which can implement any Logic function of a number of inputs. So, if you look at the Logic triggering in PicoScope 6, that just implements both functions, giving you any combinatorial Logic function for a number of inputs (note that, for more than 2 inputs, its easier to think of XOR as odd Parity, i.e. equal to 1 for an odd total number of ones).

Regards,

Gerry

Sorry for the delay.

Actually, you don't just use ps6000SetTriggerChannelConditions to create an XOR condition (and XOR is just a combinatorial Logic function of inverted, ANDed, and ORed functions, as shown in the diagram below, so no storage is needed). So, ps6000SetTriggerChannelConditions is performing the ANDing and or inverting the inputs, while PS6000_TRIGGER_CONDITIONS is performing the ORing and or inverting the outputs.

We have Digital Triggering in PicoScopes, so the logic is implemented in an FPGA, and the Logic fabric of an FPGA is based upon Karnaugh Maps which can implement any Logic function of a number of inputs. So, if you look at the Logic triggering in PicoScope 6, that just implements both functions, giving you any combinatorial Logic function for a number of inputs (note that, for more than 2 inputs, its easier to think of XOR as odd Parity, i.e. equal to 1 for an odd total number of ones).

Regards,

Gerry

Gerry

Technical Specialist

Technical Specialist

### Re: XOR Logic Trigger on the 4000A

Sorry if I didn't clarify, but I am using ps4000a not 6000. So, I do not see PS6000_TRIGGER_CONDITIONS within the SDK. However, I think I see what you are getting at. I should be able to AND (A and not B) with one call then immediately call (B and not A). This should OR the two calls and give a XOR, correct?

### Re: XOR Logic Trigger on the 4000A

Hi Kapton,

Sorry, Multitasking gone haywire (was looking at a 6000 issue earlier...should have just read the Title ).

Yes, that is exactly what you need to do.

Regards,

Gerry

Sorry, Multitasking gone haywire (was looking at a 6000 issue earlier...should have just read the Title ).

Yes, that is exactly what you need to do.

Regards,

Gerry

Gerry

Technical Specialist

Technical Specialist

### Re: XOR Logic Trigger on the 4000A

So with this, how would you go about doing XOR across more than 2 inputs? I know you XOR the first XOR with the next input and you keep this pattern going recursively. This is kinda like the original problem where you need to store the first XOR result in order to do the next... unless you don't.

You have been a huge help so far, and I appreciate advice you have. Thanks for your time.

You have been a huge help so far, and I appreciate advice you have. Thanks for your time.

### Re: XOR Logic Trigger on the 4000A

Hi Kapton,

Sorry for the delay in getting back to this.

The best way to think of how to implement the trigger conditions that you want, as a multi input Exclusive-Or gate, would be to think in terms of Sum-Of-Products (SOP). So if you have the Trigger States defined let's look at an example for 4-inputs.

As I mentioned, in my post about the breakdown of an XOR gate into it's combinatorial constituents, "(note that, for more than 2 inputs, its easier to think of XOR as odd Parity, i.e. equal to 1 for an odd total number of ones)" which makes the setting up the SOP fairly easy to do. Essentially, you just need to sum all of the AND terms that would have an odd number of asserted Trigger State conditions for the inputs. So for 4 Trigger states on Ch A, CH B, Ch C and Ch D you would have the following Product terms:

Product terms with 1 asserted condition

A*notB*notC*notD

notA*B*notC*notD

notA*notB*c*notD

notA*notB*notC*D

Product terms with 3 asserted conditions

A*B*C*notD

A*B*notC*D

A*notB*C*D

notA*B*C*D

So those 8 product terms woud be 8 PS3000A_TRIGGER_CONDITIONS structures. Where you have a 'not asserted' trigger condition for a channel in the product term you would use the constant PS3000A_CONDITION_FALSE, and where you have an 'asserted' trigger condition you would use the constant PS3000A_CONDITION_TRUE.

Just correcting my last comment, you don't make multiple calls to the ps3000aSetTriggerChannelConditions function. What you need to do is put the structures in an array, call ps3000aSetTriggerChannelConditions, telling it how many structures are in the array, and giving it a pointer to the array. This would then result in OR'ing together all of the product terms giving you the following:

A*notB*notC*notD+notA*B*notC*notD+notA*notB*c*notD+notA*notB*notC*D+

A*B*C*notD+A*B*notC*D+A*notB*C*D+notA*B*C*D = A⊕B⊕C⊕D

(note that in Boolean Logic, * is AND, + is OR, and ⊕ is XOR)

I'll come back to this post and write a thorough description of how to create the SOP function for any type of logic function of the Trigger States, (with code examples) when my workload drops a bit.

Regards,

Gerry

Sorry for the delay in getting back to this.

The best way to think of how to implement the trigger conditions that you want, as a multi input Exclusive-Or gate, would be to think in terms of Sum-Of-Products (SOP). So if you have the Trigger States defined let's look at an example for 4-inputs.

As I mentioned, in my post about the breakdown of an XOR gate into it's combinatorial constituents, "(note that, for more than 2 inputs, its easier to think of XOR as odd Parity, i.e. equal to 1 for an odd total number of ones)" which makes the setting up the SOP fairly easy to do. Essentially, you just need to sum all of the AND terms that would have an odd number of asserted Trigger State conditions for the inputs. So for 4 Trigger states on Ch A, CH B, Ch C and Ch D you would have the following Product terms:

Product terms with 1 asserted condition

A*notB*notC*notD

notA*B*notC*notD

notA*notB*c*notD

notA*notB*notC*D

Product terms with 3 asserted conditions

A*B*C*notD

A*B*notC*D

A*notB*C*D

notA*B*C*D

So those 8 product terms woud be 8 PS3000A_TRIGGER_CONDITIONS structures. Where you have a 'not asserted' trigger condition for a channel in the product term you would use the constant PS3000A_CONDITION_FALSE, and where you have an 'asserted' trigger condition you would use the constant PS3000A_CONDITION_TRUE.

Just correcting my last comment, you don't make multiple calls to the ps3000aSetTriggerChannelConditions function. What you need to do is put the structures in an array, call ps3000aSetTriggerChannelConditions, telling it how many structures are in the array, and giving it a pointer to the array. This would then result in OR'ing together all of the product terms giving you the following:

A*notB*notC*notD+notA*B*notC*notD+notA*notB*c*notD+notA*notB*notC*D+

A*B*C*notD+A*B*notC*D+A*notB*C*D+notA*B*C*D = A⊕B⊕C⊕D

(note that in Boolean Logic, * is AND, + is OR, and ⊕ is XOR)

I'll come back to this post and write a thorough description of how to create the SOP function for any type of logic function of the Trigger States, (with code examples) when my workload drops a bit.

Regards,

Gerry

Gerry

Technical Specialist

Technical Specialist

### Re: XOR Logic Trigger on the 4000A

Thanks for the reply. So, that's kinda what I was thinking, a SOP. With the ps4000A_CONDITION structure, I didn't think it was possible to put multiple channels into the structure. I'm assuming its 1 channel with its condition.

So with how the ps4000aSetTriggerChannelProperties is set up, I would need to call it 16 times (8 with 1 asserted condition and 8 with 3 asserted conditions).

Each call is a row

(A*notB*notC*notD*notE*notF*notG*notH) for example

and by calling it 16 times, I am then ORing every row giving me a XOR.

Gerry, you have been a big help and i look forward to seeing your write up.

So with how the ps4000aSetTriggerChannelProperties is set up, I would need to call it 16 times (8 with 1 asserted condition and 8 with 3 asserted conditions).

Each call is a row

(A*notB*notC*notD*notE*notF*notG*notH) for example

and by calling it 16 times, I am then ORing every row giving me a XOR.

Gerry, you have been a big help and i look forward to seeing your write up.

### Re: XOR Logic Trigger on the 4000A

You don't call it 16 times you create an array with 16 structures in, and then call it once saying that you have 16 structures. This will then OR all 16 structures.

Martyn

Technical Support Manager

Technical Support Manager