Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Stepper Motors
Page 2 of 2 | |||||
Author | Message | ||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
The code I now have. SETPIN 15,DOUT SETPIN 16,DOUT SETPIN 17,DOUT SETPIN 18,DOUT dim FWD%(3)=(&b0110,&b0101,&b1001,&b1010) dim REV%(3)=(&b1010,&b1001,&b0101,&b0110) do fOR x = 1 to 250 ' half a revolution FWD FOR STP=0 TO 3 'CW rotation PORT(15,4)=FWD%(STP) PAUSE 5 'increase PAUSE value to SLOW rotation. NEXT STP next x Pause 50 for y = 1 to 250 ' half a revolution REV FOR STP=0 TO 3 'CW rotation PORT(15,4)=REV%(STP) PAUSE 10 'increase PAUSE value to SLOW rotation. NEXT STP next y LOOP Two problems, with a Pause of 5 the motor does not turn, I can feel it trying but no go. I have to increase the Pause to 10, it then goes but too slowly but it does not reverse. I thought that by reversing the values the motor would reverse. This stepper motor is geared down by 64:1, maybe the motor wont turn it fast enough for the speed I want. At the moment the shaft turns once in about 20 seconds. Edit.... Looking at the code again I dont think I can use the port command I will try the old code. Edited 2023-07-28 13:11 by palcal "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
circuit Senior Member Joined: 10/01/2016 Location: United KingdomPosts: 245 |
Your assumption is not quite correct; stepper motors come in an enormous range of sizes. "Real" stepper motors that are tiny are to be found in cameras where they operate the aperture diaphragm, in camera lenses where they achieve focus and so forth. VERY tiny stepper motors are common in wristwatches. The stepper motor inside the 28BYJ-48 IS a proper stepper motor, just one that is designed to drive a miniature high-ratio gearbox. The large scale of manufacturing in China keeps the price low, but yes, the quality somewhat variable. |
||||
Revlac Guru Joined: 31/12/2016 Location: AustraliaPosts: 1026 |
@Hans, That turntable looks Good , mostly 3D printed, I run G Scale, a large turn table could be done much the same way I would think, having to pick up a large Loco or wagon by hand to turn it around the other way is not ideal or fun. Would like to see some of your build and ideas some time if you would like, I expect it would need another thread. Cheers Aaron Off The Grid |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4247 |
pascal, when changing direction on the stepper motor, you should continue from the place you stopped. forward STP=0 STP=1 SPT=2 stop (wait 0.1 sec) reverse STP=1 (backward from where you sttopped at step 2) STP=0 STP=3 STP=2 I think you stepper motor is a 5V device. You can (at cost of heat) speed it up (so it may be able to do the 5ms pause) when you connect it to a higher voltage. But to prevent the windings burn out, you have to limit the current the the maximum the motor can handle. This is often performed by connecting the motor via a resistor. The resistor must have the right value for maximum speed gain, and minimum heat in the motor. Volhout P.S. some motor drivers use PWM to emulate the resistor in a loss-less configuration. P.P.S. if you vary the PAUSE time you may be able to achieve higher speeds. Start slow (PAUSE=20, then 18,, then 16, then 14 etc...) and at every step (STP value) make the PAUSE shorter until the motor stops advancing. You may find a value that is better than 10 for maximum speed. Each time you reverse, or start rotation, follow that sequence. Edited 2023-07-28 20:25 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4247 |
Pascal, This should work for you (note I used different IO pins. Change these back to your setup...) 'interface definition SetPin 4,DOUT SetPin 5,DOUT SetPin 6,DOUT SetPin 7,DOUT Dim FWD%(3)=(&b0110,&b0101,&b1001,&b1010) 'motor parameters, change these for your motor curve = 0.95 'this is acceleration parameter maxspeed = 5 minspeed = 20 'initial state STP=0 'the movement Do 'move forward speed=minspeed For x = 1 To 250 ' half a revolution FWD STP=(STP+1) Mod 4 ' CW rotation Port(4,4)=FWD%(STP) speed = Max(speed*curve, maxspeed) Pause speed ' dynamic PAUSE value controls rotation. Next x Pause 100 'move reverse speed=minspeed For x = 1 To 250 ' half a revolution REV STP=(STP+3) Mod 4 ' CCW rotation (SPT+3 is equal to STP-1) Port(4,4)=FWD%(STP) speed = Max(speed*curve, maxspeed) Pause speed ' dynamic PAUSE value controls rotation. Next x Pause 100 Loop P.S. the trick with STP+3 equals STP-1 is that it does the same, but never gets negative. P.P.S. you should adapt the motor specific parameters to get the best out of your motor. Edited 2023-07-28 21:09 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Hans Senior Member Joined: 18/10/2022 Location: CanadaPosts: 116 |
Hi Aaron; Yes, a new thread would be better. It probably wasn’t a good idea to post on someone else’s thread, sorry guys, but it was related to the same stepper that palcal was using. This turntable is all 3-D printed on an FDM printer Creality 3. I also have an Elegoo Mars Pro resin printer. The contact me page doesn’t seem to be working as I was going to contact the forum manager to ask if there was a way to create a model train Electronics specific forum. That might have some interest to a number of people I know. Hans … |
||||
DaveJacko Regular Member Joined: 25/07/2019 Location: United KingdomPosts: 76 |
Hans wanted to know about this stepper board... have a look for this on ebay, to get you started. "CNC Shield V3 - A4988 Stepper Motor Driver Expansion Board for RepRap 3D Printer" quite a nice litle board that carries up to 4 stepper drives regs |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
@Volhout That code does not run the motor at all, I can feel it trying and I also feel it when it tries to reverse but no movement. With my code I can get it to run CW but not CCW. Edited 2023-07-29 07:42 by palcal "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2137 |
"Other Stuff" page sometimes has model railway threads. |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
@ Volhout I have managed to get the motor to run with your code by commenting out the line speed = Max(speed*curve, maxspeed) and setting the speed to 10. But it only travels clockwise it does not reverse. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
@ Volhout I have it working finally using a different step sequence. There was no information with the motor so I went by a magazine article that appeared to use the same motor. There is a lot of information for Arduino but Arduino code and Chinese are very similar to me. So after a lot of searching I found this Full Step sequence &b1000,&b0100,&b0010,&b0001 It works, It just needs some work on the speed. There is another sequence I will try tomorrow &b1001,&b1100,&b0110,&b0011 "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4247 |
Pascal, I know where it went wrong. The patterns is closely tied to how the coils are connected to the io pins. Good that you found a working pattern Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
The annoying thing is, I had one of these running some time ago and I've been looking for the code. I can't find it, but I know it's on a SD card somewhere.... IIRC I modified the recommended code for the Arduino "experimenter" kit. They aren't too horrible as long as you don't want accurate positioning or a decent speed. :) Good for experimenting with as the supplied driver board has LEDs and the motor shaft isn't running too fast so you can see what's happening. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
@ Volhout, Thanks for your help "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Page 2 of 2 |
Print this page |