CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Electronics > PIC Programing / Design


PIC Programing / Design Discuss programing of PIC chips here and design of electronics using PIC chips.


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 09-30-2008, 08:49 AM
 
Join Date: Apr 2007
Location: Brazil
Posts: 10
Bomber-eng is on a distinguished road
Control Stepper Drive if PIC?

Good morning.
I would like to know how to generate a routine to control a stepper motor drive with the logic of pulses using a PIC18F.
Would someone have some routine to generate these pulses?
I am having difficulties in creating this routine.
I'm using a Geckodrive G203V.

Pleased I need this information as soon as possible....

Thanks for your attention....
Tweet this Post!Share on Facebook
Reply With Quote

  #2   Ban this user!
Old 10-02-2008, 04:19 PM
 
Join Date: Feb 2006
Location: US
Posts: 72
extrapilot is on a distinguished road

Much more information is needed here-
Which 18F MCU would be a start... And, what is the target application? Just one drive, or multiple? And do you want to generate the drive data internally (i.e. robot), or is this an intermediate/translator, etc?

Generating a TTL logic pulse from most any 18F part is trivial. All you have to do is set the TRIS for the pins in question to Output, and then toggle the values for the given port (i.e. PORTE.0 = 1, PORTE.0 = 0). You may also have to disable other peripherals on the port(s) in question- depending on the PIC variant and the port.

You can do that in a timer interrupt routine, or just in the main loop, etc. If you have a motor control PIC (2430 etc) then you have access to some native functionality for HBridge driving, which you could probably use with the 203V just in terms of simplifying step frequency and pulse width.

Are you using a high-level compiler? If so, which?

R
Tweet this Post!Share on Facebook
Reply With Quote

  #3   Ban this user!
Old 10-03-2008, 06:45 AM
 
Join Date: Apr 2007
Location: Brazil
Posts: 10
Bomber-eng is on a distinguished road
Steps....

Actually must generate 400 different speeds for the stteper driver.
Every time I work in a pre determined speed. I tried in TIMER_0 generate a table with the frequencies and running, but when you increase the routine of my program this routine change, changing the frequency of work.
I would like to generate pulses to control properly the speed of the step motor using a PIC 18F in any pin if a 20MHz XTAL.
I do not know how to do a routine to generate these pulses to control the GECKODRIVE G203 with accuracy without the PIC is slow.
I`m so sorry about my english.

Thank's
Tweet this Post!Share on Facebook
Reply With Quote

  #4   Ban this user!
Old 10-03-2008, 07:15 PM
 
Join Date: Feb 2006
Location: US
Posts: 72
extrapilot is on a distinguished road

Bomber
I dont think I understand your application. If you are saying that you have 1 of 400 defined frequencies to use per job, your only issue is 'how to tell the pic which frequency you want.' The PIC 18F family have some devices that are designed specifically for motor control. I believe the 18F2431 and 18F4431 are the more capable in that family. These have dedicated PWM modules, which simplify the methods of controlling both the period (frequency) and duty cycle of an output, but the module also manages additional pins so that you can manage hbridge or stepper drivers without concern for output faults (i.e. having opposite sides of an HBridge enabled at the same time).

But you can emulate this in code. Generally, the PIC just leverages a timer and an interrupt for this type of application. So you set the timer value to whatever your period needs to be (timer is a function of the Xtal frequency remember). Then when the timer is started, it counts down to 0, and throws an interrupt. Your interrupt modifies the pin state (high to low, etc), resets the timer value, clears the interrupt, and restarts the timer. So, that process will repeat, and the frequency is determined by the timer value you set, and any timer prescalers or postscalers you set.

There is lots of sample code on the Microchip website (forums). It is not difficult to implement, but if you are new to Interrupts, you need to look at some sample code (since there are some specific details regarding clearing flags, disabling interrupts, etc that are not obvious to someone new to it).

Regarding 'how' to set one of 400 frequencies- It seems to me there are a number of options. One would be some serial link (RS232 is easy)- where you just send a command which contains the new timer value to use. There are other options (like a keypad for direct entry of commands, or just sampling a pot via the ADC converted- so you could twist a control dial to change the frequency)- but that would require a little more code to interpret the keypress or ADC values, and to confirm the setting somehow (maybe a serial LCD panel, or some beep code, or 7-segment LED displays, etc). It really just comes down to the application requirement- the PIC can do any of these things with no difficulties.

R
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 10-06-2008, 09:58 AM
 
Join Date: Apr 2007
Location: Brazil
Posts: 10
Bomber-eng is on a distinguished road

Good Morning Extrapilot.

I will try to explain better what I want to do.
I would like to generate the pulses to control the speed of Geckodrive G230. I can enable and disable the brake and change direction of spin easily. But I can not generate an exact routine for each speed. Because many frequencies to vary
I am sending two links below to demonstrate the operation of these drives:

http://www.geckodrive.com/upload/Step_motor_basics.pdf
http://www.geckodrive.com/upload/G203V-REV-6-MANUAL.pdf

Each frequency of a square wave below, is a set speed of my step motor:

Frequency(Hz):
0
3,1
6,2
9,4
12,5
15,6
18,7
21,8
25,0
28,1
31,2
34,3
37,4
40,6
43,7
46,8
49,9
53,1
56,2
59,3
62,4
65,5
68,7
71,8
74,9
78,0
81,1
84,3
87,4
90,5
93,6
96,7
99,9
103,0
106,1
109,2
112,3
115,5
118,6
121,7
124,8
127,9
131,1
134,2
137,3
140,4
143,6
146,7
149,8
152,9
156,0
159,2
162,3
165,4
168,5
171,6
174,8
177,9
181,0
184,1
187,2
190,4
193,5
196,6
199,7
202,8
206,0
209,1
212,2
215,3
218,4
221,6
224,7
227,8
230,9
234,1
237,2
240,3
243,4
246,5
249,7
252,8
255,9
259,0
262,1
265,3
268,4
271,5
274,6
277,7
280,9
284,0
287,1
290,2
293,3
296,5
299,6
302,7
305,8
308,9
312,1
315,2
318,3
321,4
324,6
327,7
330,8
333,9
337,0
340,2
343,3
346,4
349,5
352,6
355,8
358,9
362,0
365,1
368,2
371,4
374,5
377,6
380,7
383,8
387,0
390,1
393,2
396,3
399,4
402,6
405,7
408,8
411,9
415,1
418,2
421,3
424,4
427,5
430,7
433,8
436,9
440,0
443,1
446,3
449,4
452,5
455,6
458,7
461,9
465,0
468,1
471,2
474,3
477,5
480,6
483,7
486,8
489,9
493,1
496,2
499,3
502,4
505,6
508,7
511,8
514,9
518,0
521,2
524,3
527,4
530,5
533,6
536,8
539,9
543,0
546,1
549,2
552,4
555,5
558,6
561,7
564,8
568,0
571,1
574,2
577,3
580,4
583,6
586,7
589,8
592,9
596,1
599,2
602,3
605,4
608,5
611,7
614,8
617,9
621,0
624,1
627,3
630,4
633,5
636,6
639,7
642,9
646,0
649,1
652,2
655,3
658,5
661,6
664,7
667,8
670,9
674,1
677,2
680,3
683,4
686,6
689,7
692,8
695,9
699,0
702,2
705,3
708,4
711,5
714,6
717,8
720,9
724,0
727,1
730,2
733,4
736,5
739,6
742,7
745,8
749,0
752,1
755,2
758,3
761,4
764,6
767,7
770,8
773,9
777,1
780,2
783,3
786,4
789,5
792,7
795,8
798,9
802,0
805,1
808,3
811,4
814,5
817,6
820,7
823,9
827,0
830,1
833,2
836,3
839,5
842,6
845,7
848,8
851,9
855,1
858,2
861,3
864,4
867,6
870,7
873,8
876,9
880,0
883,2
886,3
889,4
892,5
895,6
898,8
901,9
905,0
908,1
911,2
914,4
917,5
920,6
923,7
926,8
930,0
933,1
936,2
939,3
942,4
945,6
948,7
951,8
954,9
958,1
961,2
964,3
967,4
970,5
973,7
976,8
979,9
983,0
986,1
989,3
992,4
995,5
998,6
1001,7
1004,9
1008,0
1011,1
1014,2
1017,3
1020,5
1023,6
1026,7
1029,8
1032,9
1036,1
1039,2
1042,3
1045,4
1048,6
1051,7
1054,8
1057,9
1061,0
1064,2
1067,3
1070,4
1073,5
1076,6
1079,8
1082,9
1086,0
1089,1
1092,2
1095,4
1098,5
1101,6
1104,7
1107,8
1111,0
1114,1
1117,2
1120,3
1123,4
1126,6
1129,7
1132,8
1135,9
1139,1
1142,2
1145,3
1148,4
1151,5
1154,7
1157,8
1160,9
1164,0
1167,1
1170,3
1173,4
1176,5
1179,6
1182,7
1185,9
1189,0
1192,1
1195,2
1198,3
1201,5
1204,6
1207,7
1210,8
1213,9
1217,1
1220,2
1223,3
1226,4
1229,5
1232,7
1235,8
1238,9
1242,0
1245,2
1248,3

I am having difficulties in generating these frequencies with the PIC18F4685. Got it?

I`m so sorry about my english.

Thank's one more time.
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 10-06-2008, 05:10 PM
 
Join Date: Feb 2006
Location: US
Posts: 72
extrapilot is on a distinguished road

Bomber-
Your English is much better than my Portuguese, so please do not worry about that!

I have several 203V drives here, and am familiar with their workings- great hardware.

If you do not have a transfer function (i.e. an equation that will output the value based on some simple input), then you will need to setup a lookup table. Normally, that is done using a memory array, so that you would have a cell ID and a value (predefined). It could look just like your example data, with the first column being the cell (row) identifier, and the second the value.

So in the array, if you lookup row 18, you will see value '7' stored there. Now, I dont understand how the numbers you defined function- it appears that the first number is just an increment of 3 over the previous, and the second is some value between 0-9. So how this yields 400 frequencies I am not sure.

Regardless, in my example, you can setup an array and then define the appropriate values as constants. Then, you need to determine 'how' you will communicate with the PIC to tell it which row to use for its new frequency. As I mentioned in an earlier message, there are many ways to communicte with a PIC- so that depends on your requirements. Often, RS232 is the most simple, but there are USB-RS232 converter chips from FTDI that make USB very easy to implement. You could also use a native USB-capable PIC (like the 18F4550), but they are memory constrained.

Do you have a development board you are using? Have you selected a compiler? If not, have a look at Mikroelectronica, they have some very functional development boards, and a compiler you can download for free (just has some limits on the size of the code you compile, but should not be a problem for your app, or at least for testing a smaller array table). There is also lots of sample code included, and on the support forums regarding PWM setup, constant arrays, RS232, etc.

Best,
Rob
Tweet this Post!Share on Facebook
Reply With Quote

  #7   Ban this user!
Old 10-07-2008, 07:59 AM
 
Join Date: Apr 2007
Location: Brazil
Posts: 10
Bomber-eng is on a distinguished road

Good Morning Rob!

I`m using CCS compiler to do my program. And a dedicate circuit to control a drive.

Could you please pass your e-mail? So I send the source code to which I have done for their better understanding of what I am doing. But there is a slight problem in my source code, the comments are in Portuguese .....

Thanks again for your help and attention.
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 10-07-2008, 05:59 PM
 
Join Date: Feb 2006
Location: US
Posts: 72
extrapilot is on a distinguished road

Bomber- sent you a private message with my email and some questions-
Tweet this Post!Share on Facebook
Reply With Quote

  #9   Ban this user!
Old 10-08-2008, 06:57 AM
 
Join Date: Apr 2007
Location: Brazil
Posts: 10
Bomber-eng is on a distinguished road

Thank you for your attention and sent an email to you.
Thanks for everything so far.
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Control: USB Thumb Drive 'ejecting'? Donkey Hotey Haas Mills 35 12-12-2009 06:13 PM
DC motor drive control jedcam67 General Electronics Discussion 3 06-03-2007 04:53 PM
Reconfiguring Yaskawa Drive for Position Control? rpseguin Servo Motors and Drives 13 10-31-2006 08:09 PM
difference between a stepper indexer and a stepper drive pcroxford Stepper Motors and Drives 0 11-02-2005 08:35 AM
Control Technique Digitax DBE 750 AC Servo-Drive GalaticDan Servo Motors and Drives 6 09-16-2005 07:32 AM




All times are GMT -5. The time now is 06:55 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

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