reading Pokeys pins

C Scripting questions and answers
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Never tried a PoScope. I have a  bench scope and a small pocket scope
thats usb I use in tight situations, but I havent tried a PoScope.

  Ill keep cross my fingers crossed for you.

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

I think you will be happy, I have the new kb wired up and tested it with auggie and the spindle is working m3 S it is changing the speeds ok and m5 shuts it down so will m3 s0.. I haven't tested what the RPM's are yet ended up needing a battery for my rpm reader.. will let you know in the next day or 2 how close it is compared to what I set it to with the m3 S code..

Also I am thinking of setting up CW and CCW spindle I have m4 working, my question is, I still have problems figuring out how to set pins from high to low.
Like if a wanted to control a relay not on board, I need to send 5+ to trigger the relay would SetPinDig GetPinDig be the proper way to read and write to the pin#?.
I know with the probe you have pin19 built into auggies config..

Ok I hooked up pin28 from the lcd 16pin plug and 5+, if I power on pokeys I get nothing from the pin no voltage if I set to 0 or 1 from auggie, now if I run the pokeys config I see the pin28 is set for digital out, but still no voltage change from auggie, but if I invert the pin in pokeys config it will start to work with auggie I can invert it again and still works I can close out the pokeys config and it works great, but if I power the pokeys off and back on its back to not working seems like I allways have to make a change to the pin in pokeys config for it to start working, Any thoughts on this?..


have you had a chance to check the g code m6 running when g code file first loaded..

Thanks gary 
Last edited by gburk on Sun Jun 09, 2019 12:47 pm, edited 1 time in total.
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

I think we have discussed this before dialogs.

anyway if I remember there is no way to read which button was pressed Ok or Cancel correct?

and if I create my own button, is there a way to close the dialog when button pressed?..

dialog doesn't seem to close endless you hit Ok Cancel or the X..

Thanks gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

>>would SetPinDig GetPinDig be the proper way to read and write to the pin#?.

  Yes, Those should set any pin. I dont use any myself though, both my systems
are using the relays as the only output. But, on my test rig, I can turn on or off an LED
on a pin I set with those calls. Im not sure why you need to set it in pokeys though,
I dont. Did you tell the pokeys to save the config when you set it to digtial?
Is it still set to digital out when you next run Pokeys again?

  Last test I did , the M6 didnt run on load, I did add a kill for that but now
Im not sure if I released that version. I will check it and release a version
today or tomorrow just so we're sure. I turned off all macro calls during load
as a safety as I recall.

  As to the Dialog issue, I dont think you have much choice as it is implemented,
the user has to press OK or cancel to exit and close the dialog. I will add a Close()
command for you today , call if from any script that dialog is calling from a button
or item.

  Should be out within a day or two..

Art



gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Some of my problem setting relays other than the 2 onboard is for some reason pokeys is outputting at least 1.6v from a pin before I trigger it..

for example if I use the LCD pin28  opps I forget if I had the other wire to gnd or +5 but anyway it would have 1.6v pin not triggered and for the relays I was using that was enough to trigger the relay on, so as soon as I powered pokeys the relay set if I triggered the relay it would jump to +5 so it was working.. I also tried the SSR output and I was getting the same voltage results..

The two onboard relays work fine, problem is I have 2 relays for power to the spindle m3 m4 and 2 for forward and 2 for reverse... SSR relays
I just ordered a couple DTDP I am going to try hopefully that will eliminate 2 relays..

I don't know to much about the oc1 2 3 4 outputs is it possible to use them?.

And a close() for the dialog would be great thenks

Gary 
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

New Auggie is online. It has a Close() command for dialogs
as a test, its untested as of yet.

  As to the voltages, that really sounds dodgy, if your connected to the
pokeys ground you should have 0 volts to the pin, or 5, but it may be your
requesting too much current. The outputs are pretty low ma capability
so wiring can count. Are you triggering with a transistor circuit?

oc's should work, though I havent used them I dont think..

Art


Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Thanks will test the close().

I'm not sure but sleep on it, and went back to testing voltage now the SSR is working fine 0 to 5v..

I think you may be right the pokeys may not be able to handle the voltage output to relays from the LCD pins.. I tested again and received 4.6v not connected to relay when I hooked up the relay it dropped to almost nothing and relay didn't trigger..

OC'S question are they PWM, I can turn them on but no voltage change.. would I need a PWN to voltage board?.

Tested the Close(), doesn't seem to work I may be using it wrong..
I created a global dialog
I also created a button call.
I press the button and it does call the function correct.
I put a ProbeLengthDialog.Close(); in the function but doesn't close it..
I assume the only way I can close a dialog from another function is it has to be global..

There already was a Close statment in auggie before but not sure what it's use was intended for.


Thanks gary
Last edited by gburk on Fri Jun 14, 2019 9:22 am, edited 1 time in total.
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Did a test with the g code, I attached a copy..

It's still running the m6 t when g code first loaded, brings up my dialog and retracts to 1" but the g codel stays at the first line of the code.. first line is hi lighted.

gary
Attachments
XballscrewmountFinal6.zip
(1.39 KiB) Downloaded 202 times
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  Thx, I had lost that file, Ill retest and fix the m6 start.. Ill check the close as well..

>>I think you may be right the pokeys may not be able to handle the voltage output to relays from the LCD pins.. I tested again and received 4.6v not connected to relay when I hooked up the relay it dropped to almost nothing and relay didn't trigger..

  Yeah, there's not enough current to push a relay with a pinout, it has only enough for an
LED or signal , running an opto is one way to make it drive a relay.
OC's are open collector outputs, they are like pins with opto's added so that you can draw
enough current for a relay for example.  You put 5 volts for example on one side of
a relay, and the other side can be hooked to an OC output. There are 4 OC's, and
you can script call them with  Pokeys.SetOC( int oc, int state).

  Note: to do this you need to make sure whatever power supply is driving the relay
must share the same ground as the pokeys..

Art


  These 4 exist mainly to drive relays..

Be a day or two till I can test the M6.. Ill get back to you soon.

Art

User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Small correction. According to the manual the OC's are all
galvanically isolated from the pokeys. So each OC has its own
ground, OC- to be hooked to the ground of the supply driving the
relay from the OC+. The OC command basically if set to state:1
will short those pins OC+ and OC-. Current will flow from OC+ to OC-
when the they are shorted.

  You can think of it as a transistor with the OC+ being the collector,
the OC- a grounded emitter, and the state is the base.
So in short this would be an NPN transistor with emitter ( OC-) to
be connected to your power ground and the collector (OC+) to
be connected to one side of the relay. The other side of the coil to
power supply +.

Art

supply grund, and the collector (OC+)
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Thanks the oc's work wired up per your directions and relay gos on and off..

Gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Is it actually opening a dialog on load? I cant find any bad behaviour there, it loads that file and does nothing till I press run and the first dialog opens. What happens there exactly?


..

  Your right on the close function, it would have to be a global dialog at that point as a
button code has no way of knowing its parent. Im finding it difficult to find
a way of allowing  a close command that will work. Ill keep dwelling on it.

I think I will have to add a sim = GlobalGet("Simulation") as a command so that
a script can be self aware that its being called during a load. It occurs to me there
are time you want to define motion during a load so it shows up in a toolpath,
and other times you may not want to activate during a load.. so the above command
would at least allow that. Im not sure I can do a close..but Ill see what I can think of..

Art
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  In order to solve the issue of allowing your button script to close a dialog,
the following change has been made. It will be in the next release in a few days.

When adding a button, if you wish it to close the dialog after running your script,
make the call like this..

WaitDialog.AddButton("Touch OFF Z_close","MyToolChange");

  Note the buttons name has "_close" appended to the end. This text will
not show up in the actual button , but is a tag telling the system that this
button, after being processed, should then do an implicit OnCancel() to
close the dialog. This will close it just as if the user had pressed the
cancel button with no other effect.

  Note:  Using _close appended to any control, checkbox, edit window..
anything.. will cause the dialog to close if that function script  is called.
Ive tested this with your Gcode file, seems to work fine. I still
dont see any run on load of the tool change though.


Art

gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Thanks Art

What I am getting when the g code loads is the m6 call seems to run instantly, and the dialog appears and the z axis dro runs to 1"
and that's how I have the m6 script setup it jogs to 1" to do manual tool change..

you are right the code doesn't run, till run is pressed, other that the m6 for some reason, I can hit run now and it will run fine.. jest worries me it does the m6 when g code loaded it could move the axis and mess up things if you don't have the tool in a safe place first ?

I will test it again and let you know the sequence of what exactly is going on.. 

As for the dialog would it be easier to add getting feed back form the OK - Cancel Buttons they close the dialog and then you could react if cancel do this if ok do that.

Thanks gary
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Ok A clearer picture of what's going on.
I load the g - code it loads fine no call to M6.. good

Now I press RUN it runs to the first M6 call does what its suppose to do, my dialog pops up I close my dialog and now I see the message End of g code run then press RUN the g code seems to rewind and go back to first line.
Now I hit Run again and it stops again at the first M6 my dialog pops up again I exit it, hit Run and now it runs fine, starts running the rest of the g code

Also is there a way to have the g code start running when I close the dialog box so I don't have to keep hitting the RUN button?.

Gary
Last edited by gburk on Sun Jun 16, 2019 7:42 am, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests