This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Use of ADC0 and ADC1 with DMA

Other Parts Discussed in Thread: MSP430F6777

Hi,

I am using TM4C1237 and want to configure ADC along with DMA.  I want to measure AC voltage(Vout),current (Iout)for calculating KW. Along with this I have another 8 ADC inputs mainly AC voltages.

My Plan is like follows 

1. Configure ADC to run at 10 KSPS.
2. Configure ADC0 sample 0 for Vout and ADC1 sample 0 for Iout (All 8 Samples)
3. Confiure ADC0 sample 1 and ADC1 sample 1 for rest of the imputs.
4. Use SYNCWAIT functionality of ADC1 for Sample 0.
5. Use DMA to transfer all results (Say 200 samples each)
6. Trigger Sample 1 with 1 second timer
7. Trigger Sample 0 continuously.

Can any one suggest any problem with this method or any better approch.

Chetan

 

 

  • Hi,

    Some other details are needed - mainly if some accuracy is mandatory and what is the level of such parameter. This will trigger further decisions in your approach. Also important to know if you must analyze the tri-phase power line or there are some other nine loads. It is not clear why you need to trigger sequencer 0 all the time - this contradicts your imposed 10Ksps.

    If you decide to use two converters, then it will be wise to trigger both at the same time, since one after another will introduce a delay between voltage and corresponding current channel which will affect the needed accuracy.

    Useful to know that TI has a dedicated microcontrollers for power line measurement - look for this micro and read at least the application notes to realize the problems involved in such project: http://www.ti.com/lit/ds/symlink/msp430f6777.pdf

    Try to investigate also the algorithms needed and figure out the amount of computing needed for real time measurements. Do not rush to coding phase - maybe it is too early... The power may be active, reactive and different algorithms should be used.

    Petrei

  • Hi Petrei,

    Thanks for quick reply.
    I am not looking at the 3 phase energy measurement. I have three phase input and have to select one of the healthy phase. Morever selection of healthy phase is also not very much time critical (say within 2-3 seconds).
    I want to measure a single phase active power (KW) and in turn active energy (KWH) for the selected phase. Vr,Vy,Vb,Vout,Iout,Vn,Vaux AC measurements along with other three DC measurements are available. Along with this operation my application will be handling CAN,RS485 and USB interfacees and few GPIOs. I do not have choice for controller selection as the board is already made and I am working on the firmware part of it.

    I am planning to set sample rate at 125KSPS minimum, ( Hardware averaging idea dropped out to reduce speed). I think continuous sampling is needed to get KW. I can drop out a cycle or two for Vout and Iout  and do the measurements of other channels. 10 KSPS was thought using hardware averaging to minimize RAM requirement and interrupt occurence time.
    I mentioned SYNC to start sampling of Vout and Iout simaltaneously. I am expecting accuracy of 2% and is not interseted in reactive power. Apparent power I will calculate based on RMS values.

    Can you suggest any link I shuould look into and any comment about my ADC strategy.

    Chetan

  • Hi,

    Still my advise to look at the application notes related to MSP430 micro mentioned in my first reply - there is some theory about measurement by sampling power lines and also an analysis of errors in measurements and their corrections. Could give you an idea "how-to" and the problems related to such application.

    You must realize that applying sampling, by definition the power and energy are an integral over the signal period - so be careful to sample the exact same number of times per period for each possible frequency - and you have a range to cover (so the sampling rate must change as a function of frequency. Do not mix that with ADC conversion time, which can be as high as possible, 1Msps). 

    Also, if some signals are less frequently measured or of less importance, you can route them on other sequencer(s) and keep the most important ones on sequencer 0. 

    Of equal importance is the RAM - make some calculations, since the micro may not have enough ...

    Petrei

  • Hi,

    Thanks for reply.

    I have another question. ADC FIFO registers are 32 bit registers (ADADCSSFIFO1). However result is in lower 12 bits only. Every example of using ADC with DMA I come accross uses DMA in a 32 bit mode. with the destination defiend as unsigned long e.g.

    uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT, UDMA_SIZE_32 |  UDMA_SRC_INC_NONE |  UDMA_DST_INC_32 | UDMA_ARB_4);

    uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT, UDMA_MODE_BASIC,
             (void *) (ADC0_BASE + ADC_O_SSFIFO0 + (0x20 * 0)), g_ulAdcBuf, ADC_DSTBUF_SIZE);

    g_ulAdcBuf defined as
    unsigned long g_ulAdcBuf[ADC_DSTBUF_SIZE];

    Will there be any problem if I use it as unsigned short like follows

    uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT, UDMA_SIZE_16 |  UDMA_SRC_INC_NONE |  UDMA_DST_INC_16 | UDMA_ARB_4);

    uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT, UDMA_MODE_BASIC,
             (void *) (ADC0_BASE + ADC_O_SSFIFO0 + (0x20 * 0)), g_ulAdcBuf, ADC_DSTBUF_SIZE);

    and g_ulAdcBuf defined as
    unsigned short g_ulAdcBuf[ADC_DSTBUF_SIZE];

    As result is in lower 12-bits only I can save the RAM reruirement by Half.

    Regards

    Chetan

     

     

  • Hi,

    You may try that, but you must foresee the future functions and operations/calculus where it will be safer to have the buffers in 32 bits format. Usually shrinking and then re-sizing variables generate supplimentary code with impact on both code generated size and bigger execution time. Not a good idea.

    You may try also to lower the number of samples - do you have a real reason to choose 200 or is just a guessed starting piont?

    Petrei

  • @Chetan


    We can use 16-bits as you are mentioning.