Filtering AC wave into DC (schmitt triggering?) - Page 1
Forum section: electronics / beginners

author: expertmax
author_rank: Regular Contributor
timestamp: September 16, 2013, 06:53:17 pm
content: 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.

author: olsenn
author_rank: Frequent Contributor
timestamp: September 16, 2013, 07:01:13 pm
content: 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.

author: expertmax
author_rank: Regular Contributor
timestamp: September 16, 2013, 07:23:19 pm
content: 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:// 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>// Variablesint cylinder = 10; //// Prototypesint getMAPValue(void);int getTPSValue(void);int getETCValue(void);void cycle(void);void sendSpark(int coil);void sendFuel(int injector);// Mainint 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); //debugPORTC &= ~(1 << coil);}void sendFuel(int injector){PORTC |= (1 << injector);_delay_ms(100); //debugPORTC &= ~(1 << injector);}

author: olsenn
author_rank: Frequent Contributor
timestamp: September 16, 2013, 07:41:59 pm
content: 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?

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 16, 2013, 08:12:14 pm
content: its been a while, so... biased peak detector as olsen said...

author: expertmax
author_rank: Regular Contributor
timestamp: September 21, 2013, 02:54:36 am
content: 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 !