Esempio:
Se X si trova tra 0 e 800 attiva relè 1 e spegne relè 2 3 4
Se X si trova tra 800 e 1600 attiva relè 2 e spegne relè 1 3 4
Se X si trova tra 1600 e 2400 attiva relè 3 e spegne relè 1 2 4
Se X si trova tra 2400 e 3200 attiva relè 4 e spegne relè 1 2 3
Grazie in anticipo per l' aiuto
Io ho scritto questo codice ma non va....
- Code: Select all
int PortRele1 = 2;
int PinRele1 = 20;
int PortRele2 = 2;
int PinRele2 = 21;
int PortRele3 = 2;
int PinRele3 = 22;
int PortRele4 = 2;
int PinRele4 = 23;
double XMachPos = exec.GetXmachpos();
if(XMachPos >0 || XMachPos <800)
{
exec.Setoutpin(PortRele1, PinRele1);
exec.Clroutpin(PortRele2, PinRele2);
exec.Clroutpin(PortRele3, PinRele3);
exec.Clroutpin(PortRele4, PinRele4);
exec.Wait(1000);
}
if( XMachPos >800 || XMachPos <1600)
{
exec.Clroutpin(PortRele1, PinRele1);
exec.Setoutpin(PortRele2, PinRele2);
exec.Clroutpin(PortRele3, PinRele3);
exec.Clroutpin(PortRele4, PinRele4);
exec.Wait(1000);
}
if( XMachPos >1600 || XMachPos <2400)
{
exec.Clroutpin(PortRele1, PinRele1);
exec.Clroutpin(PortRele2, PinRele2);
exec.Setoutpin(PortRele3, PinRele3);
exec.Clroutpin(PortRele4, PinRele4);
exec.Wait(1000);
}
if( XMachPos >2400 || XMachPos <3200)
{
exec.Clroutpin(PortRele1, PinRele1);
exec.Clroutpin(PortRele2, PinRele2);
exec.Clroutpin(PortRele3, PinRele3);
exec.Setoutpin(PortRele4, PinRele4);
exec.Wait(1000);
}