72Views8Replies

Author Options:

water meter? Answered

Hello everyone,

I have the water meter (it's just having piston and analog meter). I want to connect this meter to msp430g2553 chip.

In this the output of the water meter should be A(low)  A(low)B(low) B(low), i.e. when one input is connected to chip the output will be 2 pulse.

I am doing code in IAR embedded workbench.

can anyone help me with the code.

#include <msp430g2553.h>

void main( void)
{

    P1DIR = 0XFF;P1OUT = 0X00;                      // Clear port 1
    P2DIR = 0XFF;P2OUT = 0X00;                      // Clear port 2
    P3DIR = 0XFF;P3OUT = 0X00;                      // Clear port 3
   

  WDTCTL = WDTPW + WDTHOLD;                                            // Stop watchdog timer                            

  if (CALBC1_1MHZ == 0xFF || CALDCO_1MHZ == 0xFF)                                    
  { 
    while(1);                                                                                         // If calibration constants erased
  }

  DCOCTL = CALDCO_16MHZ;                                                      // Set MCU to run at approximately 16 Mhz
  BCSCTL1 = CALBC1_16MHZ;

/*****Initialize Port 1 & 2******/
  P1DIR = 0x01;                                                                                   // Set P1.1 input (C)
  P1SEL = 0x01;                                                                                  // Set as I/O port
  P1SEL2 &=~ 0x01;

  P1SEL &= ~0x10;
  P1SEL2 &= ~0x10;
  P1DIR |= 0x10;                                                                                  // Set P1.4 output
  P1OUT |= 0x10;


/************flash********/
void write_SegC (char value)
{
  char *Flash_ptr;                                 // Flash pointer
  unsigned int i;

  Flash_ptr = (char *) 0x1040;                     // Initialize Flash pointer
  FCTL1 = FWKEY + ERASE;                           // Set Erase bit
  FCTL3 = FWKEY;                                   // Clear Lock bit
  *Flash_ptr = 0;                                  // Dummy write to erase Flash segment

  FCTL1 = FWKEY + WRT;                             // Set WRT bit for write operation

  for (i=0; i<64; i++)
  {
    *Flash_ptr++ = value;                          // Write value to flash
  }

  FCTL1 = FWKEY;                                   // Clear WRT bit
  FCTL3 = FWKEY + LOCK;                            // Set LOCK bit
}

/********prog******////////
int i;
while(1)
{
  e=getdata()


i have written till here. suggest me how i will take the data from meter and i will produce the 2 pulse at the output?

thank you

Tags:msp430

Discussions

0
None
steveastrouk

2 years ago

I'm sorry, I don't follow the question. All you have posted is the boiler plate initialisation code.

0
None
Dushyant KumarSsteveastrouk

Answer 2 years ago

Consider a water meter which has two wire A &B. I want to connect this two wires into my msp430g2553
board. The board consists of a msp430 chip and three holes on the board
as A, B & C. The one wire of meter wire will connect to C and
another one will be at GND. The output will be from A & B and the
output will be A AB B(all low) in one cycle of 5ms. It means the output
will be 2 pulse. If 100 liters of water is passing through the meter,
the output will generate 2 pulse ->AABB.

0
None
steveastroukDushyant KumarS

Answer 2 years ago

While true;

{

IF C=false then

{ A:=low;B:=high;

wait (5ms)

A:=High;B:=low;

wait (5ms)

A:=High;B:=high

While C=false;

}

}

0
None
steveastroukDushyant KumarS

Answer 2 years ago

Words are not adequate for matters like these. Draw some diagrams.

You get a single pulse from the meter for every what volume out ?

0
None
Dushyant KumarS

2 years ago

here is the diagram. A & B are output and C is input. when C is closed i.e. C is low A & B should be high and when C is open i.e. high; A & B should be low. The output I want you can see in the pic. time 500ms

IMG_20160708_142023.jpg
0
None
Downunder35m

2 years ago

Details, details, details.....
You might know exactaly what you have and want but not everyone has a clue what you do and use ;)
How does the meter provide the pulses, how are they related to the water usage?
How do you aquire the signal from the meter?
Why do you need different pulses?

0
None
Dushyant KumarSDownunder35m

Answer 2 years ago

Ok. the thing is Consider a water meter which has two wire A &B. I want to connect this two wires into my msp430g2553 board. The board consists of a msp430 chip and three holes on the board as A, B & C. The one wire of meter wire will connect to C and another one will be at GND. The output will be from A & B and the output will be A AB B(all low) in one cycle of 5ms. It means the output will be 2 pulse. If 100 liters of water is passing through the meter, the output will generate 2 pulse ->AABB.