06-14-2011 04:22 AM
Our chief engineer gave me a task yeasterday.He asked me to do software testing and calculate bit error rate that we would know our communication stability.
However,I have never touched this aspect of knowledge. I have known a bit about CVI and I want to write bit error rate code using CVI.Thus,I could test the communication stability.
But I don't know how to analyse and judge the receiving codes whether they are right or wrong.
We use Modbus communication protocol and receive data via serial port,so I want to save all datas and record the total datas number ,marking as M.
then,save the eligible datas and record the mumber marking as N. So, bit error rate is (M-N)/M .
Whether this is feasible ? Or you have any good idea. Thank you very much.
unsigned char in_data[100]; inqlen = GetInQLen (comport); for(i=0;i<inqlen;i++) { in_data[i]=ComRdByte(comport); }
Above is my code that receive all datas and I want to save the array in_data[] data and record the number.
switch(inqlen) { case 19: { crc=usMBCRC16(in_data,inqlen ); if((in_data[1] == 0x03)&&(crc==0)&&(in_data[0]==device_addr)) { } }
Above is the condition judgement that receive eligible datas which number marks as N.
I know there is a precondition that I filter out all the wrong data . However ,I don't know any good idea. I will appreciate if anyone could help me.
Thank you very much.
Best regards.
xiepei
Solved! Go to Solution.
06-15-2011 12:47 AM
Hi ,
I can give you a simple idea it's not a know algorithm but it can do the job.
Declare 2 char arrays size of 256.
randomChar[256];
copyChar[256];
Then fill randomChar with random letters/numbers and copy it to copyChar;
send the randomChar and receive it with your serial connection.
Then compare you result and find how many bits from you array ( 8 * 256 ) where changed.
Calc your error by WrongBitsNum/TotalNumberOfBits .
You can send this a few times and get a better resolution of your error rate.
06-15-2011 01:08 AM
Hi Kobi Kalif !
Thank you very much for your reply.
Your idea is good.
but,I don't know whether it is feasible .Because the system to be tested is not my programm.It's the system that send me the datas.
Our cheif engeer wants to know that system's communication stability and ber.
Is there another idea ?
Thank you very much.
Best regards.
xiepei
06-15-2011 01:19 AM
I probably didn't understand ,
So you have a device that sends to you data and you want to test the BER of that data.
If you know what's the data send to you ( Number / String ..... ) then you can simply compare it with know "strings" if it's not equal then you test the bits to see how many received with error.
If I sill doesn't understand your system then add a draw or something like that , and I will try to help more.
06-15-2011 02:03 AM
Hi !
You are right.I have a device that sends to me data and I want to test the BER of that data.
Let me tell you detail. Our company's mine power sells well ,but with lots of problems when using.So our chief engineer wants to know the mine power's communication stability and it's BER.
I have not touched this aspect of knowledge about software testing.So I want to use CVI receiving the datas that coming from mine power and write a piece of code to calculate BER.
However,I do not know to to write this code.
Of course,I could use another tool .But I only know some knowledge about CVI.
Thank you very much.
Best regards.
xiepei
06-15-2011 04:05 AM
Hi ,
you have a product that uses serial comunication lets say RS232 for example and you want to test the comunication for BER with CVI.
What you need to do is to go to the RS232 Library and use it's function.
Look at the examples they are greate.
If you know whats the transmitions you need to get for example lets say your device is sending you throw RS232 the string "10101010101010101010101010101"
then you know that you go to the port recive it's contant and analize it with a compare string if you find error like 10101010101030101010101010101
then you go to 3 and counts how many bits are wrong in our case it's 1 error ( 00000001 - > 00000011 ) now you take the error count ( 1 ) and divid it in the total number of bits ( 8 * string size )
for our example 1/(29*8) = 4.3 * 10^-3.
06-15-2011 04:41 AM
Hi xiepei,
since you are using modbus, a simple error checking is implicit in the protocol and is the comparison between returned checksum and the calculated one on the received message: checksum errors, if any, are an effect of communications errors (you should have at least 2 bits changed and on particular patterns to have the checksum be calculated correctly!). You won't be able to calculate BER on them, but you can calculate PER (Packet Error Rate).
Another flag for communication errors, on the other direction, is to intercept error messages from the device: if it fully implements modbus protocol, it should return some warning in case of error (I seem to remember that in some cases it returns the reveived message with some error bits added: please check in modbus documentation).
06-26-2011 10:35 PM
Hi !
Thank you very much for your reply.
I'm sorry to reply it so late.Because I asked for leave these days.
Now,I don't use Modbus communication in this testing programm.It is only based on RS232.
I am trying to calculate BER first.
Next step I want to calculate PER.
However,I have no idea what to do it.
Could you help me with it ?
Thank you very much.
Best regards.
xiepei
06-26-2011 10:39 PM
Hi !
Thank you very much for your advice.
I am sorry to reply it so late, because I have asked for leave these days.
Now I don't use Modbus communication in this testing programm and it is only based on RS232.I am trying my best to calculate BER.
Thank you !
Best regards.
xiepei
06-27-2011 12:12 AM
Hi xiepei,
the basic question is whether you can set your device to transmit a specific bit patter or not. If yes, then you can repeatedly make the device to transmit some message and test the received pattern against the expected one, calculating BER. In this wikipedia page some concepts on BER are depicted, together with some BER stress patterns you may want to use to test communications quality in your environment.
If you cannot set the device to transmit a fixed message, then you need at least a CRC in transmitted message: CRC comparison will permit you a good calculation of PER and some guess on BER.