Page 31 of 59
Re: reading Pokeys pins
Posted: Sun Jul 07, 2019 2:15 pm
by gburk
Art
It was failing when I added the code line the hitting RUN...
So of course it was bugging me all night, so first thing this morning I decided to delete the script file..
I then entered one tool change function at a time, it has a little less code per function now, and all 16 tool functions are working,,
don't know what will happen as I add more code to each function but will find out later...
anyway it does seem to be working now, i'm thing maybe some sort of a glitch somewhere in the code not one I was able to see
spent a lot of time on till I decided to delete old file and start again
You didn't mention if you thought that I would be alright running with the dos's not running to the values I entered 2 seems to stop at 1.994 does it with all the axis's
but if I enter for it to return to 0.0 it doe's ok
Gary
Re: reading Pokeys pins
Posted: Mon Jul 08, 2019 12:54 am
by gburk
Art
It was working then I went to add or modify the code, if I check back in the lib I see no errors in the lib, but if I edit the lib and do a RUN I get compile erorrs
If I hit the tool1 button it runs OK except the machine and work cord seem messed up now if I set the dro's to 0 and them run the script, I added a print to show the start x y z axis positions i am getting them with GetAxisPos(1 2 and 3) I don't get a 0 value I will get what seems random values one time I will get 0.033 but I don't get 0 even though the DRO's are set to 0
My thought is because I am getting the compile errors problem is I don't see anything wrong, only seems to happen after adding or editing the script, but once it starts I have to redo the entire script..
Do you think I should break up the tool chance script into 3 or 4 separate scripts, there is 16 functions in the script. I haven't tried that yet maybe next thing to try.
Thanks gary
Re: reading Pokeys pins
Posted: Mon Jul 08, 2019 1:51 am
by ArtF
Gary:
Breaking it up will probably get it to run. I will check into the GetAxisPos
to see what the error may be. Ill see if I can figure out why the limitation as well,
though I may not be able to do much on that score..depends on its cause.
Art
Re: reading Pokeys pins
Posted: Mon Jul 08, 2019 2:26 pm
by gburk
Art
Update
I deleted the entire script and folder..
Started from scratch..
Now tool1 seems to be working getting the correct Positions values the only thing I see is I do a Gcode or Rapid move on x y z then I do FreeTo
when it does the free move I get the message buffer underrun.. still seems to jog to the correct value though. and now returns to 0..
Still stops a little short of the distance entered seem to be the same every time
if I enter 2.0 axis go's to 1.9994 same for all axis's off just a tad..
I think a lot of the problems are from the scripts getting corrupted don't know why, have typed in some code into notepad++ and copy and pasted into auggie
just a thought..
I have had to redo the tool button scripts from scratch 3 or four times now confused as to why, I did split the tool change into two lib scripts one with tool 1-8 and the other with toll 9-16 will see how that go's..
The getaxispos is ok I think when the script gets corrupted it for some reason messes that up also..
Thanks gary
Re: reading Pokeys pins
Posted: Wed Jul 10, 2019 12:21 am
by gburk
Art
Have a spindle problem, not sure if is me or something internal,
If I do a M3 S3000 the spindle and relays turn on as expected.. and the speed is ok.
Now if I do a M3 S0 it seems to mess up it looks like auggie is calling all the M3 functions over again, turning on relays again, and I get the message spindle turned on it should be turned off I have gone though the code and when I get the spindle speed = 0 I call the spindleoff() function it seems to turn off the spindle and relays but then it looks like it starting the M3 again and turning on the relays
M5 Works fine everything turns off.. Only problem is M3 with a value of 0.
not sure if i'm being clear?.
Gary
Re: reading Pokeys pins
Posted: Wed Jul 10, 2019 1:02 am
by ArtF
Gary:
I think you'd have to add to the SpindleOn script a check of the speed, and if
its zero, just turn it off. I suspect auggie is getting fooled by the m3s0 and not
really knowing what to do. I dont think m3s0 is a typical command, though I can
see where it would have it uses.
Art
Re: reading Pokeys pins
Posted: Wed Jul 10, 2019 1:51 pm
by gburk
Art
Yes I already had a check for 0 if speed = 0 then SpindleOff() it just reacts weird to m3 s0 its fine if m3 is >0 it runs the relays and spindle as expected..
But if I enter a m3 s3000 all is good then if I enter another m3 with s0 is when it messes up.
I have nothing in the code for it to do anything other the relays and spindeoff with m3 s0.,,
Thats why I am thinking if you already sent an m3 s-speed, then another one m3 s0 the second m3 seems to rerun the m3 from the beginning and not just change the speed... I attached the script..
Gary
Re: reading Pokeys pins
Posted: Wed Jul 10, 2019 7:46 pm
by gburk
Art
Did some more messing around with the m3 calls
best I can tell auggie calls, gobal SetSpindleSpeed = function( speed ) is called first, I put a print statement in that function also a sleep(10)
I also put a print statement in global SetSpindleState = function( state ) and a sleep(10).
it printed the print from gobal SetSpindleSpeed = function( speed ) but the sleep didn't seem to have any affect there.. it printed the print from SetSpindleState = function( state ) with no delay at all, but it did sleep after the print in SetSpindleState = function( state ).
So it looks like every time a m3 is called it runs both functions so endless i'm not getting this, and i'm probably not, is if a m3 s200 is call the fist m3 call its good
Now if I call it again m3 s0 or any value it auggie is calling both functions again, so the SetSpindleState = function( state ). is calling spindleOn again and it does set the speed to 0 but it is messing up the relays, that are set with the first spindleOn call...
let me know if you get what I'm trying to say a little confusing
New update
made a few changes seems like it may work here is some of the code let me know if you think its Good or if I may have a problem with it somewhere down the road.
still have the long delays but seemed to do what I expected now..
global MySpindleOutput = 5;
global MySpindleAxis = 5;
//global SpindleMODE = 0;
global SpindleDevice = Motion();
//Sets the Spindle speed, triggered by S3000 fo example
global SetSpindleSpeed = function( speed )
{
print("first speed");
SpindleSpeed( speed );
};
//Set Spindle State.
global SetSpindleState = function( state )
{
if (SpindleMODE == 0 || state == 0)
{
//1 = CW, 2 = CCW, 0 = off
print( "Setting Spindle with " + state);
sleep(10);
switch( state )
{
case 1: { if( lookup("SpindleOn")) { SpindleOn( ); }; }
case 2: { if( lookup("SpindleREV")) { SpindleOff( ); }; }
case 0: { if( lookup("SpindleOff")) { SpindleOff(); }; }
};
}
};
global SpindleOn = function()
{
global SpindleMODE = 1;
FreeSetSpeed( MySpindleAxis, GlobalGet("SpindleSpeed")); //turn on spindle
print("Frequency Spindle was turned on");
print("Set to Frequency " + GlobalGet("SpindleSpeed"));
};
//this is a relay spindle control,
//it will use only the OC output #1
//to control a relay to turn a simple
//on/off spindle, on or off.
global SpindleOff = function()
{
//FreeSetSpeed( MySpindleAxis,0); //turn off spindle
print("Spindle speed zeroed turned off");
global SpindleMODE = 0;
};
//this is a relay spindle control,
//it has no speed control but this dummy
//routine will stop any error, and maybe
//test for zero speed.
global SpindleSpeed = function( speed )
{
print("Entering SpindleSpeed function "+speed);
sleep(10);
if( speed != 0)
{
Maxspeed = GlobalGet("MAXspindleSpeed"); // Max spindle speed
zerotohundred = (speed / Maxspeed) * 100; // Get PWM5 value to set the spindle speed 0-100 for 0-10 volts
SpindleDevice.SetPWM( MySpindleOutput, zerotohundred );
print("Spindle Speed set to " + speed );
}
else
{
SpindleDevice.SetPWM( MySpindleOutput, 0 );
print("Spindle Speed set to " + speed );
};
};
Is there a way to check to see if when sending an m3 if the S is sent also, from what I can tell if no S code sent its doesn't call the spindle speed function
but it still calls the spindleon with no speed setting so I can't check for 0 speed...
Gary
Re: reading Pokeys pins
Posted: Thu Jul 11, 2019 4:52 pm
by ArtF
Gary:
>>You didn't mention if you thought that I would be alright running with the dos's not running to the values I entered 2 seems to stop at 1.994 does it with all the axis's
but if I enter for it to return to 0.0 it doe's ok
Yes, thats fine, its not unusualy to stop just short of a step. So you probably are
using 166.6 steps per inch or mm.. Mach3 does the same, it knows internally where you are
as a number of steps, not a position really.
Im still reading your scripts, but the command m3 literally means turn
on spindle while S means set speed. Typically you turn it on and then only use
S commands to change the running speed. So M3S0 wouldnt be quite the same as
M5 as a stop. Speed is set first when command are on one line, this is just a priority
thing and the spindle speed has higher priority than spindle on.
Now when you call M3, the spindle is set to on, then your script is called.
If the M3 is seen again it does the same. Now I could change this internally
so that if M3 is called when the spindle is already running, the M3 could
be ignored. The S command will still work, you dont need an M3 before
every S command, just for the first turn on.
That may be the best way around it.
Art
Re: reading Pokeys pins
Posted: Thu Jul 11, 2019 5:42 pm
by gburk
Art
Thanks I think I may have it figured out, not being a programmer I sometimes get lost in the logic maybe most of the time.
Anyway with a few global var, placed in the right spots I do have it running fine...
Now that I when from testing m6 to m3 I see that the g code I sent you has no S commands only m3 so spindle turning on but not moving..
So I had to edit cambams post again re ran it an now I have m3 S3000 in the g code,
I ran the g code it was looking good all relays turning on and off spindle flood exc.. tool change dialog also..
But seems like cambam left out the m8 after doing the two dill pecks cycles. so when it started to run the pocket holes no flood strange not sure if I can fix that in the post..
anyway seems like I got the m3 m4 m5 scripts going ok.. tool change seems ok also, so maybe I can clean them up a little now...
I'm sure I will have more questions, we came a long way..
Thanks again Gary