Author Topic: Filtering AC wave into DC (schmitt triggering?)  (Read 2747 times)

0 Members and 1 Guest are viewing this topic.

Offline expertmaxTopic starter

  • Regular Contributor
  • *
  • Posts: 51
Filtering AC wave into DC (schmitt triggering?)
« on: September 16, 2013, 06:53:17 pm »
Hi !

I'm designing my own little car ECU from a ATMEGA32.

Right now all my outputs are designed and perfectly working (Fuel injectors and ignition coils).

I have a crank sensor and a cam sensor who each produces an AC field (with voltage rising when RPM is rising too).

The cam sensor has one tooth which is the timing reference. But for the crank sensor, I must convert this AC signal into DC signal with the same duty cycle (around 25%).

This is an example :



This is the image from the car service manual :



I have absolutely no idea how to achieve this since I'm more a programmer than a designer.

Thanks a million !

Max.
 

Offline olsenn

  • Frequent Contributor
  • **
  • Posts: 993
Re: Filtering AC wave into DC (schmitt triggering?)
« Reply #1 on: September 16, 2013, 07:01:13 pm »
When the sine wave goes above a certain voltage/amplitude, the output goes to and stays at that voltage, and when the input (sine wave) goes back below that value, the output drops back to zero. Look into comparators.

If the position the input had to go to for the output to go high was larger than what it had to fall below in order to bring the output back to zero, then it would be a shmitt trigger.
 

Offline expertmaxTopic starter

  • Regular Contributor
  • *
  • Posts: 51
Re: Filtering AC wave into DC (schmitt triggering?)
« Reply #2 on: September 16, 2013, 07:23:19 pm »
The issue is : the faster the engine spins, the higher the voltage goes. So my duty cycle will change if I use a comparator.

EDIT: To clarify my situation, I will include screenshots from Altium Designer and my C code for my AVR.



Code: [Select]
// 4cyl-fi-ecu.c
// Created by: Maxime Clermont

// Define
#define CKP INT0
#define CMP INT1
#define MAP PORTA0
#define TPS PORTA1
#define ECT PORTA2

#define INJ1 PORTC0
#define INJ2 PORTC1
#define INJ3 PORTC2
#define INJ4 PORTC3
#define COIL1 PORTC4
#define COIL2 PORTC5

#define F_CPU 16000000UL // 16Mhz

// Include
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

// Variables
int cylinder = 10; //

// Prototypes
int getMAPValue(void);
int getTPSValue(void);
int getETCValue(void);

void cycle(void);
void sendSpark(int coil);
void sendFuel(int injector);

// Main
int main(void)
{
DDRC |= (1 << INJ1) | (1 << INJ2) | (1 << INJ3) | (1 << INJ4) | (1 << COIL1) | (1 << COIL2);
MCUCR |= (1 << ISC01) | (1 << ISC00) | (1 << ISC11) | (1 << ISC10);
GICR |= (1 << INT0) | (1 << INT1);

sei();

    while(1)
    {

    }
}

ISR(INT0_vect) // CKP
{
cylinder++;
cycle();
_delay_ms(100); //debug
}

ISR(INT1_vect) // CMP
{
cylinder = 0;
}

void cycle()
{
if(cylinder == 1)
{
sendFuel(INJ1);
sendSpark(COIL1);
}
if(cylinder == 2)
{
sendFuel(INJ3);
sendSpark(COIL2);
}
if(cylinder == 3)
{
sendFuel(INJ4);
sendSpark(COIL1);
}
if(cylinder == 4)
{
sendFuel(INJ2);
sendSpark(COIL2);
}
}

void sendSpark(int coil)
{
PORTC |= (1 << coil);
_delay_ms(100); //debug
PORTC &= ~(1 << coil);
}

void sendFuel(int injector)
{
PORTC |= (1 << injector);
_delay_ms(100); //debug
PORTC &= ~(1 << injector);
}
« Last Edit: September 16, 2013, 07:29:28 pm by expertmax »
 

Offline olsenn

  • Frequent Contributor
  • **
  • Posts: 993
Re: Filtering AC wave into DC (schmitt triggering?)
« Reply #3 on: September 16, 2013, 07:41:59 pm »
This is going to be an obscure suggestion, and I admit that I am not exactly thinking about the problem at the moment; however, would you perhaps be able to use either a resistor divider on a peak-detector to bias a comparator at a certain percentage of the peak voltage, or b) feed a frequency-detection circuit into a 555 timer (or even your AVR) to create a square wave with a fixed duty-cycle at the appropriate frequency?
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11634
  • Country: my
  • reassessing directives...
Re: Filtering AC wave into DC (schmitt triggering?)
« Reply #4 on: September 16, 2013, 08:12:14 pm »
its been a while, so... biased peak detector as olsen said...
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline expertmaxTopic starter

  • Regular Contributor
  • *
  • Posts: 51
Re: Filtering AC wave into DC (schmitt triggering?)
« Reply #5 on: September 21, 2013, 02:54:36 am »
Allright, will take a look at comparators. If I put a schottky diode it will remove the negative portion of the signal while keeping the voltage relatively the same... then feed this signal thru the peak detector circuit using a comparator, it should work !
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf