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.

Cross correlation flow meter using MSP430

Other Parts Discussed in Thread: MSP430F5529

Hi everyone.

I'm working on a project to develop a flow meter using MSP430F5529.

I would like to know about processing power of this microcontroller.

I'm new in MSP430 family.

I this project i'll have to use the cross correlation algoritm to find the velocity of the liquid.

This algoritm needs a lot of multiplication.

My point is, the MSP430F5529 can do the job or i'll have to use some DSP?

Thanks and sorry for the bad english : )

  • Hello,

    If I am understanding the question correctly, this is not a matter of clock cycles required for multiplication.  You're afraid that so many multiplication commands will cause the MCU to stall.  The compiler is optimized to process multiplication as quickly as possible, but there are a few factors that affect this such as variable sign (unsigned is faster) and size (8-bit multiplication is faster than 16-bit).  Division takes longer, so try to avoid it altogether.  The MSP430 initializes at an operating frequency of 1 MHz, but you can raise that up to 24 MHz to increase your processing speeds.  Refer to the Family User's Guide to find out how to do that.  This also all depends on how many other peripherals and interrupts are being used, consuming more clock cycles, but the fact that you think it can be accomplished with a MSP430F5529 makes any DSP overkill by comparison

    Thanks

    Ryan

  • Lucian Silva said:

    I this project i'll have to use the cross correlation algoritm to find the velocity of the liquid.

     What processor can sustain number crunching is matter of underneath math and physic detail of what is in your mind...

     To answer this question some more detail are needed to evaluate how many multiplication must be done on one second. This processor has hardware multiplier on chip so it can handle multiplication in parallel to cpu from table using a dma channel for example.

     How you need measure the speed, ultrasound or other?

     Wich resolution do you need?

     How many dynamic do you need?

     Bandwidth or throughput of processed data?

     Maybe this processor is adeguate, you need a 32 bit or a multicore DSP but before we need fix problem values.

  • First of all thanks for the answer Ryan!

    I'll use 13 A/D pins to read 13 values of a phototransistor Vout.

    I was thinking to collect 50 samples of these A/D pins (50*13 values) and after do the cross correlation of the values.

    I'll use a timer interrupt for the A/D reads, and after finished calculate the cross correlation of these value.

    My goal is to verify if this calculation can be done in 500ms.

    I'll use a 24MHZ crystal on XT2.

    I have a doubt: for multiplication process, the compiler otimizate using automatically the 32 bits multiply hardware (MPY32) or i have to use the functions in MPY32.C library?

    Thanks!

  • Thanks for the answer Roberto (are you brazilian?it's a common brazilian name :P)

    I don't know certainly what speed i'll be, but i believe in max of 100km/h.

    The A/D resolution it will be 8bits.

    I'll need to calculate the cross correlation between two Vout voltage signals of a pfototransistor that will be disturbed by the passage of the liquid. The maximum cross correlation will give me the phase shift of the signals (in samples delay), and with the known distance between the phototransistors i can calculate de speed of the liquid.

    My goal is to calculate the speed in 500ms (2Hz).

  • Lucian Silva said:

    I'll use 13 A/D pins to read 13 values of a phototransistor Vout.

     This sound strange,  is the yellow part to be interpreted as <<from phototransistorS>> ?

     So 13 values got from ad then:

    Lucian Silva said:

    I was thinking to collect 50 samples of these A/D pins (50*13 values) and after do the cross correlation of the values.

    so you need 50*13 -> 650 values or an array 13*50 in size of integer values.

     Multiply and Multiply accumulate execute on a single clock cycle but you have to load data to multiplier and store away, I suppose this can steal at least 10 cpu cycles if highly optimized, supposing a lot of other calculation has to be done to correlate in a 500mS @25Mhz you have 12.5 Million clock cycles that can fit near a million hardware multiplication. IMHO your low bandwidth application of 2Hz can fit better on this processor, otherwise I don't know again about what kind of correlation you are thinking about.

     Sampling can be done with a small cpu intervention just feeding the new sample array base at end of sequence filling up a new sampling table, this just with a good adc sequencer programming, then a background process has a lot of time to do calculation for on a twin table model.

    Lucian Silva said:
    I have a doubt: for multiplication process, the compiler otimizate using automatically the 32 bits multiply hardware (MPY32) or i have to use the functions in MPY32.C library?

     Again this is dependent from IDE compiler are you using for, can be automatic usage or dedicated to some part of code.

     If you plan all correlation calculations can be done from table driven only,  then coefficient table, sample table and processed values can be completely feed and stored from MPY just by DMA channel without cpu intervention.

  • Lucian Silva said:

    I don't know certainly what speed i'll be, but i believe in max of 100km/h.

     I was speaking about processing speed so this is irrelevant to choose computing power then processor. 100Km/h translate to 27.777... m/s but again this has no detail to what are you are measuring from fluid flow.

    Lucian Silva said:
    The A/D resolution it will be 8bits.

     MSP 430 family carry a 10 or 12 Bit SAR type or 16 to 24BIT sigma delta AD converter, processor is a 16Bit so is better to extend all sample to 16 Bit signed or unsigned value to increase processing time. Usage of 8 bit values slow down processing needing conversion of operand, take this in mind if you need save storage space, 25 MHz devices are the top series 5xx 6xx and I think ram is enough to store two samples array and all you need leaving enough spare space.

    Lucian Silva said:
    My goal is to calculate the speed in 500ms (2Hz).

     And again here you wrote about phase calculation but phase of what?

    Are you thinking about refractometry reading the phase of fluid travelling waves distortion read by a some surrogate of linear ccd reading how much light is adsorbed in space and time? This can be achieved by processor.

     Are you thinking about phase shift of laser doppler velocimetry or anemometry (again no detail about fluid kind) so a coherent laser source and phase detectors can read phases differences from source? This can be more difficult and maybe demand for a DSP dedicated processor coupled with high speed ADC.

    Lucian Silva said:
    Thanks for the answer Roberto (are you brazilian?it's a common brazilian name :P)

    Then the less important question:

     I live in Italy where I born and I am tired a lot of my country bad government still destroying our industrial knowledge and infrastructure and still school where it was the key to respin country too. I am too old to move away but this country is driving me to go far far away from here.

     I think this addressed your need, greet  have good time.

  • Hi Roberto, thanks again for the answer!

    My goal is to put on one side 13 IR emitter and on the otherside 13 Phototransistors.

    The arrays of IR emitters-phototransistors  will be like this:

     

          |           liquid flow

          \/   

    x x x x x x 

    x x x x x x

    The first array of emitters-phototransistors will give me some voltage values and the second array too.

    The density of the liquid it changes , so the voltage values will be diferent over the time.

    My goal is to compare the signals from the first and the second array. For this i'll use the cross correlation algorithm. With this, my goal is to calculate the speed of the liquid by the phase shift of the 2 signals generated by the disturbance of the liquid.

    I dont know how many A/D values i'll need to do the cross correlation calculus .

    I'll start with 50 values and see if works.

    Again, sorry for the bad english.

  • Lucian Silva said:

    The first array of emitters-phototransistors will give me some voltage values and the second array too.

    The density of the liquid it changes , so the voltage values will be diferent over the time.

     Ok this set the method you are planning to use so you are evaluating the fluid wave density transported by fluid speed, I had no direct experience on that method but I can suggest try a linear ccd on one side and a uniform IR source on other side.

     A ccd has no intensity difference between cells, is faster and can catch better the wave image in one shot without adding optical aliasing due to sampling rate.

    Lucian Silva said:
    Again, sorry for the bad english.

     Problem is not little English or misspelling but lack of important details about how to help you, I am not native so I am not so proficient too.

  • Thanks Roberto for the advices.

    I'll search this CCD and see how it works.

    Best regards!

    Lucian

  • Ryan, as the others stated, this MSP has an MPY32 hardware multiplier, and the compiler uses it by default.
    So any integer multiplication, whether 8, 16 or 32 bit, signed or unsigned, doesn’t take longer than a few MCLK cycles. Just as long as it takes to write the operands and read the result.

    Roberto: 16/32 bit multiplication actually takes more than one MCLK cycle. However, the LSW (least significant word) is available while the MSW is still being calculated, so while you read the LSW, the MSW gets calculated and is available on the next MCLK cycle. You won’t see a difference. :)

    The hardware multiplier has separate registers for 8, 16 or 32 bit signed and unsigned operands, so there is no need for any operand conversion. However, it depends on the compiler (and partly on the formula) whether this advantage is fully used. Unfortunately, the C language interferes here: for a multiplication with 32 bit result, both operands are cast to 32 bit first, while the HWM could easily do an 8*16 multiplication with a 32 bit result without any previous cast.

    Another drawback is that the MPY32 can't save its internal state. If an interrupt interferes and uses multiplication, then it will destroy the ongoing main multiplication (or, worse because more likely, any MAC operation)
    As a result, the compiler disabels interrupts before the multiplication and restores the interrupt state after. This extends the tiem required for multiplication by some MCLK cycles.
    MSPGCC offered a compiler switch to not use hardware multiplication in interrupts and not change the interrupt status around multiplicaitons in main code. Sometimes an option with quite some speed gain.

**Attention** This is a public forum