Page 1 of 1

PIC32MZ2048EFM100 ADC problem.

Posted: Tue Jul 25, 2017 9:24 pm
by Lagoda
Hi All,

I would like to use the AD Converter of the Curiosity PIC32MZ EF circuit board, but the attached program does not work in the target circuit.
Can I get some help?

Best Regards,

Lagoda

Re: PIC32MZ2048EFM100 ADC problem.

Posted: Wed Jul 26, 2017 10:48 am
by Benj
Hello Lagoda,

Your SPI component properties appear to be missing a valid Prescale setting. Also if you are talking to an SPI device then you probably need to toggle the CS pin using an output icon in single bit mode, or at least pull the CS pin low before you start sending out SPI bytes.

Is there a LED on the board that you can flash, the 1 second flash program is a very good starting point.

https://www.matrixtsl.com/wikiv7/index. ... ED_flasher

If you can do this then you can maybe add PWM out to the LED and use the ADC to set the PWM duty to confirm the ADC is functioning.

I was going to buy one of the boards to chip in and help but they seem a bit expensive so we will try without for now.

Re: PIC32MZ2048EFM100 ADC problem.

Posted: Wed Jul 26, 2017 3:57 pm
by Lagoda
Hi Ben,

Thanks for the quick response.
I set the prescale value in the SPI component.
To the SPI MOSI and SPI CLK output only the oscilloscope was connected to monitor the ADC Return Value.
Bus Settings:
Clock Polarity: Idle Low
Clock Phase:Leading Edge (actually is the Trailing Edge on the photo!)
Sample Point: Middle

I connected a 220Kohm potentiometer between 3.3V and GND.The AN13 pin was connected to the potentiometer's slider contact. But the SPI MOSI Data does not change. (I turned the potentiometer button right and left. :wink: )


Is ADC7 the default modul in the in the PIC32MZ? (When I use the Potentiometer Component.)
It is not necessary to the ADC inputs are simultaneously sampling in my project.

Best Regards,

Lagoda

Re: PIC32MZ2048EFM100 ADC problem.

Posted: Mon Jul 31, 2017 9:53 am
by Lagoda
Hi Ben,

I accepted your advice, and already I am able to flashing LEDs professionally. :wink:
But the ADC does not work properly.

The problem is that the Potentiometer component uses the ADC0 module.
ADC0 is only assigned to AN0 ├ęs A45 with an multiplexer which is connected the RB0(AN0) pin. (This pin connected to a LED on my circuitboard.)
Otherwise it seems ADC0 is working well.
Temporarily, the ADC7 would be a better choice because we can would to use the analog pins from AN7 to AN34.

What is your opinion?


Best Regards

Lagoda

Re: PIC32MZ2048EFM100 ADC problem.

Posted: Tue Aug 01, 2017 1:15 pm
by Benj
Hello Lagoda,

I think I have now made all the changes necessary to enable ADC7 rather than ADC0, though it's complicated so I'm not 100%.

Simply copy the attached file into your "Flowcode 7/CAL/PIC32BIT" folder and recompile your project.

We could do with a nicer way of dynamically switching between ADC modules depending on which channel you want to read.

PIC32BIT_CAL_ADC.c
(15.38 KiB) Downloaded 168 times


Let me know how you get on.

Re: PIC32MZ2048EFM100 ADC problem.

Posted: Tue Aug 01, 2017 3:23 pm
by Lagoda
Hello Ben,

Unfortunately, it did not work.
I modified it a bit (ARDY7 and ADCDATA7 from ARDY0 and ADCDATA0) and now the AN7 input is active and the resolution is 6 bits.
Should be used in Class 2 or Class 3 mode.
The channel parameter is completely ineffective, and can not select the analogue input.

It's more complicated to setup than the other classical ADC-s. (I do not like this type of ADC.) :?

Best Regards,

Lagoda

Re: PIC32MZ2048EFM100 ADC problem.

Posted: Tue Aug 01, 2017 3:48 pm
by Benj
I do not like this type of ADC


Agreed, Who knows what they were thinking when they came up with this design.

Let me know if you make any more progress.

Re: PIC32MZ2048EFM100 ADC problem.

Posted: Thu Aug 03, 2017 2:04 pm
by Lagoda
Hi Ben,

I've made a version that tested in my Curiosity circuitboard and working.
I do not know how to program in C but "A blind man may perchance hit the mark."

The idea of the solution can be found in the PIC32 Family Reference Manual, ADC Scanning Multiple Inputs example.

The point is that all ADCs are initialized and turned on in scan mode, but only the selected ANx pin is scanned.
To solve this I needed a new variable (TEMP_CHANNEL) and a pointer (ANx_DATA).
Maybe starting to be good for the final version.

My experiences: ANx inputs related to ADC7 produce more noisy data results in this mode than inputs related to ADC0-ADC4.
Longer running time.
The chip temperature didn't drop either. :)

May need to review the port settings again too.

I hope I could help you with it.
I am interested in your opinion.

Best Regards,

Lagoda