reading Pokeys pins

C Scripting questions and answers
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

 The Pokeys controls that voltage with PWM from 0 - 100%. Usually the Spindle is
controller by just that 0 - 100% setting.

 So to calibrate such a setting.. you set it for 100% and measure the spindle speed. You then
know 100% is ..say 20,000RPM. So then youd script it to put out an error if the requested
rpm is greater than 20,000 or just set 100%, other wise youd set the PWM
to a percentage reflecting the request. So

newpwm = (requestedRPM / 20000.0) * 100.0;

 That RPM would be a simple linear responce curve. One could get more complex I guess.
If you look in the library youll see I use a PWM channel for laser power, in the TestFire
library function it fires the laser with the sliders power for a set time. Youd setup
your Pokeys so a particular channel controls the 0-10volts.
 You can test it just by using the script tab and sending PWM commands
to set various voltages. Then just set the pwm commands into the
SetSpindleSpeed script..

Art

Last edited by ArtF on Wed May 22, 2019 2:09 am, edited 1 time in total.
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

Ok Still lost in space..
In the pokeys configuration the pwm is set to pin17 (pwm 5)
Pdm period 50 and set to (us)

You have a few different scripts with the global SpindleOn() it looks link if I run SpindleOn() in the script window its turning on OC #5 that is in SpindleLib-RelayOnly
I did change it to #5 so I do get the message Relay spindle was turned on OC #5. and I left the other scripts as they were..
If I hit the fire button I get the message spindle not turned on
So to get it to turn on and fire I have to change the  if( Engine.GetSpindleState() == 0 ) to == 1 now the auto on led lights and I get the message
Firing Test: Power and the time, when I press the fire button, but I get no voltage change on pin 17...
I also tried changing global LaserPWMChannel = p.GetInt("Channel",5); to #5 is this correct...?

If I don't change anything and hit the fire button I see the onboard led for OC #4 light up...
But the is no OC led for PWM 5

Also I am running your default laser screen and have all my scripts turned off...

So Like you see i'm lost and most likely on the wrong path here..

Most likely getting you confused as well..

One other thing I see Axis 5 Dro moving when I hit fire and keeps running...

Thanks gary



Last edited by gburk on Sat May 18, 2019 12:29 am, edited 1 time in total.
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

When I turn on the spindle I get the message channel 5 axis 5, this is confusing as far as I can see in your scripts its set to channel 4 axis 8..

and axis 5 starts running I don't see anywhere in the laser scripts that has this print message, so not sure where this channel and axis are being set I don't seem to be able to change it...

Gary
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

In my laser spindle script, I have

p = Profile("rtPWM");
global LaserAxis = p.GetInt("Axis",8);
global LaserMaxPower = 100;  //max power = 100%
global LaserPWMPeriod = p.GetFloat("Period",.0002); //for 5khz tickle 
global LaserPWMChannel = p.GetInt("Channel",4);
//get a pokeys link for the spindle
global SpindleControl = Motion();

    This means the system starts up with getting these data items from
the profile under the heading rtPWM. The declaration as in

global LaserAxis = p.GetInt("Axis",8);


  Means to set the LaserAxis to whatever is stored in the profile,  and
to use 8 as the axis is nothing has ever been set. The 8 is just a
default though. To change it it this type of use you can
simply change my declarations to

LaserAxis = 8; for example. It may be in your profile its stored as
a 5 and so doesnt use the 8 as default. Same thing with Channel
and such, they have defaults, but if set in the profile they can differ.

(You can open your profile, its just text and see if there are entries
for those variables unless you intend to use your own globals.).

Art


gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

I have all my scripts turned off and your default screen running.
and only the script spindlelib-laser turned on the profile for this setup shows axis 8 channel 4 how would I wire that to check output voltage when FIRE Held down?
tried the pins for OC4 + - and also the 0-10v pins... no power change

Now if I run my profile it show's axis 5 channel 5, I have the default laser screen loaded with myprofile and the same scripts loaded as your default screen that has the globals set for axis to 8 and channel to 4, but never changes form axis 5 channel 5 back to axis 8 channel 4.. do I have to save the screen for this... it doesn't change even if I run the script...

With both profiles the correct free axis show dro movement when I use SpindleOn();
But the M3 S has no effect, only using the command SpindleOn(); in the script window...

I had a feeling this was going to be a hard one for me to figure out..

Thanks gary

ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Lets back this up a touch. I havent used the 0-10 volt myself, I use only the
PWM signals themselves. You wont want to use the LaserSpindle library, the
rtSpindle stuff ( Real-Time-Spindle) is a very fast PWM controller for a laser, it
modifies every ms, so its not good for spindle cnc use. We'll use a totally
different control for a cnc spindle.

  So lets first get the 0-10 volts working properly. If you have the correct
PWM channel, then changing its output from 0 - 100% in the Pokeys
software in its PWM config will change the voltage from 0 -10 volts?
Does that much work?  We need to start at a point where we know
that the Pokeys is controlling the 0-10 volts. Then we need
to get to the point where a single script call in the script
window can change that voltage with SetPWM functions. From there
the spindle will not be hard.

You dont need to call any spindle function for that, as I
say we need to ignore the rtLaserSpindle, its a special internal
control and you wont use it.

  When SetSpindleState( state ) is called, you dont need to call
SpindleOn() or SpindleOff(), instead you need to simple call a
function that sets a pwm to the channel controlling the 0-10 volts.
 
inside SetSpindleState( state )
{

  if ( state == 0): SetPwmDuty( channel, 0);
if (state == 1): SetPwmDuty( channel , properspeeddutycycle);
}

  So get the pokeys so you know the right channel is controlling the
0-10 volts.. and once thats definite, Ill guide you to finding what
number is the proper speed and how to send it to the pokeys
at the right time. But igfnore the LaserSpindle library, you will
be turning that off and simply recoding its calls as a general cnc instead
of photo laser engraver.

Art
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

Thanks will start over and shut down all my scripts to test spindle only i'm not totally sure but in the pokeys configuration it show pin 17 pwm 5

so I assume I have to set the axis to 5 or 6 or 7 or 8 whichever I choose and the channel to 5, will start here... anyway.

guess I was steering you in the wrong direction... sorry

Thanks art
gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

Art

I think you mat have me on the right track here is the script

I called it with
SetSpindleState (0); this changed the voltage from .222 to .442
SetSpindleState (1); changed the voltage to 8.5 I think that's the max I seem to be able to output can't reach 10v even with mach4 and my pokeys has no trim pot so can't make any hardware adjustments

Think i'm on the right track?

don't know if the axis is suppose to move like in your laser scripts but it doesn't...

global channel = 5;
global spindleaxis = 5;
global speeddutycycle = 100;
global SpindleControl = Motion();

global SetSpindleState = function(state)
{
  if ( state == 0)
  {
  SpindleControl.SetPWM( channel, spindleaxis);
  }
  if (state == 1)
  {
  SpindleControl.SetPWM( channel , speeddutycycle);
  }
};

Thanks gary
Last edited by gburk on Mon May 20, 2019 4:38 pm, edited 1 time in total.
ArtF
Global Moderator
Global Moderator
Posts: 4557
Joined: Sun Sep 05, 2010 5:14 pm
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

>>SpindleControl.SetPWM( channel, spindleaxis);

You have the right idea, but the wrong parameters. The "SpindleControl" is just a
hook to the Pokeys, so thats correct. But the call is actually..

SpindleControl.SetPWM( channel,  dutycycle );

  So if you set 100, youll get full voltage, if you set 0, youll get 0vdc.
So, in the call you can do a

commandspeed = GlobalGet("SpindleSpeed"); //this will be the Gcode commanded last speed
percent = (commandspeed / 20000) * 100;
SpindleControl.SetPWM( channel,  percent );

  Add a function so that S calls are handled as in..

global SpindleSpeed = function( speed )
{
  /*power is automatic in laser spindle mode..
    no need to specify, in laser mode, spindle
    power is a function of augmentation */
  //but in CNC , we need to set the dutycycle to proper speed.


percent = (speed / 20000) * 100; //0-100% linearized to 0 - 100%
SpindleControl.SetPWM( channel,  percent );

}; 

  Thats about all you need to make a spindle go, though you can be more
complex in its speed command, putting low limits and linearizing just
from min to the max.. many ways to do that I think.

Art


gburk
Site Admin
Posts: 324
Joined: Mon Nov 26, 2018 2:57 am

Re: reading Pokeys pins

Post by gburk »

>> You have the right idea, but the wrong parameter s. The "SpindleControl" is just a
>>hook to the Pokeys, so thats correct. But the call is actually. .

>>SpindleControl.Set PWM( channel,  dutycycle );

Yes figured that out and had removed it...

>>global SpindleSp eed = function( speed )
>>{
>>  /*power is automatic in laser spindle mode..
>>    no need to specify, in laser mode, spindle
>>    power is a function of augmentat ion */
>> //but in CNC , we need to set the dutycycle to proper speed.


>>percent = (speed / 20000) * 100; //0-100% linearize d to 0 - 100%
>>SpindleCo ntrol.Set PWM( channel,  percent );

Yes already have this working also..
I have a setting for max spindle speed and replace the / 20000 with / MaxSpindleSpeed that's in a dro I placed on the screen

haven't tried it on the mill yet but the voltage does go form 0 to 8.5 volt depending on the percent values...

so I think it will work I will try it on the mill in the next couple of days its been hotter that heck here weather people are talking about reaching 100 this week...

My next and hopefully the last function to get working, endless I find other problems along the way..
Is the spindle index, i'm not sure how you would connect it up with auggie  the pokeys doc's say it on pin 13 of the ultra fast encoder...
So I am not sure if a script would be fast enough for the index,  kind of like the probe routine i'm thinking, and it would have to be accessed Constantly to update the rpm dro?

With mach4 I have it connected with the smoothstepper and I am using a c3 I think that's the board from cnc4pc maybe a c6 and just to a pin on the BOB I think i'm using pin 15.
Would I need the index board for pokeys also, it doesn't sound it from the docs but if that would make it easier then that's what I will do..

Thanks gary
 
Post Reply