Hello Guest it is March 29, 2024, 06:47:22 AM

Author Topic: Control micro servo with Macro  (Read 2415 times)

0 Members and 1 Guest are viewing this topic.

Control micro servo with Macro
« on: October 27, 2017, 02:07:50 PM »
Hi guys, i am trying to develop a mechanical tool changer, but i am stuck at the following point, i need to control a micro servo using an output
from my motion controller. I tried to write a code, like this, to try creating a "pulse":

Code: [Select]
Sub Advance_Servo()
Dim i As Integer
i = 0
While i<10
ActivateSignal(OUTPUT4)
Sleep(1.5)
DeactivateSignal(OUTPUT4)
Sleep(18.5)
i=i+1
Wend
End Sub

This is creating a square wave in the oscilloscope, but it's so weird, really weird.

The pulses are not in the programmed time. Is this the motion controller, or macro's just can't create a nice waveform ?

This is my servo:
http://mekanus.com.br/imagens_ML/servo-9g/s3.jpg

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Control micro servo with Macro
« Reply #1 on: October 27, 2017, 02:40:37 PM »
activate and deactiate outpult will allways create a square Signal (what else !!?)

1.5ms on a Windows System where the macro scripting is running in a 10ms Task,
no way.

---Is this the motion controller, or macro's just can't create a nice waveform ?

what Hardware are you using on the Controller side ?



Thomas
« Last Edit: October 27, 2017, 02:42:34 PM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Control micro servo with Macro
« Reply #2 on: October 27, 2017, 03:47:36 PM »
I am using a nevex(Brazilian company) motion controller.

I said weird when referring to the not constant period. Yes 10ms.. i see, the only way to make this happen is to use
the activate signal to signal some pic or signal generator outside the motion controller ?

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Control micro servo with Macro
« Reply #3 on: October 28, 2017, 04:16:14 AM »
if you need such a precise timing  (1,5/18,5ms) the only way is a extrenal Signal Generator. 
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Control micro servo with Macro
« Reply #4 on: October 28, 2017, 09:26:23 AM »
As i imagined.
Re: Control micro servo with Macro
« Reply #5 on: November 02, 2017, 07:50:35 AM »
It worked nicely, used a PIC to generate the square wave for the servo.