Analog input not working on PIC32MZ2048ecg100

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Fri Aug 31, 2018 4:33 pm

Hi Ben

On the program with a PIC32MZ2048ecg100 a have a little problem.

If I insert potentiometer (slider) and get an int or get a string, the program is frezzing....
I tried AN22 and AN28

kersing
Valued Contributor
Valued Contributor
Posts: 1873
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 530 times
Been thanked: 1040 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby kersing » Fri Aug 31, 2018 5:10 pm

Simulation or on hardware?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Fri Aug 31, 2018 5:25 pm

on my own hardware

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Fri Nov 09, 2018 9:05 am

Hi Ben

I tried potentiometer slider and potentiometer panel. It's compieling and the program is running until I GetString or GetInt. It stops on this command.

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Wed Nov 14, 2018 12:48 pm

Hi Ben

The program in the PIC will hang on the part of the Analog Input GetString or GetInt.
where does the problem come from? From the Component or PIC32mz definition?
Or am I doing something wrong?

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby Benj » Wed Nov 14, 2018 1:49 pm

Hello,

Please can you try calling the following ADC functions to help see specifically which call is causing the lock up.

Print LCD ("ADC-")
RawEnable()
Print LCD ("En")
RawSampleInt()
Print LCD ("Int")
RawDisable()
Print LCD ("Dis")

Both the enable and sample functions contain a while loop so I'm guessing one of these is causing the issue.

Attaching a simple program that demonstrates the problem might also be useful so we can look at your configuration settings etc.

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Wed Nov 14, 2018 2:50 pm

Hi Ben

Enable/Disable are ok but Rawsample not.

Print LCD ("ADC-")
RawEnable()


OK

Print LCD ("En")
RawSampleInt()



Frezz


Print LCD ("Int")
RawDisable()
Print LCD ("Dis")


OK

I trie to make a small program for the AD and post it

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Wed Nov 14, 2018 3:24 pm

Hi Ben

Here the program for the AD Converter.

I need the AN22 on Pin 6 Port C1


Fc8_ecg4matrix_reduced_ad_converter.fcfx
(48.52 KiB) Downloaded 66 times

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Tue Nov 20, 2018 4:20 pm

Hi Ben

I tried with FC8.1 but the analog Input is still not working..

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Mon Nov 26, 2018 11:51 am

Hi Ben

I found in the PIC32BIT_CAL_ADC.c some infos.
But nothing about the command.
FCD_0d101_Akku1__RawSampleByte();


/* ADC Type 2 Supported Devices ************************************************************
PIC32MZ2048ECG100 Family
*******************************************************************************************/

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby Benj » Mon Nov 26, 2018 6:21 pm

Hello,

You can find the source code for the RawSampleByte function here.

"C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\PIC32BIT\PIC32BIT_CAL_ADC.c"

The PIC32MZ2048ecg100 device uses ADC type 2 which starts on line 147.

The CAL file basically defines three functions.

FC_CAL_ADC_Enable
FC_CAL_ADC_Sample
FC_CAL_ADC_Disable

The function FCD_0d101_Akku1__RawSampleByte will be defined in your Flowcode project C file and will directly call the three CAL functions.

If you need me to dig in and try and find the problem then I can do but I may need hardware to do it properly.

Also have you checked the Microchip site, specifically the Errata document for the device to make sure it's not a known silicone problem. If it's a known problem then they will often provide a workaround you can employ.
These users thanked the author Benj for the post:
stefan.erni (Mon Nov 26, 2018 7:53 pm)
Rating: 5.26%
 

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Wed Nov 28, 2018 12:41 pm

Hi Ben

I looked at the code PIC32BIT_CAL_ADC for a while. There is a line to start the conversation as a comment. How then is the conversion started?

Yes I would like to send you a hardware, but I should have it back at the end of January.


MX_UINT16 FC_CAL_ADC_Sample (MX_UINT8 Sample_Mode)
{
MX_UINT16 iRetVal;

_SFR_WRITE(&AD1CON3,((_SFR_READ(&AD1CON3)&0xBFFFFFFF)|0x40000000));
//AD1CON3bits.GSWTRG = 1;
/* Wait the conversions to complete */
while (_SFR_BIT_READ(&AD1DSTAT1,MX_Current_Channel) == 0);

/* fetch the result */
if (Sample_Mode)
{
iRetVal = _SFR_READ(&AD1DATA0 + MX_Current_Channel);
}
else
iRetVal = (_SFR_READ(&AD1DATA0 + MX_Current_Channel) >> 2); //8-bit ADC

delay_us(1); //Required or processor locks up using Raw functions

return (iRetVal);
}


stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Thu Jan 17, 2019 6:03 pm

Hi Ben

Can you give me an idea what do to that the analog input is working.
regards

Stefan

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Wed Jan 30, 2019 9:41 am

Hi Ben

I suspect the problem is somehow here.....


Code: Select all

_SFR_WRITE(&AD1CON3,((_SFR_READ(&AD1CON3)&0xBFFFFFFF)|0x40000000));
 //AD1CON3bits.GSWTRG = 1;
 /* Wait the conversions to complete */
 while (_SFR_BIT_READ(&AD1DSTAT1,MX_Current_Channel) == 0);

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby Benj » Wed Jan 30, 2019 6:55 pm

Hello,

Sorry for the delay. Let me see if I can replicate the problem here for you and see if I can get it working.

I'll bring my PIC32MZ board in tomorrow.
These users thanked the author Benj for the post:
stefan.erni (Fri Feb 01, 2019 2:14 pm)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby Benj » Thu Feb 07, 2019 5:06 pm

Hello,

Right I'm testing the ADC on the PIC32MZ2048EFG100 and this is not hanging but doesn't seem to be giving me the correct value at the moment.

I'll investigate and see if I can get this working and then compare with the ECG device.
These users thanked the author Benj for the post:
stefan.erni (Sun Feb 10, 2019 6:24 pm)
Rating: 5.26%
 

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Wed Feb 27, 2019 2:22 pm

Hi Ben

This old ECG Type PIC PIC32MZ2048ECG is on the old chipKIT Wi-FIRE! Revision B

https://reference.digilentinc.com/chipk ... 1507019925

The newer EFG Type PIC32MZ2048EFG100 microcontroller is on the newer chipKIT Wi-FIRE

https://store.digilentinc.com/wi-fire-w ... ler-board/

User avatar
Benj
Matrix Staff
Posts: 14371
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4447 times
Been thanked: 4150 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby Benj » Wed Feb 27, 2019 5:30 pm

I do happen to have a ChipKit WiFire board here in my collection but it's the newer version :( Same as the board you sent.

I got excited for a minute there :roll:

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Fri Mar 29, 2019 11:22 am

Hi Ben

How is the AD with the PIC32MZ2048efg going on?
Maybe with the PIC32MZ2048ecg it will not work.

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Wed Aug 07, 2019 2:21 pm

Hi Ben

Now Im using the newer PIC32MZ2048efg100

If I use the analog input its not crashing but it don't give me a correct value back.
I put 2.2 volt on the input and it shows like 0.00324 but sometimes a little more or less.
If I remove the 2.2volt it's always shows the same values..
The progam use the AN22. I config to AN21 and AN23 but the same value even there is no 2.2volt

regards

Stefan

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Fri Aug 23, 2019 8:03 am

Hi Ben

You wrote me a while ago about the AD from the PIC. Is there a way to fix it?
regards

Stefan

Right I'm testing the ADC on the PIC32MZ2048EFG100 and this is not hanging but doesn't seem to be giving me the correct value at the moment.

I'll investigate and see if I can get this working and then compare with the ECG device.

stefan.erni
Posts: 527
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 165 times
Been thanked: 152 times
Contact:

Re: Analog input not working on PIC32MZ2048ecg100

Postby stefan.erni » Thu Dec 05, 2019 11:48 am

Hi Ben

I use a simple programloop to test the AD converter in the PIC Pin6 AN22.
I send the result to the Computer. It shows just numbers like 1,2,0,1,0,1
On the hardwarepin it's the correct voltage of 1.9Volt.(litium akku divided by 2)
There is a problem somewhere ...

Analog-input.PNG
Analog-input.PNG (15.32 KiB) Viewed 115 times