<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comentários em: CONTROLADOR DE SERVOS III – P/ USO COM CÂMERAS DIGITAIS – COM PIC 12F675 (REF196)	</title>
	<atom:link href="http://picsource.com.br/archives/7634/feed/" rel="self" type="application/rss+xml" />
	<link>http://picsource.com.br/archives/7634/</link>
	<description></description>
	<lastBuildDate>Mon, 12 Sep 2016 01:48:24 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>
	<item>
		<title>
		Por: Claudio Larios		</title>
		<link>http://picsource.com.br/archives/7634/comment-page-1/#comment-4941</link>

		<dc:creator><![CDATA[Claudio Larios]]></dc:creator>
		<pubDate>Tue, 23 Aug 2016 18:16:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.larios.tecnologia.ws/iBlog/?p=7634#comment-4941</guid>

					<description><![CDATA[Em resposta a &lt;a href=&quot;http://picsource.com.br/archives/7634/comment-page-1/#comment-4939&quot;&gt;Gerson Moura&lt;/a&gt;.

Olá Gerson! 
Nesta montagem foi usado o Mplab X   XC8. 
Cláudio]]></description>
			<content:encoded><![CDATA[<p>Em resposta a <a href="http://picsource.com.br/archives/7634/comment-page-1/#comment-4939">Gerson Moura</a>.</p>
<p>Olá Gerson!<br />
Nesta montagem foi usado o Mplab X   XC8.<br />
Cláudio</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		Por: Gerson Moura		</title>
		<link>http://picsource.com.br/archives/7634/comment-page-1/#comment-4939</link>

		<dc:creator><![CDATA[Gerson Moura]]></dc:creator>
		<pubDate>Tue, 23 Aug 2016 11:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.larios.tecnologia.ws/iBlog/?p=7634#comment-4939</guid>

					<description><![CDATA[Olá Cláudio, bom dia!
Tire mais uma dúvida por favor... Fiz o esquema na protoboard, funcionou bem, só que o servo só funciona de um lado no potenciômetro. Exemplo: Colocando o potenciômetro todo pra cima o servo horizontal desloca todo para a esquerda e na medida que vou voltando o potenciômetro o servo volta ao lugar normal, parecendo não ir pra direita. Esse ajuste eu faço no trecho que o Sr. deixou no artigo? Qual compilador o Sr. usa? Mais uma vez muito obrigado !  :grin:]]></description>
			<content:encoded><![CDATA[<p>Olá Cláudio, bom dia!<br />
Tire mais uma dúvida por favor&#8230; Fiz o esquema na protoboard, funcionou bem, só que o servo só funciona de um lado no potenciômetro. Exemplo: Colocando o potenciômetro todo pra cima o servo horizontal desloca todo para a esquerda e na medida que vou voltando o potenciômetro o servo volta ao lugar normal, parecendo não ir pra direita. Esse ajuste eu faço no trecho que o Sr. deixou no artigo? Qual compilador o Sr. usa? Mais uma vez muito obrigado !  😀</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		Por: morais		</title>
		<link>http://picsource.com.br/archives/7634/comment-page-1/#comment-4073</link>

		<dc:creator><![CDATA[morais]]></dc:creator>
		<pubDate>Sun, 08 Nov 2015 19:30:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.larios.tecnologia.ws/iBlog/?p=7634#comment-4073</guid>

					<description><![CDATA[ok!larios no esquema é o pic 12f675 vou testar.muito obrigado pela força, sucesso.]]></description>
			<content:encoded><![CDATA[<p>ok!larios no esquema é o pic 12f675 vou testar.muito obrigado pela força, sucesso.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		Por: Claudio Larios		</title>
		<link>http://picsource.com.br/archives/7634/comment-page-1/#comment-4067</link>

		<dc:creator><![CDATA[Claudio Larios]]></dc:creator>
		<pubDate>Sat, 07 Nov 2015 23:28:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.larios.tecnologia.ws/iBlog/?p=7634#comment-4067</guid>

					<description><![CDATA[Em resposta a &lt;a href=&quot;http://picsource.com.br/archives/7634/comment-page-1/#comment-4062&quot;&gt;morais&lt;/a&gt;.

Olá Morais!
Parece que está faltando o &#039;include&#039; com o  tipo de microcontrolador. Pelo esquema no link que me passou não dá para enxergar nada, nem o tipo de microcontrolador.
Na suposição que esteja usando o 12f675, consegui compilar conforme abaixo:


#include   &lt;12F675.h&gt;//supondo que seja o 12f675
//#device adc=10
#fuses INTRC_IO,NOWDT,NOPUT //,NOBROWNOUT
#use delay(clock=4000000)


#use fast_io(a)
#use rs232(baud=9600, xmit=PIN_A2)
//analog implementation
//AN0=target
//AN1=potentiomenter
//driver type:
//type 0: ch0-left, ch1-right,
//type 1: ch0-on/off, ch1-direction
#define driver_type 0
//output (type=0)
#define motorL PIN_A4
#define motorR PIN_A5
//output (type=1)
#define motorON PIN_A4
#define motorDIR PIN_A5
//PID
#define Kp 0.2 * 16
#define Ki 0.0 * 16
#define Kd 0.0 * 16
#define dead_band 1
#define offset 30
#define max_pwm 240
#define max_integration 20000
#define derivate_dead_band 10
#byte ADRESH=0x1e
#byte ADRESL=0x9e
#byte ADCON0=0x1f
#byte ANSEL=0x9f
#define get_analog(var) #asm \
movf ADRESL,w \
movwf &#038;var \
movf ADRESH,w \
movwf &#038;var+1 \
#endasm
#define neg16(a) #asm \
COMF a,F \
COMF &#038;a+1,F \
INCF a,F \
BTFSC 03,2 \
INCF &#038;a+1,F \
#endasm
#define txd16(dato) putc((int)dato); putc((int)(dato&#062;&#062;8))
//long BARG;
#define sgn16(i) (bit_test(i,15))
int sign;
int16 target,pot,e,pwm,tmp,prev_e=0,derivate,integration=0;
void main()
{
int cont;
set_tris_a(0b00001011);
ANSEL=0b00010011; //0:nc, 001:fosc/8, 0011:DDAA
#if driver_type==0
output_low(motorL); output_low(motorR);
#else
output_low(motorON);
#endif




while(true) //bucle
{
//Get analog channels
//TARGET
ADCON0=0b10000001; //1: Right, 0: vref=5v, 00:NC, 00: ch=0, 1: start, 1: AD_ON
delay_us(100);
bit_set(ADCON0,1); //start
while(bit_test(ADCON0,1));
get_analog(target);
//POTENTIOMETER
ADCON0=0b10000101; //1: Right, 0: vref=5v, 00:NC, 01: ch=1, 1: start, 1: AD_ON
delay_us(100);
bit_set(ADCON0,1); //start
while(bit_test(ADCON0,1));
get_analog(pot);
//** IMPLEMENTS PID *******
pwm=0;
e=target-pot; //error
derivate=e-prev_e; prev_e=e; //derivate
if((e&#062;dead_band) &#124;&#124; (e+dead_band&#062;4));
if (sign) neg16(pwm);
//Kd
sign=false;
if (sgn16(derivate)) { sign=true; neg16(derivate); }
if(derivate&#062;derivate_dead_band)
{
tmp=derivate*Kd; //tmp=tmp&#062;&#062;4;
if (sign) neg16(tmp);
pwm=pwm+tmp;
}
}
//Ki
sign=false;
if (sgn16(integration)) { sign=true; neg16(integration); }
if (integration&#062;max_integration) integration=max_integration; //check limits
tmp=integration; tmp=tmp&#062;&#062;4;
tmp=tmp*Ki; tmp=tmp&#062;&#062;4;
if (sign) {neg16(tmp); neg16(integration) }
pwm=pwm+tmp;
tmp=pwm;
if(pwm)
{
if(sgn16(tmp))
{
//negative
#if driver_type==0
output_high(motorL);
#else
output_high(motorON);
output_high(motorDIR);
#endif
neg16(tmp);
}
else
{
//positive
#if driver_type==0
output_high(motorR);
#else
output_high(motorON);
output_low(motorDIR);
#endif
}
tmp+=offset;
if(tmp&#062;max_pwm) tmp=max_pwm;
}
//************************
//implements PWM
for(cont=0;cont&#060;255;cont++)
{
delay_us(50);
if ((int)tmp==cont)
{
#if driver_type==0
output_low(motorL); output_low(motorR);
#else
output_low(motorON);
#endif
}
}
#if driver_type==0
output_low(motorL); output_low(motorR);
#else
output_low(motorON);
#endif
/* //monitor
putc(&#039;0&#039;); txd16(POT);
putc(0x3c); txd16(TARGET);
putc(0x3d); txd16(PWM);
*/
} //while(1)


 //}


gerando o seguinte hex:


:1000000000308A0004280000FF238316900000308F
:100010008A000A2884011F3083051F08BF399F000A
:1000200083161F08F0390F389F00073083129F0096
:100030000515B001B101B401B5010B3065001330F5
:1000400083169F0083120512851281309F00213094
:10005000A000A00B29289F149F182C2883161E0887
:100060008312A6001E08A70085309F002130A00043
:10007000A00B38289F149F183B2883161E08831254
:10008000A8001E08A900AD01AC0128082602AA009C
:100090002708AB002908031C290FAB0230082A02ED
:1000A000B2002B08B3003108031C310FB3022B0838
:1000B000B1002A08B000AB08031D70282A08013CD3
:1000C000031C702801302A07B7002B08B80003185A
:1000D000B80AB808031D70283708043C031C7028B0
:1000E000A50803197828AC09AD09AC0A0319AD0AB3
:1000F000A501B31F82280130A500B209B309B20AD5
:100100000319B30AB308031D892832080A3C0318EF
:100110009928AF01AE01A50803199328AE09AF09CC
:10012000AE0A0319AF0A2E08AC070318AD0A2F0850
:10013000AD072528A501B51FA4280130A500B409E5
:10014000B509B40A0319B50A35084D3C0318B3289C
:10015000FF3A031DAF283408203C0318B3284E3063
:10016000B5002030B4003508AF003408AE00AF0C45
:10017000AE0CAF0CAE0CAF0CAE0CAF0CAE0C0F3027
:10018000AF05AF01AE01AF0CAE0CAF0CAE0CAF0CB7
:10019000AE0CAF0CAE0CAF05A5080319D928AE09FB
:1001A000AF09AE0A0319AF0AB409B509B40A0319B5
:1001B000B50A2E08AC070318AD0A2F08AD072D08A5
:1001C000AF002C08AE002C082D040319FF28AF1F28
:1001D000F0280516AE09AF09AE0A0319AF0AF128D7
:1001E00085161E30AE070318AF0AAF08031DFC28A2
:1001F0002E08F03C0318FF28AF01F030AE00B60126
:10020000360F032910291030A000A00B052900008B
:1002100036082E02031D0E2905128512B60A002982
:06022000051285126300C7
:02400E00F43983
:00000001FF
;PIC12F675


Mas como não sei o esquema, nem tenho certeza do pic usado, não posso afirmar que vá funcionar. Fica por sua conta e risco.

Cláudio]]></description>
			<content:encoded><![CDATA[<p>Em resposta a <a href="http://picsource.com.br/archives/7634/comment-page-1/#comment-4062">morais</a>.</p>
<p>Olá Morais!<br />
Parece que está faltando o &#8216;include&#8217; com o  tipo de microcontrolador. Pelo esquema no link que me passou não dá para enxergar nada, nem o tipo de microcontrolador.<br />
Na suposição que esteja usando o 12f675, consegui compilar conforme abaixo:</p>
<p>#include   &lt;12F675.h>//supondo que seja o 12f675<br />
//#device adc=10<br />
#fuses INTRC_IO,NOWDT,NOPUT //,NOBROWNOUT<br />
#use delay(clock=4000000)</p>
<p>#use fast_io(a)<br />
#use rs232(baud=9600, xmit=PIN_A2)<br />
//analog implementation<br />
//AN0=target<br />
//AN1=potentiomenter<br />
//driver type:<br />
//type 0: ch0-left, ch1-right,<br />
//type 1: ch0-on/off, ch1-direction<br />
#define driver_type 0<br />
//output (type=0)<br />
#define motorL PIN_A4<br />
#define motorR PIN_A5<br />
//output (type=1)<br />
#define motorON PIN_A4<br />
#define motorDIR PIN_A5<br />
//PID<br />
#define Kp 0.2 * 16<br />
#define Ki 0.0 * 16<br />
#define Kd 0.0 * 16<br />
#define dead_band 1<br />
#define offset 30<br />
#define max_pwm 240<br />
#define max_integration 20000<br />
#define derivate_dead_band 10<br />
#byte ADRESH=0x1e<br />
#byte ADRESL=0x9e<br />
#byte ADCON0=0x1f<br />
#byte ANSEL=0x9f<br />
#define get_analog(var) #asm \<br />
movf ADRESL,w \<br />
movwf &amp;var \<br />
movf ADRESH,w \<br />
movwf &amp;var+1 \<br />
#endasm<br />
#define neg16(a) #asm \<br />
COMF a,F \<br />
COMF &amp;a+1,F \<br />
INCF a,F \<br />
BTFSC 03,2 \<br />
INCF &amp;a+1,F \<br />
#endasm<br />
#define txd16(dato) putc((int)dato); putc((int)(dato&gt;&gt;8))<br />
//long BARG;<br />
#define sgn16(i) (bit_test(i,15))<br />
int sign;<br />
int16 target,pot,e,pwm,tmp,prev_e=0,derivate,integration=0;<br />
void main()<br />
{<br />
int cont;<br />
set_tris_a(0b00001011);<br />
ANSEL=0b00010011; //0:nc, 001:fosc/8, 0011:DDAA<br />
#if driver_type==0<br />
output_low(motorL); output_low(motorR);<br />
#else<br />
output_low(motorON);<br />
#endif</p>
<p>while(true) //bucle<br />
{<br />
//Get analog channels<br />
//TARGET<br />
ADCON0=0b10000001; //1: Right, 0: vref=5v, 00:NC, 00: ch=0, 1: start, 1: AD_ON<br />
delay_us(100);<br />
bit_set(ADCON0,1); //start<br />
while(bit_test(ADCON0,1));<br />
get_analog(target);<br />
//POTENTIOMETER<br />
ADCON0=0b10000101; //1: Right, 0: vref=5v, 00:NC, 01: ch=1, 1: start, 1: AD_ON<br />
delay_us(100);<br />
bit_set(ADCON0,1); //start<br />
while(bit_test(ADCON0,1));<br />
get_analog(pot);<br />
//** IMPLEMENTS PID *******<br />
pwm=0;<br />
e=target-pot; //error<br />
derivate=e-prev_e; prev_e=e; //derivate<br />
if((e&gt;dead_band) || (e+dead_band&gt;4));<br />
if (sign) neg16(pwm);<br />
//Kd<br />
sign=false;<br />
if (sgn16(derivate)) { sign=true; neg16(derivate); }<br />
if(derivate&gt;derivate_dead_band)<br />
{<br />
tmp=derivate*Kd; //tmp=tmp&gt;&gt;4;<br />
if (sign) neg16(tmp);<br />
pwm=pwm+tmp;<br />
}<br />
}<br />
//Ki<br />
sign=false;<br />
if (sgn16(integration)) { sign=true; neg16(integration); }<br />
if (integration&gt;max_integration) integration=max_integration; //check limits<br />
tmp=integration; tmp=tmp&gt;&gt;4;<br />
tmp=tmp*Ki; tmp=tmp&gt;&gt;4;<br />
if (sign) {neg16(tmp); neg16(integration) }<br />
pwm=pwm+tmp;<br />
tmp=pwm;<br />
if(pwm)<br />
{<br />
if(sgn16(tmp))<br />
{<br />
//negative<br />
#if driver_type==0<br />
output_high(motorL);<br />
#else<br />
output_high(motorON);<br />
output_high(motorDIR);<br />
#endif<br />
neg16(tmp);<br />
}<br />
else<br />
{<br />
//positive<br />
#if driver_type==0<br />
output_high(motorR);<br />
#else<br />
output_high(motorON);<br />
output_low(motorDIR);<br />
#endif<br />
}<br />
tmp+=offset;<br />
if(tmp&gt;max_pwm) tmp=max_pwm;<br />
}<br />
//************************<br />
//implements PWM<br />
for(cont=0;cont&lt;255;cont++)<br />
{<br />
delay_us(50);<br />
if ((int)tmp==cont)<br />
{<br />
#if driver_type==0<br />
output_low(motorL); output_low(motorR);<br />
#else<br />
output_low(motorON);<br />
#endif<br />
}<br />
}<br />
#if driver_type==0<br />
output_low(motorL); output_low(motorR);<br />
#else<br />
output_low(motorON);<br />
#endif<br />
/* //monitor<br />
putc(&#039;0&#039;); txd16(POT);<br />
putc(0x3c); txd16(TARGET);<br />
putc(0x3d); txd16(PWM);<br />
*/<br />
} //while(1)</p>
<p> //}</p>
<p>gerando o seguinte hex:</p>
<p>:1000000000308A0004280000FF238316900000308F<br />
:100010008A000A2884011F3083051F08BF399F000A<br />
:1000200083161F08F0390F389F00073083129F0096<br />
:100030000515B001B101B401B5010B3065001330F5<br />
:1000400083169F0083120512851281309F00213094<br />
:10005000A000A00B29289F149F182C2883161E0887<br />
:100060008312A6001E08A70085309F002130A00043<br />
:10007000A00B38289F149F183B2883161E08831254<br />
:10008000A8001E08A900AD01AC0128082602AA009C<br />
:100090002708AB002908031C290FAB0230082A02ED<br />
:1000A000B2002B08B3003108031C310FB3022B0838<br />
:1000B000B1002A08B000AB08031D70282A08013CD3<br />
:1000C000031C702801302A07B7002B08B80003185A<br />
:1000D000B80AB808031D70283708043C031C7028B0<br />
:1000E000A50803197828AC09AD09AC0A0319AD0AB3<br />
:1000F000A501B31F82280130A500B209B309B20AD5<br />
:100100000319B30AB308031D892832080A3C0318EF<br />
:100110009928AF01AE01A50803199328AE09AF09CC<br />
:10012000AE0A0319AF0A2E08AC070318AD0A2F0850<br />
:10013000AD072528A501B51FA4280130A500B409E5<br />
:10014000B509B40A0319B50A35084D3C0318B3289C<br />
:10015000FF3A031DAF283408203C0318B3284E3063<br />
:10016000B5002030B4003508AF003408AE00AF0C45<br />
:10017000AE0CAF0CAE0CAF0CAE0CAF0CAE0C0F3027<br />
:10018000AF05AF01AE01AF0CAE0CAF0CAE0CAF0CB7<br />
:10019000AE0CAF0CAE0CAF05A5080319D928AE09FB<br />
:1001A000AF09AE0A0319AF0AB409B509B40A0319B5<br />
:1001B000B50A2E08AC070318AD0A2F08AD072D08A5<br />
:1001C000AF002C08AE002C082D040319FF28AF1F28<br />
:1001D000F0280516AE09AF09AE0A0319AF0AF128D7<br />
:1001E00085161E30AE070318AF0AAF08031DFC28A2<br />
:1001F0002E08F03C0318FF28AF01F030AE00B60126<br />
:10020000360F032910291030A000A00B052900008B<br />
:1002100036082E02031D0E2905128512B60A002982<br />
:06022000051285126300C7<br />
:02400E00F43983<br />
:00000001FF<br />
;PIC12F675</p>
<p>Mas como não sei o esquema, nem tenho certeza do pic usado, não posso afirmar que vá funcionar. Fica por sua conta e risco.</p>
<p>Cláudio</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		Por: morais		</title>
		<link>http://picsource.com.br/archives/7634/comment-page-1/#comment-4062</link>

		<dc:creator><![CDATA[morais]]></dc:creator>
		<pubDate>Tue, 03 Nov 2015 22:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.larios.tecnologia.ws/iBlog/?p=7634#comment-4062</guid>

					<description><![CDATA[olá larios queria saber se é possivel transformar esse codigo em hex,já tentei copilar mais sempre dar erro nao sei quem é o autor.Trata-se um drive de servo ou seja ele converte o pwm  (1a2ms) e aciona o motor .
é um projeto para hobista que querem como eu construir seus proprio  servo motor!!

codigo
#include 
#fuses INTRC_IO,NOWDT,NOPUT //,NOBROWNOUT
#use delay(clock=4000000)
#use fast_io(a)
#use rs232(baud=9600, xmit=PIN_A2)

//analog implementation
//AN0=target
//AN1=potentiomenter

//driver type:
//type 0: ch0-left, ch1-right,
//type 1: ch0-on/off, ch1-direction
#define driver_type 0

//output (type=0)
#define motorL    PIN_A4
#define motorR 	PIN_A5

//output (type=1)
#define motorON   PIN_A4
#define motorDIR	PIN_A5

//PID
#define Kp 0.2 * 16
#define Ki 0.0 * 16
#define Kd 0.0 * 16

#define dead_band   1
#define offset     30
#define max_pwm    240
#define max_integration 20000
#define derivate_dead_band 10


#byte ADRESH=0x1e
#byte ADRESL=0x9e
#byte ADCON0=0x1f
#byte ANSEL=0x9f


#define get_analog(var) #asm \
	movf	ADRESL,w \
	movwf	&#038;var \
	movf	ADRESH,w \
	movwf	&#038;var+1 \
   #endasm

#define neg16(a) #asm \
  COMF   a,F \
  COMF   &#038;a+1,F \
  INCF   a,F \
  BTFSC  03,2 \
  INCF   &#038;a+1,F \
  #endasm

#define txd16(dato) putc((int)dato); putc((int)(dato&#062;&#062;8))

//long BARG;
#define sgn16(i) (bit_test(i,15))
int sign;
int16 target,pot,e,pwm,tmp,prev_e=0,derivate,integration=0;

void main()
{
int cont;

 set_tris_a(0b00001011);
 ANSEL=0b00010011;  //0:nc, 001:fosc/8, 0011:DDAA


 #if driver_type==0
 output_low(motorL); output_low(motorR);
 #else
 output_low(motorON);
 #endif

 while(true) //bucle
 {
   //Get analog channels

   //TARGET
   ADCON0=0b10000001; //1: Right, 0: vref=5v, 00:NC, 00: ch=0, 1: start, 1: AD_ON
   delay_us(100);
   bit_set(ADCON0,1); //start
   while(bit_test(ADCON0,1));
   get_analog(target);

   //POTENTIOMETER
   ADCON0=0b10000101; //1: Right, 0: vref=5v, 00:NC, 01: ch=1, 1: start, 1: AD_ON
   delay_us(100);
   bit_set(ADCON0,1); //start
   while(bit_test(ADCON0,1));
   get_analog(pot);

//** IMPLEMENTS PID *******
   pwm=0;
   e=target-pot; //error
   derivate=e-prev_e; prev_e=e; //derivate

   if((e&#062;dead_band) &#124;&#124; (e+dead_band&#062;4;
      if (sign) neg16(pwm);


      //Kd
      sign=false;
      if (sgn16(derivate)) { sign=true; neg16(derivate); }
      if(derivate&#062;derivate_dead_band)
      {
        tmp=derivate*Kd; //tmp=tmp&#062;&#062;4;
        if (sign) neg16(tmp);
        pwm=pwm+tmp;
      }
   }

   //Ki
   sign=false;
   if (sgn16(integration)) { sign=true; neg16(integration); }
   if (integration&#062;max_integration) integration=max_integration;    //check limits
   tmp=integration; tmp=tmp&#062;&#062;4;
   tmp=tmp*Ki; tmp=tmp&#062;&#062;4;
   if (sign) {neg16(tmp); neg16(integration) }
   pwm=pwm+tmp;

   tmp=pwm;
   if(pwm)
   {
      if(sgn16(tmp))
      {
         //negative
         #if driver_type==0
         output_high(motorL);
         #else
         output_high(motorON);
         output_high(motorDIR);
         #endif
         neg16(tmp);
      }
      else
      {
         //positive
         #if driver_type==0
         output_high(motorR);
         #else
         output_high(motorON);
         output_low(motorDIR);
         #endif
      }

      tmp+=offset;
      if(tmp&#062;max_pwm) tmp=max_pwm;
   }

//************************

   //implements PWM
   for(cont=0;cont&#060;255;cont++)
   {
     delay_us(50);
     if ((int)tmp==cont)
     {
       #if driver_type==0
       output_low(motorL); output_low(motorR);
       #else
       output_low(motorON);
       #endif
     }
   }
   #if driver_type==0
   output_low(motorL); output_low(motorR);
   #else
   output_low(motorON);
   #endif

/*     //monitor
     putc(&#039;0&#039;);  txd16(POT);
     putc(0x3c); txd16(TARGET);
     putc(0x3d); txd16(PWM);
*/
  } //while(1)
}

endereço da imagem
      
https://lh3.googleusercontent.com/XtoVKgDyEFR_Aw1Hu11MLnD02bdXUnXlstgMZ1A9ffgqJlpiJj-Y57GGVVwa-qdfxn5G=s123]]></description>
			<content:encoded><![CDATA[<p>olá larios queria saber se é possivel transformar esse codigo em hex,já tentei copilar mais sempre dar erro nao sei quem é o autor.Trata-se um drive de servo ou seja ele converte o pwm  (1a2ms) e aciona o motor .<br />
é um projeto para hobista que querem como eu construir seus proprio  servo motor!!</p>
<p>codigo<br />
#include<br />
#fuses INTRC_IO,NOWDT,NOPUT //,NOBROWNOUT<br />
#use delay(clock=4000000)<br />
#use fast_io(a)<br />
#use rs232(baud=9600, xmit=PIN_A2)</p>
<p>//analog implementation<br />
//AN0=target<br />
//AN1=potentiomenter</p>
<p>//driver type:<br />
//type 0: ch0-left, ch1-right,<br />
//type 1: ch0-on/off, ch1-direction<br />
#define driver_type 0</p>
<p>//output (type=0)<br />
#define motorL    PIN_A4<br />
#define motorR 	PIN_A5</p>
<p>//output (type=1)<br />
#define motorON   PIN_A4<br />
#define motorDIR	PIN_A5</p>
<p>//PID<br />
#define Kp 0.2 * 16<br />
#define Ki 0.0 * 16<br />
#define Kd 0.0 * 16</p>
<p>#define dead_band   1<br />
#define offset     30<br />
#define max_pwm    240<br />
#define max_integration 20000<br />
#define derivate_dead_band 10</p>
<p>#byte ADRESH=0x1e<br />
#byte ADRESL=0x9e<br />
#byte ADCON0=0x1f<br />
#byte ANSEL=0x9f</p>
<p>#define get_analog(var) #asm \<br />
	movf	ADRESL,w \<br />
	movwf	&amp;var \<br />
	movf	ADRESH,w \<br />
	movwf	&amp;var+1 \<br />
   #endasm</p>
<p>#define neg16(a) #asm \<br />
  COMF   a,F \<br />
  COMF   &amp;a+1,F \<br />
  INCF   a,F \<br />
  BTFSC  03,2 \<br />
  INCF   &amp;a+1,F \<br />
  #endasm</p>
<p>#define txd16(dato) putc((int)dato); putc((int)(dato&gt;&gt;8))</p>
<p>//long BARG;<br />
#define sgn16(i) (bit_test(i,15))<br />
int sign;<br />
int16 target,pot,e,pwm,tmp,prev_e=0,derivate,integration=0;</p>
<p>void main()<br />
{<br />
int cont;</p>
<p> set_tris_a(0b00001011);<br />
 ANSEL=0b00010011;  //0:nc, 001:fosc/8, 0011:DDAA</p>
<p> #if driver_type==0<br />
 output_low(motorL); output_low(motorR);<br />
 #else<br />
 output_low(motorON);<br />
 #endif</p>
<p> while(true) //bucle<br />
 {<br />
   //Get analog channels</p>
<p>   //TARGET<br />
   ADCON0=0b10000001; //1: Right, 0: vref=5v, 00:NC, 00: ch=0, 1: start, 1: AD_ON<br />
   delay_us(100);<br />
   bit_set(ADCON0,1); //start<br />
   while(bit_test(ADCON0,1));<br />
   get_analog(target);</p>
<p>   //POTENTIOMETER<br />
   ADCON0=0b10000101; //1: Right, 0: vref=5v, 00:NC, 01: ch=1, 1: start, 1: AD_ON<br />
   delay_us(100);<br />
   bit_set(ADCON0,1); //start<br />
   while(bit_test(ADCON0,1));<br />
   get_analog(pot);</p>
<p>//** IMPLEMENTS PID *******<br />
   pwm=0;<br />
   e=target-pot; //error<br />
   derivate=e-prev_e; prev_e=e; //derivate</p>
<p>   if((e&gt;dead_band) || (e+dead_band&gt;4;<br />
      if (sign) neg16(pwm);</p>
<p>      //Kd<br />
      sign=false;<br />
      if (sgn16(derivate)) { sign=true; neg16(derivate); }<br />
      if(derivate&gt;derivate_dead_band)<br />
      {<br />
        tmp=derivate*Kd; //tmp=tmp&gt;&gt;4;<br />
        if (sign) neg16(tmp);<br />
        pwm=pwm+tmp;<br />
      }<br />
   }</p>
<p>   //Ki<br />
   sign=false;<br />
   if (sgn16(integration)) { sign=true; neg16(integration); }<br />
   if (integration&gt;max_integration) integration=max_integration;    //check limits<br />
   tmp=integration; tmp=tmp&gt;&gt;4;<br />
   tmp=tmp*Ki; tmp=tmp&gt;&gt;4;<br />
   if (sign) {neg16(tmp); neg16(integration) }<br />
   pwm=pwm+tmp;</p>
<p>   tmp=pwm;<br />
   if(pwm)<br />
   {<br />
      if(sgn16(tmp))<br />
      {<br />
         //negative<br />
         #if driver_type==0<br />
         output_high(motorL);<br />
         #else<br />
         output_high(motorON);<br />
         output_high(motorDIR);<br />
         #endif<br />
         neg16(tmp);<br />
      }<br />
      else<br />
      {<br />
         //positive<br />
         #if driver_type==0<br />
         output_high(motorR);<br />
         #else<br />
         output_high(motorON);<br />
         output_low(motorDIR);<br />
         #endif<br />
      }</p>
<p>      tmp+=offset;<br />
      if(tmp&gt;max_pwm) tmp=max_pwm;<br />
   }</p>
<p>//************************</p>
<p>   //implements PWM<br />
   for(cont=0;cont&lt;255;cont++)<br />
   {<br />
     delay_us(50);<br />
     if ((int)tmp==cont)<br />
     {<br />
       #if driver_type==0<br />
       output_low(motorL); output_low(motorR);<br />
       #else<br />
       output_low(motorON);<br />
       #endif<br />
     }<br />
   }<br />
   #if driver_type==0<br />
   output_low(motorL); output_low(motorR);<br />
   #else<br />
   output_low(motorON);<br />
   #endif</p>
<p>/*     //monitor<br />
     putc(&#039;0&#039;);  txd16(POT);<br />
     putc(0x3c); txd16(TARGET);<br />
     putc(0x3d); txd16(PWM);<br />
*/<br />
  } //while(1)<br />
}</p>
<p>endereço da imagem</p>
<p><a href="https://lh3.googleusercontent.com/XtoVKgDyEFR_Aw1Hu11MLnD02bdXUnXlstgMZ1A9ffgqJlpiJj-Y57GGVVwa-qdfxn5G=s123" rel="nofollow ugc">https://lh3.googleusercontent.com/XtoVKgDyEFR_Aw1Hu11MLnD02bdXUnXlstgMZ1A9ffgqJlpiJj-Y57GGVVwa-qdfxn5G=s123</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		Por: wesley ramos natal		</title>
		<link>http://picsource.com.br/archives/7634/comment-page-1/#comment-3936</link>

		<dc:creator><![CDATA[wesley ramos natal]]></dc:creator>
		<pubDate>Mon, 21 Sep 2015 19:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.larios.tecnologia.ws/iBlog/?p=7634#comment-3936</guid>

					<description><![CDATA[bom dia larios e um prazer muito grande de conhecer jente nova tenho 48 anos trabalho no ramos de eletronica departamento de radio frequencia e eletronica analogica e muito bom ver teus projetos microcomtrolado fusiona muito bem um abraço wesley]]></description>
			<content:encoded><![CDATA[<p>bom dia larios e um prazer muito grande de conhecer jente nova tenho 48 anos trabalho no ramos de eletronica departamento de radio frequencia e eletronica analogica e muito bom ver teus projetos microcomtrolado fusiona muito bem um abraço wesley</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
