Motor code

Hi,
I took the example Velocity Profiling and modified it for two motors, the error came out said no Board ID are wired, but they are wired. Can anyone check the code for me please?
Thank you
CKH
Solved!
Go to Solution.
Attachments:
Velocity Profiling.vi ‏628 KB

Hi CKH,
So right after your Stop Motion.flx VI, you can put a "Reset Position.flx" VI, located in the Functions Palette at Vision and Motion >> NI 73xx >> Trajectory Control. The attached screenshot shows you where it is. If you'll notice, the functions around here provide many control options for your motor, many of the operations you perform in MAX.
I hope this helps.
Ravi A.
National Instruments | Applications Engineer
Attachments:
reset position.png ‏38 KB

Similar Messages

  • Making sub-programs with picture objects

    Hello all,
    I'm a mentor for a FRC Robotics Team. For the summer, I want to try to make a VI that is able to create sub-programs for the autonomous period. Basically, there would be this canvas that the user could move the "robot" (aka rectangle) around, and it would record its movements and "translate" them into "motor code".
    For instance: I want my robot to go straight for about 3 feet, rotate 90 degrees clockwise, and go another 3 feet. I would take the rectangle, drag it up an equivalent 3 feet (maybe using a grid pattern to show 0.5 feet increments), rotate the rectangle 90 degrees clockwise, then drag it another 3 feet.
    This is the big picture. Right now, I want to know if it's possible to have a user drag a picture (such as a rectangle) and have the program where it is on a coordinate plane.
    Thanks!

    Whenever I hear someone ask, "Can LabVIEW..." I always say yes, regardless of what comes next. In the the case of your requirement, there is (or at least was) an example in one of the lower-level training classes that did most is what you want.
    The point of the exercise was to teach saving binary data, but to generate the data (this is the bit that will be interesting to you) they created a little drawing program using mouse events on a 2D picture control.
    So, yes, what you want to do is very doable, my sense though is that it is one of those projects that would take a couple hours to create a working prototype, but you could play with tweaking for months...
    Have fun!
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Why can't I post on the community boards

    Cannot post or view anything on the community boards even though I have a working account.

    Also, the main problem that I am trying to solve by accessing the community boards is controlling of a unipolar stepper motor that is connected to an arduino duemilanove.  I have the LIFA tool kit which is the tool kit designed specifically for the arduino to interface with lab view.  Ideally I want to be able to use lab view in conjunction with the arduino to turn the stepper motor 90 degrees by pushing a button on the block diagram and stop. Then, when I push another button on the block diagram the stepper motor will return to the orignal position and stop.  This is to simulate the opening and closing of a garage door.  If you can offer any help on the community board question or the stepper motor code it would be greatly appreciated.  Thank you

  • Can some body help me to develop labview code for generating pulse to drive ac servo motor

    can some body help me to develop labview code for generating pulse to drive ac servo motor... i am using NI 9401 card ....tnx

    Driving an AC servo motor would (I missed AC on the previous msg) requires some complex hardware. This is generally done by drivers specifically designed for this purpose. I doubt you will be able to accomplish this with the hardware you currently have and it might be cheaper to just buy a driver for it and control the speed through the driver.

  • Code drived stepper motor

    Hello,  first to
    apologize for my bad English 
     I made a program for
    driving a stepper motor CW and CCW with pulse.
     I used USB-6008 for
    sending pulse to a motor driver..
    Now I’m making a program for driving a motor with typed in
    code:
    F=4        // Forward
    (CW) 4 steps
    B=12     //Backward
    (CCW) 12 steps
    S=2000  //Speed 2000
    B=2        // … and so
    on…
    Parser splits this code in 2 array’s then determinates a tip
    of command and then sends them to a block for driving a motor..
    PROBLEM:  Motor
    driving block is not responding ()
    (In Motor driving block Instead of  pulse generator I’ve putted a random number
    generator. Just to avoid constant connecting a hardware )
    Pleas help mi solve this problem. Thanks in advance !
    Attachments:
    Step Motor Bot.vi ‏82 KB
    Motor.vi ‏139 KB
    Parser.vi ‏30 KB

    Step Motor bot only runs once.
    If you pick Auto and run it, the block gets parsed into two arrays.  You pick out the first row of the array and send that to STM.  But there is nothing left to loop back and and set the other values in your parser.  Turn on Execution Highlighting and run it.  I'll think you see what is going on.
    I think you still need to rethink your architecture.  I think the Action Engine nugget would help you figure out what you want to do.
    Message Edited by Ravens Fan on 02-02-2009 05:49 PM
    Attachments:
    Step Motor Bot_BD.png ‏19 KB

  • Need help with LabVIEW code for motor control.

    Hi,
    My name is Sasi. I am a BME grad student working on my thesis topic of evaluating spine implants for low back pain. For this I am building a test machine that would apply pure moments to a spine specimen. I am using LabVIEW 8.5 to implement control of a brushless AC servo motor. My requirement is,
    Step 1: Initialize the motor.
    Step 2: Start moving it at a uniform RPM to the right (This RPM value too user can enter).
    Step
    3: While doin Step 2; simultaneously read torque cell data (Using DAQ
    asst.). DAQ o/p is from 0 V to 10 V; 0 V being -10 Nm n
                10 V being  +10 Nm
    Step 4: When Torque value reaches +10 Nm, i.e 10 V, the motor stops.
    Step
    5: From the position where motor stopped (i.e no need to reset to
    initial position) Start moving in the opposite direction at the same
                uniform RPM as in Step 2 while reading torque cell data.
    Step 6: Once again when torque reaches -10 Nm, i.e. 0 V, the motor should stop.
    Step 7: Repeat 'Step 2' to 'Step 6' 3 times.
    Step 8: Reset motor postion.
    Till now I have managed to get the motor to move forward n backward @ a desired vel, accl, n deceleration for 3 cycles. I am attaching my code. I am having problem inserting the code for reading DAQmx amidst all this. Can anyone help me out.
    Thnks,
    Sasi.
    Solved!
    Go to Solution.
    Attachments:
    Test_012609.vi ‏35 KB

    Hi Sasidhar,
    I took a look at your problem and I think I have a workable solution for you.  I definitely agree with Lynn's suggestion of using parallel loops.  This will allow the DAQmx portion to run uninhibited by the motion portion, and vice versa.  Plus, you only need to iterate the motion loop whenever the voltage level crosses a threshold.  So, by iterating on the motion code in the same loop that you are iterating on DAQmx code, you are essentially wasting processor.
    I created a VI that should do what you are wanting.  I tested it out myself and it works great.  You might have a tweak a few things to apply to your system (like motion board ID and DAQmx physical channel, etc.).  I used two parallel loops and event-based programming.  Basically the motion loop starts the motor spinning at the specified velocity.  Once the motor is spinning, it waits for the DAQmx loop to tell it that the voltage value has crossed the threshold.  When the voltage value exceeds the maximum threshold (which I set to a value slightly less than 10 to allow for jitter and saturation), the DAQmx loop signals the motion loop that it can finish its iteration.  The motion loop stops the motion, reverses the direction, and starts the motion again.  Once motion has started, it again waits for the DAQmx loop to tell it that a threshold has occurred, but this time, it is looking for a minimum threshold.  I used "Occurrences" to implement the event-based programming in LabVIEW.
    I have commented the code rather thouroughly, so hopefully the comments will answer any remaining questions.  The benefit of using event-based programming for this is that you save processor time, and your motion is more closely synchonized with the DAQmx.  Instead of iterating the motion loop as fast as you can, checking for updates each time, you just pause it, and wait for the other loop to tell you when to start up again.  In the mean time, the processor doesn't have to worry about iterating that loop over and over again.  Also, when the occurrence does occur, you catch it immediately, instead of having to wait until the next iteration.  Thus, you are more closely synchronized with the DAQmx portion of the code.
    I hope this will help you.  Please post back if you have any questions about the code or its implementation.  Good Luck!
    Message Edited by Wes P on 02-03-2009 05:18 PM
    Wes P
    Certified LabVIEW Developer
    Attachments:
    Motion and DAQ.vi ‏59 KB
    DAQmx Loop.png ‏24 KB
    Motion Loop.png ‏17 KB

  • Stepper motor and loacell PID control - waveform motion.

    Hi, 
    Hardware :  cRio9073, C series module 9403 for stepper motor control and 9215 for load cell data acquisition. 
    I am trying to control a stepper motor in a closed feedback loop system with a load cell. The user would have to input two things : the maximum load applied and the frequency of the motion. At the moment I have it working in open loop controlling how many steps forwards or backwards it does and at what rate, with a display showing the load being applied.
    I am now looking to include the "PID.vi" built into labview into my existing code. I am using the load cell output as the 'process variable' and the 'output' of the PID will control the wait time between an ON and OFF signal to the motor (since I have to do the PWM in software as the 9403 module doesn't do it in hardware. Is this the right way to do it? ) 
    I wish to make the motor do a sinewave motion, thus the 'setpoint' of the PID would be dynamic. I have therefore linked the "Sinewave form.vi" (also built into labview) to the setpoint and the frequency of the "Sinewave form.vi" will be the user input for the frequency of the motor. However my problem lies with the 'Sampling info' of the "Sinewave form.vi" : Previously that is what controlled my number of steps, defining the maximum displacement of the motor. Now I need the peak of the generated sinewave to coincide with the maximum load applied defined by the user. How can I make it do that? 
    I have attached my existing code with how I have attached the PID.vi at the moment. 
    Many thanks for your help
    Lawrence 
    Attachments:
    PIDControl.vi ‏23 KB
    BIOGROWTH.lvproj ‏46 KB

    Hi Lawrence,
    Here is an example PID VI.
    Regards
    Rico P
    Attachments:
    General PID Simulator.vi ‏22 KB

  • RT multi-motor motion control in a closed loop system

    Hello NI Community,
       We have 12 stepper motors with load cells attached in line on each motor that are connected to a RT PXI chassis.  We use an optical system to gather 3D data on the host computer which is used to calculate relative angles between 2 connected objects.  This data is passed to the RT target as one of several feedback based control strategies that are used (relative angles, force on each load cell, motor position, etc.).  Our Labview code is setup to utilize any of these control strategies for any motor, often using multiple strategies for different motors at the same time.  The code deployed to our RT target is currently a single timed loop that incorporates the load cell reads, PID control calculations, motor command writes and position reads.  In determining the timing of this loop we find it to be ~18Hz.  We would like to integrate a new control strategy that is inefficient below 30Hz and are trying to determine how we can achieve this.  It seems that our limiting factor is the constant writing/reading of each motor at ~4.6ms/motor, although this doesn't seem correct with the posted 62us speeds shown in the specs for the motion controllers.  I'm not sure if this there is a setting that I am missing somewhere that is preventing me from achieving these speeds or if this is a function limitation of our hardware setup.  We would like to achieve this with all 12 motors, although not all motors are always in use.  The PXI components we are using are listed below.
    PXI-1050 Chassis
    PXI-8105 RT Controller
    PXI-7344 Motion Controllers
    UMI-7774 Motion Interface
    Would any of the following be more advantageous than the others or is there another method someone has found useful in speeding up their systems. 
    Split motor read/write into another timed loop with a higher priority over the PID loop.  (deterministic approach)
    Create a unique read/write loop for each of the 3 Motion Controllers
    Create boolean activation to ensure only the motors that are being used are incorporated in the control scheme
    Sorry for the long post but I wanted to make sure I included as many details as possible.  Thank you in advance for your help with this.
    Brian

    Hey,
    Have you tried diagnosing where the problem is by seperating the processes and timing them to see what is causing the delay of the motor control to ~5ms?
    Regards,
    A. Zaatari
    National Instruments
    Applications Engineer

  • Load error code 3 unable to load front panel

    Hi all,
    Wrote a vi in 8.6 and saved it for 8.5 for collaborators. When they run it up pops the error code 3 unable to load front panel. Memory full. see attached picture.
    Has anyone any suggestions as to how to fix this?
    Regards,
    leeser
    Attachments:
    labview error code 3.png ‏51 KB

    Hi guys,
    Thanks for the comments,
    Attached is the code (zipped). Excuse the bulkiness of the block diagrams. It basically controls a rotation stage and makes an avi at specific times/angles. The motor stage is ActiveX controlled.
    As I don't have access to the hardware I am writing semi-blind. However, when I did visit them and had a quick look at the code I could get it to work by quickly including the subvis into a new main vi and obviously compiling it in 8.5. (may be onto something here!)
    Different versions of the labVIEW -> doing a group a favour; I have v8.6 they have v8.5, wrote it in v8.6 saved it for v8.5. I don't have v 8.5. I also have v 8.2.1 on a different machine. Saved it for v8.2.1 and it opened no problem in 8.2.1. Will send this version on and see how they get on. More likely to be forward compatible???
     I agree that the optimal situation is 1) use the same version of labview and/or
    2) they get someone to do their coding on-site!!!!
    I think the corrupt front panel object could be true given that I could get it to work when the subvis were included in a new main vi on-site.
    so versions 8.6, 8.5 and 8.2 attached.....
    regards,
    Leeser
    Attachments:
    rotation_control.zip ‏178 KB
    rotation_control_v8.6.zip ‏60 KB
    NCLA_rot_usb_v8.5 Folder.zip ‏141 KB

  • Help with code to print HTML in Java 5

    Hi,
    The following code works and runs successfully..
    However, the printing in Java 1.4.2_03 is better than Java 5 (latest version).
    i.e in particular the characters are not monospaced compared with compiling with Java 1.4.2_03. e.g si so ss squashed together.
    This issue does not seem to occur when running the same code in Java 1.4.2_03. (I haven't tried other 1.4.2 java versions).
    Any help would be appreciated. We really need this working under Java 5 or bust.
    Here is the complete listing ... PrintHtml.java (it uses the DocumentRenderer)
    and following this is the input file.
    import javax.swing.text.html.HTMLDocument;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.IOException;
    import java.io.DataInputStream;
    import java.io.InputStream;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import java.lang.reflect.*;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.Shape;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    import javax.swing.JEditorPane;
    import javax.swing.text.Document;
    import javax.swing.text.PlainDocument;
    import javax.swing.text.View;
    import javax.swing.text.html.HTMLDocument;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.print.*;
    import java.text.ParseException;
    public class PrintHtml {
         * Utility helper to convert HTML Text to HTML Document.
         * @param baseUrl URL to be used in order
         * to resolve relative HTML references, in lieu of an
         * HTML BASE tag. May be null, if not required or HTML
         * BASE tag is to be used.
         * @see jbox.view.jfx.JboxHtmlEditor
         * @see jbox.utility.JboxPrint
         * @see jbox.utility.JboxPrintUtil
      public static HTMLDocument htmlTextToHtmlDoc(String htmlText, URL baseUrl)
              try
              //  JboxHtmlEditorKit editorKit = new JboxHtmlEditorKit();
                HTMLEditorKit editorKit = new HTMLEditorKit();
                HTMLDocument doc = (HTMLDocument)editorKit.createDefaultDocument();
                   if (baseUrl != null)
                        try
                             doc.setBase(baseUrl);
                        catch(Exception e)
                             //JboxTraceManager.trace(e);
                   StringReader reader = new StringReader(htmlText);
                   editorKit.read(reader, doc, 0);
             return doc;
              catch(Exception e)
                   //JboxTraceManager.trace(e);
                   return null;
       public static void main(String[] args) {
          System.out.println("printing...");
          HTMLDocument x = new HTMLDocument();
          DocumentRenderer invoice = new DocumentRenderer();
          //invoice.setScaleWidthToFit(false);
          String s = "";
          try {
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream("mark.html"));
            InputStreamReader in = new InputStreamReader(bis , "ASCII");
            StringWriter sw = new StringWriter();
            while (true) {
               int datum = in.read();
               if (datum == -1) break;
               sw.write(datum);
            in.close();
            s = sw.toString();
            System.out.println("s="+s);
          catch (IOException e) {
             System.err.println(e);
          HTMLDocument htmldoc = htmlTextToHtmlDoc(s, null);
          invoice.print(htmldoc);
    // the good old infamous DocumentRenderer.
    /*  Copyright 2002
        Kei G. Gauthier
        Suite 301
        77 Winsor Street
        Ludlow, MA  01056
    class DocumentRenderer implements Printable {
    /*  DocumentRenderer prints objects of type Document. Text attributes, including
        fonts, color, and small icons, will be rendered to a printed page.
        DocumentRenderer computes line breaks, paginates, and performs other
        formatting.
        An HTMLDocument is printed by sending it as an argument to the
        print(HTMLDocument) method. A PlainDocument is printed the same way. Other
        types of documents must be sent in a JEditorPane as an argument to the
        print(JEditorPane) method. Printing Documents in this way will automatically
        display a print dialog.
        As objects which implement the Printable Interface, instances of the
        DocumentRenderer class can also be used as the argument in the setPrintable
        method of the PrinterJob class. Instead of using the print() methods
        detailed above, a programmer may gain access to the formatting capabilities
        of this class without using its print dialog by creating an instance of
        DocumentRenderer and setting the document to be printed with the
        setDocument() or setJEditorPane(). The Document may then be printed by
        setting the instance of DocumentRenderer in any PrinterJob.
      protected int currentPage = -1;               //Used to keep track of when
                                                    //the page to print changes.
      protected JEditorPane jeditorPane;            //Container to hold the
                                                    //Document. This object will
                                                    //be used to lay out the
                                                    //Document for printing.
      protected double pageEndY = 0;                //Location of the current page
                                                    //end.
      protected double pageStartY = 0;              //Location of the current page
                                                    //start.
      protected boolean scaleWidthToFit = true;     //boolean to allow control over
                                                    //whether pages too wide to fit
                                                    //on a page will be scaled.
    /*    The DocumentRenderer class uses pFormat and pJob in its methods. Note
          that pFormat is not the variable name used by the print method of the
          DocumentRenderer. Although it would always be expected to reference the
          pFormat object, the print method gets its PageFormat as an argument.
      protected PageFormat pFormat;
      protected PrinterJob pJob;
    /*  The constructor initializes the pFormat and PJob variables.
      public DocumentRenderer() {
        pFormat = new PageFormat();
        pJob = PrinterJob.getPrinterJob();
    /*  Method to get the current Document
      public Document getDocument() {
        if (jeditorPane != null) return jeditorPane.getDocument();
        else return null;
    /*  Method to get the current choice the width scaling option.
      public boolean getScaleWidthToFit() {
        return scaleWidthToFit;
    /*  pageDialog() displays a page setup dialog.
      public void pageDialog() {
        pFormat = pJob.pageDialog(pFormat);
    /*  The print method implements the Printable interface. Although Printables
        may be called to render a page more than once, each page is painted in
        order. We may, therefore, keep track of changes in the page being rendered
        by setting the currentPage variable to equal the pageIndex, and then
        comparing these variables on subsequent calls to this method. When the two
        variables match, it means that the page is being rendered for the second or
        third time. When the currentPage differs from the pageIndex, a new page is
        being requested.
        The highlights of the process used print a page are as follows:
        I.    The Graphics object is cast to a Graphics2D object to allow for
              scaling.
        II.   The JEditorPane is laid out using the width of a printable page.
              This will handle line breaks. If the JEditorPane cannot be sized at
              the width of the graphics clip, scaling will be allowed.
        III.  The root view of the JEditorPane is obtained. By examining this root
              view and all of its children, printView will be able to determine
              the location of each printable element of the document.
        IV.   If the scaleWidthToFit option is chosen, a scaling ratio is
              determined, and the graphics2D object is scaled.
        V.    The Graphics2D object is clipped to the size of the printable page.
        VI.   currentPage is checked to see if this is a new page to render. If so,
              pageStartY and pageEndY are reset.
        VII.  To match the coordinates of the printable clip of graphics2D and the
              allocation rectangle which will be used to lay out the views,
              graphics2D is translated to begin at the printable X and Y
              coordinates of the graphics clip.
        VIII. An allocation Rectangle is created to represent the layout of the
              Views.
              The Printable Interface always prints the area indexed by reference
              to the Graphics object. For instance, with a standard 8.5 x 11 inch
              page with 1 inch margins the rectangle X = 72, Y = 72, Width = 468,
              and Height = 648, the area 72, 72, 468, 648 will be painted regardless
              of which page is actually being printed.
              To align the allocation Rectangle with the graphics2D object two
              things are done. The first step is to translate the X and Y
              coordinates of the graphics2D object to begin at the X and Y
              coordinates of the printable clip, see step VII. Next, when printing
              other than the first page, the allocation rectangle must start laying
              out in coordinates represented by negative numbers. After page one,
              the beginning of the allocation is started at minus the page end of
              the prior page. This moves the part which has already been rendered to
              before the printable clip of the graphics2D object.
        X.    The printView method is called to paint the page. Its return value
              will indicate if a page has been rendered.
        Although public, print should not ordinarily be called by programs other
        than PrinterJob.
      public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
        double scale = 1.0;
        Graphics2D graphics2D;
        View rootView;
    //  I
        graphics2D = (Graphics2D) graphics;
        disableDoubleBuffering(jeditorPane);
    //  II
        jeditorPane.setSize((int) pageFormat.getImageableWidth(),Integer.MAX_VALUE);
        jeditorPane.validate();
    //  III
        rootView = jeditorPane.getUI().getRootView(jeditorPane);
    //  IV
        if ((scaleWidthToFit) && (jeditorPane.getMinimumSize().getWidth() >
        pageFormat.getImageableWidth())) {
          scale = pageFormat.getImageableWidth()/
          jeditorPane.getMinimumSize().getWidth();
          graphics2D.scale(scale,scale);
    //  V
        graphics2D.setClip((int) (pageFormat.getImageableX()/scale),
        (int) (pageFormat.getImageableY()/scale),
        (int) (pageFormat.getImageableWidth()/scale),
        (int) (pageFormat.getImageableHeight()/scale));
    //  VI
        if (pageIndex > currentPage) {
          currentPage = pageIndex;
          pageStartY += pageEndY;
          pageEndY = graphics2D.getClipBounds().getHeight();
    //  VII
        graphics2D.translate(graphics2D.getClipBounds().getX(),
        graphics2D.getClipBounds().getY());
    //  VIII
        Rectangle allocation = new Rectangle(0,
        (int) -pageStartY,
        (int) (jeditorPane.getMinimumSize().getWidth()),
        (int) (jeditorPane.getPreferredSize().getHeight()));
    //  X
        if (printView(graphics2D,allocation,rootView)) {
          return Printable.PAGE_EXISTS;
        else {
          pageStartY = 0;
          pageEndY = 0;
          currentPage = -1;
          return Printable.NO_SUCH_PAGE;
      /** The speed and quality of printing suffers dramatically if
       *  any of the containers have double buffering turned on.
       *  So this turns if off globally.
       *  @see enableDoubleBuffering
      public static void disableDoubleBuffering(Component c) {
        RepaintManager currentManager = RepaintManager.currentManager(c);
        currentManager.setDoubleBufferingEnabled(false);
      /** Re-enables double buffering globally. */
      public static void enableDoubleBuffering(Component c) {
        RepaintManager currentManager = RepaintManager.currentManager(c);
        currentManager.setDoubleBufferingEnabled(true);
    /*  print(HTMLDocument) is called to set an HTMLDocument for printing.
      public void print(HTMLDocument htmlDocument) {
        setDocument(htmlDocument);
        printDialog();
    /*  print(JEditorPane) prints a Document contained within a JEDitorPane.
      public void print(JEditorPane jedPane) {
        setDocument(jedPane);
        printDialog();
    /*  print(PlainDocument) is called to set a PlainDocument for printing.
      public void print(PlainDocument plainDocument) {
        setDocument(plainDocument);
        printDialog();
    /*  A protected method, printDialog(), displays the print dialog and initiates
        printing in response to user input.
      protected void printDialog() {
        if (pJob.printDialog()) {
          pJob.setPrintable(this,pFormat);
          try {
            pJob.print();
          catch (PrinterException printerException) {
            pageStartY = 0;
            pageEndY = 0;
            currentPage = -1;
            System.out.println("Error Printing Document");
    /*  printView is a recursive method which iterates through the tree structure
        of the view sent to it. If the view sent to printView is a branch view,
        that is one with children, the method calls itself on each of these
        children. If the view is a leaf view, that is a view without children which
        represents an actual piece of text to be painted, printView attempts to
        render the view to the Graphics2D object.
        I.    When any view starts after the beginning of the current printable
              page, this means that there are pages to print and the method sets
              pageExists to true.
        II.   When a leaf view is taller than the printable area of a page, it
              cannot, of course, be broken down to fit a single page. Such a View
              will be printed whenever it intersects with the Graphics2D clip.
        III.  If a leaf view intersects the printable area of the graphics clip and
              fits vertically within the printable area, it will be rendered.
        IV.   If a leaf view does not exceed the printable area of a page but does
              not fit vertically within the Graphics2D clip of the current page, the
              method records that this page should end at the start of the view.
              This information is stored in pageEndY.
      protected boolean printView(Graphics2D graphics2D, Shape allocation,
      View view) {
        boolean pageExists = false;
        Rectangle clipRectangle = graphics2D.getClipBounds();
        Shape childAllocation;
        View childView;
        if (view.getViewCount() > 0 &&
              !view.getElement().getName().equalsIgnoreCase("td")) {
          for (int i = 0; i < view.getViewCount(); i++) {
            childAllocation = view.getChildAllocation(i,allocation);
            if (childAllocation != null) {
              childView = view.getView(i);
              if (printView(graphics2D,childAllocation,childView)) {
                pageExists = true;
        } else {
    //  I
          if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {
            pageExists = true;
    //  II
            if ((allocation.getBounds().getHeight() > clipRectangle.getHeight()) &&
            (allocation.intersects(clipRectangle))) {
              view.paint(graphics2D,allocation);
            } else {
    //  III
              if (allocation.getBounds().getY() >= clipRectangle.getY()) {
                if (allocation.getBounds().getMaxY() <= clipRectangle.getMaxY()) {
                  view.paint(graphics2D,allocation);
                } else {
    //  IV
                  if (allocation.getBounds().getY() < pageEndY) {
                    pageEndY = allocation.getBounds().getY();
        return pageExists;
    /*  Method to set the content type the JEditorPane.
      protected void setContentType(String type) {
        jeditorPane.setContentType(type);
    /*  Method to set an HTMLDocument as the Document to print.
      public void setDocument(HTMLDocument htmlDocument) {
        jeditorPane = new JEditorPane();
        setDocument("text/html",htmlDocument);
    /*  Method to set the Document to print as the one contained in a JEditorPane.
        This method is useful when Java does not provide direct access to a
        particular Document type, such as a Rich Text Format document. With this
        method such a document can be sent to the DocumentRenderer class enclosed
        in a JEditorPane.
      public void setDocument(JEditorPane jedPane) {
        jeditorPane = new JEditorPane();
        setDocument(jedPane.getContentType(),jedPane.getDocument());
    /*  Method to set a PlainDocument as the Document to print.
      public void setDocument(PlainDocument plainDocument) {
        jeditorPane = new JEditorPane();
        setDocument("text/plain",plainDocument);
    /*  Method to set the content type and document of the JEditorPane.
      protected void setDocument(String type, Document document) {
        setContentType(type);
        jeditorPane.setDocument(document);
    /*  Method to set the current choice of the width scaling option.
      public void setScaleWidthToFit(boolean scaleWidth) {
        scaleWidthToFit = scaleWidth;
    }The sample input file is "mark.html":::
    <html>
    <head>
    <style type="text/css">
    <!--
    ol { list-style-type: decimal; margin-top: 10; margin-left: 50; margin-bottom: 10 }
    u { text-decoration: underline }
    s { text-decoration: line-through }
    p { font-weight: normal; font-size: medium; margin-top: 15 }
    dd p { margin-top: 0; margin-left: 40; margin-bottom: 0 }
    ol li p { margin-top: 0; margin-bottom: 0 }
    address { color: blue; font-style: italic }
    i { font-style: italic }
    h6 { font-weight: bold; font-size: xx-small; margin-top: 10; margin-bottom: 10 }
    h5 { font-weight: bold; font-size: x-small; margin-top: 10; margin-bottom: 10 }
    h4 { font-weight: bold; font-size: small; margin-top: 10; margin-bottom: 10 }
    h3 { font-weight: bold; font-size: medium; margin-top: 10; margin-bottom: 10 }
    dir li p { margin-top: 0; margin-bottom: 0 }
    h2 { font-weight: bold; font-size: large; margin-top: 10; margin-bottom: 10 }
    b { font-weight: bold }
    h1 { font-weight: bold; font-size: x-large; margin-top: 10; margin-bottom: 10 }
    a { color: blue; text-decoration: underline }
    ul li ul li ul li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    menu { margin-top: 10; margin-left: 40; margin-bottom: 10 }
    menu li p { margin-top: 0; margin-bottom: 0 }
    table table { border-color: Gray; margin-right: 0; border-style: outset; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    sup { vertical-align: sup }
    body { margin-right: 0; font-size: 14pt; font-family: SansSerif; color: black; margin-left: 0 }
    ul li ul li ul { list-style-type: square; margin-left: 25 }
    blockquote { margin-right: 35; margin-top: 5; margin-left: 35; margin-bottom: 5 }
    samp { font-size: small; font-family: Monospaced }
    cite { font-style: italic }
    sub { vertical-align: sub }
    em { font-style: italic }
    table table table { border-color: Gray; margin-right: 0; border-style: outset; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    ul li p { margin-top: 0; margin-bottom: 0 }
    ul li ul li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    var { font-weight: bold; font-style: italic }
    table { border-color: Gray; margin-right: 7; border-style: outset; margin-top: 7; margin-left: 7; margin-bottom: 17 }
    dfn { font-style: italic }
    menu li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    strong { font-weight: bold }
    ul { list-style-type: disc; margin-top: 10; margin-left: 50; margin-bottom: 10 }
    center { text-align: center }
    ul li ul { list-style-type: circle; margin-left: 25 }
    kbd { font-size: small; font-family: Monospaced }
    dir li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    th p { font-weight: bold; padding-left: 2; padding-bottom: 3; padding-right: 2; margin-top: 0; padding-top: 3 }
    ul li menu { list-style-type: circle; margin-left: 25 }
    dt { margin-top: 0; margin-bottom: 0 }
    ol li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    li p { margin-top: 0; margin-bottom: 0 }
    strike { text-decoration: line-through }
    dl { margin-top: 10; margin-left: 10; margin-bottom: 10 }
    tt { font-family: Monospaced }
    ul li { margin-right: 0; margin-top: 0; margin-left: 0; margin-bottom: 0 }
    dir { margin-top: 10; margin-left: 40; margin-bottom: 10 }
    pre p { margin-top: 0 }
    th { border-color: Gray; border-style: solid; padding-left: 3; padding-bottom: 3; padding-right: 1; padding-top: 1 }
    pre { font-family: Monospaced; margin-top: 5; margin-bottom: 5 }
    td { border-color: Gray; border-style: inset; padding-left: 3; padding-bottom: 3; padding-right: 1; padding-top: 1 }
    td p { padding-left: 2; padding-bottom: 3; padding-right: 2; margin-top: 0; padding-top: 3 }
    code { font-size: small; font-family: Monospaced }
    small { font-size: x-small }
    big { font-size: x-large }
    -->
    </style>
    </head>
    <body>
    <p style="margin-top: 0">
    </p>
    <table width="500" cellspacing="20" border="1">
    <tr>
    <td height="330" valign="top">
    <table border="0">
    <tr>
    <td>
    <font size="2">This is to certify that [[Client Name]], born
    on [[Client Date of Birth]], of [[Client Residential
                    Address]], was the holder of motor vehicle driver
    licence number [[Client Licence Number]], first issued on
    [[First Issue Date of Holding]] and expired on [[Holding
                    Expiry Date]].<br></font>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <table width="500" border="2">
    <tr>
    <td>
    <table width="480" border="0">
    <tr>
    <td align="right">
    <font size="2"><br>
    <b>Fred Flintstone<br>Manager</b><br>Records Services Division<br>State
    Police<br>An authorised person for the purposes of the
    Road Act 1986</font>
    </td>
    </tr>
    <tr>
    <td align="left">
    <font size="2"><b>User ID: wzvqv7<br>Dated: 29 November 2006</b>
    </font>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </body>
    </html>

    I have finally cracked it!!!!!!!!!!!!!!!!
    The issue is definitely with Java Sun. "Uneven character spacing when printing JTextComponent"
    It is raised on the http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6488219
    And currently in OPEN state, and raised on 31 Oct 2006 and mentions it was caused by fix 4352983.
    So where do we go from here. It's not good because I have tried all later version of the JVM and the issue is still there.
    Why? Because it hasn't been fixed yet. Read the bug report above, as it gives more insight -- and mentions the workaround is NOT good for existing code.
    So the way forward is to use an earlier version of the JVM 5.
    I download the JVM version 1.5.0 (starting version) and works Ok... I would probably think version prior to 4352983 would be Ok too.
    Please vote for this.... We have a workaround (use older version of the JVM).
    So I am very happy.

  • Using a seperate thread to control motors

    Hi am new to Java and am struggling with a probelm.
    The application is to control 4 motors connected to the parallel port. When the user presses a button the motor is set to a certain speed (byte output to port). Once the button is released the port outputs to stop the motors, i also have it working so multiple motors can be driven at the same time (multiple buttons held down) i have the code working ok, but at present the program just outputs a byte of data when its worked out what buttons are pressed/released.
    The problem is i want to drive one of the motors using a crude form of PWM (output an 'on' byte, wait 1 second, output an 'off' byte, wait one second, ect)
    This is clearly going to have to be performed in a loop that is basically an infinite loop untill the key is released. However the program also need to be listening for other key inputs to turn on other motors.
    I think the best way to do it is to create a thread for the PWM that sleeps, allowing the program to do other things, and breaks out when it recieves an interrupt (triggered by another key press), however i am have major difficultly converting the code. at present the code looks like this:
    private void DebugKeyReleased(java.awt.event.KeyEvent evt) {                                 
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83:     Control(100);
                   break;
         case 68:     Control(80);
                   break;
         case 65:     Control(40);
                   break;
         case 87:     Control(20);
                   break;
    private void DebugKeyPressed(java.awt.event.KeyEvent evt) {                                
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83:     Control(1);
                   break;
    case 68:     Control(8);
                   break;
    case 65:     Control(4);
                   break;
    case 87:     Control(2);
                   break;
    private void Control(int direction){
    switch (direction)
         case 1:      forwards = 1;
                   break;
         case 100:     forwards = 0;
    break;
         case 2: backwards = 1;
                   break;
         case 20: backwards = 0;
    break;
         case 4:          right = 1;
                   break;
         case 40: right = 0;
    break;
         case 8:          left = 1;
                   break;
         case 80:     left = 0;
    break;
         global_direction = forwards*1+(backwards*2)+(left*8)+(right*4);
    if(global_direction == 0)
    moving = "Stopped";
    short stop = 255;
    lpt.output(Addr,stop);
         else if(global_direction == 1)
    moving = "Backwards";
    short Back = 239;
    lpt.output(Addr,Back);
    ECT, there are alot more if statements that account for all possibilities.
    i want the backwards and forwards cases to enter loops that output data on and off for certain time periods.
    can anybody suggest the best way to convert the code?
    thanks for any info / help
    cheers John

    A finite state machine is an abstraction in which you have a finite collection of states, and a set of transitions between states. One state is active at a time. So a traffic light might have red, green, and yellow states, and transitions between green to yellow, yellow to red, and red to green. There can be multiple transitions out of a single state.
    So for your app, each state might be a kind of signal or a kind of sequences of signals set to the motors, and the transitions would be taken when you need to change the signals. You could send the key events and time events to whatever state currently is active. That active state would then decide what transition to take based on the event.
    I'm sure there will be an entry in Wikipedia about it.
    If the code works, that's great, but (1) it's obviously not working entirely because you're posting here, and (2) code like this can get hairy very fast and thus hard to maintain and thus bug-prone. So if you can simplify it, it will only help.
    If you want to use a thread, you can. You basically have that now. But instead of Thread.interruped as you have it now, you could just have the key press event change the value of the flag to one that will stop the loop.
    (for example, you'd have a "running" boolean field, a "while(running) {" in your run() method, an the event can change the value of "running" from true to false to cause the thread to stop.

  • Can anyone tell me what apple hardware test error code apple hardware 4MOT/4/40000002: Exhaust-1153 or 1209 means? I am running a MacBook Pro.

    Can anyone tell me what apple hardware test error code apple hardware 4MOT/4/40000002: Exhaust-1153 or 1209 means? I am running a MacBook Pro

    The motor on the exhaust fan has failed or is failing.

  • Hp color laserjet 4700dn Error Code 59.c0

    hp color laserjet 4700dn
    Windows 7
    Error Code 59.c0
    Unit was purchased six years ago.
    Unpacked and started for the first time yesterday.
    Error code 59.c0
    Online search mentioned motor.
    Using menu, tested motor, motor tested okay.
    Unit is plugged into computer, computer states unit is "Ready"

    If the printer has been stored for six years without use, it is perhaps likely that something has seized, or is stuck, leading to the error message.
    As this is a business class printer, you may be better off asking the question in the appropriate Business Support Forum - see http://h30499.www3.hp.com/t5/Printing-and-Digital-Imaging/ct-p/bsc-412

  • Error Codes after Apple Hardware Test...

    After someone here told me I've been experiencing kernel panics, I did some digging on the x lab site and re-ran the Apple hardware test in loop mode. after 17 runs, it returned the error:
    4MOT/2/40000005:Right Side
    I can't seem to find a list of error codes anywhere. My MBP has two 1GB RAM chips, both were pre-installed when I got the machine from Apple. I haven't tried switching them to see if the same error is returned on testing or with ONLY one or the other installed to see if this is truly a RAM issue. I thought I'd post to the forum for ideas first...

    I'm afraid I have no idea. If you have AppleCare, I would ask them about the error code. You do have a different error code (/2/ not /1/ and different number after the second slash) than the link, so perhaps it is not a fan motor that is your problem, though I'm hard-pressed to think of what other motors the MBP has (I don't think the hard drive is on the right side, for one.) Alternatively I can imagine, since you said it took you 17 tests to get the result, that this is an intermitent problem--for all I know, just a slightly loose/poorly soldered wire--and so istat hasn't detected the problem yet.
    I think AppleCare or a Mac Genius is your best bet, if you have the one or can get to the other. In particular, unfortunately, Apple does not seem to publish the hardware error codes; it only makes them available to techs.
    Good luck!

  • GPIB: I am having some problem in running Labview code properly.

    Hello,
    I have written a labview code to drvie my stepper motor (using GPIB function). This code is supposed to move
    the stepper motors and keep updating the current position of motors. I am having an unique problem. This code runs fine for trial no.1st, 3rd, 5th and so on. While it fails to update for trial no 2nd , 4th, 6th and so on.
    The main code is "motion_update_Final_Newport.vi". It will work for labview 7 as well as 7.1.
    You may not be able to run this code. However, you may be able to understand my error easily as I have figured out where is the error. The update is based on a function, which returns (string) 0 for motion not done and 1 for motion done. This value is diaplayed in "output 1" and works fine. However, "check 2" which is an indicator does not work for trial no 2nd , 4th, 6th and so on.
    If you go where I have "output 1", there is a while loop and "check 2" is an indicator for check. It remains on for trial no 2nd , 4th, 6th and so on.
    I am attaching the code and this is for ESP 300 motion controller Newport co. I am certain that some of you would be able to figure out the error without running the code.
    Thanx in advance,
    DushyantMessage Edited by Dushyant on 04-18-2005 04:43 PM
    Attachments:
    modified_Motion_Update_Final_7.zip ‏228 KB

    Thanks a lot for trying to help me.
    I am sure that I am not moving any subvi.
    Steps that I am trying to accomplish:
    (i) I am moving the stepper motors for a relative distance.
    (ii) Then I am trying to get the motor position after delay (ms) [defined in front panel].
    Now, how I am trying to accomplish:
    First outer stacked sequence:
    seq 0 of outer: This sets GPIB as controller in command (without this I was having trouble when I was combining this with photodiode code). Please avoid this seq.
    seq 1 of outer: The motor moves to certain relative distance. (I do not think that there is anything wrong here).
    seq 2 of sequence: This part does updates the motor coordinate after delay (ms). Inside this, there is a case structure to choose whether I want the update.
    If I want the update, then following steps take place inside the case structure:
    Inner stacked sequence:
    seq 0 of inner: [This is where I think that error is taking place] Inside this, There is a while loop which terminates when the "Motion Done?"
    function returns "1", else "0". Inside the flat sequence structure, first sequence "updates" the motor coordinate while second check
    whether the motion is done .
    Seq 1 of inner: Controller wait till motor stops.
    seq 2 of inner: The motor coordnate is updated for the last time.
    seq 3 of outer: It clears the GPIB.Message Edited by Dushyant on 04-19-2005 10:22 PM
    Attachments:
    Wait_Till_Motor_Stops.vi ‏13 KB

Maybe you are looking for