C?est un programme pour commander un moteur pas a pas par excellence, et de commander les différentes entrées & sorties de l?ordinateur.
C?est le début d?un projet de commande des moteur, je suis entrains de modifier cette source pour une commande absolu même au niveau de transmission de mouvement , calcul vitesse ...
Je mettrais la suite du projet dans qlq jours ,elle contient environs 800 lignes
Je demande votre aide pour continuer ce projet surtout au niveau de lecture &écriture des fichier si par exemple on veut intégrer un tout petit compilateur ,par exemple :
On écrit dans un fichier :
Move 4 //pour avacer 4 pas ou
Move 4deg//pour avancer 4 degrés ou encore
IN ?
La question qui se pose comment lire move et si on trouve le mot move on lit la suite et si tout va bien on avance.
Source / Exemple :
/***************************
//FREE SOURCE CODE
/*
THE STEPPER CONTROL 1.0
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <string>
#include <windows.h>
#include <conio.h>
#include <fstream>
using namespace std;
#define pport 0x378;
void move(int tm);
void move_to4(int step_number,int tm);
void move_to44(int step_number,int tm);
//void open_file();
int main(int argc, char* argv[])
{
string command;
int pval;
int stime;
int snbr;
printf("<<<<****>>>> & STEPPER CONTROL 1.0 & <<<<****>>>>\n");
Sleep(500);
printf(" MSDOS MODE \n");
Sleep(1000);
printf(" (c)YESSINE 2004 \n\n");
while(command !="exit")
{
cout<<"-";
cin>>command;
// OUT : X PORT
if ((command=="op")||(command=="OP")||(command=="Op")||(command=="OpenPort")||(command=="openport")||(command=="OPENPORT"))
{
unsigned short port_num;
int port_val;
printf("PORT NUM : ");
cin>>port_num;
printf("VALUE : ");
cin>>port_val;
_outp(port_num, port_val);
}
//HELP
if ((command=="help")||(command=="HELP")||(command=="Help"))
{
int ch ;
cout<<"[COMMAND]"<<endl;
cout<<" [PORT OUT ] [1]"<<endl;
cout<<" [PARALLELE PORT OUT ] [2]"<<endl;
cout<<" [MOVING THE STEPPER1] [3]"<<endl;
cout<<" [MOVING THE STEPPER2] [4]"<<endl;
cout<<" [RETURN ] [5]"<<endl<<endl;
cout<<">";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Syntax : OpenPort(port number ,value)"<<endl;
cout<<" : OPENPORT(port number ,value)"<<endl;
cout<<" : openport(port number ,value)"<<endl;
cout<<" : OP(port number ,value)"<<endl;
cout<<" : Op(port number ,value)"<<endl;
cout<<" : op(port number ,value)"<<endl;
break;
case 2:
cout<<"Syntax : ppo(value)"<<endl;
cout<<" : PPO(value)"<<endl;
cout<<" : Ppo(value)"<<endl;
cout<<" : ParallePortOut(value)"<<endl;
cout<<" : paralle_port_out(value)"<<endl;
break;
case 3:
cout<<"Syntax : move(time_millisecond)"<<endl;
cout<<" : Move(time_millisecond)"<<endl;
cout<<" : MOVE(time_millisecond)"<<endl;
break;
case 4:
cout<<"Syntax : move_to(Step_number,time_millisecond)"<<endl;
cout<<" : Move_To(Step_number,time_millisecond)"<<endl;
cout<<" : MOVE_TO(Step_number,time_millisecond)"<<endl;
break;
case 5:break;
default:break;
}
//open_file();
}
// OUT : PARALLE PORT
if ((command=="ppo")||(command=="PPO")||(command=="Ppo"))
{
printf("OUT NUM [0..1..2..4..8..16..32..64..128]: ");
cin>>pval;
_outp(0x378, pval);
}
// OUT : PARALLELE PORT
if ((command=="ParallePortOut")||(command=="paralle_port_out"))
{
printf("OUT NUM [0..1..2..4..8..16..32..64..128]: ");
cin>>pval;
_outp(0x378, pval);
}
// STOP THE CURRENT ACTION
if ((command=="stop")||(command=="Stop")||(command=="STOP"))
{
_outp(0x378, 0);
printf("STOPPED!");
}
// GET PORT
/*if ((command=="in")||(command=="In")||(command=="IN"))
{
DWORD port_number1[5];
printf("PORT NUM : ");
cin>>port_number1;
cout<<_inp(port_number1);
}*/
// MOVING 4 STEPS
if ((command=="move")||(command=="Move")||(command=="MOVE"))
{
printf("SLEEPING TIME : ");
cin>>stime;
printf("MOVING . . . . .\n");
move(stime);
}
//MOVING X STEPS
if ((command=="move_to")||(command=="Move_TO")||(command=="MOVE_TO"))
{
printf("STEP NUM : ");
cin>>snbr;
printf("SLEEPING TIME : ");
cin>>stime;
printf("MOVING . . . . .\n");
if (snbr<=4)
{
move_to4(snbr , stime);
}
if (snbr>4)
{
move_to4(snbr,stime);
move_to44(snbr , stime);
}
}
}
return 0;
}
//MOVING 4 STEPS
void move_to4(int step_number,int tm)
{
int i;
for(i=1;i<=step_number;i++)
{
switch(i)
{
case 1:
Sleep(tm);
_outp(0x378, 1);
break;
case 2:
Sleep(tm);
_outp(0x378, 2);
break;
case 3:
Sleep(tm);
_outp(0x378, 4);
break;
case 4:
Sleep(tm);
_outp(0x378, 8);
break;
}
}
}
//MOVING STEP-4
void move_to44(int step_number,int tm)
{
int i;
for(i=1;i<=step_number-4;i++)
{
switch(i)
{
case 1:
Sleep(tm);
_outp(0x378, 1);
break;
case 2:
Sleep(tm);
_outp(0x378, 2);
break;
case 3:
Sleep(tm);
_outp(0x378, 4);
break;
case 4:
Sleep(tm);
_outp(0x378, 8);
break;
case 5:
Sleep(tm);
_outp(0x378, 1);
break;
case 6:
Sleep(tm);
_outp(0x378, 2);
break;
case 7:
Sleep(tm);
_outp(0x378, 3);
break;
case 8:
Sleep(tm);
_outp(0x378, 4);
break;
default:printf("MAX SETEPS = 12 !!");
break ;
}
}
}
void move(int tm)
{
int i;
for(i=1;i<=4;i++)
{
switch(i)
{
case 1:
Sleep(tm);
_outp(0x378, 1);
break;
case 2:
Sleep(tm);
_outp(0x378, 2);
break;
case 3:
Sleep(tm);
_outp(0x378, 4);
break;
case 4:
Sleep(tm);
_outp(0x378, 8);
break;
}
}
}
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.