View Single Post
  #9   Ban this user!
Old 01-30-2005, 05:44 PM
Swede's Avatar
Swede Swede is offline
 
Join Date: Dec 2003
Location: United States
Posts: 383
Swede is on a distinguished road

Hi again Darren,

I never had any problem with the motors going too slow! There may be hardware differences between our setups. The little CNC machine I made used two 200 step 5.25" floppy drive motors in an electronic gearing configuration. Each motor used a "Ramsey" hobby-kit stepper motor board, capable of 500mA. I don't remember the chip, but to get the motor to move required two things - first, the chip's ENABLE line was taken high and left there. The chip then had more logic options - one line was half/full step; another was CW/CCW. Finally, to actually make the motor take a step, I took a CLOCK line high, then low. The act of toggling the clock line actuated the chip and thus the stepper.

It seemed that the chip was quite fast... I did not have to "hold" the CLOCK high for any length of time, simply cycling the clock high/low did the trick.

'Where bit 4 is the clock
'Take CLOCK high:
Result = Out (Addr, 1111 0000)

'Take CLOCK Low:
Result = Out (Addr, 1110 0000)

These two lines back to back would step the motor. I was using VB6, compiled, not interpreted. The speed of the motor was regulated then by whatever software delays I created between CLOCK pulses. I found to my irritation that a standard timer control was too slow, and without using the Win32 API, just wanting to get the project done, I executed a nested FOR:NEXT loop, varying the duration of the loop. This worked great on an old Pentium 2 computer. Of course, when I moved the software to a 2.6 gig P4, the motors screamed and lost steps!

I rewrote the code, using handy CONSTs to better time the system. It ultimately worked out OK.

You sound like a fairly advanced VB guy... if you haven't done so already, I would recommend creating a TYPE variable, something like so:

Type MotorVar
Name As String * 32 'User Definable name
PosAbsolute As Long 'Absolute Motor Position
PosRelative As Long 'Relative Motor Position
Target As Long 'Target Position
StepType As Long 'Half or full step
Direction As Long 'FORWARD or REVERSE
Delay As Long 'Looping Delay for motor
Slope As Long 'Ramp, higher = slower
SlopeReg As Long 'Temp math register
BitPattern(0 To 1) As Integer 'Value written to PortAddr
End Type

It makes dealing with the motors MUCH easier overall.

This has been a lengthy post... I don't know if I've been much help. If you'd like, PM me and I will send you the whole project, saved for VB6. The code is well commented and decently structured. There may be some tidbits that might be of use, especially the ramping aspects which were pretty tough.

Again, Good luck!

Swede
Reply With Quote

 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361