View Full Version : lynxmotion ssc-32 servo controller
theengine
August 15th, 2007, 08:56 PM
Hello!
Taking a stab at setting up girder (noob) to control a Lynxmotion ssc-32 servo controller.
Heres what works:
Dedicated lynxmotion sequencer software. I am able to control the servors as expected so I know everything is setup right.
So I load a serial port monitor to capture the commands the sequencer sends to the DB9 port and controller.
For example:
If I want to move servo 1 to a certain position, the command would be #1P1600T100 Which means: #1 is servo 1 P = position of servo gears and T = time 1000 being a second.
Here is the exact port capture of a 2 step command to set the servo positions:
IRP_MJ_WRITE DOWN TRUE 0x0 23 30 50 31 34 30 31 23 31 50 32 32 34 36 54 31 30 30 30 0D #0P1401#1P2246T1000.
IRP_MJ_WRITE UP TRUE 0x0 23 30 50 31 34 30 31 23 31 50 32 32 34 36 54 31 30 30 30 0D #0P1401#1P2246T1000.
IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK: Wait for event)UP TRUE 0x0 04 00 00 00 ....
IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK: Wait for event)DOWN FALSE 0x0
IRP_MJ_WRITE DOWN TRUE 0x0 23 30 50 31 34 30 31 23 31 50 31 37 39 36 54 31 30 30 30 0D #0P1401#1P1796T1000.
IRP_MJ_WRITE UP TRUE 0x0 23 30 50 31 34 30 31 23 31 50 31 37 39 36 54 31 30 30 30 0D #0P1401#1P1796T1000.
IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK: Wait for event)UP TRUE 0x0 04 00 00 00 ....
IRP_MJ_DEVICE_CONTROL (IOCTL_SERIAL_WAIT_ON_MASK: Wait for event)DOWN FALSE 0x0
How do I generate a lua file and use that as a serial device in the plugin section and then add the serial send commands?
Im sure Im missing some sort of info to help with the answer so please let me know what you need to know so I can know
theengine
August 16th, 2007, 10:54 AM
Got it for those that care. Here is the lua file in the serial plugins directory. Now onto Netremote to control the servos over the network.
local Super = serial.Classes.Simple
local device = Super:New({
Name = "SSC32",
GlobalName = "ssc-32",
Description = "Lynxmotion SSC-32",
LogLevel = false,-- change this to false when the device is working
BaudRate = 115200,
Parity = N,
DataBits = 8,
StopBits = 1,
FlowControl = 'N',
CallbackType = serial.CB_TERMINATED,
ReceiveTerminator = '\r',
SendStartByte = '',
SendTerminator = '\r',
IncompleteResponseTimeout = 100,
NoResponseTimeout = 1000,
Initialize = function(self)
if Super.Initialize(self) then
-- add your own initializations here
self.Status = 'Initialized'
return true
end
end,
ReceiveResponse = function(self, data, code)
if math.band(code, serial.RXCHAR) then
-- add code here to process the data parameter
end
Super.ReceiveResponse(self, data, code) -- must call the parent's ReceiveResponse
end,
})
serial.AddDevice(device)
Rob H
August 16th, 2007, 12:11 PM
Actually, this line
if math.band(code, serial.RXCHAR) then
should be
if math.band(code, serial.RXCHAR) > 0 then
theengine
August 16th, 2007, 06:49 PM
ok kids Im learning....that I need to learn more
I have netremote working fine now sending events to girder to control the servos position. However with the varied positions I assigned the arrow buttons in the CCF, I still do not have a way to control a smooth motion. Is there a generic slider function or a STEP command script? Again here is an example of servo positions:
#0P1200T1200 = servo 0 is at a certain angle set at 1.2 seconds
#0P1500T1200 = servo 0 is now 300 steps past 1200
How would I assign a slider or step command in lua and netremote to control a constant input to change the steps smoothly?
Thanks!
theengine
January 29th, 2008, 04:41 PM
Bump on the above....
just wondering what lua code I would need to assign a static address to a servo (#0) then the Position command (P) then the location (number)
I would need the #0P to remain the same and just the number value change.
any thoughts?
Rob H
January 30th, 2008, 02:41 AM
what's the range of values that the position parameter can take? - I'd guess that it's from 0000 to 9999? Or is that not a fixed length field?
Presumably the T parameter is the time it should take in ms?
I'm not quite clear, do you have a working slider in NetRemote?
theengine
January 30th, 2008, 06:35 AM
I have the range set manually right now since the servos are running pan tilt on a camera.
for example:
home position for the panning servo is 1460 so to set that the serial command to the SSC-32 controller is #0P1460
I am not worried about the time control, it can always stay static.
to move it just a bit to the right would increase to 1470, so the command that has to be sent is #0P1470. To move left would decrease.
its the same for all the other servos, the first 3 characters are static and the last 4 (or down to 3 in 4 cases) change. The range is from 880 to 1900.
I have done a slider in netremote that sends something to girder, but I guess Im kinda lost on what to do on the girder side for variable code. I tried to set the variables in the slider thumb control range with the #0Pxxxx but it keeps crashing when I save. If I just put numbers in, I know that wont work and I still dont know how to make those numbers transfer to "serial send" since Im using a custom serial device plugin.
I have netremote working fine with girder controlling the servos using a static event to action, but again Im not sure how or where to put the variable code in Girder action/events.
thanks for helping the noob!
Rob H
January 30th, 2008, 12:31 PM
Simplest thing will be to set the range of the slider from 880 to 1900
When you adjust the slider you should see an event coming from NetRemote with the value of the slider in pld3
First thing - in your serial device change the Global name to SSC32 - that's the name of the global variable that is created - you can't have a '-' in an identifier.
So, create a scripting action that looks something like this :-
SSC32:Send(string.format('#0P%04dT1200', tonumber(pld3)))
Save and close the action.
In NetRemote drag the slider (I'd probably recommend setting it to only send on release) and then drag the event from the logger to the newly created action.
Save the GML and try moving the slider and see whether it now works.
theengine
January 31st, 2008, 08:18 AM
ok here is where Ive gotten so far, and thanks for the continued help.
I have a thumb slider in NR with a var of panC1
this is the system lua code in NR designer ccf
NetRemote.RegisterVariableWatch([[panC1]],NetRemote.GetPlugin('Girder'))
in NR thumb properties the image var is blank, the VAR is panC1 and the range is the same as the above post
when I move the slider (connected tcp to girder on another machine) I see the input coming which says: source: com server details panC1 and the time
when I copy the log it just says
TIME Date Source Details Payloads
I dragged that over to the scripting action I made with your above code and in the lua console I get an error
string "ssc32.gml:\SSC32\Scripting"]:1: attempt to call method `send' (a nil value)
clueless...
Rob H
January 31st, 2008, 08:26 AM
Why are you copying the log? To post here?
You need to select some lines in the log to copy it.
You can't use copy/paste to add an event though, you have to drag it from the logger to the action in your GML
theengine
January 31st, 2008, 08:37 AM
right I did that, I dragged the event over and I have edited my post (not sure which one you read) but Im getting a scripting error (see above in case you havent)
thanks
Rob H
January 31st, 2008, 09:49 AM
Lua is case-sensitive - that should be Send not send
theengine
January 31st, 2008, 06:28 PM
yea, in the actual script I have it Send...
It seems no values are getting to the action script from the event, the slider causes a basic event in girder but the script error says its getting a Nil value..
any thoughts?
Rob H
February 1st, 2008, 02:05 AM
Real error messages should be shown in the Lua console.
Did you change the GlobalName property as I suggested?
theengine
February 1st, 2008, 02:58 AM
yes I changed it here is the error
string "ssc32.gml:\SSC32\Scripting"]:1: attempt to call method `send' (a nil value)
what should I be seeing as far as values or an event coming from the slider? Do you have an example slider code that is throwing variables at girder serial send I could see? Maybe I could adopt that.
thanks!
Rob H
February 1st, 2008, 03:15 AM
Can you paste the actual script from the scripting action?
theengine
February 1st, 2008, 06:08 AM
here is my gml and my lua file
thanks
I am in on remote so I hope I grabbed the right files
Rob H
February 1st, 2008, 07:38 AM
Mea culpa it should be SendCommand rather than Send! It's been too long since I looked at old style serial plugins.
theengine
February 1st, 2008, 11:06 AM
sweet! I hope :)
I'll try it when I get home. I'm just scratching the surface of what I plan on doing with netremote and girder, I wish I had the brain power and time to learn this proper.
thanks again
theengine
February 1st, 2008, 04:41 PM
ARE YOU FRIGGEN KIDDING ME!!
:)
works great. Just saved me $200 from having to buy a network serial port program. Glad I spent the $200 here :)
now....to program pan tilts for 3 more cameras.....
thanks again!
Just an edit...complete success! I am able to smoothly pan/tilt (and soon to be zoom, but thats a different character set for the camera's zoom control via rs232..we'll see if I can do this on my own now) All I have to do is change the scripting code now to indicate which servo is getting the control. The SSC-32 can take up to 32 servos.
Rob H
February 2nd, 2008, 03:34 AM
Terrific news!
theengine
February 2nd, 2008, 05:00 PM
ok Rob need yer advice again...heres the new issue and what Ive managed to get done.
Samsung SCC-C4307 camera on rs485 port. I have the code set from the samsung protocol that is used by the DVR software. Its sending HEX codes. For example:
to zoom the lens OUT, the software sends A000010140000000BD which is the START zoom command. I know this because when I enter this code alone the camera full zooms out without stopping. The STOP command is sent right away and thats A000010100000000FD.
I made a macro that starts with the first A0 and then sends the 2nd A0 stop command. This works nice because it step zooms the lens which is fine.
For the zoom IN HEX its A000010120000000DD then the stop command A0000101000000FD.
So my GML looks like this:
zoom.out (macro)
serial send A0xxBD
serial send A0xxFD
zoom.out (event string)
Next I made a slider in netremote with the variable zoom.out, did the scripting for that variable and moved the logged event to the macro file. This works fine.
Now, what I cant figure out is how to tell the slider that the bottom of the slider is zoomed out, and the top of the slider is zoomed in, and have it step during the travel of the slider frame. The only way I can figure it out right now is by creating 2 buttons, one for zoom out, one for in...which will work..but its not as slick :P
any thoughts?
Thanks!
Rob H
February 3rd, 2008, 03:19 AM
I'm not entirely clear what the problem is here I'm afraid?
Do you get any feedback from the camera to tell you the current zoom setting?
theengine
February 3rd, 2008, 05:08 AM
I have made it work fine using just buttons and the macro that sends the start command, a wait (I can vary the zoom amount with that)...hmm..now that I think about it, can I have a button that sends a command then a wait while you are holding it then another command upon release? I think I saw that somewhere.
I have decied not to use a slider for the zoom since the buttons actually work better now that I did the ccf in netremote. The only thing is I have to keep clicking the button to either zoom in or zoom out, Id like to be able to click and hold to zoom on one button, then click and hold to zoom out on another. the sequence of commands is 2 fold, the start command and the end command for each of the zoom out and zoom in.
thanks!
Rob H
February 3rd, 2008, 05:22 AM
How about splitting the Zoom into two parts? One event triggers the zoom start and another the zoom end. Then you could use the "Send event to Girder" and "Send Event to Girder on release" actions to trigger each part. What happens if the zoom end isn't sent? Does it just zoom to the end point and then stop or does it keep trying to zoom?
theengine
February 3rd, 2008, 05:29 AM
if the 2nd end command is not sent, it just zooms all the way (either in or out) Im able to use the wait command to vary the amount of zoom now, but that does not give much control. I think this will work best:
zoom out button press (start command) hold: zoom out. release button stops (end command)
same for zoom in.
Im at work but its slow so Im in on remote now seeing what I can figure out :)
Rob H
February 3rd, 2008, 05:39 AM
Another option is to use a Lua event action. This is called with two parameters, the button that was pressed and a call number. The button down has a call number of 0, button up is -1 and every 250ms the call number will increment.
You could use that to send one of 3 events to Girder e.g.
e.g.
function (elem, callno)
if callno = 0 then
NetRemote.ExecuteAction(-1,0,1, 'ZoomOut.Start')
elseif callno = -1 then
NetRemote.ExecuteAction(-1,0,1, 'ZoomOut.End')
else
NetRemote.ExecuteAction(-1,0,1, 'ZoomOut.KeepAlive')
end
end
In Girder you would start the zoom on a ZoomOut.Start event and also create a timer with say a 300ms duration that would stop the zoom.
The ZoomOut.End event would kill the timer and stop the zoom
The ZoomOut.KeepAlive event would reset the timer. If Girder didn't see that event then the timer would fire and stop the zoom.
How does that sound?
BTW NetRemote.ExecuteAction(-1, 0, 1, EventString) sends EventString to the default Girder plugin instance
theengine
February 3rd, 2008, 05:45 AM
sounds great as I read it :)
I'll try it and let you know.
thanks for the continued help!
On a side note, while I think about it....and I have not even tried to read about this, but...is there a way to have a live video feed in a netremote window? Like a frame that accepts a webcam or something? If its horribly complicated or there is already a thread on it just let me know and I'll dig it up. Thanks again.
Rob H
February 3rd, 2008, 06:03 AM
It depends on the webcam - generally this is done using the web browser plugin, but for some webcams you might want to use an embedded ActiveX control.
Try searching here for 'webcam' and you should find some useful information.
theengine
February 17th, 2008, 08:29 PM
since this seems to be just us in this thread, figured Id not start a new one. I went a different route with the toggle switch stuff and use panel jump. Here is my first crack at a fully functioning CCF file. Its kinda goofy looking but it works, and looks good on my pda phone! Now to find a pda that works with netremote and IR, my tmobile MDA does not have the right ir hardware.
theengine
August 13th, 2009, 07:34 PM
Hey Rob
Seems I have to visit this thread for another project, but I'm unable to make the following work:
Have a button in Netremote that sends 2 events to girder. First one is Pan.up then the 2nd event is send to girder on release pan.up.stop. The first even is making it through, but the pan.up.stop is not. In girder I have 2 serial sends that have each of the events as triggers. What am I doing wrong?
Thanks
Rob H
August 14th, 2009, 03:04 AM
That seems a bit odd, can you mail me the CCF to rob.h AT promixis.com
theengine
August 14th, 2009, 08:25 PM
Funny thing maybe I should have already known, but after setting up those events and the GML, it all required a restart before working. Once I restarted netremote, it all worked fine. Thanks!
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.