How can I set specific bits in a 16-bit integer?

Hello everyone,
as the title says I need to modify or rather to set a specific bit in a string which then is sent to a motor. I need to be sure that my command is correct as I am experiencing troubles with that motor and need to identify if its source.
First of all my strings have to be in the Little Endian order. Then the structure of the string should be the following:
Change Velocity command ‘V’xxCR 056h + one unsigned short (16-bit) integer + 0Dh (Note: Uppercase ‘V’)
Note: The lower 15 bits (Bit 14 through 0) contain the velocity value. The high-order bit (Bit 15) is used to indicate the microstep-to-step resolution: 0 = 10, 1 = 50 uSteps/step.
Until now, I used Flatten To String to convert 32 bit integers into bytes of the correct order. I thought I could use the Join Numbers function, but that only works for at least 8 bit numbers and there is no "1 bit number". I searched for an option to build a a string and set the bits via a Boolean Cluster, but I did not really understand how to transfer this to my problem.
How can I build up the correct 16-bit integer (e.g. set the velocity to "10000" with a resolution of 50 µSteps/step)
I would like to add the "V" and the CR via Concatenate Strings to the 16-bit integer, but other possibilites are also welcome.
I have seens the examples for bit manipulation in C-code, but I wish to do this with LabView as I am not familiar with C,matlab and so on.
Thank you very much for your help!
Solved!
Go to Solution.

You really need to learn Boolean logic and how to shift bits around.
AND is really good for masking out bits (forcing them to 0) and OR is really good for adding bit values.  Then Logical Shift is used to get the bits in the right places before doing the AND and OR.
NOTE: Rate is an enum with 10 being a value of 0 and 50 being 1.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Bit Packing.png ‏15 KB

Similar Messages

  • How can I set the textbox properties to get only integer on netbean?

    I use Netbean GUI and I create the swing textbox how can I set it to enter only Integer I don't want the people to enter the string.

    Please ask netbeans questions on the netbeans forum.
    Sounds like you want a JFormattedTextField or maybe a JSpinner.

  • How Can I set Specific RingTone for one person and general ringtone for all?

    Hello All,
    I have a problem with ringtone. I want to set specific ringtone for manager in my 99 series ip phone. Customer needs to know when manager calls him, that is why he told me that he wants to set specific ringtone for Manager.
    Thanks a lot
    Bahlul

    Hi Bahlul,
    I don't see such a feature on CUCM where you can have a separate ringtone for a Directory number based on the calling party number. Even to have separate ringtones for different lines on the same IP phone you need to play with Distinctiveringlist.xml , but that too does not fit your requirement as it will always be the same ringtone for all the calls on that line. You may probably get this feature through some third party solution but i am not sure if it would be worth it for applying it on one phone only.
    HTH
    Manish

  • How can I set Firefix to always start in 32-bit mode?

    Running FF 4.0.1 on OS X 10.6.7. Apparently defaults to start 64-bit mode. This doesn't work with an extension needed for Netflix streaming, requiring restart in 32-bit mode. How can I set FF to start in 32-bit mode in the first place? (And what would I miss out on if I did that?)

    ''Courtesy of cor-el''
    https://support.mozilla.com/en-US/questions/823873
    Other users should note that Firefox has public release versions of 64bit only for Mac And Linux; not for Windows, yet.

  • How can I set my Mac to only share SPECIFIC folders with Win7

    It used to work, but, even though I have set only my Public folder and a specific photographs folder to share with a Win7 PC on my home network, the Win7 machine can see the entire Mac HD.
    I followed instructions from here:
    http://www.trickyways.com/2011/07/file-sharing-mac-os-x-lion-and-pc-windows-7/
    But if I type Run then enter the ip address of the Mac, all the folders appear. Is there a way to limit them to only the two specific folders?
    I've mapped the single folder to a drive, so admittedly, unless you go into "Run", you can't see the other Mac folders and drives, but I'd still like to make sure it can't be done.
    Thanks

    Welcome to the Apple Community.
    Cricket66 wrote:
    ........ How can I set photo stream to only upload specific images?
    That's not possible unfortunately.

  • How can I set a specific user log on neme to a specific machine

    Greeting,
    I have a question : 
    How can I set a specific user log on name to a specific machine.
    e.g. 
    Only User.A can log on to PC.A and the other can not.
    Base On :
    Windows Server 2003
    Active Directory Version : 5.2.3790.1812

    Technically we're both right.  This depends on what scenario you're setting this up.
    1)  If you want to say only this person can log on to this machine, and it's not an enterprise solution (meaning you have a handful of computers you want restricted, not all computers) then do something like Yan Li has recommended.  However, I
    do not recommend using any DENY LOCAL LOGON user rights.  In this case, you would have to deny everyone except 'User A' and your Administrators.  If you put a user in ALLOW LOCAL LOGON and DENY LOCAL LOGON, then DENY wins and no one logs in.  Instead,
    you should remove all the settings from ALLOW LOCAL LOGON and add only User A and administrators.
    2) If this is an enterprise solution, use the LOG ON TO option I mentioned before.  Managing user right assignments per machine is very difficult and isn't a practical way to do it on a large scale.  If every user in your domain is assigned a computer
    that they can use, only that user can use that machine and that machine will effectively only allow that user.  For this to work, EVERY user must be restricted to a workstation, if no setting is present, then that user can log on anywhere.  This
    is my preferred solution still.
    Like I said, it depends on your situation to which route is better.  I hope this helps and is clear and easy to understand.
    - If you have my posts to be helpful, or the answer, please mark them appropriately.  Thank you.
    Chris Ream

  • How can I set a specific start play time after disc insertion?

    How can I set an automatic play start time of (say, a minute after the DVD was inserted) if the watcher has not selected anything from the main menu?
    TIA.
    MacBook Pro 2.16 ghz 17   Mac OS X (10.4.9)   FCP 5.1.2 DVDSP 4.1.1

    Set the timeout action for the menu in inspector
    (General Tab for the menu, set the seconds and what
    it should do there)
    I set the At End menu to Timeout, set the seconds to the same as the time for the song playing in the background to finish, and set the Action to go to the Track where the video is. The song ends but it just remains on the Main menu. The video doesn't start.
    What have I missed?
    Again, TIA.
    MacBook Pro 2.16 ghz 17   Mac OS X (10.4.9)   FCP 5.1.2 DVDSP 4.1.1

  • I do not see where to enter IP addresses in the Open VPN setup. Also, how can I set it up so that I can choose different servers in the same way as I can currently choose them with my VPN app but for PPTP?

    I think I have it working on my iPhone 5. But, I do not see how I can control the exit point that I would like for the VPN. Are all the exit points shown in the VPN setting now going to work with Open VPN, or do they remain PPTP? If I am reading correctly, they look like they remain PPTP. If I cannot control the exit point for open VPN, which exit point is the default in the profile you provided me?I note that Open VPN Connect does not work with any of the new 64 bit devices like the iPhone 5S, the iPad Air, and the new iPad MIni. Is there any chance that you guys will come up with an update for your app so that open VPN can be made to work on all iOS devices? That would be nice, particularly if the Open VPN Connect app does not give me a choice of exit points.Thanks,
    I do not see where to enter IP addresses in the Open VPN setup. Also, how can I set it up so that I can choose different servers in the same way as I can currently choose them with my VPN app but for PPTP?
    Just a quick note to tell you that Open VPN has updated their app so that it is compatible with 64 bit ARM devices like the iPhone 5S, the iPad Air, and the iPad Mini Retina.That does not resolve the problem of how to easily choose among the various possibilities for the exit server. We need to find an easy way to choose.

    Thank you for trying the new Firefox. I'm sorry that you’re unhappy with the new design.
    I understand your frustration and surprise at the removal of these features but I can't undo these changes. I'm just a support volunteer and I do not work for Mozilla. But you can send any feedback about these changes to http://input.mozilla.org/feedback. Firefox developers collect data submitted through there then present it at the weekly Firefox meeting
    I recommend you try to adjust to 29 and see if you can't make it work for you before you downgrade to a less secure and soon outdated version of Firefox.
    Here are a few suggestions for restoring the old design. I hope you’ll find one that works for you:
    *Use the [https://addons.mozilla.org/en-US/firefox/addon/classicthemerestorer/ Classic Theme Restorer] to bring back the old design. Learn more here: [[How to make the new Firefox look like the old Firefox]]
    *Use the [https://addons.mozilla.org/en-US/firefox/addon/the-addon-bar/ Add-on Bar Restored] to bring back the add-on bar. Learn more here: [[What happened to the Add-on Bar?]]

  • How can I install photoshop elements on a 64 bit windows system?

    How can I install photoshop elements on a 64 bit windows system?

    You just use the appropriate install disk/ download. See this:
    Install Premiere Elements, Photoshop Elements
    Or are you asking about some specific procedures?
    Mylenium

  • How Can I set up a JTable columns?

    Dear All,
    How can I set up my JTable columns to have the amount the user specifies?
    for example when the user types in 50 in JTextField 1 I want the JTables columns to then set to 50.
    How can this be done?
    Thanks
    lol
    import javax.swing.*;
    import javax.swing.table.TableModel;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class si1 extends javax.swing.JFrame implements ActionListener {
        JTextField name = new JTextField(15);
        JTextField name1 = new JTextField(15);
        public si1() {
            super("DataBase Loader");
            setSize(1025,740);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel pane = new JPanel();
            JPanel pane1 = new JPanel();
            JPanel pane2 = new JPanel();
            JPanel pane3 = new JPanel();
            JPanel pane4 = new JPanel();
            pane.setLayout(new GridLayout(20,1));
            pane1.setLayout(new BorderLayout());
            int j=10;
            String[][] data = new String[j][2];
            for (int k=0; k<j; k++){
               String[] row = {"",""};
               data[k] = row;
            String[] columnNames = {"First Name", "Last Name"};
            JTable perstab = new JTable(data, columnNames);
            perstab.setGridColor(Color.yellow);
            perstab.setPreferredScrollableViewportSize(new Dimension(500,500));
            JScrollPane scrollPane = new JScrollPane(perstab);
            pane1.add(new JPanel(), BorderLayout.EAST);
            JButton btn = new JButton("What are the names?");
            btn.addActionListener(this);
            btn.putClientProperty("DATABASE", perstab);
            pane1.add(new JPanel().add(btn), BorderLayout.SOUTH);
            pane2.add(name);
            pane3.add(name1);
            pane.add(pane2);
            pane.add(pane3);
            pane1.add(pane, BorderLayout.WEST);
            pane4.add(scrollPane);
            pane1.add(pane4, BorderLayout.CENTER);
            setContentPane(pane1);
            show();
        public static void main(String[] args) {
            si1 frame = new si1();
            frame.setVisible(true);
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable)((JButton)e.getSource()).getClientProperty("DATABASE");
            TableModel model = table.getModel();
            int count = model.getRowCount();
            String[] firstnames = new String[count];
            String[] lastnames = new String[count];
            for (int i=0; i < count; i++) {
               firstnames[i] = (String)model.getValueAt(i, 0);
                System.out.println("first name at row " + i + ": " + firstnames);
    lastnames[i] = (String)model.getValueAt(i, 1);
    System.out.println("lastname name at row " + i + ": " + lastnames[i]);

    As you can see I have tried this, but no success.
    If I am doing something wrong please accept my apology, and address me in the right direction.
    Thanks
    Lol
    import javax.swing.*;
    import javax.swing.table.TableModel;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.awt.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class si1 extends javax.swing.JFrame implements ActionListener {
        JTextField name = new JTextField(15);
        JTextField name1 = new JTextField(15);
        public si1() {
            super("DataBase Loader");
            setSize(1025,740);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel pane = new JPanel();
            JPanel pane1 = new JPanel();
            JPanel pane2 = new JPanel();
            JPanel pane3 = new JPanel();
            JPanel pane4 = new JPanel();
            pane.setLayout(new GridLayout(20,1));
            pane1.setLayout(new BorderLayout());
            int j=10;
            String[][] data = new String[j][2];
            for (int k=0; k<j; k++){
               String[] row = {"",""};
               data[k] = row;
            String[] columnNames = {"First Name", "Last Name"};
            JTable perstab = new JTable(data, columnNames);
         ((DefaultTableModel)perstab.getModel()).setColumnCount(Integer.parseInt(name.getText()));
            perstab.setGridColor(Color.yellow);
            perstab.setPreferredScrollableViewportSize(new Dimension(500,500));
            JScrollPane scrollPane = new JScrollPane(perstab);
            pane1.add(new JPanel(), BorderLayout.EAST);
            JButton btn = new JButton("What are the names?");
            btn.addActionListener(this);
            btn.putClientProperty("DATABASE", perstab);
            pane1.add(new JPanel().add(btn), BorderLayout.SOUTH);
            pane2.add(name);
            pane3.add(name1);
            pane.add(pane2);
            pane.add(pane3);
            pane1.add(pane, BorderLayout.WEST);
            pane4.add(scrollPane);
            pane1.add(pane4, BorderLayout.CENTER);
            setContentPane(pane1);
            show();
        public static void main(String[] args) {
            si1 frame = new si1();
            frame.setVisible(true);
        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable)((JButton)e.getSource()).getClientProperty("DATABASE");
            TableModel model = table.getModel();
            int count = model.getRowCount();
            String[] firstnames = new String[count];
            String[] lastnames = new String[count];
            for (int i=0; i < count; i++) {
               firstnames[i] = (String)model.getValueAt(i, 0);
                System.out.println("first name at row " + i + ": " + firstnames);
    lastnames[i] = (String)model.getValueAt(i, 1);
    System.out.println("lastname name at row " + i + ": " + lastnames[i]);

  • In EIC, how can we set the SLA of a subcategory to none SLA-related.

    Hi Experts,
    This is our current setup in EIC...
    Category 0501 has an SLA of 8 hours. Subcategory 050101 has to be none SLA relevant. But if we put zero or blank to the SLA Target Value field, it will automatically have a due date defaulted to today. If we will not indicate 050101 on the configuration, it will have the 0501 SLA of 8 hours.
    How can we set the 050101 SLA off?
    The path: IMG --> Personnel Management --> Employee Interaction Center (EIC) --> Interaction Center Web-Client --> Application Functions --> Activity --> Service Level Agreement (SLA) --> Define SLV Properties
    Thanks in advance.

    Hi Harish and Jarret.
    @Harish, I already tried unchecking the checkbox of the Display field but the problem with this is, it will also apply for the rest of the categories. It should only be for this specific subcategory.
    @Jarret, apology, but can you explain to me further about your instruction/advise? I get the feeling that we're on to something with your advise but I didn't quite get it on how to exactly.
    1. You should build the SLA from the lowest level up...
                        -I'm not really sure how, actually.
    2. If you have 8 subcats... will put the 8 entries in the table...
                        -where do I put the 1 subcat? This is because if I don't put that "No SLA" subcat in the table, the due date of that specific subcat will automatically appear todayu2019s date.
    Thanks for both of you. I really appreciate your help. 

  • How can I set up a rule to delete all messages older than 6 months left in Apple Mail's main inbox?

    How can I set up a rule to delete all messages older than 6 months left in Apple Mail's main inbox?
    I have created other rules to move some of my daily messages into specific folders and I don't wish to auto-delete those.
    Just the general stuff that keeps piling up in my me.com main email box.  Mail such as FB announcements and other low priority stuff I want to look at before deleting but don't want to keep longer than a week or month.
    TIA
    thokitts

    Thanks, but I am looking for a more automated solution than hand marking emails as junk. I might as well move them to the trash myself.
    Again, these are emails I want to receive and quickly read, but not keep longer than a week or month or so. By setting a rule to toss any older than 30 days back then my Mail program (and thus my hard drive) won't be wasting so much space. For example, currently I have over 6000 read messages, with their attachments, in my main email box. I'd rather not have to physically attend to sorting the one I don't want out.
    The one I do keep for other reasons get moved into other folders.
    It seems this should be possible.
    thokitts

  • How can I set home page for a new tab? how can i get firefox to open the home page every time i open a new tab in Windows vista home basic??

    How can I set home page for a new tab? how can i get firefox to open the home page every time i open a new tab in Windows vista home basic??
    == This happened ==
    Every time Firefox opened

    Firefox can have multiple home pages if you wish. Each home page that will open when starting Firefox is separated by the "|" character.
    See: http://support.mozilla.com/en-US/kb/How+to+set+the+home+page
    To have new tabs open a specific web site, add one of the following extensions:
    http://sogame.awardspace.com/newtaburl/
    https://addons.mozilla.org/en-US/firefox/addon/777

  • How can I set BOE XI R2 InfoView to use MM/DD/YYYY date format?

    How can I set BOE XI R2 InfoView to use MM/DD/YYYY date format instead of the default yyyy-mm-dd that comes up?
    Thank you.
    Paul

    I'm sorry to be dense.  Are you using BOE XI R2?  I don't see a "preferred viewing local" under preferences.  I see "My Interface Locale is..." under the General tab, which I have set to United States.  I don't see anywhere where I can enter in the dates and numbers.
    I also checked in the CMC under Business Object Enterprise applications, and did not see anything there either.
    Can you be specific?
    Thanks again.
    Paul

  • How can I set the size of an image in java?

    How can I set the size of an image in java? I have to choose the width and height of image...thanks to everybody...sorry for my english :-)

    Hi 43477
    Can you provide more details, do you want to setsize to display an image on a screen of when saving image etc?
    PS.
    There is a good invention called googlegoogle is good, but sometimes it's better to use more specific search, there is a search field avove on this page :)

Maybe you are looking for