Is there a library for ZUNO to control a stepper motor?

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
jeffhumster
Posts: 3
Joined: 22 Jun 2018 22:33

Is there a library for ZUNO to control a stepper motor?

Post by jeffhumster » 13 Jul 2018 22:58

Hello everyone, I am trying to control a step motor using ZUNO, I have seen arduino use the <stepper> library to control motor, I wonder does ZUNO has a similar library?

Any idea and suggestion is welcomed. :D

p0lyg0n1
Posts: 157
Joined: 04 Aug 2016 07:14

Re: Is there a library for ZUNO to control a stepper motor?

Post by p0lyg0n1 » 14 Jul 2018 19:10

Hi,
I have looked here https://github.com/arduino-libraries/St ... tepper.cpp.
The code is simple. There are no specific hardware features. The only thing that we have to modify is passing of parameters especially for constructors. In case of Z-Uno the stack usage is critical. Don't use large list of parameters, use pointers instead.
original code:

Code: Select all

Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
                                      int motor_pin_3, int motor_pin_4,
                                      int motor_pin_5)
{
Optimized code for Z-Uno (note I use byte instead of int)

Code: Select all

Stepper::Stepper(byte number_of_steps, byte * motor_pins)
{
You could try it yourself.

jeffhumster
Posts: 3
Joined: 22 Jun 2018 22:33

Re: Is there a library for ZUNO to control a stepper motor?

Post by jeffhumster » 15 Jul 2018 23:55

Thanks, I will try the solution, and will let u know how things going. Really appreciate your help.

p0lyg0n1
Posts: 157
Joined: 04 Aug 2016 07:14

Re: Is there a library for ZUNO to control a stepper motor?

Post by p0lyg0n1 » 01 Aug 2018 20:08

Hi,
today we have released a new beta 2.1.5b1 that contains library for step motors. The news will be further in separate topic. The library calls ZUNO_Stepper. Here is an example that shows how to use it. We don't have any step motor in the office. I have debugged it using logic analyzer. So, it'll very cool if you could test it with your hardware.

Code: Select all

#include <ZUNO_Stepper.h>
CCBYTE motor_pins[] = {0,1,2,3,4}; // z-uno pins connected to motor, 4-pins mode
Stepper stepper_motor(64, sizeof(motor_pins), motor_pins);   // 64 steps for whole rotate
void setup() {
    stepper_motor.setSpeed(1000); // 1000 rpms
}
void loop() {
    stepper_motor.step(10); // 10 steps forward
    delay(1000);
    stepper_motor.step(-5); // 5 steps backward
    delay(1000);
}


Post Reply