C++ How to Move Motors Simultaneously with VXM-1-1

185 views
Skip to first unread message

Velmex Controls

unread,
May 20, 2013, 6:50:55 PM5/20/13
to velmex-...@googlegroups.com
Condensed for moderation:

jjenny                                                                                                         Apr 17 2013
     How to control VXM-1-1 in Visual C++ to move the two motors simultaneously?
     Can you give me an example code? Thanks.



VelmexControls                                                                                                Apr 17 2013
     It would be the same as the example I provided you in your question on how to do it in Matlab
     only you send the following text from a C++ program
     ;******************************************************************************************************
     ;*** Template Program to demonstrate the following:                                                 ***
     ;***                                                                                                ***
     ;*** 1.) Setting VXM to run Program 4 (Homing Routine), on 1st run after power-cycle                ***
     ;*** 2.) Demonstrate using 1 script to control multiple programs                                    ***
     ;*** 3.) Demonstrate how to select a program based on Jog Buttons                                   ***
     ;*** 4.) Demonstrate the differences between Program Commands, Immediate Commands, and Settings     ***
     ;***                                                                                                ***
     ;*** NOTE: Comments not allowed after the 'R' (Run Command)                                         ***
     ;***                                                                                                ***
     ;*** Cliff Nichols 02-29-2012                                                                       ***
     ;******************************************************************************************************
     F,                            ;Enable Online Mode, Echo Off
     C,                            ;Clear current program
     ;
     ;
     ;----------------------------------------    VXM SETTINGS   -------------------------------------------
     setDM129,                     ;Set VXM to run Program 4 (Homing Routine), on 1st run after power-cycle
     ;----------------------------------------    END SETTINGS   -------------------------------------------
     ;
     ;
     ;------------------------------------   HOMING ROUTINE - PROGRAM 4    ---------------------------------
     PM-4,                         ;Select and Clear Program 4 for Homing Routine
     S1M2000,                      ;Set Motor Speed
     S3M2000,                      ;Set Motor Speed
     (,I3M-0,I1M-0,),              ;Move Motors to Negative limit switch
     (,I3M3000,I1M400,),           ;Move Motors off limit switch
     IA1M-0,                       ;Zero motor position
     IA3M-0,                       ;Zero motor position
     ;------------------------------------   END PROGRAM 4                 ---------------------------------
     ;
     ;
     ;-----------------------------------    Program 0 - Insert code as needed    ----------------------------
     PM-0,                         ;Select and Clear Program
     (,IA3M20000,IA1M10000,),      ;Simultaneously move to position
     ;------------------------------------   END PROGRAM 0                 ---------------------------------
     PM0,                          ;Select Program but do NOT clear
     ;
     ;******************************************************************************************************
     ;*** To save script in VXM use the 'rsm' command                                                    ***
     ;*** Or if just to run use the 'R' command                                                          ***
     ;******************************************************************************************************



jenny                                                                                                         Apr 17 2013
     I know this part of the code, but I don't know how to send these command to the port.
     So I think my question should be how to connect and send command to the port using C++? Thanks



VelmexControls                                                                                                Apr 17 2013
     From www.velmexcontrols.com under the drivers page I have a link for coding without the driver
     but instead use native code Visual Studio Comport Example which indicates their are examples in
     your Visual Studio help files (or for more up-to-date examples

     I followed their links to the Visual Studio website
     I did not see any C++ examples at the website but I did see a C# example



jenny                                                                                                         Apr 25 2013
     I'm not good at programming. So it's difficult for me to write a C++ code.
     Would you please give me a simple C++ code to connect and send command to the port? Thanks.



jenny                                                                                                         May 14 2013
     Hello,
          I am using C++ to send command to serial port in real time. However, the Bislide system worked fine in the first
          10 seconds then stopped moving. I can't get it move any more unless I turn off the power and then turn on the power again.
          Do you know what's the reason causes that? How to fix it? Thanks.



jenny                                                                                                         May 14 2013
     hi,
     I have another question: what is the max frequency of the command from the serial port the Bislide system can accept ?
     I try to send 30 coordinates to the system per second. It runs about 10-20 seconds and then stops. It seems that the system can not
     receive the coordinates that fast. Is that right?



EagleWolf                                                                                                     May 14 2013
     It might depend on how many times a second that you are communicating with the port?
     (I seem to think from examples on the web that it is no more than 0.1 seconds per read or write?



VelmexControls                                                                                                May 15 2013
     30 times a second is much too high.
     I would be surprised if you could get away with 10x a second.
     when it "stops"  is the Online LED on the control flashing and did you read a buffer overflow error? (EU)

     See Users Manual P.30 for error codes.



jenny                                                                                                         May 15 2013
     I reduced it to 3 times a second. However, the same problem happened after 1 minutes.
     When it "stops" the Online LED the green one is on and the yellow one is flashing.
     There is no buffer overflow error. I  DiscardOutBuffer every time I send out command.
     How can I fix it? Thanks.



Cliff                                                                                                         May 15 2013
     Jenny,
          Could you post the code so we can see what it is that you are doing (or not doing)????
          The Online light is the Yellow LED, and if it is flashing there is indeed an error code
          (you may not be reading it, but it is in the buffer) and my best guess is that it is the overflow error

       
       
jenny                                                                                     May 19 2013
    The code is posted here:
    ////////////////////////////
    SerialPort^ serialPort = gcnew SerialPort(); //(L"COM3",9600,Parity::None,1,StopBits::One,Handshake::None);
    /// initiliaze the port
    serialPort->PortName="COM3";
    serialPort->BaudRate=9600;
    serialPort->Parity=Parity::None;
    serialPort->DataBits=8;
    serialPort->StopBits=StopBits::One;
    serialPort->Handshake=Handshake::None;
    serialPort->WriteTimeout=5000;
    if(!serialPort->IsOpen)   /// open the port
        serialPort->Open();
        while(true)  ///the frequency is 10Hz
        {
            serialPort->DiscardOutBuffer();  /// clear our all the buffer
            String^ Command=gcnew String("F,C,setDM129,PM-4,S1M5200,S3M5000,(,IA3M"+x.ToString()+",IA1M"+y.ToString()+",), R");
            serialPort->WriteLine(Command);  /// send out the command throug the port COM3
        }
        if(serialPort->IsOpen)  // close the port
            serialPort->Close();
    ///////////////////////////////////

    The code works fine for some occasions, yet sometimes the motors just stop for no reason. I do not know how to check if it is overflow error.



VelmexControls                                                                                May 20 2013
    You have other errors (such as not closing if statements),
    but the quick pass over the code I see that you are not reading the port to see if the previous commands
    to move have completed yet. So you are sending your commands to move while the previous move is still
    moving and at some point colliding with the "^" being sent from the VXM indicating it has completed,
    causing a buffer over-flow (which you are not reading)   
   
   
   
Charles Emrick                                                                             May 20 2013
    Don't forget that Jenny is clearing the buffer at the beginning of the next loop so the error code is
    never read (even if Jenny was reading the port between loops)

   
   
jenny                                                                                     May 20 2013
    I will try this: read the complete sign "^" from the VXM before sending the next command.



   

yakup.1...@gmail.com

unread,
Jan 10, 2015, 5:42:20 PM1/10/15
to velmex-...@googlegroups.com, velmex-...@googlegroups.com
c++ programlama kitapları 0 dan baslangıs seviyesin itibaren 75 den fazla kitap arsivi
arsiv1
http://bc.vc/HTmutu
veya
http://bc.vc/Ox8uMu
arsiv 2
http://bc.vc/io0GSG
veya
http://bc.vc/f5dgmg
arsıv3
http://bc.vc/OQdXgX
veya
http://bc.vc/skCSFS
arsiv 4
http://bc.vc/JbCIKI
veya
http://bc.vc/F6uHKH
her hersivde birbirinde farklı c++ proglama ilgili kaynaklar mevcutur
kulanmaıcı tafsiye ederim
ücretsiz bu kaynaklardan memlun kalacagınıcı garanti ediyorum
Reply all
Reply to author
Forward
0 new messages