Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Delay on Expression Window Values (Read 10304 times)
TommiP
Newbies
*
Offline


Posts: 7
Location: Finland
Joined: Feb 4th, 2015
Delay on Expression Window Values
Feb 4th, 2015 at 6:31pm
Print Post  
Hi All

I've have an issue with AvrStudio 6 (v6.2.1502 SP1) debugger expression window delay. I've used Visual Micro for awhile now and just registred it today.. I don't know was there a connection but after that I noticed that there is a huge delay is values compared printed to the LCD.. I've one breakpoint and it will show four variables in Expression window.. There is several seconds, after a while even longer delay in the values.

- Does anyone knows is there particular reason for that ?
- Are there some settings I might try to change to get it live again?

It seems to have something to do with some memory because it keeps increasing while debugger is on. At the moment it's not worth of using for expression window and debugger.

I'm using Uno and 1.0.6 IDE..

BR 
TommiP
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Delay on Expression Window Values
Reply #1 - Feb 4th, 2015 at 6:49pm
Print Post  
Hi,

I have only ever seen a delay when the arduino is sending so much serial data that windows can not process it or the usb driver is struggling.

I assume the same thing happens if you re-start your pc?

How often are you breakpoints executing? Are they in a fast loop? If so I suggest adding a breakpoint condition or setting the hit count.
  
Back to top
IP Logged
 
TommiP
Newbies
*
Offline


Posts: 7
Location: Finland
Joined: Feb 4th, 2015
Re: Delay on Expression Window Values
Reply #2 - Feb 4th, 2015 at 8:12pm
Print Post  
Tim@Visual Micro wrote on Feb 4th, 2015 at 6:49pm:
Hi,

I have only ever seen a delay when the arduino is sending so much serial data that windows can not process it or the usb driver is struggling.

I assume the same thing happens if you re-start your pc?

How often are you breakpoints executing? Are they in a fast loop? If so I suggest adding a breakpoint condition or setting the hit count.


Me neither.. Reboot didn't help. The breakpoint was executed each cycle (about every 90ms) but I moved it to the loop which is updated every 250ms and now it's much better now. Also clearing the Output window will help, when it starts to delay. I haven't tried hit count yet. I first have to learn how to use it.

- Is there maybe a setting available which will stop Output window / serial printing totally while debugging? I wouldn't need the information anyway 'cos there is an Expression window..

TommiP
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Delay on Expression Window Values
Reply #3 - Feb 4th, 2015 at 8:15pm
Print Post  
Thanks for the update, few questions ...

Are you talking about the output window called micro trace?

Is your code also outputting serial messages?

By the way the breakpoint hit count defaults to millis but not much point in using it if you have your own time controlled routines and can slow things down as you have.

« Last Edit: Feb 4th, 2015 at 8:16pm by Tim@Visual Micro »  
Back to top
IP Logged
 
TommiP
Newbies
*
Offline


Posts: 7
Location: Finland
Joined: Feb 4th, 2015
Re: Delay on Expression Window Values
Reply #4 - Feb 5th, 2015 at 6:16pm
Print Post  
Tim@Visual Micro wrote on Feb 4th, 2015 at 8:15pm:


Thanks for the update, few questions ...

Are you talking about the output window called micro trace?



Yes, that's the one. It keeps printing those same variables which are in the Expression window.. 


Tim@Visual Micro wrote on Feb 4th, 2015 at 8:15pm:


Is your code also outputting serial messages?



No, if you mean by "Serial.print();".. I don't have any of those in my code. It was my point for start using debugger, that I'll get rid of those by that.


Tim@Visual Micro wrote on Feb 4th, 2015 at 8:15pm:


By the way the breakpoint hit count defaults to millis but not much point in using it if you have your own time controlled routines and can slow things down as you have.



Maybe not but please forgive me, I'm just a newbie in this part of the world  Smiley

I just updated my computer, let me get it fixed and I get you some print screens to clear my jibberish.. Smiley


Edit: Partial ScreenSnip added..
« Last Edit: Feb 5th, 2015 at 7:42pm by TommiP »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Delay on Expression Window Values
Reply #5 - Feb 5th, 2015 at 8:54pm
Print Post  
Hi,

Thanks for the picture. 

One suggestion is to remove all text and white space from your "When Hit" message. Visual Micro will then write one less trace line per breakpoint. 

Visual micro detects if there are just expressions in the when hit (ie: no text or spaces etc), if not it assumes there is a message to be printed.

This combination would not cause a message to be printed...

{var1}{var2}{var3}

This would cause a message
{var1} {var2}{var3}

and this would cause a message

//some text{var1}{var2}{var3}

Another option, if you want a message, is to click the bug icon on the serial monitor and switch text messages from the trace to the output message window. This will leave the trace in one output window and the messages in another which your pc will probably handle better. Alternatively use the same menu to switch messages to the serial monitor which does auto clear when the size grows to large.

We will look at limiting the output window data in future versions. Out of interest what is the spec. of you pc?

Thanks
  
Back to top
IP Logged
 
TommiP
Newbies
*
Offline


Posts: 7
Location: Finland
Joined: Feb 4th, 2015
Re: Delay on Expression Window Values
Reply #6 - Feb 8th, 2015 at 1:15pm
Print Post  
Tim@Visual Micro wrote on Feb 5th, 2015 at 8:54pm:
Hi,

Thanks for the picture. 

One suggestion is to remove all text and white space from your "When Hit" message. Visual Micro will then write one less trace line per breakpoint. 

Visual micro detects if there are just expressions in the when hit (ie: no text or spaces etc), if not it assumes there is a message to be printed.

This combination would not cause a message to be printed...

{var1}{var2}{var3}

This would cause a message
{var1} {var2}{var3}

and this would cause a message

//some text{var1}{var2}{var3}

Another option, if you want a message, is to click the bug icon on the serial monitor and switch text messages from the trace to the output message window. This will leave the trace in one output window and the messages in another which your pc will probably handle better. Alternatively use the same menu to switch messages to the serial monitor which does auto clear when the size grows to large.

We will look at limiting the output window data in future versions. Out of interest what is the spec. of you pc?



Thanks. It seems to be working fine in ~4Hz loop and without any extra texts (only{var1}{var}..)

PC which was used is laptop, dual 1.35 GHz AMD E1-6010 APU processor and 12Gt of RAM.
I've changed since into my new computer which is Intel Core i7-4790 CPU Quad 3.6 GHz and 8Gt RAM

Even with the new one it's not working in fast loop, I don't should it or am I doing something wrong..

-Tommi
« Last Edit: Feb 8th, 2015 at 1:16pm by TommiP »  
Back to top
 
IP Logged
 
TommiP
Newbies
*
Offline


Posts: 7
Location: Finland
Joined: Feb 4th, 2015
Re: Delay on Expression Window Values
Reply #7 - Feb 8th, 2015 at 1:42pm
Print Post  
TommiP wrote on Feb 8th, 2015 at 1:15pm:
Tim@Visual Micro wrote on Feb 5th, 2015 at 8:54pm:
Hi,

Thanks for the picture. 

One suggestion is to remove all text and white space from your "When Hit" message. Visual Micro will then write one less trace line per breakpoint. 

Visual micro detects if there are just expressions in the when hit (ie: no text or spaces etc), if not it assumes there is a message to be printed.

This combination would not cause a message to be printed...

{var1}{var2}{var3}

This would cause a message
{var1} {var2}{var3}

and this would cause a message

//some text{var1}{var2}{var3}

Another option, if you want a message, is to click the bug icon on the serial monitor and switch text messages from the trace to the output message window. This will leave the trace in one output window and the messages in another which your pc will probably handle better. Alternatively use the same menu to switch messages to the serial monitor which does auto clear when the size grows to large.

We will look at limiting the output window data in future versions. Out of interest what is the spec. of you pc?



Thanks. It seems to be working fine in ~4Hz loop and without any extra texts (only{var1}{var}..)

PC which was used is laptop, dual 1.35 GHz AMD E1-6010 APU processor and 12Gt of RAM.
I've changed since into my new computer which is Intel Core i7-4790 CPU Quad 3.6 GHz and 8Gt RAM

Even with the new one it's not working in fast loop, I don't should it or am I doing something wrong..

-Tommi


I have an other project where Breakpoint could be in the fast loop and there aren't any delay..
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Delay on Expression Window Values
Reply #8 - Feb 11th, 2015 at 11:52am
Print Post  
In the sketch that you encountered the problem, is it possible your breakpoint happened in code that was not hit for a few seconds after the actual event?
  
Back to top
IP Logged
 
TommiP
Newbies
*
Offline


Posts: 7
Location: Finland
Joined: Feb 4th, 2015
Re: Delay on Expression Window Values
Reply #9 - Feb 15th, 2015 at 10:20am
Print Post  
Tim@Visual Micro wrote on Feb 11th, 2015 at 11:52am:
In the sketch that you encountered the problem, is it possible your breakpoint happened in code that was not hit for a few seconds after the actual event?


I'm sorry about delay but I've been quite busy Smiley

No, I don't think that's possible if I understood your questions right. It's on the line which will be hit every third cycle.
There are only three states in this machine and it will be on the line every 10-20ms..

Code
Select All
void loop()
{
	switch(state)
	{
		case 0:	//readPots
		readPots();
		break;

		case 1:	//rudderControl
		rudderControl();
		break;

		case 2:	//printLCD
		printLCD();
		break;

		case 3:	//readRotaryEncoder
		readRotaryEncoder();
		break;
	}

	//analogWrite(3, abs(Output));
}

void readPots()	//state 0
{
	currentState = 0; //nykytila
	nextState = 1; //seuraava tila

	PotSensorValue = analogRead(PotAnalogInPin); //luetaan ohjauspotikan arvo
	ServoSensorValue = analogRead(ServoAnalogInPin); //luetaan actuattorin potikan arvo
	deltaSensor = PotSensorValue-ServoSensorValue; //lasketaan potikoiden välinen erotus

	if(filtering == true) //jos vaimennus on päällä (rivi 12)
	{
		//Vaimennus
		//OUTPUT =(INPUT + OUTPUTlast * k - 1) / k
		PotSensorValue = (float)(PotSensorValue + PotSensorValueWas*(PotVk-1))/PotVk;
		PotSensorValueWas = PotSensorValue;

		ServoSensorValue = (float)(ServoSensorValue + ServoSensorValueWas*(ServoVk-1))/ServoVk;
		ServoSensorValueWas = ServoSensorValue;
	}

	//PotSensor: {PotSensorValue}, RudderCommand: {rudderCommand}, ServoSensor: {ServoSensorValue}, rudderPosition: {rudderPosition}
	state = nextState; //asetetaan seuraava tila
}

void rudderControl()	//state 1
{
	currentState = 1; //nykytila
	nextState = 2; //seuraava tila

	if(deltaSensor > deadBand || deltaSensor < -deadBand)
	{
		if(deltaSensor > deadBand)  //Actuator should move out
		{
			movingOut = true;
			if(steeringActivated == true)
			//if(outputValue <= 255 && steeringActivated == true)
			{
				outputValue = deltaSensor * sk + motorSpeedMin;
				outputValue = constrain(outputValue, 0, 255);  //outputValue can't be > 255
				analogWrite(analogOutPin1, outputValue);
			}
		}

		else if(deltaSensor < -deadBand)  //Actuator should move in
		{
			movingIn = true;
			if(steeringActivated == true)
			//if(outputValue <= 255 && steeringActivated == true)
			{
				outputValue = -deltaSensor * sk + motorSpeedMin;
				outputValue = constrain(outputValue, 0, 255);
				analogWrite(analogOutPin2, outputValue);
			}
		}
	}
	else if(deltaSensor < deadBand || deltaSensor > -deadBand)
	{
		if(movingOut && deltaSensor <= 0)
		{
			movingOut = false;
			outputValue = 0;
			analogWrite(analogOutPin1, 0);
			analogWrite(analogOutPin2, 0);
		}
		if(movingIn && deltaSensor >= 0)
		{
			movingIn = false;
			outputValue = 0;
			analogWrite(analogOutPin1, 0);
			analogWrite(analogOutPin2, 0);
		}
	}
	state = nextState; //asetetaan seuraava tila
}

void printLCD()	//state 2
{
	currentState = 2; //nykytila
	nextState = 0; //seuraava tila

	currentMillis = millis();

	//lcdUpdate
	if(currentMillis - previousMillisLcdUpdate >= lcdUpdateInterval)
	{
		previousMillisLcdUpdate = currentMillis;

		// print the results to the lcd
		lcd.setCursor(3,0);
		lcd.print("Pot:");
		lcd.setCursor(8,0);
		lcd.print(PotSensorValue);

		lcd.setCursor(1,2);
		lcd.print("Servo:");
		lcd.setCursor(8,2);
		lcd.print(ServoSensorValue);

		lcd.setCursor(3,3);
		lcd.print("Out:");
		lcd.setCursor(8,3);
		lcd.print(outputValue,0);
		lcd.print("    ");

	}
	state = nextState;
}

void readRotaryEncoder() //state 3
{
	currentState = 3; //nykytila
	nextState = 0; //seuraava tila

	static int pos = 0;

	encoder.tick();
	debouncer.update();

	int button = debouncer.read();
	int newPos = encoder.getPosition();

	if(button == false && buttonPressed == true)	//nappi painettuna
	{
		digitalWrite(LED_PIN, HIGH);
		buttonReleased = true;
		buttonPressed = false;

		if (cursorOn == false) cursorOn = true;
		else cursorOn = false;

		cursorPos++;
		if (cursorPos >= 7) cursorPos = 1;
	}
	else if(button == true && buttonReleased == true)	//nappi vapautettuna
	{
		digitalWrite(LED_PIN, LOW);
		buttonReleased = false;
		buttonPressed = true;


	}

	if (pos != newPos)
	{
		if(newPos < pos)
		{
			if(cursorPos == 1 && Kp <= 9) Kp = Kp + 1.0;	//Kp 1.0
			if(cursorPos == 2 && Kp <= 9) Kp = Kp + 0.05;	//Kp 0.1
			if(cursorPos == 3 && Ki <= 9) Ki = Ki + 1.0;	//Ki 1.0
			if(cursorPos == 4 && Ki <= 9) Ki = Ki + 0.05;	//Ki 0.1
			if(cursorPos == 5 && Kd <= 9) Kd = Kd + 1.0;	//Kd 1.0
			if(cursorPos == 6 && Kd <= 9) Kd = Kd + 0.05;	//Kd 0.1

			Kp = constrain(Kp, 0, 9.9);
			Ki = constrain(Ki, 0, 9.9);
			Kd = constrain(Kd, 0, 9.9);
		}
		else
		{
			if(cursorPos == 1 && Kp >= 0) Kp = Kp - 1.0;	//Kp 1.0
			if(cursorPos == 2 && Kp >= 0) Kp = Kp - 0.05;	//Kp 0.1
			if(cursorPos == 3 && Ki >= 0) Ki = Ki - 1.0;	//Ki 1.0
			if(cursorPos == 4 && Ki >= 0) Ki = Ki - 0.05;	//Ki 0.1
			if(cursorPos == 5 && Kd >= 0) Kd = Kd - 1.0;	//Kd 1.0
			if(cursorPos == 6 && Kd >= 0) Kd = Kd - 0.05;	//Kd 0.1

			Kp = constrain(Kp, 0, 9.9);
			Ki = constrain(Ki, 0, 9.9);
			Kd = constrain(Kd, 0, 9.9);
		}
		pos = newPos;
	}
	state = nextState;
}[/size]
 



Anyway, I've been working with debugger now in other projects and it has worked like a dream.. 
I must have done something stupid with that one but I can't tell what it is..  Sad Huh Smiley
« Last Edit: Feb 15th, 2015 at 12:29pm by TommiP »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Delay on Expression Window Values
Reply #10 - Feb 15th, 2015 at 2:14pm
Print Post  
Ok thanks for the update. 

In the project that failed is it possible you switched off the project property called ThrottleEnabled?

10-20ms is too fast for the pc to process serial/debug messages. In that case Visual Micro should slow the arduino cpu down by pausing to ensure breakpoint messages are sent max every 70-100ms. The throttle setting does this and it is enabled by default.

So my question is: did you switch the throttle off? If not that means that Visual Micro needs to increase the automatic throttle delay (which is calculated based on pc cpu speed)

Thanks
« Last Edit: Feb 15th, 2015 at 2:15pm by Tim@Visual Micro »  
Back to top
IP Logged
 
TommiP
Newbies
*
Offline


Posts: 7
Location: Finland
Joined: Feb 4th, 2015
Re: Delay on Expression Window Values
Reply #11 - Feb 15th, 2015 at 5:32pm
Print Post  
Tim@Visual Micro wrote on Feb 15th, 2015 at 2:14pm:
Ok thanks for the update. 

In the project that failed is it possible you switched off the project property called ThrottleEnabled?

10-20ms is too fast for the pc to process serial/debug messages. In that case Visual Micro should slow the arduino cpu down by pausing to ensure breakpoint messages are sent max every 70-100ms. The throttle setting does this and it is enabled by default.

So my question is: did you switch the throttle off? If not that means that Visual Micro needs to increase the automatic throttle delay (which is calculated based on pc cpu speed)

Thanks


Yes, it seems that was the one.. It was "false" and after I changed it to "true" and Alt+F5 it again, it started to work. Smiley
It runs perfectly even it's keep hitting every 15 milliseconds.

Thanks for help Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint