Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - servo motor question

(you are viewing a thread; or go back to list of threads)

servo motor question (by Alex)
Hello again, i´ve been looking for information about step motor and servo motor and i think that servo works better for my application, but first i would like to know if some has an exmple for using a servomotor sg90 (little one), for practicing, there is an example at Ihor´s ldmicro wiki, but his design is for 0.800000 Mhz using 16f887, i only have 16f877a with 20mhz, i´ve read that ldmicro is too slow for servos, "but" so isn´t a way to do this :


https://www.youtube.com/watch?v=r1VRvI2j7dM

or using buttons, an easy way to do that?, i mean understandable like this arduino code:

#include <Servo.h>

Servo myservo;

void setup()
{

servo.attach(9);
servo.write(0)
delay(2000);

}

void loop()
{

servo.write(90);
delay(1000);
servo.write(0);
delay(1000);

}

P.D. i don´t like delay, i shown it for description
Thu Mar 28 2019, 20:11:19
(no subject) (by Ziggy)
LD micro can do thaat task admirably.

Main issue is to set the PWM frequency as close as practicable to operate at a pulse duty cycle appropriate for the servo mechanism.

By setting the PWM duty cycle You can position the servo to the correct position.
Use the duty cycle option presetable in ten bit numbers and calculate the range of duty cycle values whihc will give you the range of movement.'

Once You know the center position value and left and right extremities... link Your input variable range to the movement range and its done.
Fri Mar 29 2019, 06:56:01
(no subject) (by Alex)
thanks, i´ll try... calculate,mn, i have tried it my testing values, it moves to one direction by pressing one button and to the other direction pressing another button, but when it stops it keeps making a sharp noise, had to wear ears plugs, and it started to heat up, do, i have to turn off pwm output when don´t use buttons?
Fri Mar 29 2019, 12:09:37, download attachment prueba servo.ld
(no subject) (by MGP)
It is impossible to make a LD program for a (sg90) servo with a 20Mhz crystal.
Fri Mar 29 2019, 14:23:14
(no subject) (by Ziggy)
Not familiar with PIC 16F877 but...

The trick is to figure out what the clock rate needs to be to allow LD micro to establish PWM frequency whihc is suitable for servo operation and make sure the PIC will run with it.

Then start planing the ladder to achieve the requisite PWM outputs for the range of movements.
Sat Mar 30 2019, 21:08:39
(no subject) (by Alex)
thanks for your reply, clock rate yo mean, change crystal o change plc cycle, it is gonna be a little hard, but it will be need to be tested, at least with buttons
Sat Mar 30 2019, 23:29:47
(no subject) (by Ziggy)
Crystal frequency.

I run with ATmega processor .. some choices with onboard oscialaator... cant comment on PIC ..
Set crystal to be able to get the required PWM frequency so that the servo motor recognises settings ( I think typically 20 to 50 Hz PWM )

Set PLC cycle to have sufficient time to do all things that need to happen.
Sat Mar 30 2019, 23:43:40
(no subject) (by Alex)
it would be great to use PCA9685 arduino module for controlling servos with ldmicro, it is programmable via i2c, it has its own
clock to generate its own pwm signal in 12 bits precision, i wonder if it can be used with ldmicro32?
Mon Apr 1 2019, 09:29:54
(no subject) (by Alex)
Hello again, i have beed testing using pulses for controlling a servo motor, i have managed to move it left and right (see video please) but never from 0° to 180° and back, is there some way to move it close to 0° and 180°?

https://www.youtube.com/watch?v=xk_t81cP13o&feature=youtu.be


i attach ladder
Sun Apr 14 2019, 22:12:01, download attachment servo test pulses.ld
(no subject) (by Alex)
here is a picture for pulses i took from youtuber profe garcía
Sun Apr 14 2019, 22:13:46, download attachment pulse for servo motor.jpg
(no subject) (by José GILLES)
Hi Alex

Concerning I2C, you can now use it with last ldmicro version 5.3.0.3 and external libraries for AVRs or PICs.

It should work with your PCA9685, and it would be a good experiment to test it.

I can help if need be.

José
Mon Apr 15 2019, 02:02:05
(no subject) (by Alex)
Thank for your reply José GUILLES, i'll get the module first
Mon Apr 15 2019, 09:49:14
(no subject) (by Ziggy)
Alex,

Try setting the clock to say 1MHz ( 0.8MHz is rejected by LDmicro as 0MHz )
At 1 MHz you can set PWM frequency to 61Hz.

Make an LD program to sample analog voltage and pass the sampled data ( 0-1023 counts) to the PWM duty cycle variable.

Use the PWM signal to drive the servo.

You will find the servo will respond to this signal with some algebraic massaging to cover the range You need
Tue Apr 16 2019, 00:50:03
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):