Hot!ADC 10bits and 12bits

Author
romain.delpoux
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2017/03/24 13:36:54
  • Location: 0
  • Status: offline
2018/04/06 06:19:28 (permalink)
0

ADC 10bits and 12bits

Hi!
 
For a motor control application, I use the MCLV2 board with dspic33EP256MC506. 
 
For my motor control, I have to measure at least 2 currents, synchronized with the PWM. For this purpose I use ADC with 10bits. I need to measure data from a torque meter. For a better precision, I want to use the ADC on 12bits. Is it possible on simulink to have some data with 10bits ADC and others with 12bits ADC at slower sampling time?
 
Best regards
 
Romain DELPOUX
 
 
 
#1

6 Replies Related Threads

    Mysil
    Super Member
    • Total Posts : 2911
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: online
    Re: ADC 10bits and 12bits 2018/04/06 09:18:46 (permalink)
    0
    Hi,
    In datasheet there is a parameter:
    AD63  tDPU Time to Stabilize Analog Stage from ADC Off to ADC On:  max 20 us
     
    So if changing resolution, you may need this time before results become stable again.
    If there is a little noise around,
    you may be able to make 20 or 40 measurements of signal from torque meter in 10 bit resolution,
    in the time needed to change, and calculate the average value.
    This may recover some of the resolution between 10 and 12 bits.
     
    I have no idea about simulating this in simulink.
     
       Mysil
    #2
    KTrenholm
    Super Member
    • Total Posts : 556
    • Reward points : 0
    • Joined: 2012/08/08 14:04:23
    • Location: Connecticut, USA
    • Status: online
    Re: ADC 10bits and 12bits 2018/04/06 09:48:44 (permalink)
    0
    You mention syncing with a PWM to take motor current readings, so you would only read the motor current when the PWM is active yes?  Maybe you could switch the ADC resolution and read the torque meter during the inactive time of the PWM driving the motors? 
     
    Presuming of course you have an inactive time long enough to do so.  20uS would require a PWM of < 25kHz (50% duty) just for the switching of the resolution of the ADC.  Readings would add a bunch more on top of that. 
     
    I haven't done motor control since university so I don't actually have a frame of reference of how fast the PWM to drive a motor would be.  All the above could be moot depending on the speed of the PWM.
    #3
    Lubin
    Moderator
    • Total Posts : 320
    • Reward points : 5
    • Joined: 2007/03/31 07:38:15
    • Location: Bayonne, France
    • Status: offline
    Re: ADC 10bits and 12bits 2018/04/16 08:03:25 (permalink)
    0
    Hi Romain,
     
    With the chip you are using, the ADC is either configured with 10 bits or 12 bits resolution. It is not a common practice to switch the ADC mode back and forth between these two resolutions. You might still give it a try and integrate your own C code with the C function call block, but I would not advise to go that way as I am not convinced it can work (as mentioned in previous post, there are delay to respect etc…).

    With the ADC set in 10 bits, you have up to 4 sample and hold channels which can run in parallel. Typically, channels 2,3 and 4 are used to sample motors current and voltage in sync with the driving PWM signal. Channel 1 is used to scan as many analog inputs as required, taking a different input at each new sampling trig. But you could also use this channel 1 to oversample your sensor and obtain a higher resolution thanks to dithering effect.

    Another solution is to use an external component working over SPI or I2C. The blockset provide SPI and I2C blocks capable to connect any sensors using theses protocol. Blocks handle the I2C/SPI protocol in background which minimize the CPU load allowed to theses tasks. Microchip propose many ADC components (please visit: http://www.microchip.com/...g-to-digital-converter ); some of which are optimized for instrumentation. I have been using MPC3425 and MCP3428 (which include an instrumentation amplifier with programmable gain and output a 16 bits value) and could share further information if you are interested-in. Last, theses components are easy to solder as they require just few extra capacitors.

    The multitasking monotonic rate scheduler implemented by default with multirate model make it very easy to keep a fast motor control algorithm (~20khz) running while having a slower (1khz ?) task dedicated for instrumentation. It allows keeping synchronized motor control algorithms output data (debug) with instrumentation data which might be important when analyzing data.
     
    Lubin
    #4
    romain.delpoux
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2017/03/24 13:36:54
    • Location: 0
    • Status: offline
    Re: ADC 10bits and 12bits 2018/04/18 00:40:35 (permalink)
    0
    Hi everybody, 
     
    Thank you for your answers. I have tried to but on the same simulink two ADC blocks, one with 10bits and a second one with 12bits and the analog output of the 12 bits was never updated. I chose the same option that Lubin propose, that is, using the I2C with the ADC component MCP3221. I received the ADC today and will try it soon.
     
    Best regards 
    Romain 
     
    #5
    Lubin
    Moderator
    • Total Posts : 320
    • Reward points : 5
    • Joined: 2007/03/31 07:38:15
    • Location: Bayonne, France
    • Status: offline
    Re: ADC 10bits and 12bits 2018/04/18 07:21:08 (permalink)
    0
    Using more than one ADC block with theses dsPIC family is not working. The model should trig an error at code generation time. Future blockset release will trig an error for such case to help end user.
     
    Others dsPIC have ADC peripheral with independent core. For these chips, multiple blocks can be used, each one with its own settings and its own trig. One block could handle as many ADC channels as desired. Two blocks might share the same sampling trigger. Theses ADC are found in dsPIC EP GS family added with the V3.40, or within the PIC32MK.
     
    Using an MCP3221 external component is a good solution.
     
    Lubin
    #6
    romain.delpoux
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2017/03/24 13:36:54
    • Location: 0
    • Status: offline
    Re: ADC 10bits and 12bits 2018/04/22 23:42:02 (permalink)
    0
    Hi Lubin, 
     
    Thank you for these additional information. 
     
    It worked perfectly with the MCP3221 using the I2C block.
     
    Best regards 
    Romain 
    #7
    Jump to:
    © 2018 APG vNext Commercial Version 4.5