I trying to drive Motors with this code below.
And it not work. The motor not run.
I have to put a break point in -- 1 -- to 'see' my motor running and in -- 2 -- it did not run in the other other way.
I want to drive my motor dynamiclly so Sorties->distance[0] will be modified before the motor have reach the counter value.
Is it necessary to wait (Sleep) after each assignment.
thanks
Code: Alles auswählen
volatile IF08_TRANSFER *Adresse_Base;
volatile TA_OUTPUT *Sorties;
volatile TA_CONFIG *Config;
volatile TA_INPUT *Entrees;
INT16 Cpt;
Adresse_Base = GetIF08TransferAddress (Handle_Interface);
Sorties = &Adresse_Base->ftxTransferArea->output;
Config = &Adresse_Base->ftxTransferArea->config;
Entrees = &Adresse_Base->ftxTransferArea->input;
Config->motor[1] = true;
Cpt = Entrees->counter[0] + 100;
Sorties->distance[0] = Cpt;
Sorties->duty[1] = 0;
Sorties->duty[0] = 512;
Sleep (100);
do {
} while( Entrees->counter[0] != Cpt ); /// -- 1 --
Sleep (100);
Cpt = Entrees->counter[0] + 200;
Sorties->distance[0] = Cpt;
Sorties->duty[0] = 0;
Sorties->duty[1] = 512;
Sleep (100);
do {
} while( Entrees->counter[0] != Cpt );/// -- 2 --
vi_Retour = ftxStopTransferArea(Handle_Interface);
vi_Retour = ftxCloseDevice(Handle_Interface);
vi_Retour = ftxCloseLib();