LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing scripts in CVI

If you're having trouble understanding the hex format, google hexadecimal to find a wealth of information.

Here's a pretty concise article: http://searchcio-midmarket.techtarget.com/sDefinition/0,,sid183_gci212247,00.html

This wikipedia article is much more detailed than you probably need right now, but there's a liittle chart that shows you conversions.

 

Play with the Windows calculator.  In the Scientific view, you can convert numbers between hex, decimal, octal, and binary.  Just enter any number, then click what representation you want to see (hex, decimal, octal, or binary).

0 Kudos
Message 21 of 27
(2,418 Views)

so basically it i can assign addess with hex, and not just only binary numbers. is there also a good website of pointing to various addresses and assigning address

 

 

can you give me a website or book to look at . pointing with hex and binary

 

0 Kudos
Message 22 of 27
(2,415 Views)

Darnell:

 

Why you are asking about addresses?  In the question you posted about (ibsta & 0x8000), 0x8000 is not an address: it is a value used to check an individual bit of the global status variable ibsta.

 

If you need to know the addresses on some card you need to talk to, you need to check the programmer's manual for that card.  You don't just assign addresses.

 

Hex or binary or decimal: the number doesn't change, only the representation of it.  To a computer, everything is binary.  Once you're used to the hex representation, it is easy to see if a bit is high or low.  If I look at a number in hex, like 0xA70, I can tell you that bits 11, 9, 6, 5, and 4 are high.  But if I look at that same number in decimal, 2672, I have no idea which bits are high.  I can tell you that bit 0 is low, since it's an even number, but that's about it.

 

As I said earlier, you can just play with the Windows calculator to go back and forth from hex to decimal and binary.

 

Here's the post from wikipedia I meant to include earlier.  It may just be confusing, since it goes into a lot of detail.

http://en.wikipedia.org/wiki/Hexadecimal

 

From the CVI help on ibwrt(), here are the other bits in ibsta:

 

Status is actually the global variable named "ibsta".

Note:  If you are calling GPIB functions from more than one
       thread of execution, you should use the ThreadIbsta
       function rather than the ibsta global variable.

This value reflects a um of one or more of the following conditions:

  Defined         
  Constant        Hex Value     Condition
 --------------------------------------------------------------
    ERR             8000        GPIB error
    TIMO            4000        Timeout
    END             2000        END or EOS detected
    SRQI            1000        SRQ on
    RQS              800        Device requesting service
    SPOLL            400        Board has been serially polled**
    EVENT            200        An event has occurred**
    CMPL             100        I/O completed
    LOK               80        GPIB-PC in Lockout State
    REM               40        GPIB-PC in Remote State
    CIC               20        GPIB-PC is Controller-In-Charge
    ATN               10        Attention is asserted
    TACS               8        GPIB-PC is Talker
    LACS               4        GPIB-PC is Listener
    DTAS               2        GPIB-PC in Device Trigger State
    DCAS               1        GPIB-PC in Device Clear State

    ** MS Windows only

0 Kudos
Message 23 of 27
(2,413 Views)

hi i got a question

 

 

im trying to execute this in code. i need doing something wrong

 

.

 

var =000001 , var =00010

 

then I want to 00000100010

 

then my address number is 25 which is 11001

 

so then i want my result to be 0000010001011001

 

im doing something wrong, i dont know where im messing up at in my program.

 

 

********************************

 


int main()

{
      short int DATA1=000001,DATA2=00010,DATA_RESULT;
      short int ADDRESS=11011;
    //short int DATA = 0x044;
    //short int ADDRESS = 0x12;
        int result;
   
   

   
     
     DATA1<<=5;
     
     result= DATA1|DATA2;
     
     result|ADDRESS;
   
     printf("%x",result);
    GetKey();

return 0;
}
 

 

 

0 Kudos
Message 24 of 27
(2,377 Views)

Darnell:

 

When you say DATA2=0010 or ADDRESS=11011, the compiler does not recognize them as binary numbers.

0010 gets recognized as an octal number, due to the leading zeros.  This is really a throwback to 8 bit processors (anybody else remember those?).  Octal 0010 = 8 decimal.

11011 gets recognized as a decimal number 11 thousand 11.

 

0010 binary = 2.  You should set DATA2 = 2;

 

Hexadecimal representation is a good way to enter larger numbers if you want to easily convert them to binary in your head.  C compilers recognize numbers starting with 0x as hex.  Four binary bits = 1 hex digit, grouping from right to left.

11011 binary = 0x1B

 

You should debug your code using breakpoints, single step through your code and look at the variable values.  Some of this will be obvious when you do that.  You would have seen that your variables were not being set as you expect.

 

0 Kudos
Message 25 of 27
(2,375 Views)

i have this now.

 

but the result is not decimal value 1113, which is 0000010001011001

 

i dont know what im doing wrong?

 

 

int main()

{
      short int DATA1=1,DATA2=2,DATA_RESULT;
      short int ADDRESS=25;
    //short int DATA = 0x044;
    //short int ADDRESS = 0x12;
        int result;
  
  

  
    
     DATA1<<=5;
    
     result= DATA1|DATA2;
    
     result|ADDRESS;
  
     printf("%x",result);
    GetKey();

return 0;
}

0 Kudos
Message 26 of 27
(2,372 Views)

Darnell:

 

You need to step through your code and watch the variables as you go!  Do you know how to do that?

 

The following statement doesn't do anything because you don't assign the results anywhere (there is no '=' sign on that statement).

 

 result|ADDRESS;

 

The compiler will do the bit-wise OR, but you don't tell it where to put the results.

 

 

0 Kudos
Message 27 of 27
(2,367 Views)