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
(no subject) (by Alex)
I have tested MGP´s ladder for servo SG-90 from this post :

http://cq.cx/ladder-forum.pl?a...;parent=8714&tt=1561259407

called "servopwmPic16f88_analogtestV2.ld"

It works pretty well: (watch video)

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

it doesn´t get from 0 to 180 completely but it needs more test as described in ladder comment.

Nevertheless, in proteus it makes complete 0 to 180 full:

https://www.youtube.com/watch?v=DRyA9ma-D00


it is not going to be always as simulation i guess.

In my opinion i can use this as a "driver" for servo, like serial lcd driver for ldmicro:

https://github.com/LDmicro/LDm...CD-based-on-HD44780-controller

it would be great to have complete turn with ldmicro
Fri Nov 29 2019, 21:39:15
(no subject) (by Alex)
could you make an pot-pwm control ladder for sg90 servo with atmega328p as the previous example?

with: 16MHZ
cycle time: 1ms



https://github.com/LDmicro/LDmicro/wiki/Servo-PWM
Sat Nov 30 2019, 06:50:01
servo motor pic 12f683 (by Agnaldo F. da Silva)
ola sou novo por aqui, eu queria fazer um programa pra controlar um servo 90g com um pic 12f683 com botão pulso, sei que e possivel pois ja peguei um código pronto mas queria fazer uma modificações, fiz um programa no lader que na simulação proteus funciona mas no protobord nao funciona alguém tem algum modelo exemplo pra mim orientar
Sun Oct 17 2021, 13:34:41
(no subject) (by Calubert)
Attached how to proceed to Steps

Adjunto como proceder a Pasos
Mon Oct 18 2021, 07:42:15, download attachment Peueba pasos.ld
(no subject) (by Calubert)
adjunto STEP
Mon Oct 18 2021, 07:44:57, download attachment STEP.ld
servo pic12f683 (by Agnaldo F. da Silva)
opa boa noite, eu tentei colocar estes exeplos que me passou mas nao consegui fazer funcionar estes exeplos e pra o pic12f683
Wed Oct 20 2021, 21:15:22
(no subject) (by MGP)
You cannot select a pwm pin with the 12F683 in LDmicro!
Thu Oct 21 2021, 07:05:20
(no subject) (by Paulino Calubert)
MPG Here I attach a program that is PIC16F628.
with PWM, what if it is true that this PIC does not support El (ADC).

MGP Kola MPG Aqui te adjunto Un programa que es PIC16F628.
con PWM, lo que si es cierto que esta PIC no soporta El(ADC).
Fri Oct 22 2021, 04:51:43, download attachment PWM15F628.ld
(no subject) (by MGP)
Sorry but I don't know what you mean or what you want to say.

It's about an LD program for an SG90 servo with a 16F683 pic.
Normally you use a 50HZ PWM for this, but with a 16F683 you cannot select a PWMpin in LDmicro and that will not work.
Fri Oct 22 2021, 06:28:23
(no subject) (by Paulino Calubert)
Sorry I thought you were referring to the PIC16F628, and by my mistake I did not observe that it was talking about the PIC12F628.
I'm sorry, you are absolutely right, below is your comment that for my part I did not see it and I had another idea.

(no subject) (by MGP)
You cannot select a pwm pin with the 12F683 in LDmicro!
Yesterday, 07:05:20
Fri Oct 22 2021, 07:16:30
(no subject) (by Agnaldo F. da Silva)
tudo bem Paulino e obrigado pela atenção e que eu tenho varios destes pic 12f683 e peguei um codigo pronto com dois botoes e um potenciometro e este funciona, mas eu precisava de modificar pra um botão que aciona apertando uma vez vai pra 0 e apertando novamente vai 180 e volta e assim neste loop, depois eu ia adionar um led indicador ou buzzer, um projeto bem simpres e compacto
Fri Oct 22 2021, 23:09:27
(no subject) (by Agnaldo F. da Silva)
tudo bem Paulino e obrigado pela atenção e que eu tenho varios destes pic 12f683 e peguei um codigo pronto com dois botoes e um potenciometro e este funciona, mas eu precisava de modificar pra um botão que aciona apertando uma vez vai pra 0 e apertando novamente vai 180 e volta e assim neste loop, depois eu ia adionar um led indicador ou buzzer, um projeto bem simpres e compacto
Fri Oct 22 2021, 23:10:18
(no subject) (by Calubert)
Attached LDMicro program, as I think I have understood.
You also have an example of how to do the steps in both P and N.
If you have any questions, tell me. Please comment in (Spanish) and you will translate it. Greetings Paulino

Adjunto programa LDMicro, como creo haber entendido.
también tienes ejemplo de como hacer los pasos Tanto en P como N.
si tienes alguna duda comentamelo.
Tue Oct 26 2021, 06:07:12, download attachment Ejemplo.LD
(no subject) (by MGP)
Calubert, a SG90 servo works with PPM as used in RC-cars, boats...

I think your program generates a number of pulses and an SG90 can't do anything with that.
Tue Oct 26 2021, 12:08:00
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):