Photo of MegaMoto Plus H-bridge for Arduino Model: LC-80 by Progressive Automations

Časť I: Ako monitorovať spätnú väzbu lineárneho aktuátora?

Anna Sapiga
Anna Sapiga
PA Engineer

V dnešnom návode si ukážeme, ako zistiť, akú silu lineárny aktuátor vyvíja, monitorovaním množstva prúdu, ktorý spotrebúva. Pôjde o jeden z našich pokročilejších návodov a bude vyžadovať zložitejšie kódovanie, kalibráciu a programovanie. Budeme sa venovať monitorovaniu analógového vstupu a tomu, ako využíva svoje funkcie. Pre tento projekt použijeme MegaMoto Plus, lineárny aktuátor (používame náš PA-14 mini aktuátor), Arduino Uno a napájací zdroj s napätím aspoň 12 V.

Photo of PA-14 mini actuator, an Arduino Uno and a power supply

Na začiatok je potrebné všetko prepojiť zapojením vodičov. Začnite zasunutím MegaMoto do Arduina – jednoducho položte MegaMoto na Uno. Potom pripojte vodič z vývodu BAT+ na MegaMoto na pin Vin na Uno.

Photo of MegaMoto Plus H-bridge for Arduino Model: LC-80 by Progressive Automations


Teraz musíme pripojiť vodiče lineárnych aktuátorov na svorky A a B na MegaMoto a pripojiť 12 V zdroj k BAT+ a GND k BAT-. Taktiež je potrebné zapojiť dve tlačidlá na ovládanie – každé medzi nepoužitý pin a GND. Odporúčame umiestniť tlačidlá na breadboard.

Photo of the linear actuators wires connecting to the A and B terminals on the MegaMoto and connect the 12V power source to BAT+ and GND to BAT


Teraz je čas trochu programovať s Arduino Uno. Chceme naprogramovať tlačidlá tak, aby vedeli ovládať, kedy sa aktuátor bude vysúvať a zasúvať. Prúd sa začne monitorovať, keď sa aktuátor začne vysúvať, čo nám umožní sledovať, či neprekročí maximálny limit prúdu. Ak limit prekročí, aktuátor sa automaticky zastaví, až kým sa nerozhodnete ho zasunúť. Keďže motory v aktuátoroch majú pri prvom zapnutí veľkú prúdovú špičku, kód bude mať krátke oneskorenie pred začiatkom monitorovania prúdu. Tento kód tiež rozpozná, keď aktuátor dosiahne svoje koncové spínače – čo nastane vtedy, keď prúd klesne na 0.

const int EnablePin = 8;
const int PWMPinA = 11;
const int PWMPinB = 3; // pins for Megamoto
const int buttonLeft = 4;
const int buttonRight = 5;//buttons to move the motor
const int CPin1 = A5; // motor feedback

int leftlatch = LOW;
int rightlatch = LOW;//motor latches (used for code logic)
int hitLimits = 0;//start at 0
int hitLimitsmax = 10;//values to know if travel limits were reached
longlastfeedbacktime = 0; // must be long, else it overflows
int firstfeedbacktimedelay = 750; //first delay to ignore current spik
int feedbacktimedelay = 50; //delay between feedback cycles, how often you want the motor to be checked
currentTimefeedback = 0; // must be long, else it overflows unceTime = 300; //amount to debounce buttons, lower values makes the buttons more sensitivelong lastButtonpress = 0; // timer for debouncing
long currentTimedebounce = 0;
int CRaw = 0; // input value for current readings
int maxAmps = 0; // trip limit
bool dontExtend = false;
bool firstRun = true;
bool fullyRetracted = false;//program logic
void setup()
{
Serial.begin(9600);
pinMode(EnablePin, OUTPUT);
pinMode(PWMPinA, OUTPUT);
pinMode(PWMPinB, OUTPUT);//Set motor outputs
pinMode(buttonLeft, INPUT);
pinMode(buttonRight, INPUT);//buttons
digitalWrite(buttonLeft, HIGH);
digitalWrite(buttonRight, HIGH);//enable internal pullups
pinMode(CPin1, INPUT);//set feedback input
currentTimedebounce = millis();
currentTimefeedback = 0;//Set initial times
maxAmps = 15;// SET MAX CURRENT HERE
}//end setup
void loop()
{
latchButtons();//check buttons, see if we need to move
moveMotor();//check latches, move motor in or out
}//end main loop
void latchButtons()
{
if (digitalRead(buttonLeft)==LOW)//left is forwards
{
currentTimedebounce = millis() - lastButtonpress;// check time since last press
if (currentTimedebounce > debounceTime && dontExtend == false)//once you've tripped dontExtend, ignore all forwards presses
{
leftlatch = !leftlatch;// if motor is moving, stop, if stopped, start movingfirstRun = true;// set firstRun flag to ignore current spike
fullyRetracted = false; // once you move forwards, you are not fully retracted
lastButtonpress = millis();//store time of last button press
return;
}//end if
}//end btnLEFT
if (digitalRead(buttonRight)==LOW)//right is backwards
{
currentTimedebounce = millis() - lastButtonpress;// check time since last press
if (currentTimedebounce > debounceTime)
{
rightlatch = !rightlatch;// if motor is moving, stop, if stopped, start moving
firstRun = true;// set firstRun flag to ignore current spike
lastButtonpress = millis();//store time of last button press
return;
}//end if
}//end btnRIGHT
}//end latchButtons
void moveMotor()
{
if (leftlatch == HIGH) motorForward(255); //speed = 0-255
if (leftlatch == LOW) motorStop();
if (rightlatch == HIGH) motorBack(255); //speed = 0-255
if (rightlatch == LOW) motorStop();
}//end moveMotor
void motorForward(int speeed)
{
while (dontExtend == false && leftlatch == HIGH)
{
digitalWrite(EnablePin, HIGH);
analogWrite(PWMPinA, speeed);
analogWrite(PWMPinB, 0);//move motor
if (firstRun == true) delay(firstfeedbacktimedelay); // bigger delay to ignore current spike
else delay(feedbacktimedelay); //small delay to get to speed
getFeedback();
firstRun = false;
latchButtons();//check buttons again
}//end while
}//end motorForward

void motorBack (int speeed)
{
while (rightlatch == HIGH)
{
digitalWrite(EnablePin, HIGH);
analogWrite(PWMPinA, 0);
analogWrite(PWMPinB, speeed);//move motor
if (firstRun == true) delay(firstfeedbacktimedelay);// bigger delay to ignore current spike
else delay(feedbacktimedelay); //small delay to get to speed
getFeedback();
firstRun = false;
latchButtons();//check buttons again
}//end while
dontExtend = false;//allow motor to extend again, after it has been retracted
}//end motorBack
void motorStop()
{
analogWrite(PWMPinA, 0);
analogWrite(PWMPinB, 0);
digitalWrite(EnablePin, LOW);
firstRun = true;//once the motor has stopped, reenable firstRun to account for startup current spikes
}//end stopMotor

void getFeedback()
{
CRaw = analogRead(CPin1); // Read current
if (CRaw == 0 && hitLimits < hitLimitsmax) hitLimits = hitLimits + 1;
else hitLimits = 0; // check to see if the motor is at the limits and the current has stopped
if (hitLimits == hitLimitsmax && rightlatch == HIGH)
{
rightlatch = LOW; // stop motor
fullyRetracted = true;
}//end if
else if (hitLimits == hitLimitsmax && leftlatch == HIGH)
{
leftlatch = LOW;//stop motor
hitLimits = 0;
}//end if
if (CRaw > maxAmps)
{
dontExtend = true;
leftlatch = LOW; //stop if feedback is over maximum
}//end if
lastfeedbacktime = millis();//store previous time for receiving feedback
}//end getFeedback


Nový a vylepšený PA-01 mini aktuátor (modernizácia PA-14) je aktuálny model, ktorý ponúkame s množstvom pridaných výhod. Pre porovnanie si pozrite tabuľky nižšie a prejdite na novší model s istotou!

 

PA-01

PA-14

Možnosti dynamického zaťaženia

16, 28, 56, 112, 169, 225 lbs

35, 50, 75, 110, 150 lbs

Najvyššie zaťaženie

225 lbs

150 lbs

Najvyššia rýchlosť

3.54 "/sec

2.00"/sec

Krytie IP

IP65

IP54

Možnosti zdvihu

1" až po 40"

1" až po 40"

Spätná väzba s Hallovým efektom

Voliteľné

Nie

S týmto základným kódom budete úspešne monitorovať spätnú väzbu vášho lineárneho aktuátora. V Časti II sa podrobnejšie pozrieme na to, ako kód funguje a ako si ho upraviť podľa seba. Dúfame, že vám bol tento príspevok užitočný, a zostaňte naladení na časť II v nasledujúcich týždňoch. Ak by ste si chceli objednať niektoré jednotky použité v tomto príklade alebo sa chcete dozvedieť viac o našich produktoch, prosím kontaktujte nás.