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
CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril
Forum
ARBRE BINAIREARBRE BINAIRE par pacotheking
Cliquez pour lire la suite par pacotheking
Logiciels
Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning Academy System (17.1.3.0)ACADEMY SYSTEM (17.1.3.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|