(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
(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.
(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?
(no subject) (by MGP)
It is impossible to make a LD program for a (sg90) servo with a 20Mhz crystal.
(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.
(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
(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.
(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?
(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
(no subject) (by Alex)
here is a picture for pulses i took from youtuber profe garcía
(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é
(no subject) (by Alex)
Thank for your reply José GUILLES, i'll get the module first
(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
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
(no subject) (by Calubert)
Attached how to proceed to Steps
Adjunto como proceder a Pasos
(no subject) (by Calubert)
adjunto STEP
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
(no subject) (by MGP)
You cannot select a pwm pin with the 12F683 in LDmicro!
(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).
(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.
(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
(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
(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
(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.
(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.
Post a reply to this comment:
|