Hi
Thanks for that I will not be using Modbus so I have a dedicated serial port to the Boxford, I will be looking for anything that helps
The general idea is :-
1) start Mach
2) load G code file
The G code File then includes
3) Initialise Boxford Macro ( this is the one we are talking about)
4) Send speed control to Boxford (next TODO list )
5) Get gaurd information/ speed ( continually)
5) run G code
The initialise_boxford part of the macro is run only once at the beginning of work( does not need to be sent again unless the machine is switched off/on), if the boxford is already initialised then it will be programmed not to do it again, I do intend however to have this macro home the axis and basically set the machine up, the Guard postion is also found ( closed / open) and dependant on this I can run the rest of the G code or not, it would be nice however for a gaurd open to control a stop, this means having a serial reception running all the time, I have run out of inputs in mach so I can't use hardware.
The Boxford speed control is also set by serial commands these I will attach to the relevant macro, the spindle speed is reported back by serial @ once a second but as I have already interfaced the spindle read to Mach so it is not that important.
I have the initialise script written, however this does not yet check that the initialisation has already been done, I dropped the messages as they pop up even before the macro is run?
*****************************************************************************************
Sub intialise_boxford() ' Boxford Duet1 9600 8 data 1 stop even parity
'******************************** file send routine *****************************
message "Initialising Boxford"
Open "c:\mach3\duet.dat" For Input As #1 ' 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
message "Boxford Initialised"
playwave "c:\tada.wav"
Close #1 ' Close file.
'***********************************************************************************
End Sub
**** The read macro looks at the momment like this it's saving to a file so I can see the results
***************************************************************
' This works and reads just the available serial byte received
Open "c:\mach3\Dout.dat" For Output As #1 ' Open file.
For i = 1 To 10000
If (getportbyte(1021) And 1) <> 0 Then ' receive status register
inbyte = getportbyte(1016)
Print #1,inbyte
End If
Next i
*************************************************************
Thanks Again