Question on debugging a script

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Question on debugging a script

Re: Question on debugging a script

by GlennD » Thu Jan 28, 2016 3:47 am

YNN
Sorry about that missed that you weren't getting a value.
Change out the inMin to something less than the spindle value that is getting passed.
So put in 0 to start instead of 8000. 

Looks like we need to test the value first to make sure it is more than what the inMin is.

Glenn

Re: Question on debugging a script

by GlennD » Thu Jan 28, 2016 3:43 am

Ok I just down loaded the latest off of the web and it still shows 1.1 and even with the debug in there it isn't dropping into the scripter to step through.
I know it updated the script files since I have to add everything back in.
Really need to copy that directory.

I wonder if I have something else wrong. 

Glenn

Edit: I did there was one Auggie hung open, when I looked in the task manager.
So it couldn't over write the existing file.  ::)

Re: Question on debugging a script

by GlennD » Thu Jan 28, 2016 3:32 am

Art
Thank you for the video.
Saw some other stuff I didn't know about though.  Zooming of the screen. :)
I had 1.1 still so the debug() wasn't working. 
I thought I had updated last night but guess not.

YNN thank you for the tip.

I post this routine in the shared scripts with some things that might help people later.

Fun stuff..

Glenn

Re: Question on debugging a script

by Amazon [Bot] » Thu Jan 28, 2016 3:26 am

Good Job Glenn

I find the best way is to open the script editor then the mainscreen script, then i can step thru and see the actions.

I create some test routines to pass the data and see what is being processed.

shows me that there is no return value to be passed back from the function.

but I might be missing something you are expecting to see.

Code: Select all

global map = function(Val,inMin,inMax,outMin,outMax) 
{
  result = (Val - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
  print ("Map Result " + result);
  r2 = ToFloat(result);
  return r2;
};
Val=2;
inMin=8000;
inMax=18000;
outMin=0.1;
outMax=100;
Val3=GlobalGet("SpindleSpeed");
debug();
v1 = map(Val,inMin,inMax,outMin,outMax);
print ("map value1: "+v1);
v2 = SetPWMDuty_1(2,map(GlobalGet("SpindleSpeed"),8000,18000,0.1,100));
print ("map value2: "+v2);
v3 = SetPWMDuty_1(2,map(Val3,8000,18000,0.1,100));
print ("map value3: "+v3);
debug();
v3 = SetPWMDuty_1(2,map(Val3,8000,18000,0.1,100));
print ("map value3: "+v3);
debug();

Question on debugging a script

by GlennD » Wed Jan 27, 2016 11:39 pm

Could you do a simple video on the procedure for debugging a script?

I was adding in a mapping function so you could say put in a spindle speed of 8000 on a 18000 rpm spindle and get the appropriate PWM value out at 0 to 100%

I was guessing that the below would return a double but it does always seem to return a integer.

Code: Select all

global map = function(Val,inMin,inMax,outMin,outMax) 
{
  result = (Val - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
  print ("Map Result " + result);
  return result;
};
The print works for getting the value but was wondering if there was a way to step through the code.

Thanks
Glenn

Woohoo JR member now ;D



Top