Re: getting the 57cnc to work with G540

Discussions and file drops for Auggie
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: getting the 57cnc to work with G540

Post by ArtF »

Hi Dan:

  Its as if the power supply your feeding ht epokeys with cant handle the current of turn on/off ( it should be able to pull the
5volts to 0, not just down to 2.5.  Is your power supply for the polkeys more than 1Amp capable?

  OK,in Auggie:

  Auggie will fail to tun any program with an M3 if the spindle isnt setup script wise. You need only two libraries on really..

The Gcode library , and a spindle library. Firs, enable the Gcode library, and the Spindle-Relay library. No other spindle
lib, only one must be enabled.
 
Now, go to the config menu up top, and check the "Debug Log", this enables more messages..

Now, in the Single Line MDi, enter M3, set your line to that and hit run. You should see the following message in the log

" Setting Spindle with 1  " , if so , the Gcode library is on.

You should then see "Relay Spindle was turned on with OC1" , which is how the relay spindle
is set up. It uses OC1 to turn on or off the spindle. Check first that you get those messages.

Next, for your SuperPID on pin 45, youll change the scripts as below, but not till you verify
the messages above..

global SpindleOn = function()
{
    //SpindleDevice.SetOC( MySpindleOutput, 1); //turn on spindle
    //you want pin 45 to be digital on or off, sounds like 0 is on, so..

  Motion.SetPinDig(45,0);

    print("Relay Spindle was turned on with pin 45 = 0");
}; 

//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()
{
    //SpindleDevice.SetOC( MySpindleOutput, 0); //turn on spindle
    Motion.SetPinDig(45,1);
    print("Relay Spindle was turned off");
    print("using pin45 ");
}; 

  Speed is just as easy, but lets see how you make out with off or on.

The fact your on pin only goes to 2.5 volts or 3.5 from 5, may mean you need a pulldown
resistor in that circuit. Ill release a new version shortly to ensure all your script bugs are gone,
but this proceedure  will work if the messages are in your log as above. All we need to know is that
the proper libraries are being called. The log tells you that from the print statements in the scripts.
Let me know how far its getting..

  Using M3 and M5 in the single MDI is a good fast way to test, no need to run files till
you know its working..

Art


Art


 
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

cool thank's art I was playing with different code combo's last night, when you cut and past it make's a mess of the pasted code it needs a fix or re written.

the spindle not working with the Ethernet is a pokeys problem, if it don't work in pokeys it wont work in Auggie.

I was going to ask about the relay as on off as it works with your laser panel.

I am still have fun with it, it's a good new challenge for me to learn coding in monkey.

for the PWM will it be like what glen did. 
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

this does come up

Setting Spindle with 1

Relay Spindle was turned on with OC1

in pokeys I am getting 5.23 off 0 on. PWM is working, inverting pin 45 does nothing.

In Auggie it just stays at 3.23 no change what ever I do. M3 or M5 the wiring is good

one thing is IO online under config meant to be ticked or not, if I tick it then look again it's un ticked
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: getting the 57cnc to work with G540

Post by ArtF »

Dan:

  SO the scripts are getting called, and the OC1 relay is begin commanded. ( OC1 turns on my laser supply..)

You need to change that script to set pin 45 to on or off.. You need to put a

  SpindleDevice.SetPinDig( 45, 1); 

  Where I put the line

  SpindleDevice.SetOC( MySpindleOutput, 1); //turn on spindle

and you need to put

SpindleDevice.SetPinDig( 45, 0); 

  Where I put the line

  SpindleDevice.SetOC( MySpindleOutput, 0); //turn on spindle

  That way, instead of the OC1 relay toggling as in my system,  your pin 45 will toggle ..

Art









DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

that makes senses fuck I am a noob  ;D ;D ;D
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

did the change I have this

global SpindleOn = function()
{
    SpindleDevice.SetPinDig( 45, 1);  //turn on spindle
    //you want pin 45 to be digital on or off, sounds like 0 is on, so..

  Motion.SetPinDig(45,1);

    print("Spindle was turned on with pin 45 = 1");
}; 

global SpindleOff = function()
{
    SpindleDevice.SetPinDig( 45, 0);  //turn on spindle
    Motion.SetPinDig(45,0);
    print("Spindle was turned off");
    print("using pin45 ");
}; 

it still fall's pin45 does not switch in Auggie.

the OI is still not turning on could that be it
I changed the 1 and 0 around
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

I have been playing some more went back to OC1 it is working power 0 or -5 don't know why -.

could I use OC1 for spindle on off
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: getting the 57cnc to work with G540

Post by ArtF »

Dan:

  Yes, you can use the relay output, just ground one side of the relay, and hook the other side of the relay to your SuperPID on signal
currently on pin 45.. but see the end of this to see how to use the relay..or the OC1..


Note:

    SpindleDevice.SetPinDig( 45, 1);  //turn on spindle
    //you want pin 45 to be digital on or off, sounds like 0 is on, so..
    Motion.SetPinDig(45,1);

  You dont need both here. In fact , I probably misled you, in that same library the following line is at the top..

global SpindleDevice = Motion(); 

  This means "SpindleDevice" is a variable of Type Motion. ( The motion pokeys );

When you put

    Motion.SetPinDig(45,1); , this probably triggers an error. "Motion" is a type of variable
, in this case a Pokeys, but you cant use the word "Motion" in the command, you need to use the
variable representing "Motion", so you use the variable as above, "SpindleDevice"

Consider it this way, lets say I have in the program a variable TYPE called Car.
you could use a line similar to the spindle line above such as

MyCar = Car();

it then is OK to use

MyCar.RollDownWindow();

or MyCar.EmptyAshtray()...

but not Car.EmptyAshtray().

  To use "Car", you must "instantiate" a variable of type "Car". ex: MyCar = Car(); or Arnold = Car(), or
ThisisavariableoftypeCar = Car();

So , I probably have been misleading you as I tend to use Types as
illustrations. Ill talk about Motion.SetPinDig( pin, value) as a command
where in reality, it would be "Motionvariable".SetPinDig(pin,value);

  so , as above in the file I have a global declared..

global SpindleDevice = Motion(); 

  This means any call that derives from "Motion", you call with SpindleDevice, but you cant use the word
Motion, its reserved as a type.

So if you look in your global list in the scripter, youll see terms like

Motion.GetEncoder or Motion.SetPinDig , this all means calls to

SpindleDevice.GetEncoder or SpindleDevice.SetPinDig are legal calls, but
not the actual Motion.SetPinDig..

  The globals list is a list of Types generally, that you can make variables from,
and then call their routines. It shows all the routines a variable type may have.
Check the list , notice things like file.ReadChar and file.Open, there is a long list
of such variables, they are all types. So the globals list is showing types, and type calls.
So in that example, one coudl use

MyFile = file();
MyFile.Open("myfile");
MyFile.ReadChar() ...

  (Dont try using File till I show examples, but my point here is to show how you use
the knowledge of a "Type" to create variables and use them. Long point I know,
but remove the Motion.SetPinDlg, and just change my Spindle calls to Pin45. They should work..
but its possible the pokeys doesnt have the current sink to pull the super PID to 0 to turn it on,
so feel free to use the relay call as I do.



  Question me on this if it isnt clear, reread it a few times if not as well, as
if you understand this topic, you ocan write near anything, but one has
to understand the Types and how you make variables form those Types..


kk, now we can talk about OC1 and the relays..

GlobalSet( "ExtRelay1" , 1); will turn on the relay on the 57cnc,
GlobalSet( "ExtRelay1" , 0); will turn it off.

  These calls use the globals system to do control. Some controls on the pokeys
are important enough to have variables of their own. Relays are such.. So try the above
commands one at a time in your scripter, youll hear the relay toggle on or off. (Makes
a loud click..).

  Youll notice I have a "Laser Power" button which turns relay#1 on or off as well, it
does this by setting the global "ExtRelay1" to a 1 or a zero. This is done just by placing a button
and call it it variable name ExtRelay1. When you press the button is sets ExtRelay1 to "1" or"0",
thus doing the same as scripting a call to GlobalSet( "ExtRelay1" , 1);

  So if you want to use the relay, just replace

SpindleDevice.SetPinDig( 45, 1);  //turn on spindle

with

GlobalSet( "ExtRelay1" , 1);  //turn on YOUR spindle

and in the off script, call

GlobalSet( "ExtRelay1" , 0);


  The other posability are the OC's, these are OpenCollector outputs, they can ground any signal,
and accept much higher current and voltages than any other.. so a call to

SpindleDevice.SetOC( 1, 1); //turn on OC1 or
SpindleDevice.SetOC( 1, 0); //turn off OC1 woudl also control your spindle power,
just by hooking your pin45 on/off wire to OC1 instead, it will then ground or open
that line to control the superPID's power..

So as you can see, there are multiple paths to control anything in Auggie, just
a matter of understanding those paths, and picking the one that works for you.
(Id use the relay, hearing it click is a good diagnostic, but the OC is easier and it requires
only one wire, it will ground whatever is attached to it to turn it on..



Your getting there.. :)

Art




DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

yes you did confuse me no problem it forced me to think about it more, as there was a differences to what you put here compered to what's in Adding a spindle to Auggie.
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

I am still confused.

if I have spindle lib relay only I don't need any code to turn OC1 on or off but it's 0 vdc off and on -18.3vdc so I think that would be a bad idea.

now is this correct I think I am getting the idea that what is first is the call and what is second is the variable so

global SpindleDevice = Motion(); //SpindleDevices use variable motion

SpindleDevices.SetpinDia(45,1); // turn pin 45 on

but with above I am getting, Setting Spindle with 1, Lookup of SpindleOn failed.
GlennD
Old Timer
Posts: 80
Joined: Tue Oct 18, 2011 4:19 pm

Re: getting the 57cnc to work with G540

Post by GlennD »

Dan
 I think Art already declared a var named SpindleDevice so you are probably ok to use it. without another declare.
In either case.

The second line does have a misspelling SpindleDevices.Set pinDia(45,1);
should be SpindleDevice.Set pinDia(45,1);

Can't tell you how many times I have done something like that usually, swap letters. :)

Glenn
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

ta still no go
GlennD
Old Timer
Posts: 80
Joined: Tue Oct 18, 2011 4:19 pm

Re: getting the 57cnc to work with G540

Post by GlennD »

If that is a paste from your code I also missed that you had pinDia instead of pinDig
:)
Glenn
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

I will have to double check, it compiles.

another question where should I put the code.
DanL
Old Timer
Posts: 362
Joined: Wed Sep 10, 2014 1:35 pm

Re: getting the 57cnc to work with G540

Post by DanL »

this is what I have for spindle on off is this correct I have it in main Screen.

global SpindleOn = function()
{
    SpindleDevice.SetPinDig( 45, 1);  //turn on spindle
    //you want pin 45 to be digital on or off, sounds like 0 is on, so..

    print("Spindle was turned on with pin 45 = 0");
}; 

global SpindleOff = function()
{
    SpindleDevice.SetPinDig( 45, 1); //turn on spindle
    print("Spindle was turned off");
    print("using pin45 ");
}; 


the other thing I can think of doing is changing the laser box to a spindle box would this work or just be a waste of time. I am going to have a break for a few hours it giving me a headache
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest