LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to test the communication stability and calculate ber using the CVI ?

Solved!
Go to solution

Hi !

Thank you for reminding me that my procedure has been doing PER testing.When I press "start"button,it starts testing.I send datas in a timer(TIMER) and receive datas in another timer(PER_TIMER) .

However,the datas displayed on a text box  are  messy codes and error count keeps  increasing. When I press "stop" button,it could not calulate PER and display it.

The following is my programm.Could you please help me examine it ?

Thank you very much !

Best regards .

 

xiepei

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 11 of 20
(2,126 Views)

Hi xiepei,

there are several remarks about your code.

 

  1. Why are you using 2 timers? Time events for the timers cannot be guaranteed syncronized; that is, you may be trying to read before the device has responden or even before the command has been sent! Try using a simple polling mechanism inside a single timer: send a request, wait a little, read a response, if any
  2. Open the port with -1 in Output Queue Size parameter: see the help for it to understand the benefits of doing so
  3. You seem to ignore the 'else' statement Smiley Surprised As an example, in flagCallback you have a lot of cases done this way:
    if (countt < 599) {
       do something
    }
    if (countt > 599)
      do something else
    What if countt == 599 ????
    Another example evident example can be found in ReceiveCallback, where a simple 'else' can save a lot of testing, since you have already checked all 'right' cases
  4. Instead of a loop with ComRdByte use a single ComRd
  5. Be careful while using strlen () on binary data streams like your 'data' array: strlen is intended for ASCII text strings and will stop counting at the fisrt NULL byte, so it could give you wrong results. In this case is safe, but you must not rely on this function when treating non-ASCII data
  6. You will see garbage on the textbox with a string made of non-text binary data!
  7. This is wrong: per=(float)(errorcount/(rightcount+errorcount))
    You must do this way: per = (float)errorcount / (float)(rightcount+errorcount)
    Additionally, this line is executed on every timer callback when test is not in execution! It should be executed only once, since values are not subject to change when not testing

Try rearranging the code with these guidelines and retesting: you should get better results.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 12 of 20
(2,120 Views)

Hi !

Thank you very much for your guidelines !

I've modified my codes according  to your advice and I have got better results. But there is a little unsatisfactory about datas displayed on textbox.

It could not be seen refreshing  data when it has refreshed datas sometimes on sending  data textbox.I think it is really refreshing data but we could not see them.

Next problem is that it occurs regular mistakes in the first row 1 data on receiving data textbox.

See this picture.PER.jpg

I have set several testing time(10minutes,20minutes,30minutes,40minutes,50minutes,60minutes),so I use"countt" setting testing time.

The attachment is my programm.I'm sorry to trouble you again. Thank you very much!

Best regards.

 

xiepei

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 13 of 20
(2,097 Views)

I have partially rewritten your code in a more robust and simple way: take a look at the attached file which includes all the modifications and remarks.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 14 of 20
(2,091 Views)

Hi !

Thank you for your help !

Your rewritten code has given me a lot of help.

I admire you for your so neatly written procedures.I have a small change and it basically meet the requirements now.

Please see the picturetesting.jpg

It has only a little time difference between sending and receiving data,I think it has received the datas finally sent and it  is just not enough time to show on receive textbox.

But I don't know how to modify the code. I have to trouble you again.

I will do the BER test after the solution to this problem.

Thank you very much !

Best regards.

 

xiepei

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 15 of 20
(2,082 Views)
Solution
Accepted by topic author 佩林

Time delay between write and read is made on purpose: your device will probably use some time to respond to messages so you must consider it, since now there is a strict polling mechanism send-wait-receive.

 

I never observed a situation like yours with a different count on send and receive textboxes, but I made tests with a simple loopback on the com (tx and rx pins shorted together) so my situation is different from yours.

 

In my opinion you should add an additional case in your testing procedure for no message received at all. Also, adding vertical scrollbars to the textboxes will permit you to roll back the controls and see where the problem arised.

 

void receive_data_function (void)
{
	int		i, j = 0, inqlen;
	float	per;
	unsigned char	readbuf[30], msg[512];

	if (flag == 1) 
	{
		// Check if answer arrived
		inqlen = GetInQLen (comport);   											 			
		if (inqlen > 0) 
		{
			// Read and check answer
			ComRd (comport, readbuf, inqlen);
			if((readbuf[0] == data[0]) && (readbuf[1] == data[1]) && (readbuf[2] == data[2]) && (readbuf[3] == data[3]) && (readbuf[4] == data[4]) && (readbuf[5] == data[5]) && (readbuf[6] == data[6]) && (readbuf[7] == data[7]))
				rightcount++;       // Message OK
        	else
				errorcount++;       // Wrong pattern received

			// Echo answer to the UIR
			sprintf (msg, "%4d:", countt);
			for (i = 0; i < inqlen; i++) 
				sprintf (msg, "%s %02d", msg, data[i]);
			strcat (msg, "\n");
			SetCtrlVal (perpanelHandle, PER_PANEL_RECEIVETEXT, msg);
		}
		else {
			SetCtrlVal (perpanelHandle, PER_PANEL_RECEIVETEXT, "Answer not arrived\n");
			errorcount++;        // No message received at all
		}

                flag_send = 0; //when receive,then reset flag_send 

// Display error count SetCtrlVal (perpanelHandle, PER_PANEL_ERRCOUNT, errorcount); } if (flag == 0) { //display PER when stoping testing per = (float)errorcount / (float)(rightcount+errorcount); SetCtrlVal (perpanelHandle, PER_PANEL_PER, per); } }

 

Also, consider that if you have made the timer 5 times faster, your 'limit' variable must be multiplied by 5 as well.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 16 of 20
(2,078 Views)

Hi !

Thank you very much for your guidance !

I have added vertical scrollbars to the textboxes and it has very good effect.It could permit me to roll back the controls and see where the problem arised.

I also add a "NUMERIC" control to record the running time.

After such a long time testing,I find it would need to reset the communication board,otherwise,it may occurs errors.

Could it explain the communication system unstable ?

 

Thank you very much !

Best regards.

xiepei

 

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 17 of 20
(2,059 Views)

Hi !

Because of our product is escape capsule power supply. It is very important for the system stablity.

Do you know which contents need to be tested except PER and BER ?

Thank you very much .

Best regards.

xiepei

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 18 of 20
(2,056 Views)

Hi xiepei,

unfortunately I cannot be of mich help in this matter as I never dealed with testing digital communications characteristics. The wikipedia page I pointed you to earlier contains some informations about different stress patterns used to completely test BER, but I have no additional informations on this subject.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 19 of 20
(2,052 Views)

Hi !

Thank you very much for your reply.

You have done me a great favor.

I will think another way.

Wish you happy every day.

Best regards.

 

xiepei

I wouldn't care success or failure,for I will only struggle ahead as long as I have been destined to the distance.
0 Kudos
Message 20 of 20
(2,045 Views)