General

Welcome!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

Changing from Ardbox to Ardbox Relay

Avatar
Grant

I have the blow working code for an ardbox but would now like to convert it to run on Ardbox relay, I have  tried changing Q0_1 to R1 etc with no success. I also get an A0_6 was not declared in this scope error.


Any helps would be appreciated.



************************************START**********************************

unsigned int eStop; 

unsigned int startCutting;

unsigned int bottomSwitch;

unsigned int mercurySwitch;

unsigned int viceEnagage;

unsigned int viceDisenagage;

unsigned int sawUp;

unsigned int goodClamp;

unsigned int transHomeSw=0;

unsigned int state=0;

unsigned int computerInput=0;


void setup()

{

  Serial.begin(9600);

  //ANALOGUE/DIGITAL INPUTS

  pinMode(I0_9, INPUT); //eStop

  pinMode(I0_8, INPUT); //green start switch

  pinMode(I0_7, INPUT); //bottom switch (saw has completed cut)

  pinMode(I0_6, INPUT); //mercury switch (Saw has reached clearance height)

  pinMode(I0_5, INPUT); //computerInput

  pinMode(I0_4, INPUT); //vice disengage (UNLATCH)

  pinMode(I0_3, INPUT); //vice engaged (Vice is correctly pressurised)(LATCH)

  pinMode(I0_2, INPUT); //goodclamp (HIGH == no pressure)

  pinMode(I0_1, INPUT); //AUTO/MANUAL

  //ANALOGUE OUTPUTS

  pinMode(A0_6, OUTPUT); //toComputer

  pinMode(A0_5, OUTPUT); //?? unused ??

  pinMode(A0_4, OUTPUT); //?? unused ??

  pinMode(A0_3, OUTPUT); //?? unused ??

  pinMode(A0_2, OUTPUT); //?? unused ??

  pinMode(A0_1, OUTPUT); //?? unused ??

  pinMode(A0_0, OUTPUT); //?? unused ??

  //DIGITAL OUTPUTS

  pinMode(Q0_9, OUTPUT); //NOT WORKING

  pinMode(Q0_8, OUTPUT); //NOT WORKING

  pinMode(Q0_7, OUTPUT); //Pneumatic to hydrolic control (LATCHING)

  pinMode(Q0_6, OUTPUT); //NOT WORKING

  pinMode(Q0_5, OUTPUT); //blade on/off

  pinMode(Q0_4, OUTPUT); //coolant on/off

  pinMode(Q0_3, OUTPUT); //hydrolic pressure (Hydralick pump)

  pinMode(Q0_2, OUTPUT); //NOT WORKING

  pinMode(Q0_1, OUTPUT); //NOT WORKING

  pinMode(Q0_0, OUTPUT); //hydralic solinoid (is combined with Q0_3 hydralic pressure to rais saw)

}


void loop()

{

  if (state==0)

  {

    mercurySwitch = digitalRead(I0_6);

    goodClamp = digitalRead(I0_2); //pressure

    viceEnagage = digitalRead(I0_3); //pressure lever

    Serial.println(viceEnagage);

    viceDisenagage = digitalRead(I0_4);

    if (viceEnagage)

    {

      digitalWrite(Q0_7, LOW);

      delay(100);

      digitalWrite(Q0_3, HIGH);

      delay(100);

      digitalWrite(Q0_2, HIGH);


    }

    else

    {

      digitalWrite(Q0_3, LOW);

      digitalWrite(Q0_2, LOW);

    }

    if (viceDisenagage)

    {

      digitalWrite(Q0_7, HIGH);

      delay(100);

    }

    if (mercurySwitch)

    {

      // saw up

      digitalWrite(Q0_3, HIGH);

      digitalWrite(Q0_0, HIGH);

      delay(100);

      digitalWrite(Q0_3, LOW);

    }

    else

    {

      // saw down

      digitalWrite(Q0_0, LOW);

    }

    startCutting = digitalRead(I0_5);

    eStop = digitalRead(I0_9);

    if (startCutting && eStop)

    {

      digitalWrite(Q0_7, LOW);

      delay(200);

      while (goodClamp)

      {

        digitalWrite(Q0_3, HIGH);

        goodClamp = digitalRead(I0_2);

      }

      digitalWrite(Q0_3, LOW);

      digitalWrite(Q0_0, LOW);

      state++;

    }

  }


  else if (state==1)

  {

    // Blade ON

    digitalWrite(Q0_5, HIGH);

    // Coolant

    digitalWrite(Q0_4, HIGH);

    bottomSwitch = digitalRead(I0_7);

    delay(250);

    while (!bottomSwitch)

    {

      viceEnagage = digitalRead(I0_3);

      bottomSwitch = digitalRead(I0_7);

      eStop = digitalRead(I0_9);

      if (!eStop) //! means switch is pushed

      {

        break;

      }

      else if (viceEnagage)

      {

        digitalWrite(A0_3, HIGH);

        delay(100);

        digitalWrite(A0_3, LOW);

      }

    }

    // Blade off

    digitalWrite(Q0_5, LOW);

    // Coolant off

    digitalWrite(Q0_4, LOW);

    digitalWrite(Q0_7, HIGH);

    state=0;

  }


  else if (state==2)

  {

 

  }

}

*****************************************END*****************************************

Avatar
Descartar
1 Respuesta
0
<div> <h5 class="o_wforum_bio_popover_name mb-0"> <address class="mb-0" itemscope="itemscope" itemtype="http://schema.org/Organization"> <div> <span itemprop="name">Andrei Postolache</span> </div> <div itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress"> </div> <div> </div> </address> </h5> <span class="o_wforum_bio_popover_info"> <address class="mb-0" itemscope="itemscope" itemtype="http://schema.org/Organization"> <div class="css_non_editable_mode_hidden"> --<span class="text-muted">Andrei Postolache</span>-- </div> <div itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress"> </div> <div> <div class="css_editable_mode_hidden"> <div class="mb-2"> <br/> </div> <b class="mt-4"><i class="fa fa-diamond text-secondary"></i> 2000000000</b> <div style="display: inline-block"> <b>|</b> <span class="fa fa-trophy badge-gold ml-2" role="img" aria-label="Gold badge" title="Gold badge"></span> 0 <span class="fa fa-trophy badge-silver ml-2" role="img" aria-label="Silver badge" title="Silver badge"></span> 0 <span class="fa fa-trophy badge-bronze ml-2" role="img" aria-label="Bronze badge" title="Bronze badge"></span> 0 </div> <div class="mt-2"> </div> </div> </div> </address> </span> <div class="o_wforum_bio_popover_bio"> <address class="mb-0" itemscope="itemscope" itemtype="http://schema.org/Organization"> <div class="css_non_editable_mode_hidden"> --<span class="text-muted">Andrei Postolache</span>-- </div> <div itemprop="address" itemscope="itemscope" itemtype="http://schema.org/PostalAddress"> </div> <div> <span> </span> </div> </address> </div> </div> </div> "> Avatar
Andrei Postolache
Best Answer

Hello,

First of all to work with relay output you need to declare it like this RX_X. example: R0_1

Second, in your PLC doesn't exist the analog output A0_6, that model just have two analog outputs A0_0, A0_1.


Thank you.

Avatar
Descartar