stepper motor unipolare in full step

Nandino

Active member
Grazie mille per l'aiuto ad entrambi, spero di poter fare dei test domani. Grazie per lo schema PIEM ma a casa ho solo 08m2 ti chiedo troppo se cambi programma quindi provo subito ..... Grazie grazie grazie il tuo aiuto è davvero incredibile .... Il tempo che dedichi a aiutami ... .
 

Wrigley

Active member
[QUOTE = "Nandino, post: 335482, member: 74058"]
Thank you so much for helping both of us, I hope I can do some tests tomorrow. Thanks for the PIEM scheme but at home I only have 08m2 I ask you too much if you change the program so I try now ..... Thanks thanks thanks your help is really incredible .... The time you dedicate to help me ....
[/ QUOTE]
No problem enjoyed it. Maybe I can make 08m2 circuit later.
 

Technoman

Senior Member
Hi,

For some still having some unipolar steppers in their drawers, I recently came across articles describing how to turn an unipolar stepper motor into a bipolar one, with the advantages of an increased torque at low speed and the ease of finding chips (and breakout boards) popularized in 3D printer :
You can also find some videos on Youtube.
 

PieM

Senior Member
Grazie per lo schema PIEM ma a casa ho solo 08m2 ti chiedo troppo se cambi programma quindi provo subito
The same for 08M2 :
but I recommend the use of DRV8825 or A4988 !

Rich (BB code):
'===================================================
'Commande moteur PAP bipolaire 
'08M2 Driver L293D
' connections moteur : sur A et B du L293D 
'sequence demi pas: C0,C0C2,C2,C2C1,C1,C1C4,C4,C4C0...
'sequence pas entiers 1 enroulement: C0,C2,C1,C4,...
'sequence pas entiers 2 enroulements: C0C2,C2C1,C1C4,C4C0...
'===================================================
#picaxe 08M2
setfreq M32
'===================================================

symbol MOT = outpinsC   'MOT correspond au portC du 08M2
symbol period = W1      'temps entre pas en 1/100 de ms
symbol nbpas = W2       'Nombre de pas    
dirsC= %10111           'affectation C.0, C.1, C.2 et C.4 en sortie vers le L293

'mémorisation de la sequence de commande pour le moteur en demi pas
eeprom 0,(%10010,%10000,%10001, %00001,%00101,%00100,%00110,%00010)

'prg principal ==============================
princ: 

do
      'mise hors tension du moteur pendant 3 sec.
      Mot =%00000 
      pause 3000
      
      'actionne x demi-pas dans un sens avec une vitesse donnée
      period = 50 : nbpas = 200
      for w10 = 1 to nbpas
      inc b0
      gosub PAS
      next
      
      'actionne x demi-pas dans l'autre sens avec une autre vitesse
      period = 20 : nbpas = 200
      for w10 = 1 to nbpas 
      dec b0
      gosub PAS
      next
      
      pause 500
      
      'actionne x pas dans un sens avec une vitesse donnée
      'va lire une séquence (paire) sur deux (mode 2 enroulements alimentés)
      period = 50  :nbpas = 200: b0 = 0 
      for w10 = 1 to nbpas  
      b0 = b0+2
      gosub PAS
      next
      
      'actionne x pas dans l'autre sens avec une autre vitesse
      'va lire une séquence (impaire) sur deux (mode 1 enroulement alimenté)
      period = 28 :nbpas = 200: b0 = 1
      for w10 = 1 to nbpas  
      b0 = b0-2
      gosub PAS
      next
      
loop


PAS: ' ******************

      b0 = b0 & %00000111 'la valeur de b0 est limitée à 3 bits, soit 0 à 7 
      read b0, Mot            ' va lire la séquence 0 à 7 dans l'eeprom.
                              'et envoi de cette séquence au moteur 
      pause period            'pause en ms
return
 
Last edited:

Nandino

Active member
hello everyone, a test evening with all the suggested tests and in the end I'm stuck here,
Code:
let dirsb =% 10111
         main:
     for b1 = 1 to 50
     let pinsb =% 00101
     breaks 10
     let pinsb =% 10001
     breaks 10
     let pinsb =% 00101
     breaks 10
     let pinsb =% 00110
     breaks 10
     next b1

     let pinsb =% 00000
wait 5
     goto main:
from a suggestion of wrigley I converted the little program for my 08m2, the motor runs but very very badly, it turns but vibrates, it turns even if I connect the coil A, but at least it moves,



Test done with direct 5v on a coil and 0.5A absorption so I think the l293 can do it.



PieM, I tried with your program but nothing at all, yet with the simulator it is perfect!

at this point I don't know what to do anymore,



sorry Allycat but I have not tried your suggestion because unfortunately "google translator" does not translate very well and sometimes what you write to me is difficult for me to understand
 

AllyCat

Senior Member
Hi,
Code:
     let pinsb =%00101 ==
     let pinsb =%10001
     let pinsb =%00101 ==
     let pinsb =%00110
;Total High=     1-313
All the drive waveforms should be different and normally an equal number of Highs and Lows. There are different drive possibilities (shown by PieM's code) but try these numbers:
Code:
     let pinsb =%00001   or   let pinsb =%10001
     let pinsb =%10011   or   let pinsb =%00101
     let pinsb =%10110   or   let pinsb =%00110
     let pinsb =%00100   or   let pinsb =%10010
;Total High=     2-222
But personally I prefer an 8-phase sequence.

Cheers, Alan.
 

Wrigley

Active member
Hi to Nandino and all others on this thread.
This is an interesting topic you have posted.
Controlling steppers should be fairly easy but in practice not so. I've have made stepper circuits before and they work straight away but then others I spend hours messing about trying to get it working - and here is such a case.

I wrote a program onto an 08M2 chip. I made sure to disconnect the wire from C.0 when downloading.
I got 4 pulses out of the 08M2 but it didn't drive the stepper. I tried various pause commands but no change. The 293
got hot and was drawing over 500mA, probably because the stepper was not rotating.
Pulses some times stopped - I changed the 293 and the second one drew less current.
I have attached the NOT WORKING code for the 08m2 chip for those who are interested.

I then programmed and old 08M chip with very pretty much the same code as attached below and it worked no problem. I even used
a larger stepper and still works fine? I had no problem with this code on my model crane project (see robotic section on picaxe forum) using 18M2.
You can see my physical demo and oscilloscope pulses of two outputs photos attached.

I'm still working on solving.
 

Attachments

AllyCat

Senior Member
Hi,

PLEASE post your small programs (within [ code] [/code] tags) and photographs "in-line" not as files. I don't know about other members, but personally I often "can't be bothered" to download files, and clutter up my hard drive with files that don't even work!

Also, you don't appear to have shown which PICaxe pins are wired to the two coils (via the L293) nor the relative phase of the A/B pulses on the 'scope waveforms. I've assumed that c.4 and c.2 go to "Coil A" and c.1 and c.0 to "Coil B"; The polarity of connections doesn't matter, it only influences the direction of motor rotation.
Rich (BB code):
let dirsC = %010111      ;COMMANDS IMPORTANT TO ADD.
**************** THIS PROGRAM DOES NOT YET DRIVE THE STEPPER MOTOR.
**************** BUT THIS SIMILAR PROGRAM DOES WHEN USING THE 08m DEVICE.

;main:     ; Moved 
    ;           543210 these are the pins on the 08M2 chip. C.0 is fixed as always
    ;        an output we can't change it. C.3 is an input can't change that
    ;        either. C.5 is used when downloading although we can use it in our
    ;        program we have to type the word 'disconnect' as mentioned on a
    ;        previous thread.
    ;        C.0 is also used when downloaded
    ;           543210 "I TYPE THESE PINS NUMBERS TO HELP ME REMEBER THEM":       A+ : i : A- : B+ : B- 
    let pins = %10010      ; Coils A = +,  B = +    ; Why ?   
    pause 50
main: 
    let pins = %10001       ; Coils A = +,  B = -  
    pause 50
    let pins = %00101        ; Coils A = - ,  B = - 
    pause 50
    let pins = %00110        ; Coils A = -,  B = + 
    pause 50
    let pins = %10010        ; Coils A = +,  B = + 
    pause 100                    ; Why longer ? (I'd expect slightly shorter)    
goto main

I've pasted your code above with comments in Red. Apart from the long PAUSE (100) and additional (fifth) output in each loop, the sequence of output pulses looks (to me) that they "should" work. But personally I prefer to drive just one coil at a time (or maybe both with only a minor overlap) to reduce the power dissipation.

A disadvantage of the L293 is that its output stages have large voltage drops (it uses bipolar transistors, not FETs) ; I (have) run those particular little steppers from a 3 volt supply, a "20p" driver board (posts #1 and #8) and two pins from an 08M2. ;) Sometime I must update that thread because your little "8mm" motors work much better than the ones I showed in that thread.

BTW PE6 should be able to program an 08M, but you may need to select the "Show more PICAXE types" option at top-left.

Cheers, Alan.
 
Last edited:

PieM

Senior Member
I think you have a connection problem between picaxe - l293D and motor.
And the sequence is not correct: no step5 , it's the step 1!
24330
 

Wrigley

Active member
Hi to allycat and PieM
Just a quick update.
You are correct about not needing step5, my mistake probably a hangover from getting the 08M2 to work - I've removed it now, thanks.
I looked on other picaxe types and indeed found the older 08M

C.0 is joined to IN1 and C.1 to IN2 of the L293D (lets call that coil B).
C.2 is joined to IN3 and C4 to IN4 of the L293D (lets call that coil A).

I downloaded the rectified code into the 08M and it rotates the stepper perfect as I expected and the pic + L293 drawing 285mA. The picaxe supply
is 5v and the stepper 7 volts. The FET volt drops don't really bother the stepper.

When I replaced the 08M with the 08M2, selected 08m2 and downloaded the code, removing the wire from C.0 to stepper during this. The stepper didn't work.
I found there were not pulses from C.0 & C.2.
I tried adding disconnect but no difference.
I put the 08m back in - perfect. I put a different 08m2 in but same fault.

Conclusion:- I don't seem to have this bother on 18m2 chips but I will revisit this again. I may rebuild this circuit on a 08M development board from picaxe.com. Second my cheap scope has been playing up delaying things so buy another one maybe.

I can see why Nandino has been having trouble.
 

Nandino

Active member
[QUOTE = "PieM, post: 335526, membro: 51339"]
Penso che tu abbia un problema di connessione tra picaxe - l293D e il motore.

Ciao a tutti, gentilissimi soci, ho passato tutta la domenica a provare e riprovare, ho vagliato tutti i vostri consigli e prove, sono arrivato al punto che sono d'accordo con "Piem", ho un'idea che per qualche motivo la 293 non lo sia compatibile con il mio stepper, o per cadute di tensione come dice Allycat o per la mia incapacità ....
allo stesso tempo non voglio abbattere, ma vorrei provare con un driver diverso dall'l293, cosa ne pensate? ne hai uno da consigliare?
Grazie sempre per l'aiuto
 

AllyCat

Senior Member
Hi Wrigley,

What current did the 08M2 + L293 etc. drain? It seems very strange to "lose" the pulses from c.0 which is "Output Only", so it cannot be accidentally set to input/off. But (with an 8-pin PICaxe) you must of course avoid any SERTXD or DEBUG commands, etc. (or HPWMOUT on c.2), once the stepping code is running.

There is one significant difference between the 08M and 08M2, the 08M2 uses "newer" technology which makes the chip faster so it is more sensitive to "noise" (voltage spikes) on its supply rail. So you almost MUST connect a decoupling capacitor of around 100nF, or 10uF (or both) across Legs 1 to 8, and maybe also 100uF+ if your power supply is rather "weak". We often put a : #terminal 4800 and sertxd("Booting") at the very top of our programs (or I often report the actual supply voltage) to show if the PICaxe is being unexpectedly Reset.

Also, personally I prefer code that uses a sequence of High and Low pin commands, it's more obvious what is happening and you don't have to bother with the DIRs command.

Cheers, Alan
 

AllyCat

Senior Member
Hi,
Hello everyone, very kind members, I spent the whole Sunday trying and trying again, I went through all your advice and tests, I got to the point that I agree with "Piem", I have an idea that for some reason the 293 it is not compatible with my stepper, or due to voltage drops as Allycat says or due to my inability ....
at the same time i dont want to break down, but i would like to try with a driver other than the l293, what do you think? do you have one to recommend?
Thanks always for the help
Please can you give us a link to the " pg16l0064 " (post #33) stepper motor. The one that I found HERE does NOT have 30 ohm coils, but is still specified at 12 volts.
Note the "ratings" from the ebay listing above :

Rated Current per Phase: = 0.82A (measured at 6 volts dc)
Nominal Rated Input Voltage: = 12 V
Resistance per Phase: = 6.4 ohms


Cheers, Alan.
 

Nandino

Active member
Ciao a tutti:
corrente nominale misurata a 5v = 0.45A
Corrente nominale misurata a 12,3 V =0,78A Mentre misuro la resistenza di fase infatti non posso perché parte da 37ohm per arrivare dopo 1 minuto a stabilizzarsi intorno ai 30ohm ... forse le bobine interferiscono nel mio tester?
 

Wrigley

Active member
Hi AllyCat
The current of the pic and stepper was 140mA not rotating. No debugs, SERTXD etc.

Yes I normally add caps but didn't on the bread board so I've just connected it to a 6v oneloop NIMH pack and loaded with a high low type code as you mentioned and it works. stepper rotates clockwise, bit jerky but I can tweak the pause 50.
So thanks for that.
I have to remove the wire from C.0 to the IN1 of L293 every time I download. Then connect once that's done, fine.
In the manual it mentions the ser pin C.5 about using that pin but nothing mentioned about C.0, wonder why?

The let let pins = %****** does not yet work so need to look into that.
later I'll get some caps added and try my bench power supply with shorter leads. I've ordered those 08M dev boards from picaxe.

I typed Nandino's part number on google and clicked onto Moonsindustries.com and scrolled down that pdf called PM-EN-2019.pdf to page 58 and it's there. 9 volts coil 7.6R.
Cheers Mike
 

AllyCat

Senior Member
Hi,
Hello to all:
rated current measured at 5v = 0.45A
Nominal current measured at 12.3 V = 0.78A While I measure the phase resistance, in fact, I can't because it starts from 37ohm to arrive after 1 minute to stabilize around 30ohm ... maybe the coils interfere in my tester?
Yes, it seems that the coils are NOT "30 ohms", they're probably about 7 ohms. Therefore at 9 - 12 volts there may be large current "spikes", so you may need to pay particular attention to the power supply and decoupling (or "reservoir") capacitors, etc.. Also, the L293D is only rated up to 600 mA which is probably not enough for that motor.

@ Mike: 140 mA strongly suggests that only one coil is operational and I'd guess it's a "hardware" (e.g. not connected) issue.

I think it's reasonably "well-known" that the PICaxe needs to send a "verification" signal back from pin C.0 to the Program Editor during programming. A LED or similar can be just allowed to flash, and some of the prototype/development boards have a pin-link header to allow a (servo) motor, etc. to be disconnected from C.0 during programming. If not disconnected, it will be necessary to keep the L293D powered up (or the input pins will be pulled to ground) but you could disable the Outputs during programming.

A "trick" you might be able to use is to connect the "Input Only" (Leg 4) pin to the L293 Enable inputs and a pull-down re sistor of about 47k (to disable the L293D). Then, to enable the outputs you might use a PULLUP 8 command to pull the Enable inputs high. However, this might not work because the "Maximum" required input current is moderately high (as said before it's a Bipolar not a MOSFET integrated circuit).

Strictly, for an 08M2 and PE6, the command should be pinsC = .... (and B is also accepted) but personally I try to avoid those commands because it's not "intuitive" particularly for novices (and it may be "forgotten" by any of us). It's not really necessary for the coils to be switched in exact synchronism and anyway I prefer an "8-phase" drive capability, either with an adjustable overlap, or even shorter pulses to reduce the average power consumption. And not much has been said in this thread about switching the current(s) OFF when the motor is NOT required to rotate. ;)

Cheers, Alan.
 

Wrigley

Active member
Hi again
just before your lastest input which I have read I'll tell you what I did.
As I say I normally puts caps on silly of me not to in this case. But before I did I connected the bench psu set to 7 volts to pin 8 of the L293D
and the 5v battery to the 08m2.
Pulled out the c.0 lead and downloaded the code with let pins =%xxx and the stepper worked a treat. Then loaded similar code with fwd and rev reducing pause to 20 and spun round clock, anticlock a treat although drawing about 350mA, but with 20R coils that works out correct.

But guess what it even downloads with the wire connected to c.0 but I will remove when downloading. I didn't get this issue with my 18M2 atlas crane project but I'm going back there as I've learnt so much more being on this thread.
You also confirmed what I was thinking as well as adding caps I was going to add pull downs.

I think Nandino has a similar practical hardware wiring issue like mine (and I've worked on electronics for many years). thanks again.
 

Nandino

Active member
Salve, quando ho acquistato la picaxe nello starterkit c'è una mini breadboard con la presa 8 pin e il jack di programmazione ho sempre programmato la picaxe usando quella, per il c. 0 c è un jumper per spostare prog / out0
Quando ho scaricato il prog. Tolgo la picxe e la metto nella breadboard dove ho fatto tutti i collegamenti con la 293 .....
È qui che mi sbaglio o l'errore hardware che dici è nel l293 che non supporta il carico del mio stepper?
Purtroppo le traduzioni di google tradotte sono molto confuse ea volte mi perdo nei discorsi .....
 

Wrigley

Active member
Hi Nandino
I translated your text.
Hi, when I bought the picaxe in the starter kit there is a mini breadboard with the 8 pin socket and the programming jack I have always programmed the picaxe using that.
For the c.0 there is a jumper to move prog / out0 when I downloaded the prog. I remove the picaxe and put it in the breadboard where I made all the connections with the 293... Is this where I am wrong or the hardware error you say is in l293 not supporting my stepper load?

To nandino:- 1) It is okay to program on mini breadboard then move the 08 into your l293 board. I do this sometimes.
2) Please look at the pdf photo and tell me if this moons' stepper is the type you have. If yes then the L293D will not drive it because it uses too much current.
 

Attachments

AllyCat

Senior Member
Hi,

The "English" translation of your Ali Express link says:

"There is feedback at the back
......
The overall condition of this batch of motors is good,
But after all, it’s a disassembled motor,
It's impossible that every one is beautiful,
Please take photos with friends who have strict appearance requirements.

Motor step angle: 18 degrees
Planetary gearbox: three-stage metal gear planetary reduction
Reduction ratio: 1:64 (1280 pulses make one revolution)
Output shaft step angle: 0.28125 degrees
Weight: 53.5 g
Phase resistance: 9.3 ohms
6V short circuit current: 0.6 A


So first you need to do a "short circuit current" test at around 4 - 6 volts (or less if necessary) for each coil. Then we can decide what might be suitable to drive it. Also what does the "There is feedback at the back" mean? Are any of the other four wires (Orange, Yellow, Green and Blue) connected to anything (e.g. a resistor) ?

Cheers, Alan.
 

Nandino

Active member
Ciao Alan, confermo tutti i valori scritti relativi alla corrente e alla resistenza di cortocircuito, p. S. Nessun altro collegamento, ci sono altri 4 fili nel connettore ma non sono collegati a nulla.
 

Wrigley

Active member

Hi wriglei, yes it is just that type there, now I try to put you the link, at this point you recommend a driver that can drive it without problems ....
Morning Guys.
Just looked at your link. 6volts divide by 9.3 ohms is 645mA (0.645v). The max continuous current the L293D can do is 600mA (0.6A) (peak 1.2A) per channel.
It would be good to see what results you get from measuring one coil current. The L293 might work a bit but will get very hot and not last long.

I just found on FARNELL ITALY website two other drivers that should work with your stepper found from FARNELL ITALY. They have the same pinouts as your L293 but can do 1 amp.
1) L293B 1 AMP CONTINUOUS. Product code 2762683 made by STmicroelectronics Euro 3.75 + post.
2) L293NE 1 AMP CONTINUOUS. Product code 3118815 made by TEXAS INSTRUMENTS Euro 3.58 + post.
 

Wrigley

Active member
Hi guys

@AllyKat. I cleaned up my circuit by adding some capacitors. 100nF for 08 and l293. A 68mfd for 08 and 22mfd for L293. Trial and error basis. Also I used two separate battery packs. And I was successful in downloading a code.

I experimented with ‘disconnect’ but found it was not needed as I found I could leave c.0 still connected to IN1 of the 293. I wonder if my previous 6v pack voltage was a little high for the 08.

Also I just found out that I have to put a 10K resistor from C.5 to 0 volts otherwise the stepper does not work.
So from this post I'm going back and check out my codes etc.

@Nandino. F.Y.I.

I used a very small micro stepper with coil resistance of 40R. It drew 460 milliamps at 7.0 volts. The codes had a pause of 20 after each let pins e.g.
Let pins = %010010
Pause 20
- the stepper got very hot, the L293 was warm to touch.
I downloaded 3 different codes (one code with high, low, high etc commands and two codes with let pins = %xxxxxx commands) all rotated steppers okay.

I then tried a bigger stepper a MITSUMI, coil was 10R. And with a 6 volt battery it drew 564mA (0.564). The L293 got very very hot.
So I think your L293 with your moons stepper your L293 will get very hot also.

In fact the stepper made the batteries go down to 5 volts. So I used my Bench power supply for the L293 leg 8 and a 3 AA pack for leg 1 of picaxe and legs 1,9,16 of the L293.

I loaded all the codes again using the PSU and still worked okay.

Tick tick sound some things to check below:-
  • Not enough voltage on leg 8 L293.
  • Not enough voltage on leg 1 of picaxe.
  • Use separate voltages like battery for picaxe and powerful battery or PSU for l293 leg 8.
  • Check wiring connections – make tidy if needed.
  • Check with another bi-pole stepper if possible.
  • Read your code again carefully. It is so easy to make code mistakes – I did.
  • The EN legs 1 & 9 of L293 need +5v and does Vss leg 16.
  • Also I just found out that I have to put a 10K resistor from C.5 to 0 volts otherwise the stepper does not work.
  • When you want to stop the stepper rotating you can use let pins = %000000.
  • I've attached a photo of my breadboard circuit.
Ciao ragazzi

@AllyKat. Ho ripulito il mio circuito aggiungendo alcuni condensatori. 100nF per 08 e l293. Un 68mfd per 08 e 22mfd per L293. Base di prova ed errore. Inoltre ho usato due pacchi batteria separati. E sono riuscito a scaricare un codice.

Ho sperimentato la "disconnessione" ma ho scoperto che non era necessaria in quanto ho scoperto che potevo lasciare c.0 ancora collegata a IN1 del 293. Mi chiedo se la mia precedente tensione del pacco 6v fosse un po 'alta per la 08.

Inoltre ho appena scoperto che devo mettere una resistenza da 10K da C.5 a 0 volt altrimenti lo stepper non funziona.

Quindi da questo post torno indietro e controllo i miei codici ecc.

@Nandino. F.Y.I.
Ho usato un micro stepper molto piccolo con resistenza della bobina di 40R. Ha disegnato 460 milliampere a 7,0 volt. I codici avevano una pausa di 20 dopo ogni volta che i pin, ad es.

Consenti pin =% 010010
Pausa 20

- lo stepper è diventato molto caldo, l'L293 era caldo al tatto.

Ho scaricato 3 codici diversi (un codice con comandi high, low, high ecc e due codici con comandi let pins =% xxxxxx), tutti gli stepper ruotati vanno bene.

Ho quindi provato uno stepper più grande un MITSUMI, la bobina era 10R. E con una batteria da 6 volt ha assorbito 564mA (0,564). L'L293 è diventato molto molto caldo.

Quindi penso che il tuo L293 con le tue lune stepper anche il tuo L293 diventerà molto caldo.

Infatti lo stepper ha fatto scendere le batterie a 5 volt. Quindi ho usato il mio alimentatore da banco per la gamba 8 dell'L293 e un pacco da 3 AA per la gamba 1 del picace e le gambe 1,9,16 dell'L293.

Ho caricato di nuovo tutti i codici usando l'alimentatore e ho comunque funzionato bene.

24343
 

Attachments

Nandino

Active member
Hi wrigley, thanks for these tips this week I will try to do as you told me,
I found an old 6 wire stepper, let's see if it works,
P. S. The R of pull down on the c. 5 I was advised to put it at 33k!
See you soon, thanks in the meantime
 

Wrigley

Active member
Hi all
Hope your Christmas break was kind to you all things considered.
Having spent some time on this forum I realized that I made some mistakes on my crane stepper codes. So I purchased the picaxe AXE023
which is the prototype board which has 08M2 and L293D to experiment with.
It also has a RUN / PROG link so you don't have to add the 'disconnect' command.

@AlleyKat as you said I didn't specify where the coils were connected. Recently I saw different lines of codes with ones and noughts in different
places. I connected mine to tiny micro steppers and they don't have wires just 1mm pins, one coil to c.0 / c.1 and another to c.2 / c.4. Until I came across the 28BYJ-48 that specified which color went where.

I removed the blue cover and cut the + 5V track and used it as a bipolar stepper. I have inserted my codes (double and half step) and they work fine. Thought I would add this. Hope I've inserted the codes correctly.

Code:
; THIS CODE DRIVES A 28BYJ-48 5 VOLT STEPPER. 30th dec2020
; THE +5 VOLT TRACK HAS BEEN CUT OPEN CIRCUIT MAKING IT A BI-POLAR TYPE

; USES THE PICAXE DEVELOPMENT BOARD AXE023 08M2 MOTOR DRIVER BOARD (08M2 + L293D)
; BLUE WIRED TO pin C.0 via L293D
; YELLOW WIRED TO pin C.1 via L293D
; ORANGE WIRED TO pin C.2 via L293D
; PINK WIRED TO pin C.4 via L293D

; THE ABOVE WIRING ROTATES THE SHAFT CLOCKWISE LOOKING DOWN AT IT.
; SWAPPING WIRES PINK TO C.2 & ORANGE TO C.4 ROTATES THE SHAFT COUNTER CLOCKWISE.
; 175mA @ + 5V and 250mA @ +7 volts.

; 130 * 4 lines of code rotates the shaft approx 360 degrees in 11 seconds PAUSE 10.

; with no pause value the stepper just makes faint buzzing sound.
; with pause 5 @ 5 volts the torque is weak. current = 162mA.
; with pause 5 @ 7 volts the torque is stronger. Current = 235mA. 0-360 degrees 3 seconds.

; disconnect This command is not needed with this AXE023 because of the RUN / PROG link.
let dirs =% 10111


main :; Half Step Coil Mode
                       ; 130 rotates shaft 360 degrees
    For b1 = 1 to 130    
                 ; 43210 08M2 output pins. Ignore C.3.
    let pins =% 00101
    breaks 10
    let pins =% 00001
    breaks 10
    let pins =% 10001
    breaks 10
    let pins =% 10000
    breaks 10
    let pins =% 10010
    breaks 10
    let pins =% 00010
    breaks 10
    let pins =% 00110
    breaks 10
    let pins =% 00100
    breaks 10
    next b1

    For b1 = 1 to 130    
                ; 43210
    let pins =% 00110
    breaks 10
    let pins =% 00010
    breaks 10
    let pins =% 10010
    breaks 10
    let pins =% 10000
    breaks 10
    let pins =% 10001
    breaks 10
    let pins =% 00001
    breaks 10
    let pins =% 00101
    breaks 10
    let pins =% 00100
    breaks 10

    next b1
let pins =% 00000; stops the motor drawing current
Code:
; THIS CODE DRIVES A 28BYJ-48 5 VOLT STEPPER.
; THE +5 VOLT TRACK HAS BEEN CUT OPEN CIRCUIT MAKING IT A BI-POLAR TYPE
; USING THE PICAXE AX023 08M2 MOTOR DRIVER BOARD (08M2 + L293D)
; BLUE WIRED TO C.0
; YELLOW WIRED TO C.1
; ORANGE WIRED TO C.2
; PINK WIRED TO C.4
; THE ABOVE WIRING ROTATES THE SHAFT CLOCKWISE LOOKING DOWN AT IT.
; SWAPPING WIRES PINK TO C.2 & ORANGE TO C.4 ROTATES THE SHAFT COUNTER CLOCKWISE.
; 175mA @ + 5V and 250mA @ +7 volts.
; 130 * 4 lines of code rotates the shaft approx 360 degrees in 11 seconds.

; with no pause value the stepper just make a faint buzzing sound.
; with pause 5 @ 5 volts the torque is weak. current = 162mA.
; with pause 5 @ 7 volts the torque is stronger. Current = 235mA. 0-360 degrees 3 seconds.

let dirs =% 10111

main:
    For b1 = 1 to 130    
                ; 43210
    let pins =% 00101
    breaks 5
    let pins =% 10001
    breaks 5
    let pins =% 10010
    breaks 5
    let pins =% 00110
    breaks 5
    next b1

    For b1 = 1 to 130    
                 ; 43210
    let pins =% 10010
    breaks 5
    let pins =% 10001
    breaks 5
    let pins =% 00101
    breaks 5
    let pins =% 00110
    breaks 5
next b1
let pins =% 00000
 
Last edited by a moderator:

AllyCat

Senior Member
Hi Wrigley,

Are you using a different dialect (or language) of (PICaxe) Basic? The code above throws Syntax Errors (in PE5 and PE6) because of the use of BREAKS instead of PAUSE and the <space> character between all the % symbols and the (binary) digits. Also are you using (the equivalent of) the default SETFREQ M4, or another clock frequency, since the "numbers" don't look entirely consistent?

The normal reason for using Stepper Motors is that their movement should be totally "predictable", that's why they're used in Printers and Scanners, etc.. The 28BYJ-48 motor is specified to give (exactly) 4096 steps per revolution, yet your comments above and particularly another recent thread seem to have difficulties in reproducing or confirming that value. Certainly the term "steps" can be misleading, so I prefer to work in terms of "cycles", i.e. the periods of time that it takes for the pattern of coil currents to be repeated exactly. Generally there will be 4 or 8 steps per cycle, but more are possible. However, the "duty cycle" of the current pulses also can be changed; I believe your two versions of code have 75% and 100% duty cycles, but all values from (almost) 0% to 100% are possible.

Cheers, Alan.
 

Wrigley

Active member
Hi Alan
Thanks for your quick reply. I'm using normal English language as far as I know on pe6. Yes I noticed that after I pasted my code into (code)(code) the pause changed into break, text was shifted etc. I had to google how to do that (code/ code) etc not having done it before, maybe I made a mistake there.
I typed a comment "oops, pause changed to break" at the end of my text yesterday for you to see but those words have disappeared.

My project is making a Futaba radio control model tug boat and the steppers are controlling the movement & rotation of a crane on the deck and I haven't thought about duty cycle and 4096/rev etc. I wrote using practical trial and error to get the correct crane rotating speed bearing in mind mechanical stiffness and delays in the whole system program to overcome.
When I get the boat to final build I will move the crane by turning a knob on the Futaba transmitter. Picaxe's 18M2 will read the receiver pulses and drive steppers accordingly.

I've sent yesterdays two files again as attachments so you can see what I can in pe6, (but I haven't forgotten you prefer code insertion).

I pasted below part of the crane program showing clockwise and counter clockwise for the 28BYJ-48 STEPPER but WITHOUT cutting the +5 volt track so it still acts as a unipolar type. This rotates c/wise then cc/wise then stops. So I think I have the coding correct but ideas left me thinking I may be loosing a trick, for me to look into.
thanks Alan
Mike


starboard: ; stepper draws 415mA
For b1 = 1 to 130
let pinsb = %00010000 : pause 15 ; adjust to give the required crane rotation speed.
let pinsb = %00110000 : pause 15
let pinsb = %00100000 : pause 15
let pinsb = %01100000 : pause 15
let pinsb = %01000000 : pause 15
let pinsb = %11000000 : pause 15
let pinsb = %10000000 : pause 15
let pinsb = %10010000 : pause 15
next b

port:
For b1 = 1 to 130
let pinsb = %10000000 : pause 15
let pinsb = %11000000 : pause 15
let pinsb = %01000000 : pause 15
let pinsb = %01100000 : pause 15
let pinsb = %00100000 : pause 15
let pinsb = %00110000 : pause 15
let pinsb = %00010000 : pause 15
let pinsb = %10010000 : pause 15
next b
stop
 

Attachments

AllyCat

Senior Member
Hi,

Code is inserted between [ code] and [/code] tags as shown in the "Read me First" sticky thread (at the top). ;)

It seems that many people (and most YouTube videos) are quite happy just to make a stepper motor "Go around and around" but we can potentially do better! By their nature, stepper motors are quite limited in their maximum speed and torque (so shouldn't be used where these are important). However, it may be possible to reduce their power (current) drain, which might be useful for battery-powered applications such as yours?

To make testing faster and more convenient I would refine your program a little:

Code:
#picaxe 18M2     ;   To warn that this code will only work (unchanged) on some specific PICAXEs 
symbol pulse = 15
symbol overlap = 15
For b1 = 1 to 128
  pinsb = %00010000 : pause pulse ; adjust to give the required crane rotation speed.
  pinsb = %00110000 : pause overlap
  pinsb = %00100000 : pause pulse
  pinsb = %01100000 : pause overlap
  pinsb = %01000000 : pause pulse
  pinsb = %11000000 : pause overlap
  pinsb = %10000000 : pause pulse
  pinsb = %10010000 : pause overlap
next b1
Then you can quickly try changing the "pulse" and "overlap" values over a range of about 0 - 30. If their sum still adds up to 30, then the speed should be the same, but the average current should change over a range of about +/- 33% (a "duty cycle" range of 50% to 100%). The torque may change a little, but probably less than might be expected.

It may be possible to reduce the current drain even more by adding a symbol gap = 15 and changing all of the "overlap" lines to pinsb = %00000000 : pause gap . Again adjusting the symbol values could reduce the current to almost zero but obviously at some point the motor must stop. However, that may give a useful indication of how much "safety margin" you have in its operation, and maybe help save some battery drain. Note that if the "gap" or "overlap" is reduced to zero, the program becomes effectively "4 step" code, but I don't think the speed will change (if pulse = 30).

For bipolar steppers, I prefer to use HIGH port.pin and LOW port.pin commands because it is much easier to see what the program is actually doing. :)

Cheers, Alan.
 

Wrigley

Active member
Great information and creating symbols that can be altered easier during testing. Didn't think out of the box like that. Thanks I'll try these.
Mike
 

westaust55

Moderator
Hi Alan
Thanks for your quick reply. I'm using normal English language as far as I know on pe6. Yes I noticed that after I pasted my code into (code)(code) the pause changed into break, text was shifted etc. I had to google how to do that (code/ code) etc not having done it before, maybe I made a mistake there.
I typed a comment "oops, pause changed to break" at the end of my text yesterday for you to see but those words have disappeared.

Mike
Hello Mike/Wrigley,
Apologies in causing any problems.
I had seen that you had two "almost identical" posts both with presentation problems and had therefore:
1. removed one of the two posts - kept the seconds as it appears to be another attempt at posting the code
2. the code sections were within the [ quote ] segment and hence not displaying as code sections
3. at the end you had a line with [/code][/code][/code][/code][/quote][/code]

I had in editing your several previous posts sent you a message indicating that I had added the [ code] tags
Did you see any messages - believe there would have been an icon near your user name at the top of the forum pages.
 
Last edited:
Top