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/@)8fMQ!K(B
START$B!"(BSTOP$B!"(BRESTART$B$N;XNa$H(BRT-$B%?%9%/$N$B%G!<%?$NAw RT-$B%?%9%/(B

$B6nF07O(B RT $B%?%9%/%b%8%e!<%k(B
  1. $B%W%m%0%i%`L>!'(B pwm_enc_module.c

  2. $B%3%s%Q%$%kJ}K!!'(B make pwm_enc_module

  3. $BDj5A$5$l$F$$$k%b!<%I(B DUTY_MODE, STOP_MODE

    DUTY_MODE$BM?$($i$l$?(B DUTY $BHf$G%b!<%?$r2s$9!#(B
    STOP_MODE$B;XDj$5$l$?3QEY$^$?$O5wN%$@$1!"%b!<%?$r2s$7!"$=$NCM(B $B$KC#$7$?$i;_$a$k!#(B

  4. STOP_MODE $B;~$N@)8f(B

    $B%m!<%?%j%(%s%3!<%I$N%+%&%s%?CM$rFI$_.$5$/$9$k!#(B
    $BHfNc@)8f$r9T$C$F$$$k!#$=$N78?t$O!":81&$=$l$>$l!"(BKpl, Kpr $B$GM?$($k!#(B
    $B@)8f$r=*N;$9$kogCM!J%(%s%3!<%@$N%Q%k%9%Y!<%9!K$r(B Vmin $B$GM?$($k!#(B
    $B%b!<%?$d(B MIRS$B$N@)F0%H%k%/J,$r(B duty $BHf%Y!<%9$G!"(B vshift $B$GM?$($k!#(B

  5. FPGA $B2sO)%G!<%?$N%P!<%8%g%s$K$h$C$F!"%(%s%3!<%@$NId9g?.9f$,0[$J$k>l(B $B9g$,$"$k!#$=$NMM$J2DG=@-$,$"$k>l9g$O!"(Bpwm_enc_module.c $B$NBe$j$K!"(B pwm_enc_module2.c $B$r;H$C$F$_$k!#(B
$B9TF0@)8f%W%m%0%i%`Cf$G;HMQ$9$k@)8f4X?t(B
  1. RT-$B%?%9%/@)8fMQ!J(Bboth.c$B$NCf$GDj5A$5$l$F$$$k4X?t!K(B
    void pwm_enco_start(int period)
    $B%m!<%?%j!<%(%s%3!<%@!&(BPWM$B@)8fMQ$N(BRT-$B%?%9%/$r%9%?!<%H$5$;$k$?$a$N4X?t!#period($BC10L!'&L(Bsec) $B$r0z?t$H$7$FM?$($k!#La$jCM$OL5$7!#(B

    void pwm_enco_stop(void)
    $B%m!<%?%j!<%(%s%3!<%@!&(BPWM$B@)8fMQ$N(BRT-$B%?%9%/$rDd;_$5$;$k$?$a$N4X?t!#(B $BLa$jCM$OL5$7!#(B

    void pwm_enco_restart(void)
    pwm_enco_stop$B$GDd;_$5$;$?(BRT-$B%?%9%/$r:F%9%?!<%H$5$;$k$?$a$N4X?t!#(B $BLa$jCM$OL5$7!#(B

  2. $B%m!<%?%j!<%(%s%3!<%@@)8fMQ(B1$B!J(Bencoder.c$B$NCf$GDj5A$5$l$F$$$k4X?t!K(B
    void encoder_data(int *l_distance, int *r_distance, int *l_speed, int *r_speed, int *br)
    FIFO3$B$+$i:81&$N%m!<%?%j!<%(%s%3!<%@$N%+%&%s%HCM$H%U%i%0$N>uBV$rFI$_9~$s$G!":81&$N%?%$%d$N0\F05wN%(B $B!&B.EY$H%U%i%0$N>uBV$rLa$jCM$H$7$FJV$94X?t!#$3$N4X?t$rMQ$$$F:81&$N%?%$%d$N0\F05wN%$HB.EY$r;}$C$F$/$k$?$a$K$O!"(Bint$B7?$NJQ?t$r#4$DMQ0U$7$F!"(B

    int a, b, c, d, br;
    $B!'(B
    $B!'(B
    $B!'(B
    encoder_data(&a, &b, &c, &d, &br)$B!((B

    $B$H$$$&$h$&$K5-=R$9$k!#$3$&$9$k$3$H$K$h$C$FJQ?t(Ba, b, c, d, br$B$K$=$l$>$l:80\F05wN%(B(cm)$B!"1&0\F05wN%(B(cm)$B!":8B.EY(B(cm/sec)$B!"1&B.EY(B(cm/sec) $B%U%i%0$N>uBV$,BeF~$5$l$k!#(B
    $B$J$*!"5wN%$dB.EY$r5a$a$k:]$KI,MW$J(BRT-$B%?%9%/$N7B$O!"(Btask_control.h$B$NCf$GDj5A(B $B$5$l$F$$$k$N$G!J<~4|$O(Bperi$B!"D>7B$O(Bdiameter$B$H$$$&L>A0$G!K!"I,MW$,$"$l$P$=$l$rJQ99$9$k$h$&$K$9$k!#(B

    $B%U%i%0$K$D$$$F(B
    $B%U%i%0$O4X?t!&(Bpwm_circle_data$B$^$?$O(Bpwm_cm_data$B$r;HMQ$7$?:]$K(BMIRS$B$,F0:n$r40N;$7$?$3$H$r3NG'$9$k$?$a$N(B $B$b$N$G!"JQ?t(Bbr$B$,#1$K$J$C$F$$$l$PF0:n$,40N;$7$?$3$H$r<($9!#!JF0:nCf!"$^$?$O(Bduty$BHf%b!<%I$r;H$C$?>l9g$O#0$,F~$k!K(B

  3. PWM$B@)8fMQ!J(Bpwm.c$B$NCf$GDj5A$5$l$F$$$k4X?t!K(B
    void pwm_both_data(int l_duty, int r_duty)
    $BB.EY%G!<%?$r(BPWM$B$XAw$k$N$K;HMQ$9$k4X?t!#:81&$N%b!<%?$N(Bduty$BHf!&(Bl_duty$B!"(Br_duty$B$r0z?t$H$7$FM?$($k!#(B
    duty$BHf$O(B -100$B!A(B100 $B$NHO0O$N@0?t$G!"Id9f$O@5E>$,(B+($B%W%i%9(B)$B$G5UE>$,(B-($B%^%$%J%9(B)

    void pwm_circle_data(int angle)
    $B$=$N>l2sE>$r$9$k:]$K;HMQ$9$k4X?t!#2sE>3Q(I%(Bangle$B$r0z?t$H$7$FM?$($k!#(B
    $BId9f$O;~7W2s$j$,(B+($B%W%i%9(B)$B$GH?;~7W2s$j$,(B-($B%^%$%J%9(B)

    void pwm_cm_data(int l_distance, int r_distance)
    MIRS$B$r;XDj$7$?5wN%$@$1Av$i$;$FDd;_$5$;$k$?$a$N4X?t!#D>?J$5$;$k5wN%!JC10L!'(Bcm$B!K(I%(Bl_distance$B!"(Br_distance$B$r0z?t$H$7$FM?$($k!#(B
    $BId9f$OA0?J$,(B+($B%W%i%9(B)$B$G8e?J$,(B-($B%^%$%J%9(B)

$B0\F05wN%!&B.EY$N;;=PJ}K!(B

$B%?%$%d#12sE>$"$?$j$N%+%&%s%H?t(BC
$B%?%$%d$N1_<~(BE$B#c#m(B
$B%b!<%?!<$N%.%"Hf(B$B#1#6!'#1(B

$B!!2>$K(BMIRS$B$NB-2s$j$K4X$9$k%G!<%?$,>e5-$NDL$j$G$"$k$H$9$k$H!"%?%$%d$N0\F05wN%$HB.EY$O1$B!"#x(B2(I%%%$B#x(Bn$B$G$"$C$?>l9g!J#x(Bn$B$,:G?7$N%+%&%s%HCM$G!"%?%9%/$N $B0\F05wN%(Bd$B!'(B d [cm] $B!a(B ($B#x(B1+$B#x(B2+(I%%%(B+$B#x(Bn)$B!`(B(C$B!_(B16)$B!_(BE[cm]

$BB.EY(Bv$B!'(B v [cm/sec] $B!a(B $B#x(Bn$B!`(B(C$B!_(B16)$B!_(BE[cm]$B!`(By[sec]

$B$=$NB>$N%W%m%0%i%`(B

  1. pwm_enc.h

    $B$3$N%W%m%0%i%`72$N4X?t$G;H$o$l$F$$$k!"JQ?t$N(B define$B!"$*$h$S9=B$BN$NDj5A(B $B$r9T$C$F$$$k!#(B

  2. func_extern.h

    $B%W%m%0%i%`4V$G6&DL$K;H$o$l$k4X?t$N(B extern $B@k8@$r$^$H$a$F9T$C$F$$$k!#(B

  3. enc_test.c

    $B%(%s%3!<%@$N%F%9%H%W%m%0%i%`!#%?%$%d$r$5$;$k$H!"2sE>3Q$,I=<($5(B $B$l$k!#(B

  4. pwm_rotate.c

    $B;XDj$7$?3QEY!":81&$N%b!<%?$r2sE>$5$;$k%W%m%0%i%`!#%?%$%d%Y!<%9$N2sE>3F$r(B theta $B$GM?$($k!#I=<($O%?%$%d$N2sE>3Q!#(B

  5. pwm_enc_test.c

    $B;XDj$7$?5wN%!J%?%$%d$N1_<~49;;!K!":81&$N%b!<%?$r2sE>$5$;$k%W%m%0%i%`!#(B $BI=<($O!":81&$N%?%$%d$N1_<~49;;$N0\F05wN%(B(cm)$B!"B.EY(B(cm/sec)$B!"%U%i%C%0$N(B5 $B$D!#(B

  6. encoder2.c

    enc_test.c, pwm_rotate.c $B$G;H$o$l$k4X?t(B encoder_data2 $B$rDj5A$7$?%W%m%0%i(B $B%`!#(B

    void encoder_data(int *l_distance, int *r_distance, int *br)
    l_distance, r_distance $B$K$O!"%?%$%d%Y!<%9$N2sE>3Q$,F~$k!#(B

$B4XO"J8=q(B