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

Steppermotor homing?

Message par Micropuller »

I just found this forum today, as I'm looking for a way to control several steppermotors using DMX.
The arpschuino looks very promising, but on reading the tutorials, I haven't been able to find out if there is a way to home the motors.
Can anybody confirm if this is possible or, if not, if this is something that can be added to the code?
Preferably, the motors should start moving towards a home sensor/switch when power is applied and then remember that position as zero.

PS: I think I'm proficient enough with arduino to add code for homing the motors myself, but it would be nice to have it on the arpschuino32 and be able to configure it through the web page (and I'm pretty sure I won't be able to do that).
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

After some more searching, I found this topic: viewtopic.php?t=51
And this topic: viewtopic.php?t=17

I'm not really familiar with Visual Studio and / or Platform I/O, but I have found the Custom_port.cpp tab.
So if I'm correct, I should try to insert something based on the code provided in the second link (but without the function to control the motor using buttons), yes?
Jacques
Messages : 267
Enregistré le : dim. 31 oct. 2021 19:37

Re: Steppermotor homing?

Message par Jacques »

Hello Micropuller and Happy New Year!
Yes you are on the right track.
There are many users who need input, limit switches and homing!
We heard the message, it's in the todo list,
but we have to finish some stuff first.
You'll see that using this software shouldn't be too complicated once you've installed pVScode and platformIO.
Do not hesitate to post your code to us, we will help you if you encounter difficulties.
Avatar du membre
RitoonL
Administrateur du site
Messages : 112
Enregistré le : dim. 31 oct. 2021 10:21

Re: Steppermotor homing?

Message par RitoonL »

Hello,

Happy new year !

Don't worry with VSCode ! once your computer is connected to internet (mandatory with VSCODE), and PlatformIO is installed. PlatformIO will download himself all the files needed for compilation. You don't have to worry about linking. Specific libs are included in Arpschuino32 source code. Open folder, trust the authors and don't be affraid about all the errors, it will be fixed after PlatformIO performed all the downloads.

It may take a (long) while during first compilation, depending of the speed of your internet connexion, VSCODE is not really verbose about that but if it takes really long, it is because VSCODE is downloading, just have a coffee and wait !

Regards,

Eric
Administrateur - Forum arpschuino
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

So, I've been trying to set up homing switches for my arpschuino32 with arpstepper board and my inexperience with Vscode is blatantly showing itself...

I've added some code to Custom_port.cpp:

Code : Tout sélectionner

#include "custom_port.h"
#include <arduino.h>
#include <arpschuino32_core.h>
#include <arpschuino.h>
#include "port.h"

//put here the library you want to use :

extern Port portA;
extern Port portB;

//////////// port A //////////////
void setupA()      //this loop is executed once at startup
{
}

void action_A(const std::vector<uint8_t> & DMXslice)    //this loop is executed at each signal reception
{
}

void at_each_loop_A()   //this loop is executed continuously
{
}

//////////// port B //////////////

uint8_t zeroSwitch0=Arp8;
uint8_t zeroSwitch1=Arp9;
uint8_t zeroSwitch2=Arp10;
uint8_t zeroSwitch3=Arp11;

void setupB()   //this loop is executed once at startup
{   
  pinMode(zeroSwitch0, INPUT_PULLUP);
  pinMode(zeroSwitch1, INPUT_PULLUP);
  pinMode(zeroSwitch2, INPUT_PULLUP);
  pinMode(zeroSwitch3, INPUT_PULLUP);

  stepper0.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) 
  stepper1.refresh(255, 30);
  stepper2.refresh(255, 30);
  stepper3.refresh(255, 30);


  while (digitalRead(zeroSwitch0))//as long as the limit switch is not pressed ((! zeroSwitch) reverses the behavior) 
  {
    stepper0.continuous();//turn !
  }

  while (digitalRead(zeroSwitch1))//as long as the limit switch is not pressed ((! zeroSwitch) reverses the behavior) 
  {
    stepper1.continuous();//turn !
  }

  while (digitalRead(zeroSwitch2))//as long as the limit switch is not pressed ((! zeroSwitch) reverses the behavior) 
  {
    stepper2.continuous();//turn !
  }

  while (digitalRead(zeroSwitch3))//as long as the limit switch is not pressed ((! zeroSwitch) reverses the behavior) 
  {
    stepper3.continuous();//turn !
  }

   portB.setNbDmxChannels(0);//the number of channels used in this port. REQUIRED !
}

void action_B(const std::vector<uint8_t> & DMXslice)  //this loop is executed at each signal reception
{
}

void at_each_loop_B()   //this loop is executed continuously
{
}
But ofcourse, I get the message that the steppers are undefined.
Can I only use set up Port B for the home switches, if I set up Port A in Custom_port.ccp for steppermotors?
Or can I configure the steppermotors in Port A using the normal configuration tool?
If so, how should I define the steppermotors in Custom_port.cpp?
Jacques
Messages : 267
Enregistré le : dim. 31 oct. 2021 19:37

Re: Steppermotor homing?

Message par Jacques »

Hi Cyril,
The problem comes from the fact that the stepper objects are created elsewhere (in the portA object) and are not accessible in custom port. This is not a good approach.
You must create and use stepper objects inside custom port A or B.
The programming is then similar to what we did with the arpschuino2:
http://arpschuino.fr/tuto_stepper_e.php#7
Jacques
Messages : 267
Enregistré le : dim. 31 oct. 2021 19:37

Re: Steppermotor homing?

Message par Jacques »

First create your steppers objects :

Code : Tout sélectionner

ArpStepper stepper0(Arp1,Arp0,800);//800 stp/revol
ArpStepper stepper1(Arp3,Arp2,800);
ArpStepper stepper2(Arp5,Arp4,800);
ArpStepper stepper3(Arp7,Arp6,800);	
In the setup, init your objects :

Code : Tout sélectionner

    //(RPM_min(>0), RPM_max , revolutions, resolution(default 255))				
	stepper0.init(1, 500, 12, _8bits);
    stepper1.init(1, 500, 12, _8bits);
    stepper2.init(1, 500, 12, _8bits);
    stepper3.init(1, 500, 12, _8bits);
Then you can execute your custom setup action with the zeroSwitchs.
Set the number of DMX channels to 8 :

Code : Tout sélectionner

portB.setNbDmxChannels(8);//the number of channels used in this port. REQUIRED !
in the action loop :

Code : Tout sélectionner

    stepper0.refresh(DMXslice[0], DMXslice[1]);
    //and so on for each stepper
in at_each_loop :

Code : Tout sélectionner

stepper0.perform();
//and so on for each stepper
Of course, the other port have to be in inactive mode because you allready use some of his outputs
Jacques
Messages : 267
Enregistré le : dim. 31 oct. 2021 19:37

Re: Steppermotor homing?

Message par Jacques »

I suggest you tou upload the new version 1.0.1 with the portB servo fixed :
https://arpschuino.fr/telechargements_e.php
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

Hi Jaques, thanks for your input!
So if I understand correctly, if I want to use steppermotors with home switches, I can't configure the motors using the configuration page, but I have to set all the parameters in the code and upload it to the arpschuino32, just like I would have to when using an arpschuino2?
Micropuller
Messages : 47
Enregistré le : dim. 1 janv. 2023 15:55

Re: Steppermotor homing?

Message par Micropuller »

Jacques a écrit : lun. 16 janv. 2023 20:35 I suggest you tou upload the new version 1.0.1 with the portB servo fixed :
http://localhost/telechargements_e.php
When I click that link, I get a message that says the site can't be reached because localhost has refused the connection.
Maybe the same reason why the update tool doesn't work for me?
Répondre