Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:41:40+00:00 2026-06-12T18:41:40+00:00

I have written a script in Zaber Console to control my stages, but now

  • 0

I have written a script in Zaber Console to control my stages, but now I want to take some sensor readings during the movement. I want to move the stages, take a reading, and then move the stages again. Sometimes the sensor readings will affect the movements I need to make. How can I coordinate the movement with the sensor readings?

I want to talk to my Zaber devices on one serial port, and my sensor on a second serial port.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:41:41+00:00Added an answer on June 12, 2026 at 6:41 pm

    When you write a Zaber Console script, you have access to everything in the Microsoft.NET framework, so you can open a second serial port yourself. Here’s a simple example that tries to maintain a constant pressure on a pressure sensor. Each time through the loop, it reads the pressure sensor, then either retracts the device to increase the pressure or extends the device to decrease the pressure.

    // C# example that shows how to communicate with a second serial port
    #template(simple)
    
    const string LOAD_PORT = "COM9";
    const int MAX_SPEED = 20000;
    const int TARGET_PRESSURE = 1000; // in thousandths of a pound
    
    // set up load cell on serial port
    using (var port = new System.IO.Ports.SerialPort())
    {
        port.PortName = "COM9";
        port.BaudRate = 9600;
        port.ReadTimeout = 500;
        port.WriteTimeout = 500;
    
        port.Open();
    
        port.WriteLine("ct0\r");
        port.ReadLine();
    
        while ( ! IsCanceled)
        {
            port.WriteLine("o0w1\r");
            var pressure = Int32.Parse(port.ReadLine());
            int velocity = (pressure - TARGET_PRESSURE) * 20;
            int speed = Math.Min(Math.Abs(velocity), MAX_SPEED);
            velocity = speed * Math.Sign(velocity);
            Conversation.Device.Send(Command.MoveAtConstantSpeed, velocity);
        }
    }
    

    The using block makes sure that you close the serial port even when errors occur. The pressure sensor I used understood ct0 as a tare command and o0w1 as a command to return the current pressure, you’ll need to look at your sensor’s manual to see what commands it understands. You’ll also need to look up what baud rate and other settings to use. The SerialPort documentation lists all the communication parameters you can set.

    If you want to record the data from the sensor readings, one option is to just use Output.WriteLine(data) to dump the data values in the output window. Then you can copy and paste them into a spreadsheet or some other file. If you want to write directly to the file, look at the File.CreateText() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a script which is fetching data from database. Now I want
I have written a script which works, but I'm guessing isn't the most efficient.
I have written a Perl script for the following bioinformatics question, but unfortunately there
I have written a script in robotium which works just fine, but our application
i have written a script that prints a XML file to the screen but
I'm having some strange trouble with pamie: http://pamie.sourceforge.net/ . I have written a script
I have written php script for user login but instead of displaying the result
I have written a script that takes an XML feed of some news, and
I have written a script that saves the output in a Perl script, but
Using awk I have written this script but it's not working properly. Even I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.