haaa emc² ben si je l'utilise sur mes autres cnc
mais ici c'est un projet as base d'un controleur autonome qui tient dans l'imprimante avec un ecran 128*64 graphique sur un pic ( schéma et code de arnaud
) un pc ne rentre pas :/ donc je met le code sur une carte sd et la machine execute , et comme j'ai tout pour le faire
pour le code
c'est baser sur le code makerbot servo !
tout tient dans un seul programme , pas de librairie (j'ai d'autre code avec librairie , mais il ne gere pas les entrée stepdir et me font plien d'erreur en compilation :/
l'encodeur est addressé comme suit
#define QUAD_A_PIN 7 //encodeur
#define QUAD_B_PIN 2 //encodeur
et dans void setup
pinMode(QUAD_A_PIN, INPUT);
pinMode(QUAD_B_PIN, INPUT);
et dans les derniere ligne
void read_quadrature_a()
{
// found a low-to-high on channel A
if (digitalRead(QUAD_A_PIN) == HIGH)
{
// check channel B to see which way
if (digitalRead(QUAD_B_PIN) == LOW)
position--;
else
position++;
} // found a high-to-low on channel A
else
{ // check channel B to see which way
if (digitalRead(QUAD_B_PIN) == LOW)
position++;
else
position--;
}
}
void read_quadrature_b()
{
// found a low-to-high on channel A
if (digitalRead(QUAD_B_PIN) == HIGH)
{
// check channel B to see which way
if (digitalRead(QUAD_A_PIN) == LOW)
position++;
else
position--;
} // found a high-to-low on channel A
else
{ // check channel B to see which way
if (digitalRead(QUAD_A_PIN) == LOW)
position--;
else
position++;
}
les sortie sont gérée direct sur le code principal
genre
digitalWrite(MOTOR_RPWM_PIN, LOW);
digitalWrite(MOTOR_LPWM_PIN, LOW);
et
analogWrite(MOTOR_LPWM_PIN, motor_speed);
je pense que je vais devoir refaire un code complet :/