Apertura bocchette aspirazione

If you have a question about the software please ask it here.

Apertura bocchette aspirazione

Postby Cosimo83 » Wed Jan 23, 2019 8:18 pm

Ciao. Ho bisogno di aiuto in una "macroloop" . Devo attivare 4 relè in base alla posizione della X .

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);
}
Cosimo83
 
Posts: 29
Joined: Wed Nov 14, 2018 8:22 pm

Re: Apertura bocchette aspirazione

Postby Robertspark » Wed Jan 23, 2019 8:44 pm

Cosimo83 wrote:
Hello. I need help in a "macroloop". I have to activate 4 relays based on the position of the X.

Example:
If X is between 0 and 800, activate relay 1 and switch off relay 2 3 4
If X is between 800 and 1600 it activates relay 2 and turns off relay 1 3 4
If X is between 1600 and 2400, activate relay 3 and switch off relay 1 2 4
If X is between 2400 and 3200 it activates relay 4 and turns off relay 1 2 3

Thanks in advance for the help

I wrote this code but it does not go


This code will work....
Questo codice funzionerà ....

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();

while(loop)
{

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);
}
Thread.Sleep(50);
}


BUT.... your code appears to have several problems..... (in my opinion)
MA .... il tuo codice sembra avere diversi problemi ..... (secondo me)

1) The UCCNC motion controllers do not have port 2 with pins # 20, 21, 22 & 23......
I motion controller UCCNC non hanno la porta 2 con i pin # 20, 21, 22 e 23 ......

2) your macro loop will check the X machine position EVERY LOOP and set the relays EVERY LOOP and "WAIT 1 second" EVERY LOOP....
You may want to consider changing the code so that it does a quick check and providing the flag is set it just ignores the setting of the relays and the wait every loop

il tuo ciclo macro controllerà la posizione della macchina X OGNI LOOP e imposterà i relè OGNI LOOP e "ATTENDERÀ 1 secondo" OGNI LOOP ....
Si consiglia di prendere in considerazione la possibilità di cambiare il codice in modo che esegua un controllo rapido e, impostando il flag, ignori semplicemente l'impostazione dei relè e l'attesa di ogni ciclo
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Apertura bocchette aspirazione

Postby Robertspark » Wed Jan 23, 2019 8:55 pm

This code may work better for you..... you will still need to change the port 2 pin references to something in the range of 1-17 (and only use the output pins...)
Questo codice potrebbe funzionare meglio per te ..... dovrai comunque cambiare i riferimenti dei pin della porta 2 a qualcosa nell'intervallo 1-17 (e usare solo i pin di uscita ...)

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;
int intFLAG =0;


double XMachPos = exec.GetXmachpos();

while(loop)
{

if(XMachPos >0 && XMachPos <800)
{
    if (intFLAG == 2)
    {
    exec.Setoutpin(PortRele1, PinRele1);
    exec.Clroutpin(PortRele2, PinRele2);
    exec.Clroutpin(PortRele3, PinRele3);
    exec.Clroutpin(PortRele4, PinRele4);
    intFLAG = 2;
    }
}

if( XMachPos >800 && XMachPos <1600)
{
    if (intFLAG == 3)
    {
    exec.Clroutpin(PortRele1, PinRele1);
    exec.Setoutpin(PortRele2, PinRele2);
    exec.Clroutpin(PortRele3, PinRele3);
    exec.Clroutpin(PortRele4, PinRele4);
    intFLAG = 3;
    }
}

if( XMachPos >1600 && XMachPos <2400)
{
    if (intFLAG == 4)
    {
    exec.Clroutpin(PortRele1, PinRele1);
    exec.Clroutpin(PortRele2, PinRele2);
    exec.Setoutpin(PortRele3, PinRele3);
    exec.Clroutpin(PortRele4, PinRele4);
    intFLAG = 4;
    }
}

if( XMachPos >2400 && XMachPos <3200)
{
    if (intFLAG == 5)
    {
    exec.Clroutpin(PortRele1, PinRele1);
    exec.Clroutpin(PortRele2, PinRele2);
    exec.Clroutpin(PortRele3, PinRele3);
    exec.Setoutpin(PortRele4, PinRele4);
     intFLAG = 5;
    }
}
      Thread.Sleep(50);
}
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Apertura bocchette aspirazione

Postby Robertspark » Wed Jan 23, 2019 9:00 pm

Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Apertura bocchette aspirazione

Postby Cosimo83 » Wed Jan 23, 2019 9:09 pm

Grazie....

Io uso una scheda madre UC300ETH 5441 ..... I pin sono diversi :D :D ....

Ma con la funzione flag non va....
Cosimo83
 
Posts: 29
Joined: Wed Nov 14, 2018 8:22 pm

Re: Apertura bocchette aspirazione

Postby Robertspark » Wed Jan 23, 2019 10:48 pm

This one works fine.... I've tested it.

Questo funziona bene .... l'ho provato

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;
int intFLAG =0;


double XMachPos = 0;

while(loop)
{

XMachPos = exec.GetXmachpos();

if(XMachPos >= 0 && XMachPos < 800)
{
    if (intFLAG == 2)
    {}
    else
    {
    exec.Setoutpin(PortRele1, PinRele1);
    exec.Clroutpin(PortRele2, PinRele2);
    exec.Clroutpin(PortRele3, PinRele3);
    exec.Clroutpin(PortRele4, PinRele4);
    intFLAG = 2;
    }
}

if( XMachPos >= 800 && XMachPos < 1600)
{
    if (intFLAG == 3)
    {}
    else
    {
    exec.Clroutpin(PortRele1, PinRele1);
    exec.Setoutpin(PortRele2, PinRele2);
    exec.Clroutpin(PortRele3, PinRele3);
    exec.Clroutpin(PortRele4, PinRele4);
    intFLAG = 3;
    }
}

if( XMachPos >= 1600 && XMachPos < 2400)
{
    if (intFLAG == 4)
    {}
    else
    {
    exec.Clroutpin(PortRele1, PinRele1);
    exec.Clroutpin(PortRele2, PinRele2);
    exec.Setoutpin(PortRele3, PinRele3);
    exec.Clroutpin(PortRele4, PinRele4);
    intFLAG = 4;
    }
}

if( XMachPos >= 2400 && XMachPos < 3200)
{
    if (intFLAG == 5)
    {}
    else
    {
    exec.Clroutpin(PortRele1, PinRele1);
    exec.Clroutpin(PortRele2, PinRele2);
    exec.Clroutpin(PortRele3, PinRele3);
    exec.Setoutpin(PortRele4, PinRele4);
     intFLAG = 5;
    }
}
      Thread.Sleep(50);
}
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Apertura bocchette aspirazione

Postby Cosimo83 » Thu Jan 24, 2019 8:26 pm

Grazie !!! Funziona molto bene.

Complimenti per la tua bravura e disponibilità ...

Appena pronto posterò il video di come funziona ;) ;) ;)
Cosimo83
 
Posts: 29
Joined: Wed Nov 14, 2018 8:22 pm

Re: Apertura bocchette aspirazione

Postby Robertspark » Thu Jan 24, 2019 8:39 pm

felice di aiutare

.... grazie a google translate .... :D :D
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm


Return to Ask a question from support here

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 30 guests

cron