Creating pulses to servo motor on lead screw

Hi,

Thoughts on creating a pulse train output for a step direction servo drive.
Servo motor is 1000 pulse per revolution, lead screw is 5mm pitch, desired max speed is 180mm/sec or 36rps. This equals 36,000 pulses per sec. The minimum pulse on and off is 2.5uS. 5uS peek to peek, or 200khz.
I will also need to eventually a simple Ramp up and Ramp down element.

This may exist, but there is so much noise on pwm and position servo.

Thanks Richard

Often members are mistaken, not knowing the difference between a Servo and a Servo Motor.
Please post a link to the datasheet.

1 Like

grbl on an ESP32 or STM32?

1 Like

You are referencing a "servo motor" but describing a stepper motor. Which do you have? Typical servo motor signal looks like this:

Servo Position

Please provide a link to your motor.

Ron

1 Like

Thanks, I get your question. The servo motor with integrated controller is a IHSV57-30-10-36-01
This is a 100w 36v ac servo motor with integrated drive. Needs 3 inputs to operate. Direction, Enable, and pulse. Pulse resolution 800 to 40,000 pulses per revolution. Internally it has a 1000 line encoder, so 1/4000 positional. Frankly 1,000 steps/rev is overkill, but makes the math easy. Like I said its a servo motor, and not a positioning (toy) servo. Otherwise I would just use the pwm output. If you need more I can find a link to a PDF.

Post links to the hardware that will help us help you. Also post your preliminary schematic showing how you propose to wire this.

Actually the term servo can apply to a number of different cases. In the servo motor case I am talking about woukd be a 3 phase AC motor with a controller, driver and resolver. This has a closed loop tuneable drive integrated with the motor, so responds to pulses to achieve position. In some ways very much like a stepper with a drive, except is capable of much higher RPM tgan a stepper.

Not really looking for a G Code solution, but will take a look.

Fine. Post a link to the datasheet.

That sounds like a stepper motor. Datasheet link please....

If 1 pulse is sent to the controller, how many degrees or fractions of a revolution does the motor shaft turn? What is the maximum RPM / pulse rate you are looking for?

1/1000 of 1 revolution is 1 pulse.
Can be selected 800 to 40,000. The (max) speed I am looking for is 36 revolutions per second.

Which Arduino? Investigate the MobaTools library, it's in the IDE library manager.

Please do.

Try this...https://www.welectron.com/mediafiles/manuals/jmc/JMC%20iHSV57-30%20User%20Manual.pdf

This is the basic system.

Looks good to me, can whichever MCU you're using support that pulse rate and do anything else in the meantime (like monitor position and respond to various events, button presses, etc.)?

Using the controller hardware timers to create the required output is feasible on an Arduino Uno or Nano. The ARM or RP2040 microcontrollers may be easier to use and offer finer control of the output.

Is this the only thing that you intend to have the microcontroller perform in this project?

1 Like

simple ESP32 program to generate a pulse every 28uSec

// ESP32 - pulse using timer interrupt

// ideas from https://deepbluembedded.com/esp32-timers-timer-interrupt-tutorial-arduino-ide/

#define LED 19  // pulse output pin

hw_timer_t *Timer1_Cfg = NULL;  // timer object

volatile int counter = 0;

// timer interrupt - pulse HIGH for few uSec then LOW
void IRAM_ATTR Timer1_ISR() {  // timer ISR called on every timer event
  digitalWrite(LED, 1);         // pulse HIGH
  for (int i = 0; i < 100; i++) // delay for HIGH pulse period
    NOP();
  digitalWrite(LED, 0);         // pulse LOW
  counter++;
}
void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.printf("\n\nESP32 pulse generator\n");
  pinMode(LED, OUTPUT);
  Timer1_Cfg = timerBegin(0, 80, true);                 // 1uSec timer prescaler value and counting direction up
  timerAttachInterrupt(Timer1_Cfg, &Timer1_ISR, true);  // attach callback fundtion
  timerAlarmWrite(Timer1_Cfg, 28, true);                // 28uSec timer count and execute periodically
  timerAlarmEnable(Timer1_Cfg);                         // enable timer
}
void loop() {
  // print counter every Second
  delay(1000);
  Serial.println(counter);
  counter = 0;
}

pulse 2.8uSec width
image

every 28uSec
image

a Tensey would probably give you finer control or even an FPGA

or even a simple loop

// ESP32 - pulse every 27.8uSec

#define LED 19  // pulse output pin

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.printf("\n\nESP32 pulse generator\n");
  pinMode(LED, OUTPUT);
}
void loop() {
  while (1) {
    digitalWrite(LED, 1);          // pulse HIGH
    for (int i = 0; i < 100; i++)  // delay for HIGH pulse period
      NOP();
    digitalWrite(LED, 0);          // pulse LOW
    for (int i = 0; i < 985; i++)  // delay for HIGH pulse period
      NOP();
  }
}

gives
image

the problem is using to loop() to control timing how will you change the time between pulses?

1 Like

No there would be a couple of other small things. During a cycle. A cycle would be to move from zero speed to a (software controlled) slewing speed, then to a stop at distance, a pause, then return to start at diferent slewing speed. In this cycle, moitoring a couple of stop, inputs.