Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 5 months ago.
how to make a cyclinders identification engine ?
Bonjour. Je commencé à programmer avec le microcontrôleur mbed . Je travaille sur un projet réalsation un dispositif de réglage pour les moteurs de groupe électrogènes. Pour commencer, j'ai connecté mon microcontrôleur à mon écran lcd . J'ai ensuite programmé l'affichage de la fréquence sur mon écran lcd. Sur mon oscilloscope, j'ai veillé à garder une tension rectangulaire de 5V. Une fois cette fréquence obtenue, je l'ai convertie en tours/ min, puis j'ai affiché le rapport cyclique de mon signal rectangulaire. J'ai fait une sorte de choix utilisant les boutons poussoirs (de 1 à 6) car mon oteur a 6 cylindres grâce à des condition " if " .Cà c'est la première partie. Elle est terminée. La deuxième partie que j'ai commencer il y a 3 jours consiste à réaliser l'identification des cylindres de mon moteur afin de détecter le type de cylindre, c'est-à-dire l'endroit de chaque cylindre sur mon oscilloscope. Pour faire celà, aparament, je dois ajouter à mon programme, une deuxième entrée et une sortie, sur le cylindre numéro 1, qui est synchrone avec mon rupteur (de type 1-4-3-2 qui représente l'ordre d'affichage de mes impulsions sur mon oscilloscope ). Une fois cette partie faite, je dois afficher un menu pour chaque cylindre. Cependant j'ai beau réfléchir, je n'ai aucune idée de comment réaliser cette deuxième partie. Quelqu'un parmi vous aurait-il fait un projet du même type ? Sinon avez-vous une idée de comment je dois m'y prendre? Je vous joint mon programme et vous remercie d'avance.
how to make a cyclinders identification engine ?
#include "mbed.h"
#include "TextLCD.h"
TextLCD lcd(p15, p14, p17, p18, p19, p20); // rs, e, d4-d7 //déclaration de p15,p16,P17... dans lcd
Ticker tick;
InterruptIn in(p10); // déclaration de p10 dans in
DigitalIn e1(p21);
DigitalIn e2(p22);
DigitalIn e3(p23);
DigitalIn e4(p24);
DigitalIn e5(p25);
DigitalIn e6(p26);
Timer t;
Timer t_on;
Timer t_off;
int t_period = 0; // This is the period between interrupts in microseconds
float t_freq = 0; // <-- Set in an interrupt but read in main. Should be volatile or the compiler could optimise it out.
void flip(); //Renvoie la frequence
int main() {
int trmin;
int dwell=0;
float alpha=0;
float angle1=0;float angle2=0;float angle3=0;float angle4=0;float angle5=0;float angle6=0;
in.mode(PullDown); // Set the pin to Pull Down mode.
in.rise(&flip); //Set up the interrupt for rising edge
t.start(); //start the timer
while (1) {
wait_ms(100);
trmin=(t_freq*4*30)/4;
if (in==1) { // <--- the input that you have created not the pin number.
t_on.start();
t_off.stop();
} else {
t_on.stop();
t_off.start();
alpha=t_on/(t_on+t_off);
dwell=alpha*100;
}
if(e1==1) {
angle1=(dwell*360)/100;
lcd.printf("ac 1cy=%f\r\n",angle1);}
else if(e2==1){
angle2=(dwell*360)/200;
lcd.printf("ac 2cy=%f\r\n",angle2);}
else if(e3==1){
angle3=(dwell*360)/300;
lcd.printf("ac 3cy=%f\r\n",angle3);
break;}
else if(e4==1){
angle4=(dwell*360)/400;
lcd.printf("ac 4cy=%f\r\n",angle4);}
else if(e5==1){
angle5=(dwell*360)/500;
lcd.printf("ac 5cy=%f\r\n",angle5);}
else if(e6==1){
angle6=(dwell*360)/600;
lcd.printf("ac 6cy=%f\r\n",angle6);}
}
}
void flip() {
t_period = t.read_us();
t_freq = (1/(float)t_period)*1000000;
t.reset();
}
Hello. I started programming with the mbed microcontroller. I work on a project réalsation an adjustment device for generators Group engines. For starters, I have connected my microcontroller to my lcd screen. I then programmed the frequency display on my LCD screen. On my oscilloscope, I made sure to keep a rectangular voltage of 5V. Once this frequency obtained, I converted to rev / min, and then I posted my duty cycle square wave. I made a kind of choice using the push buttons (1 through 6) for my otor has 6 cylinders with the condition "if" .ca is the first part. It is closed. The second part I started there three days is to achieve the identification of cylinders of my engine to detect the type of cylinder, that is to say the place of each cylinder on my oscilloscope. For doing that, aparament, I have to add to my program, a second input and an output, the number 1 cylinder, which is synchronous with my switch (type 1-4-3-2 represents the display order my pulse on my oscilloscope). Once this part done, I have to display a menu for each cylinder. But I'm thinking, I have no idea how to achieve this second part. Any of you would he do a similar project? Or do you have an idea of how I should go about it? I attached my program you and thank you in advance.
posted by AGON Juppé 13 May 2015