• AVR Freaks

Hot!ADC in HarmonyV202b/MHC2024

Author
Paul PortSol
Super Member
  • Total Posts : 426
  • Reward points : 0
  • Joined: 2015/07/03 11:52:03
  • Location: Newfoundland, Canada
  • Status: offline
2017/01/30 11:24:26 (permalink)
0

ADC in HarmonyV202b/MHC2024

Anyone got HarmonyV202b working with lots of ADCs?
 
I had to modify the generated driver code to be more like HarmonmyV108/MHC1087,
and am wondering if I missed a new setting or some app code requirement?
 
Project (Set for PIC32MZ EF Starter Kit with EFH144):
- ADC45_HarmonyV202b_PIC32MZ-EF_v01PR_ModifiedGeneratedAdcDriver.zip
- Includes driver: old/new/modified
- Created fresh, but based on ADC45 project in post http://www.microchip.com/forums/m936365.aspx
 
Paul
#1

8 Replies Related Threads

    Paul PortSol
    Super Member
    • Total Posts : 426
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2017/05/26 06:34:13 (permalink)
    0
    Warning: HarmonyV202b MHC2024 can loose settings when reopen MHC. Haven't tested in MHC2035 yet...
    #2
    aatifshaikh66
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/02/20 03:17:39
    • Location: 0
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2019/03/29 22:44:49 (permalink)
    0
    Hi Paul,
     
    I'm facing some issues while building your project in my MPLAB X ID 5.15 and Harmony v2_06. Basically, I want to read 12-ADC channels sequentially after a fixed interval of time. Currently, any channels will work on my PIC32MZ starter kit (DM320007-C), later I'll change them according to my custom made board when it will be ready to use.
     
    Regards,
    Aatif Shaikh
     

    post edited by aatifshaikh66 - 2019/03/29 22:46:43

    Attached Image(s)

    #3
    Paul PortSol
    Super Member
    • Total Posts : 426
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2019/03/30 12:28:39 (permalink)
    4 (1)
    Did you do a "generate" in MHC? That could overwrite my files.
    The sample project was created in HarmonyV202, maybe the newer tools messed up something.
     
    I suggest you create a brand new project in HarmonyV206, and make all the MHC settings match my project (Careful of the mentioned "lost ADC settings").
    Then use "Beyond Compare" to check your project against mine to catch my customizations and patches.
     
    Today I'm using HarmonyV206, XC32v215, MPLabXv515 - and the ADCs are working with patches from above project.
    See zip attached of [__RequiredModsFromMHCGeneratedCode_MTMcV00_Hv206.h] 
     
    I keep a file like this with source files in each project listing what I had to do to make it work (I suggest everyone do similar to support whoever inherits your work).
    The file describes patches for ADC.
     
    See also zip by dropsend [MHC_ADC_PIC32MZ_Notes20190314PR.zip], 2.6MB
           (Crazy Microchip limits to 500K in 2019)
           Link:    myaccount.dropsend.com/file/b369d9a226f97ab2
    It has more details for the ADC patches on PIC32MZ with HarmonyV206.
     
    Sorry, I'm so buried I really can't burn time putting this in nice format again.
     
    Paul
     
     
    post edited by Paul PortSol - 2019/03/30 12:29:44
    #4
    aatifshaikh66
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/02/20 03:17:39
    • Location: 0
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2019/03/31 23:37:22 (permalink)
    0
    Thanks a bunch,
     
    I took a sample code (adchs_3dma) and manipulated the adc_drivers, system_config and other files according to your patch and uploaded code. Now the code is working somehow perfectly fine, but can you give me a little more details like how can I read the specific channels among all 45 channels which you've initialised.
    I've tried to do that on my own by 'Commenting' some of the channels, which are not necessary for my project. For testing purpose, the 3 channels available on upper-side jumper J12 (CH3, CH9 and CH14), I'm perfectly able to read channel 3 and 14(for 0v it shows 0.7v), but facing some issues in reading the channel number 9 (values does not change). 
     
    After successfully finishing my project I'll try to upload the whole project with full explanation and comments :)

    putting a print in this 'case' help me a lot to understand the flow.

    case APP_STATE_SERVICE_TASKS:
    {
         uHeartBeat++;
      if(uHeartBeat>1000*1000)
       {
         uHeartBeat = 0;
         BSP_LEDToggle(BSP_LED_1);//Toggle LED
         Nop();//For Breakpoint
         if( uADC_MaskIRQ==0x0 )//No new Samples == Error
          {
           SYS_PRINT("NO ADC TO READ!\n\r");
           //puADC_Samples[0];
           BSP_LEDToggle(BSP_LED_3);//Toggle LED //Error
           Nop();//For Breakpoint
           }
          else //Got ADC Samples
           {
              Nop();//For Breakpoint
              BSP_LEDToggle(BSP_LED_2);//Toggle LED
              uADC_MaskIRQ=0x0; //Clear ADC Sample Flags
              bADC_Ready=false; //Clear ADC Sample Flag
              uADC_CountDone = uADC_CountIRQ; //Update Number Processed Cycles
              DRV_ADC_Start();//Start Next ADC Sampling
              Nop();//For Breakpoint
              for(ucLoopCount = 0 ; ucLoopCount < 22 ; ucLoopCount++ )
             {
                flval = (((float)puADC_Samples[ucLoopCount] * 3.3f )/ 4095.0f) ;
                SYS_PRINT("puADC_Samples[%d]=%.2f\n\r",ucLoopCount,flval);
              }
         }
    }
    break;
     
     
     

    post edited by aatifshaikh66 - 2019/04/01 03:59:56
    #5
    Paul PortSol
    Super Member
    • Total Posts : 426
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2019/04/01 05:40:44 (permalink)
    5 (1)
    Not recommended to do printf in the callback, callback is probably being called by interrupt (depending on your ADC setup) and could clash with non-interrupt print calls.
     
    Note that my code is fairly slow raw adc readings (Not at a fixed rate suitable for DSP processing or other fequency analysis)
     
    In the following file use these entry points:
    - vADC_Process() //Call pteriodically to display ADC data
    - vADC_Stat()
    - uADC_Get() //Get a specific ADC (else returns flag is none ready)
    - bADC_Check() and bADC_NewSinceTriggered() check if new adc reading available
    - bADC_Trigger() request fresh ADC samples
     
    Note also the changes in system_interrupt.c to ADC Interrupts, so can detect if some of those changes get lost during MHC generate.
     
    Paul
     
    #6
    Paul PortSol
    Super Member
    • Total Posts : 426
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2019/04/01 09:13:52 (permalink)
    4 (1)
    oops, missed file: adc_mz.c
    #7
    aatifshaikh66
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/02/20 03:17:39
    • Location: 0
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2019/04/01 22:27:37 (permalink)
    0
    Thanks for all your help,
     
    I've merged ADC-code with TCP/IP-Client-code (MODBUS_TCP), now I'm able to read the ADC values via any other socket app on the LAN. I'll try to upload the source file but not sure what is the limit of file-attachments on this forum.
     
    https://drive.google.com/...-uRNk5CFq0heKcDIPPmkkL

    Warm Regards,
    Aatif Shaikh
    post edited by aatifshaikh66 - 2019/04/01 22:44:28
    #8
    Paul PortSol
    Super Member
    • Total Posts : 426
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: ADC in HarmonyV202b/MHC2024 2019/04/02 04:36:44 (permalink)
    0
    500KB - ick.
    May need to post file on a file sharing website, and share link to it here.
    (I use dropsend for 1 week sharing, for for long term not sure whats good)
     
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5