Steppermotor homing?

Toutes les questions sur les cartes By arpschuino
Questions about arpschuino boards
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

Well, it sort of works.
The code stops and tries to move the motor until the home switch is activated. But the motor barely moves.
It stutters a lot, but mostly stays in one place.
I tried entering various motor speeds, but that didn't make a lot of difference.

Could it be that it has something to do with the timing?
I also tried adding a delay of 2 and 15 after "m_stepper.continuous()", but that also didn't work.
Modifié en dernier par Micropuller le mer. 18 janv. 2023 01:32, modifié 1 fois.
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

I think it was a timing issue.
Could it be that it has to do with this? (from the stepperdriver manual):
(1) ENA must be ahead of DIR by at least 5μs. Usually, ENA+ and ENA- are NC (not connected).
(2) DIR must be ahead of PUL effective edge by at least 5μs to ensure correct direction
(3) Pulse width not less than 1.5μs
(4) low level width not less than 1.5μs
I added a delay in the while loop (obviously a delay in milliseconds was way too long) and now the motor runs smooth.

Code : Tout sélectionner

Serial.println("Homing ...");

    uint8_t zeroSwitch[4]{Arp8,Arp9,Arp10,Arp11};

    for (int i=0; i < 4; ++i) 
    {           
	pinMode(zeroSwitch[i], INPUT_PULLUP);
        m_stepper[0].refresh(255, 30);//we define a direction of rotation (255, to go in the other direction : 0), and a speed (here 30 for a slow speed) 
        if (m_stp_active[i]==true && m_action[i]==0) //m_action[i]==0 mean perform mode
        {
            while (digitalRead(zeroSwitch[i]))//as long as the limit switch is not pressed ((! zeroSwitch) reverses the behavior) 
            {
                m_stepper[i].continuous();//turn !  
                delayMicroseconds(15);              
            }                    
        }
    }
    Serial.println("end of homing!");
    
Modifié en dernier par Micropuller le mer. 18 janv. 2023 01:34, modifié 1 fois.
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

Just out of curiosity; I was watching the serial monitor, when I noticed this.
stepper 0 steps per revolution : 400; rpmmin : 50; max : 500; revolutions : 27.00; action : perform; DMX resolution : 8bits
m_RPM_min : 50
m_motor_speed_min : 3000
m_motor_speed_max : 300
Are these values correct?
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

I found one little mistake.
I connected a second motor, to check if everything was working correctly.
Only the first motor was homing, but I had to activate the home switch of the second motor to be able to control the motors.
I had to change

Code : Tout sélectionner

m_stepper[0].refresh(255, 50);
to

Code : Tout sélectionner

m_stepper[i].refresh(255, 50);
So here's the working code for homing:

Code : Tout sélectionner

Serial.println("Homing ...");

    uint8_t zeroSwitch[4]{Arp8,Arp9,Arp10,Arp11};

    for (int i=0; i < 4; ++i) 
    {           
	pinMode(zeroSwitch[i], INPUT_PULLUP);
        m_stepper[i].refresh(255, 50);//we define a direction of rotation (255, to go in the other direction : 0), and a speed (here 30 for a slow speed) 
        if (m_stp_active[i]==true && m_action[i]==0) //m_action[i]==0 mean perform mode
        {
            while (digitalRead(zeroSwitch[i]))//as long as the limit switch is not pressed ((! zeroSwitch) reverses the behavior) 
            {
                m_stepper[i].continuous();//turn !  
                delayMicroseconds(15);              
            }                    
        }
    }
    Serial.println("end of homing!");
    
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

Jacques
Messages : 267
Enregistré le : dim. 31 oct. 2021 19:37

Re: Steppermotor homing?

Message par Jacques »

Well done Cyril !
m_stepper[0] was a mistake!
A 3us delay should be enough.
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

It's been a while since I visited the forum and also since I've used the Arpschuino. Although I have been wanting to try out the new code for some time, as it looked really promising. Today I finally had some time to update the board and put together a setup for testing. It took some experimenting, but in the end I got it to work perfectly! Even updating the board using the update button, which in the past had never worked for me, and accessing the configuration page on both of my computers and my phone. I don't know what you changed, but it's a 100% upgrade!
And also the new steppermotor features (end switches, homing at startup, accelleration and auto-calibration) work flawlessly. I can't express enough how impressed I am with what you have accomplished in the past year!
I hope to be able to implement the Arpschuimo in a project in the near future, as it does the same and more as every other solution I have used in the past.
Again: my congratulations and thank you for the great work!
Jacques
Messages : 267
Enregistré le : dim. 31 oct. 2021 19:37

Re: Steppermotor homing?

Message par Jacques »

Thank you Micropuller,
This is a very pleasing message!
During this year 2023, development was very focused on motors of all types and switches.
New features, improvements and optimizations are in progress or planned. We view the arpschuino32 firmware as a work in progress and try to continually improve it.
Messages like this encourage and motivate us a lot, thank you.
Répondre