mjt Posted June 4, 2009 Share Posted June 4, 2009 Got the basics working quickly but stuck on the last key part. Copley use a register based interface. To command the controller to move to a specific position, you first set the position register, then drop a command in the command register. For the position register interface, i created a VariableValue component on Page_0, and linked it to a custom channel named CopleyPositionRegister. It has an IO type of WritePositionRegister, which is specified in the Copley_Stepnet custom protocol. Here's the code: function WritePositionRegister(position) private string in try // lock the port if (!LockPort()) throw("Unable to lock port") endif // profile type - profile absolute scurve = 1 Write("s r0xC8 1" + chr(13)) // and read until the eol: in = ReadUntil(chr(13)) //private val = CopleyPositionRegister private string vStr = DoubleToStr(position) // position Write("s r0xCA " + vStr + chr(13)) in = ReadUntil(chr(13)) // release the port UnlockPort() // and return the response return(in) catch() // error occured UnlockPort() throw() endcatch // return NULL to indicate error. This should never happen // because of the throw() statement above return(NULL) What I'm not clear about is how to get the channel value into my code so that I can write it out the port. Is there a special variable name that I can use? I've tried defining the function name with a variable position, as above. I've tried accessing the channel with 'CopleyPositionRegister'. I can't quite get it to work. Everything else was pretty easy - polling the status register, issuing move and home commands. But there's no example of outputting a channel value with custom code to convert it to serial. Link to comment Share on other sites More sharing options...
This topic is now archived and is closed to further replies.