Hello Guest it is March 29, 2024, 10:18:49 AM

Author Topic: trying to set PWM from vb script  (Read 6772 times)

0 Members and 1 Guest are viewing this topic.

trying to set PWM from vb script
« on: July 24, 2009, 06:33:30 PM »
I would like to use the PWM outputs from VB. I have had some success in reading the pokeys data and setting outputs from vb script , but I can't figure out how to pass a PWM array to pokeys from VB script. I suspect its a syntax error , but EVEN after reading the manuals , I can't figure it out. I am attaching  the offending lines below.  I have also attached the whole vb script in case it is necessary to check the whole script.

' before these lines run, the pokeys unit is initialized , the build date is read in , the arrays are dim(ed) and
' start values are assigned. full details in attachment. script needs 8 userlabels and a button.

' here are problem lines.  I tried many different syntax combos ?
' when the 2 lines below run , the vb scripts stated error is
' class does not support automation or does not support expected interface

b = device.SetPWMOutputs (channel() ,Period() ,duty() )
b = device.GetPWMOutputs (channel() ,Period() ,duty() )

thanks in advance

Offline borisz

*
  •  220 220
    • View Profile
    • www.poscope.com
Re: trying to set PWM from vb script
« Reply #1 on: July 26, 2009, 08:08:41 AM »
Hi!

You should set some values to channel, period and duty.
E.g. duty(50)

regards

Boris
www.poscope.com home of PoKeys USB HID, IO, USB, Ethernet controler and PoScope USB PC oscilloscope

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: trying to set PWM from vb script
« Reply #2 on: July 26, 2009, 10:10:36 AM »
RadientHeat,

    Are you trying to connect to the Mach3 Pokeys plugin?, if so then PWM is not currently supported through the plugin of Mach3.
The new Plugin (attached to my Post about the new plugin) does have a spindle output but it is analog 0-3.3v on pin 43 if you choose.

if the drive your using to run your spindle will only take a PWM signal then let me know.
fun times
Re: trying to set PWM from vb script
« Reply #3 on: July 26, 2009, 01:21:26 PM »
Thanks again for your quick response. No, I am not trying to use your plugin. I am trying to use the VB tools and DLL that come with pokeys to read and write to the unit from mach3/cypress vb. I can open the pokeys , read , setup and write to the device , all from cypress/vb. Only problem is I can't figure out how to pass arrays (I think thats the problem). The following code creates an error when run inside a Mach3 Button. Boris wrote that perhaps I was not setting values first , but I was , full program below.

setbuttontext "pokeys PWM test"
Dim builddate As String
Dim test As Integer
Dim b As Boolean
Dim channel(6) As Boolean
Dim period(6) As Long
Dim duty(6) As Long          ' tried type as long and single

Set device = CreateObject("PoKeysDevice_DLL.PoKeysDevice")         ' declare

test=device.enumeratedevices()
MsgBox "Devices"+str$(test)
b=device.ConnectToDevice (0)
If b <> true Then Stop

b=device.getbuilddate(builddate)
MsgBox "Build Date " & builddate   ' this shows communications working , pokeys on-line

For v = 0 To 5
channel(v)=true
period(v)= 12000000
duty(v)=6000000
Next v            ' set values


MsgBox "Values declared for Channel PWM 1 " & channel(1) & " " & Period(1) & " " & Duty(1)

b = device.SetPWMOutputs (channel() ,Period() ,duty() )  ' program fails here
b = device.GetPWMOutputs (channel() ,Period() ,duty() ) '  error message is class does not support automation or does not support expected interface

MsgBox "Results for Channel PWM 1" & channel(1) & " " & Period(1) & " " & Duty(1)

b=device.DisconnectDevice()

End

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: trying to set PWM from vb script
« Reply #4 on: July 26, 2009, 09:32:36 PM »
down load the developers manual that shows all the functions and hwo to write to them.

other than that, cant help you, sorry.

scott
fun times

Offline borisz

*
  •  220 220
    • View Profile
    • www.poscope.com
Re: trying to set PWM from vb script
« Reply #5 on: July 28, 2009, 04:19:00 AM »
b = device.SetPWMOutputs (channel(*********) ,Period(*********) ,duty(*********) )  ' program fails here
b = device.GetPWMOutputs (channel(*********) ,Period(*********) ,duty(*********) ) '  error message is class does not support automation or does not support expected interface

Hi!

Probably it is not too hard to put same values instead of "*********" what I have suggested before.
You should also read PoKeys55 protocol specs published on www.poscope.com

regards

Boris
www.poscope.com home of PoKeys USB HID, IO, USB, Ethernet controler and PoScope USB PC oscilloscope