Buonasera a tutti, mi sto imbattendo in alcuni problemi che non riesco a risolvere, premetto che sono alle primissime armi e quindi mi sto solo dilettando in alcune prove.
Sto cercando di gestire un motore nema17, (microstepping) con una scheda cnc, driver drv8825. Per intendersi il kit delle stampanti 3d. Diciamo che solo il motore riesco a pilotarlo decentemente, sia senza libreria che con la accelerstepper però da quando ho messo insieme tutto con l'lcd, è diventato ingestibile, gira ma si scalda e appena cambio qualcosa, smette di girare. Siccome capisco e penso di non essere in grado di porre nemmeno la domanda in modo esaustivo, chiedetemi di cosa avete bisogno per potermi aiutare e vi risponderò. Grazie mille a tutti e scusate la poca chiarezza.
- Schema di collegamento
- Tipo e modello del motore
- Sketch
- Foto ed eventuali
Il motore è un nema17 17HD48002H-22B.
Per quanto riguarda lo schema, lo stavo facendo su fritzing ma ancora lo devo finire, poi posterò quello. Comunque ho attaccato l’lcd direttamente sull’arduino UNO e ho collegato l’lcd alla scheda cnc (i 6 pin dell’alimentazione, poi il pin A5 lo uso come enable della cnc e i piedini 3 e 2 per step e dir), alla cnc è collegato il driver drv8825 e appunto il motore. La cnc è alimentata da una 12volt.
#include <LiquidCrystal.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // select the pins used on the LCD panel
AccelStepper motore(1, 2, 3);
MultiStepper steppers;
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 10
#define btnUP 11
#define btnDOWN 12
#define btnLEFT 13
#define btnSELECT 14
#define btnNONE 15
#define enablePin A5
long interval = 500;
long interval2 = 40;
unsigned long curMillis;
unsigned long prevStepMillis = 0;
unsigned long millisBetweenSteps = 1; // milliseconds
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
// We make this the 1st option for speed reasons since it will be the most likely result
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
return btnNONE; // when all others fail, return this.
}
void setup(){
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
motore.setMaxSpeed(200);
Serial.begin(9600);
Serial.println("Starting StepperTest");
steppers.addStepper(motore);
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("Push the buttons"); // print a simple message on the LCD
}
void loop(){
steppers.moveTo(100);
steppers.runSpeedToPosition();
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
//lcd.print(millis()/1000); // display seconds elapsed since power-up
lcd.print("Fabio");
lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons
checkButton(lcd_key);
delay(1000);
}
void checkButton( int lcd_key)
{
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:{ // push button "RIGHT" and show the word on the screen
lcd.print("RIGHT ");
break;
}
case btnLEFT:{
lcd.print("LEFT "); // push button "LEFT" and show the word on the screen
break;
}
case btnUP:{
lcd.print("UP "); // push button "UP" and show the word on the screen
break;
}
case btnDOWN:{
lcd.print("DOWN "); // push button "DOWN" and show the word on the screen
break;
}
case btnSELECT:{
lcd.print("SELECT"); // push button "SELECT" and show the word on the screen
break;
}
case btnNONE:{
lcd.print("NONE "); // No action will show "None" on the screen
break;
}
}
}
Il problema è che non gira, sento che parte ma non gira, scalda un sacco inoltre. Ho già provato a regolare la vite.
grazie mille
in effetti avevo in mente tutto uno schema diverso che non ti starò a dire perché è assurdo comunque adesso ho collegato l’enable all’1, lo step al 2 e la direzione al 3. Continua a fare il rumorino il motore ma non fa assolutamente niente di quello che sta nel codice.
Grazie e se passi da pisa comunque ti offrirò un bicchiere di vino
AccelStepper motore(1, 2, 3);
A me mi sembra dalla foto che li hai collegati ai pin 2,3,4. Il pin 1 non puoi usare perché lo usa la seriale. Il pin 4 lo usi col display.
Ciao Uwe
Quell’ “1” dell’AccelStepper indica solo che viene gestito da un driver, come indicato nella foto allegata. Il pin 1 che utilizzo è per l’enable, che gestisco via software tenendolo sempre a LOW essendo attivo basso. Più tardi magari sposto l’enable dal pin 1 al pin 11 ma sono scettico, ho fatto tutte le prove possibili, non so più che fare.
Ah, ma tu hai questa shield
Comunque non puoi usare il pin1 se usi la seriale e nello sketch tu la usi
Non sapevo nemmeno del pin 1, in ogni caso ho attaccato l'enable al pin 11, invece del pin 1, quindi accanto al 3. Ma non cambia niente.
brunello22:
Ah, ma tu hai questa shield
sìsì seguivo questo schema comunque
Ho capito il problema, il motore impazziva con delay e "lcd che fa cose" quindi riprogrammando tutto usando la funzione millis() funziona bene, era proprio un errore sulla gestione di entrambi i componenti, grazie comunque a tutti