Controlling stepper motor

chaymoss

Member
Hello,
I need some help for programming the stepper motor "https://docs.rs-online.com/9cd2/0900766b813f0a12.pdf" with PICAXE-28X2 SHIELD BASE "https://picaxe.com/docs/axe401.pdf", the driver that I'm using is STEPPER 4 CLICK "https://www.digikey.at/htmldatasheets/production/2455715/0/0/1/mikroe-2748.html"
The motor does not work.
You can see the program below.
Code:
#picaxe 28x2
main:
let b1 = 0 ; set b1 value
low B.2;
low B.5;
FOR b1 = 0 TO 1000
    high B.0 ; switch on output B.1
     pause 500 ; wait 0.5 seconds
     low B.0 ; switch on output B.1
     pause 500 ; wait 0.5 seconds
NEXT b1 
pause 1000; wait 1 seconds 
high B.5;
FOR b1 = 0 TO 1000
    high B.0 ; switch on output B.1
     pause 500 ; wait 0.5 seconds
     low B.0 ; switch on output B.1
     pause 500 ; wait 0.5 seconds
NEXT b1
pause 1000; wait 1 seconds
goto main
I checked the electric circuit, everything is working right supposedly. However, I think the problem is in the programming, cause it's my first time I'm using the Picaxe shield, and I couldn't find programming examples that are compatible with PICAXE-28X2 and the driver that I'm using for stepper motor control.
24808

As shown below in the pinout digram of the driver, I used B.2 to connect to ENABLE, B.0 connected to STEP trigger (PWM) and B.5 to DIRECTION, and RST connected to the reset of picaxe shield so I'm wondering if this is the right way to program the outputs pins in PICAXE Programming.

24807

Thank you in advance.
 

chaymoss

Member
Thank you bfgstew for your response

I switched B.2 to high, it still doesn't work.
Code:
#picaxe 28X2
main:
let b0 = 0 ; set b0 value
high B.2;
low B.0;
FOR b0 = 0 TO 1000
    high B.5 ; switch on output B.5
     pause 2000 ; wait 0.5 seconds
     low B.5 ; switch on output B.5
     pause 2000 ; wait 0.5 seconds
NEXT b0   
pause 1000; wait 1 seconds   
high B.0;
FOR b0 = 0 TO 1000
    high B.5 ; switch on output B.5
     pause 2000 ; wait 0.5 seconds
     low B.5 ; switch on output B.5
     pause 2000 ; wait 0.5 seconds
NEXT b0
pause 1000; wait 1 seconds
goto main
You can see the real circuit below, the GND and the Vcc are connected
24809

And here in the image down below, you can see the driver and all the connections, and I'm using Laboratory Power Supplies for the power supply linked to the driver (Vin /Gnd)
24810

I need help asap please

Thank you in advance
 

bfgstew

Senior Member
Check the DIP switches on driver board, it is set to standy by mode or in other words its switched off......🤞
 

chaymoss

Member
So I did the measurment of each thread after uploading the program into the board.
I found that Enable pin is receiving 5V,
ST/Clk pin is receiving also 5V for two seconds and then switched to 0V for two seconds,
DIR pin is 0V,
RESET/RST pin is 0.1V
INT/Angle/MO is 0.03V

You can find below the INPUT/OUTPUT equivalent of the circuit.
24812
 
Last edited:

chaymoss

Member
Yes I did supply it with 24V DC.
And now I verified the driver click board, and I found that the Vcc 5V pin of the driver wasn't welded correctly. So now even though the driver is on, the motor doesn't work, not with 1/32 step configuration, nor for full step.

24814
 

chaymoss

Member
I found out also that the INT/Angle pin takes 5V for two seconds when the ST pin is at 0V and 0V for two seconds when ST pin is at 5V
 

bfgstew

Senior Member
Are you getting a voltage to the motor?
Have you checked motor phases? Yellow and red, blue and orange, should have 2 ohms between each.
 

AllyCat

Senior Member
Hi,
Yes I did supply it with 24V DC.
Stew appears to have some experience with this setup (which I don't), however, the Motor current appears to be "rated" at 2 Amps/phase (coil), but the Driver is specified as having a maximum rating of 2 Amps. Ohm's Law tells me that at 24 volts, a 2 ohm resistance may pass up to 12 Amps! Now the inductance will limit the current (considerably) for short pulses, but you may need to be "careful" in selecting your operating frequency and drive mode (pulse duty cycle).

Since you have a multimeter, the first test I would be doing is to measure the voltage across each coil with both AC and DC meter modes. In a normal stepping mode, I would expect the AC measurement to be the same for both coils and to give a reasonable indication of the peak drive voltage across each coil. The DC measurement should be near to zero; a significant DC voltage indicating a drive waveform fault or too low a frequency.

If you get any zero AC measurements across a coil, then measure the DC voltage at each end of the coil, relative to Ground and Supply.

Cheers, Alan.
 

chaymoss

Member
Hi,

Stew appears to have some experience with this setup (which I don't), however, the Motor current appears to be "rated" at 2 Amps/phase (coil), but the Driver is specified as having a maximum rating of 2 Amps. Ohm's Law tells me that at 24 volts, a 2 ohm resistance may pass up to 12 Amps! Now the inductance will limit the current (considerably) for short pulses, but you may need to be "careful" in selecting your operating frequency and drive mode (pulse duty cycle).

Since you have a multimeter, the first test I would be doing is to measure the voltage across each coil with both AC and DC meter modes. In a normal stepping mode, I would expect the AC measurement to be the same for both coils and to give a reasonable indication of the peak drive voltage across each coil. The DC measurement should be near to zero; a significant DC voltage indicating a drive waveform fault or too low a frequency.

If you get any zero AC measurements across a coil, then measure the DC voltage at each end of the coil, relative to Ground and Supply.

Cheers, Alan.
Thank you AllyCat for your reply
I did the measurement and I found :
DC volage between two coils A&B =0V
DC voltage in coil A=0V
DC voltage in coil B=0V
AC volage between two coils A&B = 51mV but it varies, no actual constant value
AC voltage in one coil A =1.2mV
AC voltage in one coil B =1.2mV

Do you think I should change the driver?
 
Last edited:

bfgstew

Senior Member
Maybe the pause time is to long between steps, the decay of the field has probably occured before the next coil has been energised, thus has nothing to work with, reduce time from 500 to 50 or even lower. Also you need to zero b1 on the reverse leg of your code.......🤞
 

AllyCat

Senior Member
Hi,

(DC) Voltage measurements of around 20 , 10 or even 5 volts might give some clues as to what is wrong, but anything less than 1 volt is basically just "not working".

Personally, I would disconnect the two coils (at least at one end) and ideally (but not essential) replace with dummy load resistors of say 1k ohms (to "tame" any stray effects). Then measure the DC voltages at ALL the output pins/terminals relative to Ground (0v). As an occasional "sanity check", and if any reading is low (<1 volt), measure the voltage also relative to the main power supply rail (24 v) to check that the connection is not simply open circuit (i.e. still no significant voltage).

If the coil signals "should" be driving the motor, then I'd expect to see (average) DC levels of about 12 volts on all the coil pins, and a "large" AC voltage (> 10 volts) measuring between the two terminals intended to drive each coil. If you can't measure the "expected" voltage levels under these Light/No Load conditions, then you will need to measure back through the signal paths to to identify what's not working as expected. If it's not possible to identify what is "wrong", then the alternative is to modify the PICaxe program to output some static voltage levels and follow them through to the coils.

I'm afraid that with stepper motors you really just have to methodically test every element of the whole circuit, because there are so many reasons why they may fail to rotate. :(

BTW I haven't looked at how your program is supposed to work (as I don't know what the pins do on that controller) but I would expect that each "step" pulse to be around 10 ms, not the 500 ms which appears (?) to be in the program.

Cheers, Alan.
 

AllyCat

Senior Member
Hi,
Code:
#picaxe 28x2
...
low B.2          ; *** The ENABLE PIN
low B.5          ; *** The DIRECTION PIN
FOR b1 = 0 TO 1000
    high B.0 ; switch on output B.1 ******* B.0 is the CLOCK PIN *****
....
Looking at your Hardware and Program in detail, I can't see how it's supposed to work. :(

Firstly, meaningful comments would have been helpful, and the comment for B.0 is nonsense, B.1 is not even connected. However, you don't appear to be generating a CLOCK signal at all !?

I would expect B.0 to be driven with a PWM signal, possibly at quite a high frequency (some kHz) if you're using a high Step division factor. Also, I don't know what speed you expect the motor to rotate, but it appears to be 1.8 degrees/step, or 200 pulses per revolution, i.e. 6,400 pulses with a step division of 1/32.

Therefore, I'd expect to see a PWMOUT command instead of the High B.0 and a PWMOUT OFF instead of the Low B.0 . I won't guess at the PWM parameters, because they need to be calculated properly! ;)

Cheers, Alan.
 

oracacle

Senior Member
OK, where to start.
You can find the data sheet for the actual driver IC here: TB67S269FTG | Stepping Motor Driver ICs | Toshiba Electronic Devices & Storage Corporation | Asia-English (semicon-storage.com)

Next, drop the picaxe.
I assume the the "torque" setting is actually v-ref, and there should be a test point on the board for it - there doesn't seem to be one there. Calculation for it can be found on page 20 of the above data sheet. set in the middle ATM. Make sure the the step resolution is set to full step. Connect the motor
Give the board motor power, and logic power, pull the the enable pin high, pull the rest pin high. This should put the driver in a state ready to receive pulses and energise the coils.

Now check the motor shaft, has it locked?
if not, how does it feel when moved?
What happens when you take on pair of coil wires (ie the 2 wire for coil A) and swap them? What happens if you adjust the torque setting up and down?
What happens if you set the enable pin low?
If the motor locks what happens if you briefly touch the step pin to power?

Once we know the driver is working as expected we can have a closer look at getting the picaxe involved.
 

chaymoss

Member
Hi,

Looking at your Hardware and Program in detail, I can't see how it's supposed to work. :(

Firstly, meaningful comments would have been helpful, and the comment for B.0 is nonsense, B.1 is not even connected. However, you don't appear to be generating a CLOCK signal at all !?

I would expect B.0 to be driven with a PWM signal, possibly at quite a high frequency (some kHz) if you're using a high Step division factor. Also, I don't know what speed you expect the motor to rotate, but it appears to be 1.8 degrees/step, or 200 pulses per revolution, i.e. 6,400 pulses with a step division of 1/32.

Therefore, I'd expect to see a PWMOUT command instead of the High B.0 and a PWMOUT OFF instead of the Low B.0 . I won't guess at the PWM parameters, because they need to be calculated properly! ;)

Cheers, Alan.
I tried using PWM signal as shown in the code below
Code:
init:    PWMOUT B.5, 199, 399    ; start pwm
high B.2; ENABLE the driver 
high B.0; Direction of the spinning

main:    pwmduty B.5, 199        ; set pwm duty
    pause 500        ; pause 0.5 s
    pwmduty B.5,50        ; set pwm duty
    pause 500    ; pause 0.5 s
    goto main        ; loop back to start
I also tried a diffrent pause times (1, 200, 500, 1000ms).
The code is taken from the example of using PWMOUT command
I'm diffenetly using the full step configuration. And it still doesn't work

I did use the PWM Wizard to calculate the parameters of PWM signal
24823
 

chaymoss

Member
Maybe the pause time is to long between steps, the decay of the field has probably occured before the next coil has been energised, thus has nothing to work with, reduce time from 500 to 50 or even lower. Also you need to zero b1 on the reverse leg of your code.......🤞
I used this code to try your suggestion
Code:
#picaxe 28X2
main:
let b0 = 0 ; set b0 value
high B.2; ENABLE the driver  
high B.0; Direction of the spinning


FOR b0 = 0 TO 500
    high B.5 ; switch on output B.5/ST
     pause 1 ; wait 0.5 seconds
     low B.5 ; switch off output B.5
     pause 1 ; wait 0.5 seconds
NEXT b0

pause 1000; wait 1 seconds  
let b0 = 0 ; set b0 value
low B.0; Direction of the spinning

FOR b0 = 0 TO 500
    high B.5 ; switch on output B.5/ST
     pause 1 ; wait 0.5 seconds
     low B.5 ; switch off output B.5
     pause 1 ; wait 0.5 seconds
NEXT b0

pause 1000; wait 1 seconds

goto main
I initialised b1 in the second part of the code, and I reduced the pause time to 200ms and 1ms, I still haven't got anything
 

chaymoss

Member
After contacting the Technical Support of MicroE, they informed me that I shouldn't change the Vcc data jumper from 3.3V to 5V as shown in the images down below.
2482424825

So I should have kept the default position of the jumper.
And finally, now the stepper motor is spinning using the last shared code with pause time 50ms
Thank you everyone for your help
bfgstew , AllyCat and oracacle
 

AllyCat

Senior Member
Hi,
Code:
init:    PWMOUT B.5, 199, 399    ; start pwm     ; ******
high B.2; ENABLE the driver
high B.0; Direction of the spinning  ; *******
main:    pwmduty B.5, 199        ; set pwm duty     ; ******
    pause 500        ; pause 0.5 s
It's not going to work if you use the WRONG pins at the WRONG frequency! :(

According to your diagram in #1, B.5 is the Direction and B.0 is the Clock/PWM pin.

Previously you've reported that B.0 had a cycle of 4 seconds (i.e. 1/4 Hz), the step divider was 32 and (it appears to me) the motor step is 1.8 degrees. That implies that the motor will take over 7 hours for one revolution.

Conversely, a PWM frequency of 10,000 Hz is far too high to step the motor.

Put some proper comments (i.e. the actual function of each port.pin name) in the program, or use some SYMBOL commands to make it clear what your program is actually doing, and maybe we can create some code that does what's required ;)

Cheers, Alan.
 
Top