I am new to C#Sharp and i am developing a program to read or program energy meter via serial port.I connect to the meter at 300 baudrate and do initial handshake
At this stage i can connect to the meter after initial /?!<CR>LF> command.The problem i have is when i am attempting to send the ACK command together with baudrate change-over.
I am suppose to send this command(to the meter) withing 1.5s of receiving identification message from the meter and i can 'ACK' within the set limits but struggling with changing form 300 read mode(00) to 9600 (051) mode....."<ACK>051<CR>LF>"
i have tried to close the port (Comport.Close) and set new baud rate(Comport.Baudrate=9600) but it doesn't work.My code looks as below
ComPort.DiscardInBuffer(); // clearing buffer form Dump Mode
ComPort.RtsEnable = false;
ComPort.DtrEnable = false;
ComPort.Close();
await UseDelay();
//then set new settings
ComPort.BaudRate = 9600;// new baudrate
if (ComPort.IsOpen==false)
{
ComPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived);
ComPort.Open(); }
await UseDelay();
ComPort.RtsEnable = true;
ComPort.DtrEnable = true;
byte[] ack = new byte[] {0X06,0X30,0X35,0x30,0X0D,0X0A};
//MessageBox.Show(DataReceived);
ComPort.Write(ack, 0, ack.Length);
}
Can you help me please.
Thank you in advance.
Changing the baud rate might be sometimes difficult. You did not tell the meter model.
One option is if you don't change the baud rate. Use 300. It's slower, but you can test with that.
I also find out that you are writing 050, not 051.
I can actually change the baudate.I can set it to 300(0X30) or 9600(0x35) and i can see the difference on my data which proves that the baudrate has changed.
The issue is it does'nt take 051 .When i use 051 it would stream all data, but if i try to put onto programming mode using 051 i dont get any response from the meter.
And if i set to Manufacture specific mode (059) i get a response of 42 , which i cannot decipher its meaning.
The meter is As220 from Elster
You should check is Elster As220 supporting Programming Mode.
We haven't read IEC meters a long time because the variation between manufacturers/meters is huge.
Thats where my problem is:
1.If I send 050 it streams back data till the end on 9600 BPS
2.If i send 051 ot doesnt respond.
3.If i dont send the ACK within 1.5 sec it just wait for about 30 secs before streaming data on 300 BPS.
Problem with Baudrate change-over after establishing connecting
Hi,
Changing the baud rate might be sometimes difficult. You did not tell the meter model.
One option is if you don't change the baud rate. Use 300. It's slower, but you can test with that.
I also find out that you are writing 050, not 051.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I can actually change the baudate.I can set it to 300(0X30) or 9600(0x35) and i can see the difference on my data which proves that the baudrate has changed.
The issue is it does'nt take 051 .When i use 051 it would stream all data, but if i try to put onto programming mode using 051 i dont get any response from the meter.
And if i set to Manufacture specific mode (059) i get a response of 42 , which i cannot decipher its meaning.
The meter is As220 from Elster
Problem with Baudrate change-over after establishing connecting
Hi,
You should check is Elster As220 supporting Programming Mode.
We haven't read IEC meters a long time because the variation between manufacturers/meters is huge.
BR,
Mikko
Hi Mikko,
Hi Mikko,
Using the manufacturer's software i can read the meter ,and can successfully switch to Programming MODE.
Send: 16:23:43,77 -- /?!<CR><LF>
Recv: 16:23:44,99 -- /ELS5\@V8.23 <CR><LF>
Send: 16:23:45,19 -- <ACK>051<CR><LF>
Recv: 16:23:45,72 -- <SOH>P0<STX>(********)<ETX>h Soll: h
Send: 16:23:45,93 -- <SOH>P1<STX>(********)<ETX>?
Recv: 16:23:46,16 -- <ACK>
Send: 16:23:46,37 -- <SOH>R5<STX>0.8.0()<ETX>_
Recv: 16:23:49,26 -- <STX>0.8.0()<ETX>: Soll: :
Send: 16:23:49,46 -- <SOH>B0<ETX>q
Problem with Baudrate change-over after establishing connecting
Hi,
After you send 051 meter sends seed. You need to send password. I can't remember is baud rate changed before or after sending password.
BR,
Mikko
Thats where my problem is:
Thats where my problem is:
1.If I send 050 it streams back data till the end on 9600 BPS
2.If i send 051 ot doesnt respond.
3.If i dont send the ACK within 1.5 sec it just wait for about 30 secs before streaming data on 300 BPS.
Will keep trying.
Problem with Baudrate change-over after establishing connecting
Hi,
Have you read this?
https://www.gurux.fi/node/5415
BR,
Mikko