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, 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.
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.
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?
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?
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
every 28uSec
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
the problem is using to loop() to control timing how will you change the time between pulses?
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.