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 : MM Driving a Stepper driven coil winder
Author | Message | ||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Hi All, Ron Pugh, One of our `less young' (I wont say senior -- Ohhh I just did) members has designed this coil winder that I helped him a bit with some basic code, along with Hugh Buckle, Video His Comments below, He has some issue with the MM and driving two steppers which is why he has used a commercial board to off load some work.. It was the maximite running a stepper motor where the timing problem shows up. One needs two precisely timed complimentary signals and the maxi does not co-operate. That is why I went to the 'Easy Driver', no more problem as the maxi then has to only provide the step signal, which it can do in its own time. Also the easy driver does current limiting to the stepper so I am running a 5 volt stepper on 12 volts while the current is limited to the motor rating, not an easy task for the Maxi. Great effort Ron, good to see the MM family doing real world stuff. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
ronee Newbie Joined: 08/01/2012 Location: CanadaPosts: 20 |
Thanks Mick You are being overly modest, the major portion of the code is Mick's work, much appreciated! Yes, we have the Maximite multi tasking. Just to clarify, when I point to the "PWM" in the video, these are the off board components, the opto coupler, the gate driver and the power mosfet, the Maxi is doing the actual PWM (sound out, white and blue wires) Then on start up the wire size and bobbin length are entered and the Maximite determines the number of steps needed for that size wire and how many winds before it needs to change direction. So this information, the number of steps and the direction are output to the Easy Driver which drives the stepper for the traverse. The brass wheel contains within it a ten pulse code wheel which is used to determine when and how many step pulses are needed. Separately the maximite takes every tenth pulse and counts these to provide a total number of turns. Some of the run up work including schematics, is in the Library, see coil winder. This is the culmination. Hugh will enter the code in this file, thanks Hugh. I am using a mini PS2 keyboard so it matches the small monitor size wise, here is what is under the keyboard... Ron |
||||
shoebuckle Senior Member Joined: 21/01/2012 Location: AustraliaPosts: 189 |
Here is the code. It will be in the next library update. Mick did most of the code. I just helped with a mod to cater for the rounding error in the turns count. Cheers, Hugh 10 '---------------------------------
20 ' Coil Winder by Ron Pugh 30 ' Version 2 2012 40 ' With programming assistance from 50 ' Mick Gulovsen and Hugh Buckle 60 '--------------------------------- 70 ' PWMs.bas using Sound output pin 80 ' Plus number of turns (total count) 90 Cls 100 Font #2 110 Input"Enter Wire Dia (in Thou)";dia 120 Input"Enter Bobbin Length (in Thou)";bobbin 130 ' steps per wire thickness calculation 140 ' assumptions 150 ' 200 pulses per rotation on stepper 160 ' 10 rotations per inch stepped 170 ' Direction starts with 0 then goes to 1 180 No_Puls=Cint(dia*2/10) ' No of Pulses per 1/10th rotation 190 Puls_Fr = dia*2/10 - No_Puls ' saves the fractional part of an extra rotation 200 Max_puls=bobbin*2 : Puls_Cnt=0 210 SetPin 1,8 : Pin(1)=0' set pin 1 for Stepper pulses and init as LOW 220 SetPin 2,8 : Pin(2)=0 : Dir_stat=0 ' set pin 2 for Direction and init as 0 230 Cls 240 Line(100, 100) - (250, 150), 1, B1 250 Font 2 : Print@(120, 120) "Speed %" 260 Line(300, 100) - (400, 150), 1, B2 270 Line(100, 250) - (250, 300), 1, B3 280 Font 2 : Print@(105, 270) "Turns Count" 290 Line(300, 250) - (400, 300), 1, B4 300 GoSub 810 310 SetPin 11,5 320 Duty = 30 ' init to 30/70 PWM 330 Sound 200, 2000000, Duty ' 200 Hz duration about 33 minutes 30 % duty 340 Font #2 ' big print 350 I$=Inkey$ : If I$="" Then GoTo 470 'Test for keyboard input until key press 360 If I$="z" Then Duty = 20 : Print @(320, 120) " 20" : GoTo 440 370 If I$="x" Then Duty = 30 : Print @(320, 120) " 30" : GoTo 440 380 If I$="c" Then Duty = 40 : Print @(320, 120) " 40" : GoTo 440 390 If I$="v" Then Duty = 50 : Print @(320, 120) " 50" : GoTo 440 400 If I$="b" Then Duty = 60 : Print @(320, 120) " 60" : GoTo 440 410 If I$="n" Then Duty = 75 : Print @(320, 120) " 75" : GoTo 440 420 If I$="m" Then Duty = 100 : Print @(320, 120) "100" : GoTo 440 430 GoTo 350 440 Sound 200, 2000000, Duty 450 GoTo 340 460 'A=PIN(11) 470 If Pin(11)=A Then 480 GoTo 350 490 Else 500 ' As the calc Cint(dia*2/10) will usually result in a remainder, 510 ' here we accumulate the error and add an extra turn when the 520 ' accumulated error is greater than or equal to 1 530 Accum_Puls_Fr = Accum_Puls_Fr + Puls_Fr 540 If Accum_Puls_Fr >= 1 Then 550 Pulses = No_Puls + 1 560 Accum_Puls_Fr = Accum_Puls_Fr - 1 570 Else 580 Pulses = No_Puls 590 EndIf 600 For X=1 To Pulses 610 Pin(1)=1 620 Pause .2 630 Pin(1)=0 640 Pause .7 650 GoSub 720 660 Next x 670 A=Pin(11) 680 EndIf 690 Font 2 700 Print @(320,270)Int(A/10) 710 GoTo 350 ' go back to check for key press 720 ' 730 puls_Cnt=Puls_Cnt+1 740 If Puls_Cnt>Max_Puls Then 750 Dir_stat=Not(Dir_stat) 760 Pin(2)=Dir_stat 770 GoSub 810 780 Puls_cnt=Puls_cnt-Max_puls 790 EndIf 800 Return 810 ' 820 Print@(150, 375) " "; 830 If Dir_stat=0 Then Print "RIGHT ------->"; Else Print"<------- LEFT "; 840 Return |
||||
Print this page |