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.
Hi,
I am building an Ultrasonic fluid flow meter and am using MSP430G2553 for the velocity measurements. The outputs from pair the sensors is digitized and given to the msp. I need to find the Time Interval between the rising edge of first sensor (Sensor A) to the rising edge of the second Sensor B (during Along and Against the liquid flow).
I have used PORT 1.1 for the input of first pulse and the capture mode for detecting the Second pulse, given to PORT 1.2.
NOTE: the timing difference is in micro-seconds
I have written this code, please provide insight about it
-------------------------------------------------------------------------
#include <msp430g2553.h>
int i,j=0,k=0;
int T[100]=0;
void main(void)
{
int delta_t, velocity;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR = BIT0+BIT6; // green and red as outputs
P1IE |= BIT1; // P1.1 interrupt enabled
P1IES &= ~ BIT1; //lo to hi
P1IFG &= ~BIT1;
_BIS_SR(GIE); //enabling interrupts
while(1)
{
WDTCTL = WDTPW + WDTHOLD; // resetting it to be on the safer side
for(i=0;i<099;i=i+2)
for(j=i+1;j<100; j= j+2)
{
delta_t= T[i]-T[j]; // difference between Along and Against the flow
velocity= delta_t * 1482*1482/ (2*0.03*1000000); // to calc velocity
display(velocity);
}
}
}
// Port 1 ISR to detect the first rising pulse from Sensor-A
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
TACTL=TASSEL_2 + MC_2 + TAIE_0; //SMCLK, continuous mode, disable timer interrupt
TACCTL0= CM_1 + CCIS_0 + SCS_1 + CAP_1 + CCIE_1 + COV_0; // Capture to be taken at BIT2 (Sensor-B), rising edge
_BIS_SR(GIE);
P1SEL |= BIT2; //making bit 2 capture input
P1IFG &= ~BIT1;
}
// ISR when CAPTURE occurs
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
k++;
while(k<100) // to update the timer values in an array
{
T[k]= TA0CCR0; // time diff between pulses for 1 direction of fluid flow
TACTL=MC_0+ TACLR_1 ; //clear timer, for the concern of timer interrupts
}
--------------------------------------------------------------------------------------
Questions
1. Should I reset the watchdog timer in the infinite while loop also?
2. What is the clock frequency of SMCLK?
3. Is ok to raise another interrupt inside the port interrupt?
4. Most importantly, WILL THE PROGRAMME WORK?
Vasuki,
you do not reset your watchdog, you are disabling it. When you have disabled it right after startup, it remains disabled. No need for a second time. Same for GIE. The clock frequency after startup is something around 1MHz. If you want a more precise calibrated frequency, you should use the factory programmed frequency settings. Insert these two lines after disabling the watchdog to set the DCO to the desired frequency:
BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ;
This will give you 1MHz clock speed. You can also choose 8, 12 or 16MHz - just replace the '1' in _1MHZ (both lines) by the value you want. Concerning interrupts in interrupts...at least I think you can enable the GIE bit in a running interrupt again. But there is no need for that at all. If you think you could "loose" interrupts, first speed up your processor. And look if your ISRs are short and contain only the most important. Don't do complex calculations in there.
Does your program work? I don't know. Test it :-) I haven't looked at your program flow now. Next time when posting code you should use the syntax higlighter. It is easier to read then.
Dennis
Vasuki Shankar said:I am building an Ultrasonic fluid flow meter and am using MSP430G2553 for the velocity measurements. The outputs from pair the sensors is digitized and given to the msp. I need to find the Time Interval between the rising edge of first sensor (Sensor A) to the rising edge of the second Sensor B (during Along and Against the liquid flow).
I think this processor is powerful enough but why not use specialized one for Flow metering like 430FG series or a faster of series 55?
Are you using a frontend to flow meter? Is same are you asking for 550KHz phase detection generally used in flow metering?
Vasuki Shankar said:Yes the 550kHz phase detection is for flow measurement
Are you using a front end to measure fly time? MSP timer resolution is not enough, all depend of precision you need and what is your application. Generally Flow is also related to temperature to measure heat energy flow..
This type of applycation in a short chamber with sound speed near of 1Km/s require resolution in range of nS so have you seen some front end? TI announced but I am not sure it is available.. A better have it integrated on MSP die as for AFE series and all specialized. For now just flow for simple wheel detection seems available, ultrasound you have browse competitor.
www.ti.com/.../application_and_implementation;tisearch=Search-EN-Everything
and also tdc7200 was released so
www.ti.com/.../TDC7200;tisearch=Search-EN-Everything
with these two chip you can measure pS resolution necessary to evaluate flow. Another way is to use C2000 or DSP series processor to estimate fly time and also phase if necessary.
Vasuki Shankar said:Yes the 550kHz phase detection is for flow measurement
This is better than waste time to community for a out of order measurement, better measurement can be done with Timer D MSP430 is near 4nS you need pS resolution, so switch to appropriate hardware...
Vasuki Shankar said:for flow measurement
This is competitor chips, I fear this has no ready software and I don't know about price, both TI evaluation board are really affordable but you need 5529 launchpad, G series is not appropriate or better it is but you need interfaces to transfer data and also some math power to do calculation involved with flow integration.
**Attention** This is a public forum