Stepper Motor command blocks not working properly


#1

I am trying to use the latest version of mBlock to control the stepper motors from the mDrawbot kit. it will only allow ONE stepper motor command to be issued per program. For example I can issue it to move 6000 blocks then the program will not execute any other stepper commands to that motor.

Attached is an example that should move the stepper motor forward, then backward based on a counter. it will only ever execute the stepper motor in one direction. I have tried to add the “Wait” block, but then no stepper motor action occurs at all. I think there is a bug in the Stepper motor control in the header files. I tried running the raw example code TestStepperDriver.ino and that program would work correctly. so the problem is not hardware or connection.


#2

Your code shows that you are testing against the modulo of count1, but count1 is never initialized to a value. You might want to try initializing count1 to a known good starting value and see if that fixes anything. In C/C++ programming, the compiler would initialize all variables when compiling for debug mode, but it will not do so otherwise. It’s something that bites a lot of people all the time. :slightly_smiling:

In general, it’s not a good ideal to use uninitialized variables because you don’t know what value might be there. The value might be NaN (Not A Number), so changing it by one won’t do much. :slightly_smiling:


#3

let’s try a simpler program.
This program should run the stepper motor 6000 steps, pause for 5 seconds, then repeat, forever. it just puts load on the stepper, but no motion, and that’s it. Without the “Wait 5 secs” command it would just run forever in one direction. the stepper motor will not execute the wait, then start again, it just waits forever.


#4

I did what you said by adding a block “set count1 to 1” at the beginning of the first program snip. Now what happens i can feel load on the motor and hear the motor “change pitch” every second but I get no motion.

FYI, this is an Orion board, latest Orion firmware (1-6-16) from mBlock, plugged in to the included wall power supply. Only one stepper motor is attached to the board.


#5

Weird. I’m assuming that you have confirmed that the stepper motor is plugged into port 1 and there is nothing binding it up from moving.

If you’re trying to run it from the mBlock environment, did you try using the when clicked block instead of the Orion Program block to start the program? Just grasping at straws because I don’t have that board, so I can’t test it.

Dropping a note to @Pioneer at support@mblock.cc might be your best next step.


#6

I have confront the same problem as you. But it has been solve at the help of this site:
https://www.oyostepper.com/