Hello Guest it is November 08, 2024, 08:16:35 PM

Author Topic: Serial Port control under cypress enable  (Read 16992 times)

0 Members and 1 Guest are viewing this topic.

Offline Whacko

*
  •  239 239
  • Happy Days
Re: Serial Port control under cypress enable
« Reply #10 on: August 26, 2007, 03:53:58 PM »
I want to establish compatibility with what I want to do for you.

Copy and paste the following text in notepad. Save the file on your desktop with a .vbs file extension, example ComTest.vbs
Then close the file, exit notepad and doubleclick the .vbs file on your desktop. Wait for 10 seconds, and check if you get the second textbox.
If it works we can proceed.
----------------------------------------------------------------

'Testing compatibility
'
PORT = "COM1"
MsgBox "Ready to do 10 second test!"
Set fso = CreateObject("Scripting.FileSystemObject")
Set com = fso.OpenTextFile("COM1")
Wscript.Sleep 10000
com.Close()
MsgBox "10 Seconds passed, no error!"



--------------------------------------------------------------------------------------------------------

Let me know if it works on your pc.

Whacko
Nothing's impossible
Re: Serial Port control under cypress enable
« Reply #11 on: September 05, 2007, 08:11:30 AM »
Hi
Thanks for that I've been on holiday for a week (Spain in the SUN compared to the rainy UK it's been bliss)

I tried the code but I only have the inbuilt cypress enable VB scripter and this code does not work with it.

I have had some sucess and have now moved on to the tool changer "if anyone wants the code for the serial give us a shout" the peculiarity of the boxford tool changer is that tools are changed using X and Y , I need to first detect which tool is pesently in use ie GetCurrentTool(), GetSelectedTool() and SetCurrentTool() then this determines which direction to goto the safe zone then the tool holder has to goto the front or back depending on which tool is to be selected, one of the problems is that the tool offset has a Y component, so I need to add a Y position indicator to Mach turn. as usual any ideas greatfully received.
Re: Serial Port control under cypress enable
« Reply #12 on: December 16, 2010, 03:42:02 PM »
Hi “The_black_cat_dies” or anyone.
I just got an boxford duet and I want to control it with mach3. And I have the same problem, i can’t let my Spindel run! Unfortunately i don’t have any experience with VB or Mach3. I just startet up experimenting with the duet. I was reading the posts here and have seen you were able to solve the problem. Maybe you can help me to let the spindel of my duet run. I would be glad to get the code for the serial! And maybe also some tips how to configurate Mach.
Any help would be great...
Re: Serial Port control under cypress enable
« Reply #13 on: December 18, 2010, 01:16:43 PM »
Hi, Very interesting post. I have a Boxford TCL160 lathe that is original and uses Win98 software.

I would be interested to understand the serial communication Boxford uses and try to get Mach3 working with it.

I have put up with the win98 software for now but the reason I need a change is that the tool is selected by type and not tool position. I have a few tools of the same type but it will only select the first one it sees. It also can't do internal righthand threads without me having to tinker with the postprocessing which can be a manual nightmare.

Great work..
« Last Edit: December 18, 2010, 01:20:09 PM by cjmerlin »
Re: Serial Port control under cypress enable
« Reply #14 on: December 29, 2010, 03:12:23 PM »
Hi this is the cypress enable script to run the spindes this loads the rom on the controller board
with the file duet.dat which exists within the boxford software which you can download sorry
its not simple but that is the way it is you must talk directly to the serial ports and send six bytes
use a null modem cable you will know you have it working because there are two led's on the board
which flash and then stop, see the manua, try it ouot if you have problems place a post.


********************* M2000 **********************************
' This is a working initialisation procedure modified 051208


Sub intialise_boxford() ' Boxford Duet1 9600 8 data 1 stop even parity

'******************************** file send routine *****************************
Dim counter As Integer
Dim bytes As Integer
Dim flag As Integer

counter = 0
bytes = 0
flag = 0

Do 

   If (getportbyte(1021) And 1) <> 0 Then

   inbyte = getportbyte(1016)

   bytes = bytes + 1
   
   End If

   counter = counter + 1

   If counter > 10000 Then

   flag = 0
   
   Exit Do
   
   End If
   
   If bytes > 6 Then
   
'Print   "Boxford Already Initialised"
   
   flag = 1

   Exit Do
   
   End If
   
Loop


If flag =1 Then

GoTo Boxford_already_initialised

Else

GoTo Initialise_boxford

End If

 
Initialise_boxford:


putportbyte(888,(GetPortByte(888) Or 128)) 'This is the TX register


For i = 1 To 1000000
Next i

putportbyte(888,(PortByte And 127)) 'This is the TX register

For i = 1 To 1000000
Next i


Open "c:\mach3\data\duet\duet.dat" For Input As #1 ' Open file.
Open "c:\mach3\data\duet\Dout.dat" For Output As #2 ' Open file.

Do While Not EOF(1) ' Loop until end of file.

   outint = Asc(Input (1,#1)) ' Read value into variable.

loop_1: If (getportbyte(1021) And 32)<>0  Then   'Line Status Register bit 5 TX holding reg empty

      putportbyte(1016,outint) 'This is the TX register

   Else

   GoTo loop_1

   End If
 
Loop

   For i = 1 To 1000000
   Next i


bytes = 0
counter = 0

Do 

   If (getportbyte(1021) And 1) <> 0 Then

   inbyte = getportbyte(1016)

   Print #2,inbyte

   bytes = bytes + 1
   
   End If

   counter = counter + 1

   If counter > 10000 Then

   Print "Boxford not initialised"

   
   Exit Do
   
   End If
   
   If bytes > 6 Then

   Exit Do
   
   End If
   
   
Loop

Close #1 ' Close file.
Close #2 ' Close file.

Boxford_already_initialised:

DeActivateSignal(11)   'A
DeActivateSignal(10)   'B   This will set the index input
DeActivateSignal(9)   'C

code "M05"


End Sub


' M03 start the spindle in CW as viewed from the chuck towards the tail stock (correct view)

Dim outint(7) As Integer

outint(1) = Asc("S")
outint(2) = 0
outint(3) = 255
outint(4) = 0
outint(5) = 0
outint(6) = 0
outint(7) = 16


If (getuserLED(1010) =1 And  getuserLED(1011) = 0) Then

Message "Spindle Already CW"

Else

   For i = 1 To 7

   putint = outint(i)

   loop_1: If (getportbyte(1021) And 32)<>0  Then  'Line Status Register bit 5 TX holding reg empty
      putportbyte(1016,putint)       'This is the TX register

   Else

   GoTo loop_1
   
   End If

   Next i

   Call setuserLED(1010,1)            'Sets the LED variable to be read by getuserLED(1010)
   Call setuserLED(1011,0)            'for spindle cal CW and CWW as these are different
                     'both are set so an error check can be performed

   message "Spindle CW"
   
   DoSpinCW()

End If


Sub Mach_Code(Code_String)

Code Code_String

While ismoving()
Wend


End Sub


' M04 start the spindle in CCW as viewed from the chuck towards the tail stock (correct view)

Dim outint(7) As Integer

outint(1) = Asc("S")
outint(2) = 255
outint(3) = 0
outint(4) = 0
outint(5) = 0
outint(6) = 0
outint(7) = 16

If (getuserLED(1010) =0 And  getuserLED(1011) = 1) Then

Message "Spindle Already CWW"

Else

   For i = 1 To 7

   putint = outint(i)

   loop_1: If (getportbyte(1021) And 32)<>0  Then  'Line Status Register bit 5 TX holding reg empty
      putportbyte(1016,putint)       'This is the TX register

   Else

   GoTo loop_1
   
   End If

   Next i

   Call Mach_Code("G04 P200")

   Call setuserLED(1010,0)            'Sets the LED variable to be read by getuserLED(1010)
   Call setuserLED(1011,1)            'for spindle cal CW and CWW as these are different
                     'both are set so an error check can be performed

   Message "Spindle CCW"
   
   DoSpinCCW()
                     

End If                        

Sub Mach_Code(Code_String)

Code Code_String

While ismoving()
Wend


End Sub

Re: Serial Port control under cypress enable
« Reply #15 on: December 29, 2010, 03:17:35 PM »
Sorry forgot the speed  I hope this is enough to get you started.

   ' *************** RPM setting code *******************

   speed = RPM(requested_rpm)
   
outint(1) = Asc("S")
outint(2) = 255
outint(3) = 255
outint(4) = 0
outint(5) = 128
outint(6) = Speed
outint(7) = 16

   For i = 1 To 7

   putint = outint(i)

   loop_1: If (getportbyte(1021) And 32)<>0  Then  'Line Status Register bit 5 TX holding reg empty
      putportbyte(1016,putint)       'This is the TX register

   Else

   GoTo loop_1
   
   End If

   Next i

   
   End If
Re: Serial Port control under cypress enable
« Reply #16 on: January 03, 2011, 04:07:04 PM »
Hello again, Thank you for the script! I tried it out and I was able to send the duet.dat to the boxford. The led's flash and then stop. That is already a great success to me, tnx.  But I still have a problem with the speed!
I saved your script under spindlespeed as a macro. If I want to run the spindle i get an error in the spindlespeed. If I run it in the VB Script editor I get (compile error: Syntax error) in the last line by End[/b] If.
Do you have any idea what i do wrong?
Re: Serial Port control under cypress enable
« Reply #17 on: January 04, 2011, 02:46:21 PM »
Well done :-) so far so good. I think it's too many "end if" 's remove the last one (too many bourbons and coke for xmas). Careful with this the spindle can work at 3000 RPM also this is for the Duet MKI  I believe the MkII is different, also the guard needs to be down otherwise it won't start, you should hear the relay click on, also sorry my mistake it is 7 bytes. It could do with someone else confirming the codes I used the old software and put a COM serial sniffer to record the sent and received codes but my old dos pc is now dead.
I hope you noted that M03 and M04 are included in the post they need to split these out also I didn't include M05 I'm not near my lathe at the moment I think it's the same as M03,M04 just 0 in place of the 255 in  bytes  2&3
Re: Serial Port control under cypress enable
« Reply #18 on: January 04, 2011, 05:23:29 PM »
I noted that M3 and M4 was included and now I also made the M5. The last "End If" in the speed I removed.
now after starting the duet and run the M2000 in the MDI mode the led's flash and the green one is on. if i run M3 S500 in the MDI mode I also hear the relay click on. The message in the Status  line is (Scripter Compile Error. In: SpindleSpeed.mis) and the spindle does not turn. When I run after that M4 S500 or M5 the relay does not click anymore. (Message in the Status line: Spindle Already CW)
When I run the speed Script in the VB Script Editor I get (Error on line:3-Sub or function not defined:RPM)
Is It possible that in the Speed script is still something missing? I also believe the M5 Scrip does not realy stop the Spindle because I should hear the relay again, right?
I think one problem is the M5 script because after M5 I should be able again to hear the relay click again with M3 or M4. And the other is the speed script.