前回幕張オフでレーサー米屋太号に取り付け、えらい事になったんですが、ノーマル車体では動作するので原因はCDIでほぼ間違いない。

ということで、全く同じ構成であるはずのもう一台のCDIを取り付けてみたところ、これが動作しない。
iPhone 009
 
おそらく、、、なんかGNDあたりを変えてる最中だったような気がする。
うーん、思い出せない。
一回米屋太号のCDIと比較したい。俺製作者なのに・・・。

CDIの方ですけど、倍加回路を入れたCDIは自分でちょっと懐疑的になってきた。
確かに、トルクフルな感じは良いのだけれども、色々と課題も多い。
製作コストもさることながら、CDI自体が大きくなり過ぎるんやね。
その他の電装も気を使う必要がありますし。

SDRの点火系は、コイルは巻き直しが出来る様になったので別段問題ないけど、CDI自体はヤフオクで中古品を買うしか無くなっている。
中古品といってもすでに四半世紀前。
本当の意味で誰でも気楽に作れる極力シンプルなCDI(YPVSコントローラ込み)を何とかしたいなぁって思っています。

ま、さておき、タコメータ。
この倍加回路でも3XVのノーマルタコは動作していたので、とりあえず極力あわせる事にした。
回路はこんな感じ。 

無題
 
変更点はZDを12Vから20Vにしたことと、4700pFのコンデンサを取り付けたこと。

まぁこれでイケるんとちゃうかなと。(後日談:イケたそうです)
部品は千石でバラ買いして安く上げました。
ちなみにノーマルCDIでも動作してます。

あと前回判明した問題を少々修正。
まずバッテリーレスの押しがけ時、バッテリー車のキック時に針がチョイチョイ動いてしまう問題に対処する為に、スタートアップで2秒程ウェイトする事にしたこと。
また、キルスイッチを入れた時に針が0に戻らない問題を修正。
現在のソースはこんな感じ。

  [コードを表示する]
/* ------------------------------------------------------------------
              PIC12F1822 Pinout
              +--------+
          Vdd |1      8| GND
 Captre>- RA5 |2      7| RA0 -> OUT_B
  LED  <- RA4 |3      6| RA1 -> OUT_A
  MCLR -> RA3 |4      5| RA2 -> Suspend
              +--------+
-------------------------------------------------------------------*/

#include <xc.h> // include standard header file

// set Config bits
#pragma config FOSC=INTOSC  // Oscillator Selection bits
#pragma config PLLEN=OFF    // PLL Enable bit
#pragma config WDTE=OFF     // Watch dog timer enable bit
#pragma config MCLRE=OFF    // MCLEAR enable bit
#pragma config CLKOUTEN=OFF // Clock Out Enable bit
#pragma config IESO=OFF     // Internal External Switchover bit
#pragma config FCMEN=OFF    // Fail-Safe Clock Monitor Enable bit
#pragma config CP=OFF       // Code Protection bit
#pragma config CPD=OFF      // Data Code Protection bit
#pragma config BOREN=ON     // Brown-out Reset Enable bits
#pragma config WRT=OFF      // Flash Memory Self-Write Protection bits
#pragma config STVREN=ON    // Stack Overflow/Underflow Reset Enable bit
#pragma config BORV=LO      // Brown-out Reset Voltage Selection bit
#pragma config LVP=OFF      // Low-Voltage Programming Enable bit

// Definitions
#define _XTAL_FREQ  8000000 // this is used by the __delay_ms(xx) and __delay_us(xx) functions

#define OUTA        LATA1
#define OUTB        LATA0
#define SMD_STANDBY LATA2
#define SM_SENS     RA3
#define LED         LATA4
#define INPULSE     RA5

#define HH()  {OUTA=1;OUTB=1;}
#define LH()  {OUTA=0;OUTB=1;}
#define LL()  {OUTA=0;OUTB=0;}
#define HL()  {OUTA=1;OUTB=0;}

#define TURN_L 1
#define TURN_R 0
#define SM_PULSE_INTERVAL  4
#define RPM1000            5
#define RPMMAX           280
#define SMD_STANDBY_ON     0
#define SMD_STANDBY_OFF    1

// Global
unsigned int gSMTarget = 0;
unsigned int gPos = 0;

/* ------------------------------------------------------------------
PIC Interrupt
-------------------------------------------------------------------*/
void interrupt Interrupt()
{
  if(CCP1IF)
  {
    unsigned int ccpr1;

    SMD_STANDBY = SMD_STANDBY_OFF;

    // Reset Timer1
    TMR1H=0;
    TMR1L=0;
    
    // for YAMAHA TZR250(3XV) tacho meter scale.
    ccpr1 = ((CCPR1H * 0x100)|CCPR1L) + 1;
    gSMTarget = (unsigned int)(830000UL/ccpr1);
    
    if(gSMTarget>=RPM1000) gSMTarget -= RPM1000;
    if(gSMTarget>RPMMAX) gSMTarget = RPMMAX;
    CCP1IF = 0;
  }
  
  // Timer1: Timeout means engine stop
  if(TMR1IF) {
    gSMTarget = 0;
    if(0 == gPos) {
      SMD_STANDBY = SMD_STANDBY_ON;
    }
    TMR1IF = 0;
    LED = 0;
  }
}

/* ------------------------------------------------------------------
Rotate stepping motor
-------------------------------------------------------------------*/
void rotate(int dir)
{
  static signed char phase = 0;
  
  if( dir ) {
    phase++;
    phase %= 4;
  }  
  else
  {
    phase--;
    if( phase < 0 ) phase = 3;
  }  

  switch( phase ) {
    case 0: HH(); break;
    case 1: LH(); break;
    case 2: LL(); break;
    case 3: HL(); break;
    default: break;
  }  
  __delay_ms(SM_PULSE_INTERVAL);
}

/* ------------------------------------------------------------------
initialize stepping motor and startup demo
-------------------------------------------------------------------*/
void startupdemo()
{
  int ii;
  // delay 3sec. for battery less.
  __delay_ms(3000);
  
  // make an adjustment
  for(ii=0;ii<14;ii++)  {rotate(TURN_R);}
  // serch sensor
  while( 0 != SM_SENS ) {rotate(TURN_L);}
  while( 0 == SM_SENS ) {rotate(TURN_R);}
  rotate(TURN_R); // for sensor precision, forward one step.
  
  // fix 
  gPos == 0;
  
  // demo
  for( ii = 0; ii < RPMMAX; ii++ ) {
    rotate( TURN_R );
  }
  for( ii = 0; ii < RPMMAX; ii++ ) {
    rotate( TURN_L );
  }
}  

/* ------------------------------------------------------------------
main
-------------------------------------------------------------------*/
void main ( ) 
{
  int ii, jj;

  OPTION_REG =  0b00000000;  // 
  WPUA =        0b00000000;  // pull-up pins
  
  // set up oscillator control register
  OSCCON=    0b01110010;  // 8Mhz

  // Set up I/O pins
  // PORT A Assignments
  APFCON=    0b00000001;  // CCP1 function is on RA5
  TRISA=     0b00101000;  // 
  PORTA=     0b00000000;  // Reset port
  ANSELA=    0b00000000;  // Disable analog input
  LED = 1;

  // Timer1 Clock Source Select bits
  T1CONbits.TMR1CS=0;     // 00 = Timer1 clock source is instruction clock (FOSC/4)
  T1CONbits.T1CKPS=0x01;  // Timer1 Input Clock Prescale Select bits 1:2 Prescale value
  T1CONbits.T1OSCEN=0;    // Dedicated Timer1 oscillator circuit disabled
  T1CONbits.nT1SYNC=1;    // 1 = Do not synchronize external clock input
  T1CONbits.TMR1ON=0;     // Timer1 On bit

  // Set up Capture input
  CCP1CON=  0b00000100;  // Capture mode: every falling edge
  // CCP1CON=    0b00000101;  // Capture mode: every rizing edge

  // Reset CCP1/Timer interrupt flag
  CCP1IF=0;
  TMR1IF=0;

  // Initialize Stepping motor postion
  SMD_STANDBY = SMD_STANDBY_OFF;
  
  startupdemo();

  // Enable Interrupt
  PEIE=1;        // Enable peripheral interrupt
  GIE=1;         // enable global interrupt
  CCP1IE=1;      // enable the CCP1 interrupt   
  TMR1IE=1;      // enable Timer1 intterupt on
  TMR1ON=1;      // Timer1 On

  while(1) {
    if( gSMTarget > gPos ) {
      rotate( TURN_R );
      gPos++;
      continue;
    } else if( gSMTarget < gPos ) {
      rotate( TURN_L );
      gPos--;
      continue;
    } else {
    }
  }
}
/*---------------------------------------------------------------------------------
Copyright 2012-2014 Rilassaru All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this list
   of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this
   list of conditions and the following disclaimer in the documentation and/or
   other materials provided with the distribution.
 * Neither the name of the Rilassaru nor the names of its contributors may be used
   to endorse or promote products derived from this software without specific prior
   written permission. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

*/