Jump to content
Email-only Log-Ins Coming in December ×

IGNORED

Pricing 240z Rally Clock w/ Fully Functioning Oscillator?


dhp123166

Recommended Posts

5 hours ago, d3c0y said:

Unfortunately I only have one, so that is the only one that has been tested on.

I have several I can test it with to see if there is any variation. All the clocks have been refurbished by Ron @zclocks so are in good shape. So therefore the Oscillator should work consistently with all of them.

Link to comment
Share on other sites


Well done. 

You have done a very neat job.

 

I say that through clenched teeth because we were only about a month away from putting our own oscillator out there!

 

I have been working on this with fellow Z owner Greg Hassen. 

I have a rally clock, but Greg has done most of the testing. He has found some variation between clocks so we have put an adjustment knob on ours. To be honest, I can’t see why there should be any variation; the clock runs off a synchronous motor. I do know that the little plastic gear on the rotor shaft has a crack in one or two clocks Greg has tested, and this could be the cause of the variations. The clock I have also has a crack on the rotor shaft gear as well, in fact it is missing a complete tooth! It occasionally stalls and I expect this could be the cause (though mostly it seems to keep going despite the missing tooth, the momentum of the gears might be enough to keep it going). The pulse duty-cycle also seems to have an effect on the likelihood of stalling (I think around 80% gave the best results on my clock). 

I say all this because the cracked gear seems to be a common problem. If any of your customers has this problem and don’t realise it, they might unjustly blame your circuit. You should probably have them check the gear before selling them your oscillator, or at least inform them that the problem could exist. Greg has been looking at replacement options for the cracked gear. 

I will try to include a photo of my cracked gear. You can use it in your dealings with customers if you like. 

 

I think you have done a very neat job. And having been beaten to it, Greg and I debated whether to continue with our project. 

We think we might (it would be very unsatisfying to just drop it after all the time we have put into it, so watch out, you might have some competition on your hands!), and I think we could probably bring it to market for, say, $98.50 ;-)

And if there isn’t much of a market, or you have already saturated it, then maybe would could collaborate instead of compete (I’ll have to consult with our Global Strategic Business Development Manager: Greg). 

 

Eric

clock cracked gear small.jpg

  • Like 2
Link to comment
Share on other sites

More options for us Rally Clock enthusiasts to have a working time piece is only a good thing in my opinion. I agree that often there is as much wrong with the clocks themselves and it's not just the motors that quit.

As far as I'm aware Ron makes his own replacement motor bearings and gears to deal with these kinds of issues.

Finding any Rally Clock is getting harder now, without or without the oscillator box. So your market may be limited, but... you may be able to use your learnings to create options for the other standard clocks which have a pretty high failure rate also.

Link to comment
Share on other sites

14 hours ago, Gav240z said:

 you may be able to use your learnings to create options for the other standard clocks which have a pretty high failure rate also.

Eric has already done a writeup on fixing other clocks 6 years ago. You've probably seen it before but just forgotten.

I believe the earlier jeco 280z clock and the calendar clock share the same circuit board thats in this tutorial. I've

never had one of the earlier 280z jeco's apart to verify. Anyone have a donor?

I should probably put a warning label on soldering the new capacitor in that connects to the tiny wire from the coil. It's VERY fragile and is easy to lift

the pad off the board. If that happens, it's toast. Perhaps a safer way to put the new cap in is to snip off the legs of the old cap and solder on the new cap to the old legs.

 

On the rally clocks, I might add that people have tried to swap the original oscillators between clocks in the past and they couldn't get them to work right

and i've seen this same thing when I used our prototype oscillator on several different clocks. To keep correct time, i had to tweak the pulse or frequency to

find that sweet spot.  My thinking is every clock has its own set of mechanical resistance and wear patterns over time and therefore the pulse and frequency

need to be fine tuned to each clock.  However, I really hope i'm wrong and your oscillator works on every clock.

 

How to fix your 260Z or 280Z clock - rev 1.pdf

Edited by hr369
Link to comment
Share on other sites

I've got a few of the Rally Clocks + Oscillators (not gonna say how many, some will faint!) and I've interchanged the Oscillator between the various clocks and it hasn't made much difference. I have noticed that it can take a few minutes or so for the clock to sync up and start keeping accurate time for 1 of my oscillators and then it's good to go. I also had issues with my test bench which was 12V made up of 8x1.5V AA batteries DC batteries. 1 of the clocks would run slow, but the other was fine. Then when I connected the slow clock to my car it kept perfect time...

So they can be temperamental but that's kind of part of the charm. I kinda of like the fact that they are still somewhat mysterious...I'll look up those other guides you were talking about.

Keep in mind all mine were adjusted and rebuild by Ron so maybe they are more close in operating behavior as a result?

Link to comment
Share on other sites

Eric has mocked up a circuit board that fits inside the clock. It seems to fit well in the location where the little circuit board was.

I've assembled a kit of  3 caps and 1 transistor that are needed to fix a calendar clock and a 280z (non quartz) clock and will be selling them for $10 if anyone is interested. Pic #3 is the very fine coil wire I was referring to that is very easy to damage if you're not careful soldering in the one capacitor.

 

rally clock pcb mock-up.jpg

repair-kit.jpg

IMG_2667 (2).jpg

Edited by hr369
  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Ok, this is our version 2.0. of the oscillator.  Eric is going to send me a copy and I will try it on different clocks to see how accurate it it keeps time.

We have a speed adjustment pot just just like the original oscillator had just in case. Fits nicely in the place where the original smaller circuit board was.

 

 

oscillator running youtube

surface-mount-oscillator.jpg

surface-mount-oscillator2.jpg

surface-mount-oscillator3.jpg

surface-mount-oscillator5.jpg

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Update time. I've received the purple pcb oscillator and installed it. It's way smaller that it looks in the pictures. It took about 20 minutes to solder in the new board and bolt it in.

I will be testing it with my other clocks to see how accurate it is. Right now i've had it running a couple hours and its keeping accurate time.

It has built into it, reverse polarity protection for those of us that are electronically challenged, myself included.

I've ordered a small amount of boards as I don't anticipate many people will need them.

DSCF1963.JPG

 

clock running with new purple oscillator

 

Reverse engineering this clock and running it on 21'st century electronics was no small feat.  Here is some of the C code that Eric wrote for the prototype and resides in the

little IC chip. AWESOME work he does.  

__________________________________________________________________________________________________________________________________________________

 


#include <htc.h>
#include <xc.h>
//#include <float.h>  // do I need this?

#define _XTAL_FREQ 4000000      // Internal Oscillator... for now. Required
                                // for __delay_ms function

/* The configuration bits can be set in the IDE 'Configuration Bits' window,
 * or they can be set here. */

// PIC12F675 Configuration Bit Settings:
/* CONFIG */
#pragma config FOSC = INTRCIO   // Internal oscillator.
#pragma config WDTE = OFF       // Watchdog Timer disabled.
#pragma config PWRTE = OFF      // Power Up timer off.
#pragma config MCLRE = OFF      // MCLR pin disabled, I/O function of GP3.
#pragma config BOREN = OFF      // Brown-out detect off.
#pragma config CP = OFF         // Program memory code protection off.
#pragma config CPD = OFF        // Data memory code protection off.

unsigned int pulse_width_count = 0;     // Used to adjust pulse width.
volatile unsigned int T_pot_setting;    // Most sig 8-bits from pot ADC conversions.
volatile unsigned int F_pot_setting;    // Use all ten bits, so need 16-bit word.
volatile char outputs;          // bit0 for output 0 (GP0), bit1 for output 1 (GP1).

volatile unsigned int analog_reading;   // The 10-bit ADC result.


/********************************* SETTING UP ************************************/
/*********************************************************************************/

void init_ports(void){

//  Set input & output pins: GP2 (AN2) and GP4 (AN3) set as inputs for analog signal,
//  GP3 can only be input.
    TRISIO = 0b00011100;

//  Comparators off.
    CMCONbits.CM = 0b111;

//  Analog input register ANSEL set in setup_ADC() below.
}

////////////////////
void setup_osc(void){

    ;
//  Nothing to do here. The oscillator is set above by setting the FOSC bits.
//  OSCCAL = 0x00;  // Shouldn't be needed.
}

////////////////////////
void setup_timer1(void){

//  Timer1 is 16-bit. It will count to 65535 before overflowing.
//  With a 4MHz internal clock (Fosc), the instruction clock operates at 1MHz:
//  (Fosc/4, so Tcyc = 1usec).
//  With a desired interrupt time of 11.43msec, we have 11430 instruction cycles,
//  which is under the 65535 cycles possible with Timer1. So using Timer1 should be
//  fine!

    T1CONbits.TMR1ON = 1;   // bit 0 = 1: TMR1ON -> turn timer on.
                            // bit 1 = 0: TMR1CS -> Clock source = Fosc/4.
                            // bit 5,6 = 00: T1CKPS -> prescaler = 1:1 - no scaling.
}

/////////////////////
void setup_ADC(void){

//  Pulse_Width is analog input on AN2.
//  Pulse_Frequency is analog input on AN3.
    
//  Set ADCON0 configuration bits:
//  ADFM = 1 : ADC result right justified as we will use all ten bits. Two most
//  sig bits in ADRESH, the eight least sig bits in ADRESL.
//  VCFG = 0 : ADC reference is Vdd pin.. for now.
//  <CHS1:CHS0> = 0b10 (2dec) to select AN2 input, (<CHS1:CHS0> = 0b11 3dec) for
//  AN3 input.
//  ADON = 1 : Turn on the ADC.

    ADCON0bits.ADFM = 1;    //  ADC result right-justified.
    ADCON0bits.CHS = 3;     //  Select AN3 for ADC for first conversion (freq).
    ADCON0bits.ADON = 1;    //  Turn on the ADC.

//  Set ANSEL configuration bits:
//  <ADCS2:ADCS0> = 101 for 4us TAD conversion time (datasheet recommended for 4MHz
//  clock). Analog input on AN2 (GP2) set for pulse time adjustment pot, and AN3
//  (GP4) for frequency adjustment pot.

    ANSELbits.ADCS = 0b101;

}


/**************************** INTERRUPT SERVICE ROUTINE ***************************/


void setup_timer1_interrupt(void){

//  Timer1 is a peripheral, so peripheral interrupts must be enabled
//  (and also global interrupts).

    TMR1IF = 0; // Clear Timer1 Interrupt Flag.
    PIE1 = 1;   // Enable Timer1 Interrupt.
    PEIE = 1;   // Enable Peripheral Interrupts.
    GIE = 1;    // Enable Global Interrupts.

}

void interrupt ISR(void){
//  Interrupt Service Routine

//  This interrupt it called at twice the motor (electrical) frequency.
//  Timer1 has timed out so we must aternate the GP0 and GP1 outputs.
//  The interrupt activates on overflow, so the starting value of the timer
//  must be determined to get the correct timer period. Calculations at end
//  of code.

//  Here we read and manipulate the last ADC result and initiate the next ADC
//  conversion. We will perform ADC on the two analog inputs alternately
//  (one for pulse frequency, and one to control the pulse width)
//  In reversing the pin polarity, the pins themselves are not reversed as they
//  might both be 0 (as the expiration of pulse_width_count will set both outputs
//  to zero). So 'outputs' records the last setting of output pins, and it is
//  'outputs' that is reversed. This is then copied to the GPIO pin register.

    TMR1 = (0xDC00 - F_pot_setting);    // Reset TMR1.
    outputs = outputs^0b00000011 ;      // XOR - reverse outputs for GP0 and GP1.
    GPIO = outputs;                     // Assign 'outputs' to actual output pins.

//  Alternately update the Frequency setting (F_pot_setting) and pulse width
//  (T_pot_setting).
    
    if ((outputs & 0x01) != 0){     // Set pulse width.
        analog_reading = ADRESL + (ADRESH * 256); // Change 10-bit value to 8-bit
        T_pot_setting = (analog_reading >> 2);        // value (max 255).

        ADCON0bits.CHS = 3;         // Change A/D channel to measure Frequency pot
                                    // next time around.
        __delay_us(50);             // Delay after channel swap, avoids cross-talk.
    }
    else{                           // Set pulse frequency.
        analog_reading = ADRESL + (ADRESH *256);
        F_pot_setting = (analog_reading << 1);    // Mult by 2 to scale to 0x7FE.

        ADCON0bits.CHS = 2;         // Change A/D channel to measure pulse width pot
                                    // next time around.
        __delay_us(50);             // Delay after channel swap, avoids cross-talk.
    }

    ADCON0bits.GO_DONE = 1;         // Start next A/D conversion.
    pulse_width_count = 0;          // Reset counter for pulse width.
//    GPIO5 = 1;                      // Turn on LED at GP5 - program running.
    TMR1IF = 0;                     // Reset Timer1 overflow interrupt flag.

    return;
}


/********************************** MAIN PROGRAM **********************************/
/**********************************************************************************/

void main() {

    setup_osc();
    init_ports();
    setup_timer1();
    setup_timer1_interrupt();
    setup_ADC();

    outputs = 0b00000001;       // Initialise output pulses variable with pulse
                                // at GP0.
    GPIO = outputs;             // Write to GPIO register.


    // Turn on LED at output GP5 - program running.

    while(1){
        pulse_width_count++;    //  Delay chosen so that that 255 (0xFF)
        __delay_us(28);         //  increments take up the full 11.4 millsec.
        if (pulse_width_count > T_pot_setting){
            GPIO = GPIO & 0b11111100;   // Turn off outputs.
            GPIO5 = 1;                  // debug - turn on LED
            pulse_width_count = 0;      // Reset so we don't keep coming back.
        }   // if

    } // while
 
} // main

 

/* Determining the Timer1 starting value for interrupt for clock frequency:
 *
 * The clock I tested needs the outputs to be alternated every 11.43 millisec
 * for the clock to operate at about the right speed.
 * The microcontrller clock speed (Fosc) is set to 4MHz in the config parameters
 * at the start of the program. Timer1 increments with each instruction cycle which
 * is equal to Fosc/4 = 1MHz, so it increments at 1 microsec intervals. For 11.43
 * millisec, the clock increments 11430 times. As the timer interrupts at overflow,
 * then the timer must start at 65535 (0xFFFF) minus the 11430.
 * 65535 - 11430 = 54105 (0xD359) approx.
 * The result from the A/D converter is 10-bit, i.e. 0-1023 (0x00 - 0x3FF).
 * This permits an adjustment time of about 1 millisec. If I want an adjustment
 * time of +/- 1 millisec (2 millisec) then I will double the A/D conversion result.
 * So the timer starting point will have to be about 0xD539 + 0x3FF, so that up
 * to 2 * 0x3FF can be subtracted from it. So starting point will be about 0xD938.
 * This is approximate as there will be some latencies in processing the code, etc
 * The final value will be higher and determined experimentally. So we should
 * have a range of about 9.4 millisec to 11.4 millisec with the 'correct'
 * 10.4 millisec setting when the control pot is set to the middle position.
 *
 * Determining pulse width:
 *
 * The output of the pulse width pot is saved as an 8-bit value: 0xFF (255 decimal).
 * At lowest frequency, the pulse width above will be up to 11.4 millisec, so we
 * need the pulse width counter to increment at 45 microsec at a time (45us * 255
 * = 11.5 ms. An added delay of 28 microsec resulted in desired increment delays .
 *
 */

 

 

 

Edited by hr369
  • Like 2
Link to comment
Share on other sites

It’s been a lot of fun working with Greg on this. Though that code is somewhat old and it’s changed a bit. Also, it’s from back when the clock I had to test with had a broken tooth on one of its gears. I then installed Greg’s custom replacement gear and got the clock to work better (so I could take more reliable measurements). As it turns out, that little cylinder in the clock is what I think would be called a 10-pole PMSM (Permanent Magnet Synchronous Motor). I found the frequency it required was much closer to 50Hz with a half-cycle time of 10ms rather than the 44Hz (half-cycle time of 11.4ms) I was using when I wrote the above test code. I also found a duty cycle of about 80% worked well, so I stuck with that and got rid of the adjustment pot.

This might not be of great interest to anyone, but I felt I had to mention the timing errors in that posted code in case anyone wanted to do any tinkering of their own.

 

Eric

Edited by monkeyman
  • Like 2
Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy and Guidelines. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.