Accueil > > > COMMANDE DU PORT PARALLELE & MOTEUR PAS A PAS
COMMANDE DU PORT PARALLELE & MOTEUR PAS A PAS
Information sur la source
Description
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. **VC++ 6.0**
Source
-
- /***************************
- * (c) YESSINE 30/08/2004 *
- ***************************/
-
- //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;
- }
- }
- }
/***************************
* (c) YESSINE 30/08/2004 *
***************************/
//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;
}
}
}
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[WF4] PASSAGE D'ARGUMENTS LITERAL, VISUALBASICVALUE OU LAMBDAVALUE?[WF4] PASSAGE D'ARGUMENTS LITERAL, VISUALBASICVALUE OU LAMBDAVALUE? par JeremyJeanson
Avec la sortie de la RC de Visual Studio 2010, Microsoft a mis un peu les points sur leS i en ce qui concernait le passage d'arguments. Mais nous somme un certain nombre à avoir pris ce changement comme un coup dur. Pour résumer la situation : à la sortie...
Cliquez pour lire la suite de l'article par JeremyJeanson [RIA SERVICES] INCLUDE ET DOMAINDATASOURCE[RIA SERVICES] INCLUDE ET DOMAINDATASOURCE par Audrey
Dans un de mes articles précédents , j'avais parlé des DomainDataSource avec RIA Services dans le cas d'une interface Maître - Détail. Dans le même principe, je vais parler d'une autre manière de mettre en forme ce cas d'interface avec RIA Services. Et po...
Cliquez pour lire la suite de l'article par Audrey ZUNE : VERSION ZUNE SOFTWARE V 4.2 ET LA SOCIALISATIONZUNE : VERSION ZUNE SOFTWARE V 4.2 ET LA SOCIALISATION par ROMELARD Fabrice
Une des nouveautés de la version V 3.0 était l'apparition de l'onglet Social qui ne fonctionnait que si le MarketPlace était activé sur son poste. Cela limitait donc son intérêt, car hors du cadre commercial USA-CANADA, peu de monde trouva...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice PRATIQUE DE SILVERLIGHT PAR ERIC AMBROSIPRATIQUE DE SILVERLIGHT PAR ERIC AMBROSI par MPOWARE
Je viens de finir la lecture du dernier livre d'
Eric Ambrosi
éditions PEARSON
Son livre donne une approche pratique de Silverlight qui sera aussi bien comprise par le développeur que par le designeur.
Tous les aspects du développement RIA sont abor...
Cliquez pour lire la suite de l'article par MPOWARE APPRENDRE à DéVELOPPER POUR LES MOBILES AVEC LA NOUVELLE GéNéRATION .NETAPPRENDRE à DéVELOPPER POUR LES MOBILES AVEC LA NOUVELLE GéNéRATION .NET par odewit
2 déclinaisons de Silverlight et 2 déclinaisons de Mono permettent dorénavant (ou permettront prochainement) de développer des applications .NET mobiles pour les principales plates-formes du marché :
Silverlight pour Symbian, basé sur Silverlight 2...
Cliquez pour lire la suite de l'article par odewit
Forum
RE : INFOS CD-TEXTRE : INFOS CD-TEXT par MisterCode
Cliquez pour lire la suite par MisterCode
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|