Page 1 of 1

A/D synchronised sampling on 2 channels using BL0032

Posted: Mon Jun 14, 2021 7:44 pm
by DAVIDJOINER
Hi Ben

A while back you kindly generated a small routine to allow 2 EB085 boards to scan and take a sample at the same time ie synchronously which worked fine

Is there any chance you can do a routine doing the same functionality but this time using 2 of the A/D channels on the EB0082 rather than the EB085 boards


Best regards
David

Re: A/D synchronised sampling on 2 channels using BL0082

Posted: Wed Jun 16, 2021 1:25 pm
by BenR
Hi David,

The EB082 is a product code for a simple converter board that never went into production, is this the right code?

Re: A/D synchronised sampling on 2 channels using BL0082

Posted: Wed Jun 16, 2021 2:50 pm
by DAVIDJOINER
Hi Ben


Please ignore references to BL0082 and EB0082

I actually meant to say using 2 of the A/D channels on BL0032 ie the dspic board


David

Re: A/D synchronised sampling on 2 channels using BL0082

Posted: Thu Jun 17, 2021 11:21 am
by BenR
Hi David,

Here is a simple example that uses a timer interrupt to set the sample rate. Every time the interrupt happens we sample ADC channels 0 and 1 one after another and store the results into circular buffers.

ADC_Sampling_Simple.fcfx
(11.89 KiB) Downloaded 433 times

Here is the same example but this time we use the fact that the BL0032 has two ADC modules onboard to allow us to take both samples at approximatley the same time. Please note this should work fine as long as you are not using ADC inputs anywhere else in your program.

ADC_Sampling_Advanced.fcfx
(13.02 KiB) Downloaded 555 times

Re: A/D synchronised sampling on 2 channels using BL0032

Posted: Thu Jun 17, 2021 12:56 pm
by DAVIDJOINER
Hi Ben

Thanks for prompt reply

Your second example looks exactly what i am looking for thanks

Only have one more question roughly what do you think the difference in the sample point start time will
be between the 2 channels when using the BL0032 .
As i really need to have minimal phase difference possible

Best Regards
David

Re: A/D synchronised sampling on 2 channels using BL0032

Posted: Thu Jun 17, 2021 4:28 pm
by DAVIDJOINER
Hi Ben

I tried compiling the advance example file but it would not compile correctly, have enclosed the compile report for info

Note your simple example does however compile correctly

David

Re: A/D synchronised sampling on 2 channels using BL0032

Posted: Fri Jun 18, 2021 12:48 pm
by BenR
Hi David,

Aha thanks for letting us know, I'll get that fixed. Yes the second analogue peripheral only supports 10-bit sampling.

I've fixed it now and AD1 will use 12-bit sampling and AD2 will use 10-bit sampling.

Would you want AD1 on 12-bit and AD2 on 10-bit or both on 10-bit?

If you want 10-bit on both then open the file here in a text editor.

C:\ProgramData\MatrixTSL\FlowcodeV9\CAL\PIC16BIT\PIC16BIT_CAL_ADC.c

Goto line 1947.

Code: Select all

AD1CON1bits.AD12B = 1;									//12bit sampling
And change to this

Code: Select all

AD1CON1bits.AD12B = 0;									//10bit sampling

Re: A/D synchronised sampling on 2 channels using BL0032

Posted: Fri Jun 18, 2021 1:59 pm
by DAVIDJOINER
Hi Ben

Yes both must be same so have set AD1 TO 10 BITS as you advised

Loaded new Cal and getting nearer but still an error in compile enclosed file (Also same error if keep AD1 to 12 bits)


David

Re: A/D synchronised sampling on 2 channels using BL0032

Posted: Fri Jun 18, 2021 2:13 pm
by BenR
Hi David,

Hmm that's interesting. Maybe just try commenting out or removing this section on line 1978.

Code: Select all

			#ifdef (_AD2CON1_AD12B_POSITION)
			  AD2CON1bits.AD12B = 1;								//12bit sampling
			#endif

Re: A/D synchronised sampling on 2 channels using BL0032

Posted: Fri Jun 18, 2021 3:58 pm
by DAVIDJOINER
Hi Ben

Thanks

That fix has now sorted the compilation issue

I will be testing the code next week in my application and hopefully it will all now work

Best regards
David