mikey

Mikey's 240z - Golly gosh

75 posts in this topic

I've been working away but it's not very interesting stuff. 

 

I've cleaned up all my wiring and mounted the fuse box and rebuilt all the heater stuffs.

 

IMAG0261.jpg

 

 

Dash is back in. The tacho is being a total vag so I'm ditching that stupid circuit and replacing it with a stepper motor at some point when I care enough.

 

 

IMAG0262.jpg

 

Replaced the rubber bits on the quarter windows.

 

IMAG0264.jpg

 

If things go really well I might be driving this on the weekend. There's still lots of things to do; some upholstery, put all the windows back in, door lock actuators, all the interior panels, indicators, seats & belts. Mostly a million little thingys. 

4 people like this

Share this post


Link to post
Share on other sites

HUZZAH! I've gotten my speedo working. Basically I stripped the guts out of the stock speedo and put two stepper motors inside, put a hall sensor next to a diff flange, then I made some electronic thingys to measure the speed picked up by the sensor and move the motors in the speedo. Like so...

 

This is the motor I used for the odometer

 

IMG_20130802_203251.jpg

 

This is the type of motor I used for the needle

 

 

ScreenShot2013-11-14at85322PM.png

 

This is not my car but I basically did the same thing as this, sensor picks up the capscrews as they fly past the sensor:

 

IMG_2655_zps529df59d1.jpg

 

My hack circuit board:

 

IMAG0283-1.jpg

 

The processor is a PIC16F628A and it has two ld239 motor divers (one for each of the motors). The sensor is a Honeywell 1GT101DC.

 

It all works pretty well. I was a shocked as you!

 

The codez:

/*
 * 
 */
#include <htc.h>
#include <stdio.h>
#include <stdlib.h>
#include "system.h"

__CONFIG(CP_OFF & WDTE_OFF & BOREN_OFF & MCLRE_OFF & PWRTE_ON & FOSC_INTOSCIO & LVP_OFF);

#define SPEEDO_MULTIPLIER 5.4
#define SPEEDO_MOTOR_STEP_DELAY 4 // 2 minumum seems to work
#define ODOMETER_MOTOR_STEP_DELAY 10
#define FILTER_FRACTION 0.85

/*
 * Local function declarations
 */
void delay_ms(unsigned int ui_value);
void interrupt isr(void);
void set_step(unsigned int speed);

/*
 * Globals
 */
unsigned int speedo_step_number;
unsigned int revolution_period;
unsigned char trigger_count;
unsigned char odometer_trigger_count;

/*
 * 
 */
int main()
{    
    PORTA = 0;
    PORTB = 0;

    TRISA = 0b00010000;
    TRISB = 0b01000000;

    T1CON = 0b00110101; // Enable timer1 1:8 prescaler
    
    PIE1   = 0b00000001; // Enable timer1 interrupt
    INTCON = 0b10001000; // Enable portb interrupts    

    LED_RED = 1;

    // reset speedo
    speedo_step_number = 300;
    set_step(0);
    speedo_step_number = 0;

    trigger_count = 0;
    revolution_period = 0;
    
    while (1) {
        
        if (revolution_period) {
            set_step((unsigned int)(522000/(revolution_period/SPEEDO_MULTIPLIER)));
        } else {
            set_step(0);
        }

        if (odometer_trigger_count > 14) {
            PORTB = 0b00001000;
            delay_ms(ODOMETER_MOTOR_STEP_DELAY);
            PORTB = 0b00000010;
            delay_ms(ODOMETER_MOTOR_STEP_DELAY);
            PORTB = 0b00000100;
            delay_ms(ODOMETER_MOTOR_STEP_DELAY);
            PORTB = 0b00000001;
            delay_ms(ODOMETER_MOTOR_STEP_DELAY);
            PORTB = 0;

            odometer_trigger_count = 0;
        }
    }

    return (EXIT_SUCCESS);
}

void set_step(unsigned int step)
{
    unsigned int target_step_number = max(step, (int)(4 * SPEEDO_MULTIPLIER)) - (int)(4 * SPEEDO_MULTIPLIER);

    while (speedo_step_number != target_step_number) {

        if (speedo_step_number < target_step_number) {
            speedo_step_number++;
        } else {
            speedo_step_number--;
        }
        
        PORTA = motor2_state_map[speedo_step_number%6];

        delay_ms(SPEEDO_MOTOR_STEP_DELAY);
    }
}

void interrupt isr(void)
{
    if (RBIF) {
        unsigned char b = PORTB;
        
        if (b & SENSOR_BITMASK) {

            odometer_trigger_count++;
            
            if (++trigger_count >= 4) {

                // There's been 4 triggers (one revolution), read the timer
                union timer timer;

                timer.bt[0] = TMR1L;    // Read Lower byte
                timer.bt[1] = TMR1H;    // Read upper byte

                TMR1L = 0;
                TMR1H = 0;

                // Single pole low pass filter
                revolution_period = revolution_period + (FILTER_FRACTION * ((signed short long)timer.lt - revolution_period));

                trigger_count = 0;
            }

            if (LED_RED) {
                LED_RED = 0;
            } else {
                LED_RED = 1;
            }
        }
        
        RBIF = 0; // Clear interrupt
    }

    if (TMR1IF == 1) {

        // Timer1 has overflowed, reset and start timing again.
        trigger_count = 0;
        revolution_period = 0;

        TMR1L = 0;
        TMR1H = 0;

        TMR1IF = 0; // Clear interrupt
    }
}

/*
 * Delay in milliseconds.
 *
 */
void delay_ms(unsigned int ui_value)
{
    while (ui_value-- > 0) {
        __delay_ms(1);
    }
}
/* 
 * File:   system.h
 * Author: mikey
 *
 * 1000000 * (1/50kph) = 20,000
 *
 * 1/(speed /(_XTAL_FREQ/4)) = 50
 * Created on August 12, 2013, 8:31 PM
 */

#ifndef SYSTEM_H
#define	SYSTEM_H

#ifdef	__cplusplus
extern "C" {
#endif


#define	_XTAL_FREQ	4000000	/* Crystal frequency in MHz */

#define SW1 	RB0
#define SW2     RB1

// IO config
#define SENSOR          RB6
#define SENSOR_BITMASK  0b01000000
#define MOTOR_A         RB3
#define MOTOR_B         RB2
#define MOTOR_C         RB1
#define MOTOR_D         RB0
#define MOTOR2_A        RA0
#define MOTOR2_B        RA2
#define MOTOR2_C        RA3
#define MOTOR2_D        RA6
#define LED_RED         RA1
#define BUTTON          RB5


const unsigned char motor1_state_map[] = {
          0b00001000
        , 0b00000010
        , 0b00000100
        , 0b00000001};

// State  D C B A
// 0      1 0 0 1
// 1      0 0 0 1
// 2      0 1 1 1
// 3      0 1 1 0
// 4      1 1 1 0
// 5      1 0 0 0

const unsigned char motor2_state_map[] = {
          0b01000001
        , 0b00000001
        , 0b00001101
        , 0b00001100
        , 0b01001100
        , 0b01000000};

union timer
{
   unsigned int lt;
   char bt[2];
};

#ifdef	__cplusplus
}
#endif

#endif	/* SYSTEM_H */
 

Today I also bought some smaller tires, R888 245/45/16, clearance is touch and go with the flares, fingers crossed. 

9 people like this

Share this post


Link to post
Share on other sites

My tacho is working ZOMG!

 

ProZac sent me a spare stepper motor and I happened to be off sick yesterday when the courier arrived so I spent the next three hours stripping the guts out of the tacho and replacing it with the stepper and the worlds simplest circuit board. I wrote a simple little program and she's a good un. 

 

Finally!

 

IMAG0298.jpg

7 people like this

Share this post


Link to post
Share on other sites
I've been researching a new axle conversion, and have been collecting some parts. I've heard of people using these axles but not this combination before. This is where I'm at:

 

IMG_20160109_142913%201.jpg

 

On the right is the stock 240z axle with the twisted Wolf Creek R180 side axles. And on the left is the 4 cylinder D21 axle with factory inner CV and a VX Holden Commodore outer CV. The side axle is from an S14 I think and plugs straight into my R180 diff. 

 

If I measure the length from the side axle circlip groove to the outer face of the CV/UJ flange the stock axle is 489mm and the Terrano one is 458mm which means I have 31mm to play with without being any worse off. I had no binding issues in the past - i think, guys running R200 diffs might struggle thou.

 

The Commodore CV is a knock off of a 108mm Porsche 930 CV, and they use it on the big heavy V8s so it must be solid.

 

So now all I need to do is mate the Commodore CV to the 240z companion flange. There're two options:

 

These adapters which are a measly $92USD 

 

650-086-900x900.jpg

 

Or these replacement companion flanges which are a whopping $700USD

 

800-601-900x900.jpg

 

I'm trying to do this on the cheap so I'm going to order the adapters. I have the 240z 25-spline stub axles anyhow so the companion flange wont work, but if in future I upgrade to the 280z stub axles then it's an option.

 

If this works out I've managed to convert to CVs for really cheaps:

 

D21 Axles: $200

Commodore CVs: $60

Adapters: $200-ish

 

YAY

8 people like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now