Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

Project Request

Return
salah mahdi
salah_mahdi

posted on 2014/06/09 03:22:51 PM CEST

Audio & Speech

low frequency PWM(50Hz)

hi everybody
i need code for driving servor motor (5v) using pic 18f45k22 at 8MHz at low frequency (50 Hz) and PWM is not support low frequency any help is appreciated
thanks for all

USER Comments

Arezki YOUYOU
Electronicman

posted on 2015/06/28 07:52:02 AM CEST

Hello
you can use my library Software PWM, you can use a very low frequency of PWM

http://www.libstock.com/projects/view/1042/software-pwm

enjoy !!

  • Rating:
0
No Abuse Reported

Do you want to report abuse comment ID: 1484 in "low frequency PWM(50Hz) " request.

Robinson Velasquez
Cagiva125

posted on 2014/07/14 07:08:48 AM CEST

Hola,

Este código se puede adaptar para lo que necesita:


// PIC 16F628A XT:20MHz



//Función para generar el PWM de
//baja frecuencia, ajustado para
//cristal de 20MHz.
void Pwm_Sevo( float ang )
{
unsigned int n, max;
max = 1.61*ang;
PORTB.F0 = 1;
delay_ms(1);
for( n=0; n<max; n++ )
delay_us(1);
PORTB.F0=0;
delay_ms(15);
}
void main( void )
{
//Angulo inicial.
float ANGULO=90;
//Inicio del puerto
TRISB.F0 = 0;
//Se activan las resistencias PULL-UP.
OPTION_REG=0;
while(1)//Bucle infinito.
{
Pwm_Sevo(ANGULO); //Se genera un pulso.
//Si se pulsa el botón de RB6
//se decrementan 10 grados.
if( PORTB.F6==0 )
{
ANGULO-=10.0;
if( ANGULO<0.0 )ANGULO=0.0;
while( Button(&PORTB,6,5,0) );
}
//Si se pulsa el botón de RB7
//se incrementan 10 grados.
if( PORTB.F7==0 )
{
ANGULO+=10.0;
if( ANGULO>180.0 )ANGULO=180.0;
while( Button(&PORTB,7,5,0) );
}
}
}





Hay ejemplos en este libro:


https://www.google.com.co/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CBwQFjAA&url=http%3A%2F%2Fwww.mikroe.com%2Fdownload%2Feng%2Fdocuments%2Fpublications%2Fother-books%2Flibro_simulacion_mikroc.pdf&ei=wH7DU66QHIbfsAT4oYH4CQ&usg=AFQjCNH0P-n93V_PxmLiyL_Lsz6Iv3ac8Q&sig2=dXp8xXsTiWbd6EJOqTTGQg&bvm=bv.70810081,d.cWc

  • Rating:
0
No Abuse Reported

Do you want to report abuse comment ID: 1200 in "low frequency PWM(50Hz) " request.