AnsweredAssumed Answered

vrf Stepping Motor Control (for dummies) any examples?

Question asked by WDrago on Feb 4, 2005
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45"><TITLE>RE: [vrf] RE: Stepping Motor Control (for dummies) any examples?</TITLE></HEAD><BODY><P><FONT SIZE=2>Hi Phil,</FONT></P><P><FONT SIZE=2>Well, how do you define accurate?</FONT></P><P><FONT SIZE=2>My application needed somewhat accurate pulse trains to</FONT><BR><FONT SIZE=2>control the speed of a robotic welder. Too fast and the</FONT><BR><FONT SIZE=2>weld is weak and leaks. Too slow and you burn through.</FONT></P><P><FONT SIZE=2>I controlled the welder steppers by bit-banging a pulse</FONT><BR><FONT SIZE=2>train through a Measurement Computing digital I/O board.</FONT></P><P><FONT SIZE=2>I didn't use a timer on the mother board. All I did</FONT><BR><FONT SIZE=2>was calibrate my delay loops. That is....</FONT></P><P><FONT SIZE=2>I made a function called Delay(). Delay(8) will</FONT><BR><FONT SIZE=2>pause program execution for 8 milliseconds for example.</FONT><BR><FONT SIZE=2>Delay() works by going into a loop for the req'd number</FONT><BR><FONT SIZE=2>of iterations to achieve the desired delay.</FONT></P><P><FONT SIZE=2>How does Delay() know how many iterations to loop through?</FONT><BR><FONT SIZE=2>Glad you asked. To calibrate that, when my program starts it</FONT><BR><FONT SIZE=2>runs a 1,000,000 iteration loop and times how long that takes</FONT><BR><FONT SIZE=2>using the built-in VEE timer function.</FONT></P><P><FONT SIZE=2>Say it takes 10 seconds to do that many iterations. That means</FONT><BR><FONT SIZE=2>each iteration takes 10/1,000,000 or 0.00001S. So, if you wanted</FONT><BR><FONT SIZE=2>a 1mS delay you would loop 100 times.</FONT></P><P><FONT SIZE=2>To bit-bang a 1kHz pulse train containing 1500 pulses:</FONT></P><P><FONT SIZE=2>Set bit low   ;start with control bit low</FONT></P><P><FONT SIZE=2>Loop 1500 times</FONT></P><P><FONT SIZE=2>   set bit high   ;set control bit high</FONT><BR><FONT SIZE=2>   delay(0.5)     ;wait half a millisecond</FONT></P><P><FONT SIZE=2>   set bit low    ;set control bit low</FONT><BR><FONT SIZE=2>   delay(0.5)     ;wait half a millisecond</FONT></P><P><FONT SIZE=2>End Loop</FONT></P><P><FONT SIZE=2>Okay, though out this entire email I've been hearing</FONT><BR><FONT SIZE=2>laughs, giggles and snickers from the audience.</FONT></P><P><FONT SIZE=2>Yes, you're not supposed to be able to do this with Windoz.</FONT><BR><FONT SIZE=2>Well guess what? It works surprisingly well in my application.</FONT><BR><FONT SIZE=2>It was CHEAP and EASY and the client is happy.</FONT></P><P><FONT SIZE=2>Nothing else runs on the system driving the welder--That would be bad.</FONT><BR><FONT SIZE=2>No one touches the mouse while a weld is in progress--that would</FONT><BR><FONT SIZE=2>be really bad.</FONT></P><P><FONT SIZE=2>Granted, this is not the best solution. My client was in a jam</FONT><BR><FONT SIZE=2>when their welder broke down and this was the fastest way to</FONT><BR><FONT SIZE=2>get them back in business. My system replaced their old, dedicated</FONT><BR><FONT SIZE=2>welder controller and gave them some features they never had.</FONT></P><P><FONT SIZE=2>Since that time I have used the same technique with great success</FONT><BR><FONT SIZE=2>in various other apps that require "accurate" pulse trains.</FONT></P><P><FONT SIZE=2>Don't knock it until you've tried it.</FONT></P><P><FONT SIZE=2>Bill</FONT></P><BR><P><FONT SIZE=2>> -----Original Message-----</FONT><BR><FONT SIZE=2>> From: Phil Vossler [<A HREF="mailto:P.J.Vossler@exeter.ac.uk">mailto:P.J.Vossler@exeter.ac.uk</A>]</FONT><BR><FONT SIZE=2>> Sent: Friday, February 04, 2005 4:06 AM</FONT><BR><FONT SIZE=2>> To: VRF</FONT><BR><FONT SIZE=2>> Subject: [vrf] RE: Stepping Motor Control (for dummies) any examples?</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> Is there a way of creating a fast accurate pulse train with Vee? </FONT><BR><FONT SIZE=2>> Supposing I wanted to step a drive controller (one that uses </FONT><BR><FONT SIZE=2>> step pulses </FONT><BR><FONT SIZE=2>> and a direction line) using 1mS pulses at 1kHz. Is Vee capable of </FONT><BR><FONT SIZE=2>> sending out a predetermined number of pulses at a particular </FONT><BR><FONT SIZE=2>> frequency? </FONT><BR><FONT SIZE=2>> Assuming that we just have a simple digital i/o card and Vee has to </FONT><BR><FONT SIZE=2>> toggle the step line directly.....</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> I guess what I really want to know is whether Vee can make </FONT><BR><FONT SIZE=2>> use of any of </FONT><BR><FONT SIZE=2>> the timer/counters on a motherboard there a way of creating a fast </FONT><BR><FONT SIZE=2>> accurate pulse train with Vee? Supposing I wanted to step a drive </FONT><BR><FONT SIZE=2>> controller (one that uses step pulses and a direction line) using 1mS </FONT><BR><FONT SIZE=2>> pulses at 1kHz. Is Vee capable of sending out a predetermined </FONT><BR><FONT SIZE=2>> number of </FONT><BR><FONT SIZE=2>> pulses at a particular frequency? Assuming that we just have a simple </FONT><BR><FONT SIZE=2>> digital i/o card and Vee has to toggle the step line directly.....</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> I guess what I really want to know is whether Vee can make </FONT><BR><FONT SIZE=2>> use of any of </FONT><BR><FONT SIZE=2>> the timer/counters on a motherboard to generate an accurate </FONT><BR><FONT SIZE=2>> pulse train </FONT><BR><FONT SIZE=2>> and thats getting into real-time territory. Even so I'd be </FONT><BR><FONT SIZE=2>> interested to </FONT><BR><FONT SIZE=2>> hear what people have done in this area.</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> regards</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> Phil Vossler</FONT><BR><FONT SIZE=2>> School of Physics</FONT><BR><FONT SIZE=2>> University of Exeter</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> Drago, William @NARDAEAST wrote:</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> > Hello Tapio,</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > I wrote some vee code a while back to control 3 stepper motors.</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > I used a digital I/O card from Measurement Computing and</FONT><BR><FONT SIZE=2>> > bit-banged the stepper driver directly.</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> rd to generate an accurate pulse train and thats getting into </FONT><BR><FONT SIZE=2>> real-time </FONT><BR><FONT SIZE=2>> territory. Even so I'd be interested to hear what people have done in </FONT><BR><FONT SIZE=2>> this area.</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> regards</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> Phil Vossler</FONT><BR><FONT SIZE=2>> School of Physics</FONT><BR><FONT SIZE=2>> University of Exeter</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> Drago, William @NARDAEAST wrote:</FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> > Hello Tapio,</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > I wrote some vee code a while back to control 3 stepper motors.</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > I used a digital I/O card from Measurement Computing and</FONT><BR><FONT SIZE=2>> > bit-banged the stepper driver directly.</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > It's not that hard to do. If you know the motor has 256 </FONT><BR><FONT SIZE=2>> steps/revolution,</FONT><BR><FONT SIZE=2>> > and you want to go 1/4 turn clockwise it is a simple matter to</FONT><BR><FONT SIZE=2>> > calculate how many pulses to send (256/4 = 64), and to control the </FONT><BR><FONT SIZE=2>> > direction</FONT><BR><FONT SIZE=2>> > bit, either high or low. You'll also have to keep track of </FONT><BR><FONT SIZE=2>> the number of</FONT><BR><FONT SIZE=2>> > pulses you send in each direction so that you'll always </FONT><BR><FONT SIZE=2>> know where the </FONT><BR><FONT SIZE=2>> > motor is.</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > In my application there was a micro switch at the end of </FONT><BR><FONT SIZE=2>> each shaft. </FONT><BR><FONT SIZE=2>> > The first</FONT><BR><FONT SIZE=2>> > thing my software does is run the motor until switch closes, then I </FONT><BR><FONT SIZE=2>> > know it's "home."</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > I could send you my code, but I think you'd be better off </FONT><BR><FONT SIZE=2>> writing your </FONT><BR><FONT SIZE=2>> > own.</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > Good luck,</FONT><BR><FONT SIZE=2>> > Bill</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > > -----Original Message-----</FONT><BR><FONT SIZE=2>> > > From: tapio.ronkainen@nokia.com [<A HREF="mailto:tapio.ronkainen@nokia.com">mailto:tapio.ronkainen@nokia.com</A>]</FONT><BR><FONT SIZE=2>> > > Sent: Thursday, February 03, 2005 3:17 AM</FONT><BR><FONT SIZE=2>> > > To: VRF</FONT><BR><FONT SIZE=2>> > > Subject: [vrf] Stepping Motor Control (for dummies) any examples?</FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > > Hello Vfr's</FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > > Has anyone made any stepping motor controlling with Vee? I</FONT><BR><FONT SIZE=2>> > > need to control two stepping motors from Vee and I am looking</FONT><BR><FONT SIZE=2>> > > for a "keep it simple" solution for this. There is no major</FONT><BR><FONT SIZE=2>> > > accuracy & speed requirements. I only need to rotate two</FONT><BR><FONT SIZE=2>> > > axels with not so much torque needed.</FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > > Perhaps I am hoping too much, but the ideal solution from my</FONT><BR><FONT SIZE=2>> > > point of view would be one box that has an GP-IP / RS-232</FONT><BR><FONT SIZE=2>> > > port on one end and motor connectors on other end. Whole</FONT><BR><FONT SIZE=2>> > > thing controlled with few commands like speed & n steps to</FONT><BR><FONT SIZE=2>> > > clockwise etc.) Bed on my limited knowledge of the subject,</FONT><BR><FONT SIZE=2>> > > I am afraid that it is not this simple.</FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > > If you have working solutions / examples that you can share</FONT><BR><FONT SIZE=2>> > > with me, I would be very happy to look into them.</FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > > Br, Tapio Ronkainen</FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > > </FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> > > ---</FONT><BR><FONT SIZE=2>> > > You are currently subscribed to vrf as: William.Drago@L-3com.com</FONT><BR><FONT SIZE=2>> > > To subscribe send a blank email to </FONT><BR><FONT SIZE=2>> "join-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> > > To unsubscribe send a blank email to</FONT><BR><FONT SIZE=2>> > > "leave-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> > > To send messages to this mailing list,  email "vrf@agilent.com". </FONT><BR><FONT SIZE=2>> > > If you need help with the mailing list send a message to</FONT><BR><FONT SIZE=2>> > > "owner-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> > ></FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> >  This e-mail and subsequent attachments may contain </FONT><BR><FONT SIZE=2>> information which </FONT><BR><FONT SIZE=2>> > is proprietary to L-3 Communications Corporation. The </FONT><BR><FONT SIZE=2>> contents shall </FONT><BR><FONT SIZE=2>> > not be disclosed, copied, distributed or used unless </FONT><BR><FONT SIZE=2>> authorized by L-3 </FONT><BR><FONT SIZE=2>> > Communications Narda - East.</FONT><BR><FONT SIZE=2>> ></FONT><BR><FONT SIZE=2>> > ---</FONT><BR><FONT SIZE=2>> > You are currently subscribed to vrf as: P.J.Vossler@exeter.ac.uk</FONT><BR><FONT SIZE=2>> > To subscribe send a blank email to </FONT><BR><FONT SIZE=2>> "join-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> > To unsubscribe send a blank email to </FONT><BR><FONT SIZE=2>> "leave-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> > To send messages to this mailing list, email "vrf@agilent.com".</FONT><BR><FONT SIZE=2>> > If you need help with the mailing list send a message to </FONT><BR><FONT SIZE=2>> > "owner-vrf@it.lists.it.agilent.com". </FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> </FONT><BR><FONT SIZE=2>> ---</FONT><BR><FONT SIZE=2>> You are currently subscribed to vrf as: William.Drago@L-3com.com</FONT><BR><FONT SIZE=2>> To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> To unsubscribe send a blank email to </FONT><BR><FONT SIZE=2>> "leave-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> To send messages to this mailing list,  email "vrf@agilent.com".  </FONT><BR><FONT SIZE=2>> If you need help with the mailing list send a message to </FONT><BR><FONT SIZE=2>> "owner-vrf@it.lists.it.agilent.com".</FONT><BR><FONT SIZE=2>> </FONT></P><P><FONT SIZE=2> This e-mail and subsequent attachments may contain information which is proprietary to L-3 Communications Corporation. The contents shall not be disclosed, copied, distributed or used unless authorized by L-3 Communications Narda - East.</FONT></P>---<BR>You are currently subscribed to vrf as: rsb@soco.agilent.com<BR>To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".<BR>To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".<BR>To send messages to this mailing list,  email "vrf@agilent.com".  <BR>If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".</BODY></HTML>  

Outcomes