A/D synchronised sampling on 2 channels using BL0032

For general Flowcode discussion that does not belong in the other sections.
Post Reply
DAVIDJOINER
Posts: 140
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

A/D synchronised sampling on 2 channels using BL0032

Post 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

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

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

Post 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?

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

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

Post 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

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

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

Post 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 434 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 556 times

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

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

Post 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

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

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

Post 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
Attachments
ADC_Sampling_Advanced.msg.txt
(1.6 KiB) Downloaded 501 times

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

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

Post 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

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

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

Post 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
Attachments
ADC_Sampling_Advanced.msg.txt
(1.58 KiB) Downloaded 678 times

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

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

Post 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

DAVIDJOINER
Posts: 140
Joined: Wed Dec 02, 2020 7:35 pm
Been thanked: 18 times

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

Post 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

Post Reply