Hi.I got several 28BY J-48 bibolar stepper motors cheap on ebay and they are popular cos they are cheap
but they need pulsing with 4 phases every 2ms to rotate at max torque.
So this is a mega328p UNO solution.
I got the 1ms timer 0 demo and the timer calculator and got the values for 2ms,easy.
It uses vars forward,stop,reverse to control the motors.
The demo shows the motors running while wait command.
It is just a handler for these cheap geared stepper motors. https://www.youtube.com/watch?v=0eZFZsmpvR4&feature=youtu.be
;28BYJ-48bibolarstepperdriverfullwaveatevery2ms;thisusesportDfor2motors#chipmega328p,16#optionExplicitdiml_mot_pos,r_mot_posasbytediml_mot_dir,r_mot_dirasbyte#defineforward1;|#definereverse255;|--motordirection#definestop0;|l_mot_pos=1:r_mot_pos=1l_mot_dir=forward:r_mot_dir=forward;;setupsteppermotorinterruptsstepevery2msOnInterruptTimer0Match1CallmotorsDimOCR0ASbytealiasOCR0ADimTCCR0ASbytealiasTCCR0BWGM01=1'Timer in CTC mode - required 'Timer0Prescaler=64OCR0=124;2msTCCR0=0x28TCCR0=TCCR0or0x04;dol_mot_dir=forward:r_mot_dir=forwardwait5sl_mot_dir=reverse:r_mot_dir=reversewait5sl_mot_dir=reverse:r_mot_dir=forwardwait5sl_mot_dir=forward:r_mot_dir=reversewait5sloopsubmotorsifl_mot_dir=stopthensetportd.0off:setportd.1off:setportd.2off:setportd.3offelseifl_mot_dir=forwardthenl_mot_pos++ifl_mot_pos=5thenl_mot_pos=1endifelsel_mot_pos---ifl_mot_pos=0thenl_mot_pos=4endifendif;selectcasel_mot_poscase1setportd.0on:setportd.1on:setportd.2off:setportd.3offcase2setportd.0off:setportd.1on:setportd.2on:setportd.3offcase3setportd.0off:setportd.1off:setportd.2on:setportd.3oncase4setportd.0on:setportd.1off:setportd.2off:setportd.3onendselect;ifr_mot_dir=stopthensetportd.4off:setportd.5off:setportd.6off:setportd.7offelseifr_mot_dir=forwardthenr_mot_pos++ifr_mot_pos=5thenr_mot_pos=1endifelser_mot_pos---ifr_mot_pos=0thenr_mot_pos=4endifendif;selectcaser_mot_poscase1setportd.4on:setportd.5off:setportd.6off:setportd.7oncase2setportd.4off:setportd.5off:setportd.6on:setportd.7oncase3setportd.4off:setportd.5on:setportd.6on:setportd.7offcase4setportd.4on:setportd.5on:setportd.6off:setportd.7offendselectendsub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
'28BYJ_48_12F683_ver092.gcb'2017/1/3'A program to Run a 4096 step geared step motor 28BYJ-48'actuallythisisdoingfullstepmodeinwhich2coilsareactiveataTime' so it only has 2048 steps/turn (seems like a couple less)'Anotherarraycouldbebuilttodoeighthalfsteps'The outputs run a ULN2003 like supplied by so many chinese suppliers'TheinputPortGPIO.4hasapushbutton'Setup: routine allows the operator to align the shaft on start up'MainLoop:routinerotatesthemotoronefullturn'If you change the MainLoop in line 44 to MainLoop2 then it'willdemoa5station/positionpattern'by Mike Otte'2013'Chip model#chip 12F683, 8 dim Full(5) Full(0) = b'00000110' Full(1) = b'00000011' Full(2) = b'00001001' Full(3) = b'00001100''SetthepindirectionsdirGPIO.0out'These are wired to the uln2003 inputsdir GPIO.1 outdir GPIO.2 outdir GPIO.5 outdir GPIO.4 IN 'pushbuttoninputDimpositionasWord'Could be integer if we go below 0 positionposition =0'InitializepositionroutineSetup:' let motor turn until operator Pushes Button at home Position If GPIO.4 = 1 Then StepCW 'waitforbuttonpushIfGPIO.4=0Thenposition=0wait500msgotoMainLoop2' to demo 5 position end if goto Setup'OneturnMainLoop,getherefrom3linesabove,line44?MainLoop:'wait for button push If GPIO.4 = 1 Then goto MainLoop StepTo(2040) 'oneturnposition=0'resets position counter for next move wait 500 ms 'GivestimeforbuttonreleaseifonlyafewstepsgotoMainLoop' Example2: of going to 5 different positions and waiting for the button to be pushed'ButtonisapulldownMainLoop2:IfGPIO.4=1ThengotoMainLoop2IfGPIO.4=0Thenstation++Ifstation>5thenstation=1wait500msgotonewstationendifgotoMainLoop2newstation:Selectcasestationcase1StepTo(500)'station position 1 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase2StepTo(1500)'station position 2 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase3StepTo(2500)'station position 3 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase4StepTo(3000)'station position 4 wait 500 ms 'Givestimeforbuttonreleaseifonlyafewstepscase5StepTo(3100)'station position 5 wait 500 ms 'GivestimeforbuttonreleaseifonlyafewstepsendSelectgotoMainLoop2SubStepTo(newposasword)EnMotorDountilPosition=newposIfnewpos<positionthenStepCCWIfnewpos>positionthenStepCWloopDisEnMotorendsubSubEnMotordirGPIO.0outdirGPIO.1outdirGPIO.2outdirGPIO.5outendsubSubDisEnMotordirGPIO.0in'disables motor so it converves energy and don'theatupdirGPIO.1indirGPIO.2indirGPIO.5inendsubSubStepCWPosition++myStep=positionmod4thisStep=Full(myStep)GPIO.0=thisStep.0GPIO.1=thisStep.1GPIO.2=thisStep.2GPIO.5=thisStep.3wait2msendsubSubStepCCWPosition--myStep=positionmod4thisStep=Full(myStep)GPIO.0=thisStep.0GPIO.1=thisStep.1GPIO.2=thisStep.2GPIO.5=thisStep.3wait2msendsubEnd
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mike. These geared steppers and drivers seem popular,loads of youtube and guides.
I posted code for running them before but used a i2c port expander. I think running that and a i2c rangefinder would do my head.
As before I used an interrupt so the motors run at a constant most efficient speed.
Seems they can be run with halfwave,fullwave or a combo of both. Fullwave is simple and faster. Before I used the combo mode which is 8 different phases, more steps so slower rotation.
2ms is optimum rotation time. Any faster and they don't turn.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
SubDisEnMotordirGPIO.0in'disables motor so it converves energy and don'theatupdirGPIO.1indirGPIO.2indirGPIO.5inendsub
does gcb have portx=255 so you can set all bit in one go?
I don't think so or it would be easy to control these motors by just rotating the phase pattern left/right.
only 4 bits so 1 byte does 2 motors ie the port.
it would be portd= left phase + right phase * 8
if using 4 bits for each motor,
Hi Stan,
Here's another.
Astro photography require to move the camera as the Earth turns so you do not get "star trails". So a "Barn Door" tracker was built. Hinge on one end of two boards and a threaded rod turned by a motor on the other end. Mount the camera on the top board and screw the bottom board to a tripod. Then align the hinge pivot to the north star thus making a primative "equatorial mount". I did this with my Cannon 1000 and a 300 mm lens. Took some great pictures.
Hi.I got several 28BY J-48 bibolar stepper motors cheap on ebay and they are popular cos they are cheap
but they need pulsing with 4 phases every 2ms to rotate at max torque.
So this is a mega328p UNO solution.
I got the 1ms timer 0 demo and the timer calculator and got the values for 2ms,easy.
It uses vars forward,stop,reverse to control the motors.
The demo shows the motors running while wait command.
It is just a handler for these cheap geared stepper motors.
https://www.youtube.com/watch?v=0eZFZsmpvR4&feature=youtu.be
Hi Stan,
Here's mine.
Hi Mike. These geared steppers and drivers seem popular,loads of youtube and guides.
I posted code for running them before but used a i2c port expander. I think running that and a i2c rangefinder would do my head.
As before I used an interrupt so the motors run at a constant most efficient speed.
Seems they can be run with halfwave,fullwave or a combo of both. Fullwave is simple and faster. Before I used the combo mode which is 8 different phases, more steps so slower rotation.
2ms is optimum rotation time. Any faster and they don't turn.
mike
I send off to each port
does gcb have portx=255 so you can set all bit in one go?
I don't think so or it would be easy to control these motors by just rotating the phase pattern left/right.
only 4 bits so 1 byte does 2 motors ie the port.
it would be portd= left phase + right phase * 8
if using 4 bits for each motor,
Last edit: stan cartwright 2020-06-14
Hi Stan,
Here's another.
Astro photography require to move the camera as the Earth turns so you do not get "star trails". So a "Barn Door" tracker was built. Hinge on one end of two boards and a threaded rod turned by a motor on the other end. Mount the camera on the top board and screw the bottom board to a tripod. Then align the hinge pivot to the north star thus making a primative "equatorial mount". I did this with my Cannon 1000 and a 300 mm lens. Took some great pictures.
Pretty much only used the Battery switch, run switch and the limit switch.
New to me. https://nyxtech.us/products/nyx-tracker
That's it. mine is less refined and inexpensive.
That's it. mine is less refined and inexpensive.