LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

device card

Darnell:

 

You said that when you "put the cursor over the bytes_read=ComRd(1,inbuff,7). the bytes_read saids it 0".  Where was your breakpoint?  Had that line of code been executed?  It's commented out in the code you posted.  When you're at a breakpoint, you can view memory values (if they're in scope) before they are modified in subsequent lines of code.  You can also view the memory value of a variable name you point to in a comment.

 

At some point you actually executed at least some of the lines that were commented out in your post I pointed out earlier, otherwise you wouldn't have seen any output on the scope.  But when you post code with lines commented out, it makes us wonder what you actually executed.

0 Kudos
Message 61 of 80
(1,846 Views)

sorry about  all of the commented out , some of stuff i commented yesterday was when we were trying to find out why everything was reverse.

 

but yeah everything in my code is correct. the version i posted last , was probably the version i forgot to uncomment out before i posted the code.

 

but i did do a master reset. on the master card the address is 0. on the device card the address is 1. the bytes are being sent out, but they are not being read for some 

 

apparent reason.  everything you mention this morning we check everything yesterday. but come to find out the hardware guy end of wiring the card wrong. there wasnt

 

no power to the card at all.

 

i also mention to the hardware guys that  we probably need a cross over cable instead of a straight pin cable. the hardware guy mention that he's going to get another

 

card 

 

because he think the card is not good at this point  because the card was wired backwards and then also the card yesterday was to hot. So everything you mention

 

today further let me know that we are on the same page. 

0 Kudos
Message 62 of 80
(1,846 Views)

my breakpoint was after the ComRd. so the bytes_read was executed, its just simply not reading nothing from the card. but keep in mind there wasnt no power, then when

 

 

we added power and it still wasnt reading nothing.

0 Kudos
Message 63 of 80
(1,843 Views)

RS232 is a pretty robust interface.  Wiring the COM cable backwards should not damage the card, but obviously COM won't work with the backward cable installed.  If that was the only problem, it should be fine when you install the right cable.  You need to check with the master card supplier or their documentation to see how the cable should be wired.

 

If power was wired backwards, that could damage the card.  If there was no power to the card, I don't think it would have gotten hot.

 

When you do a master reset, you don't use the address of the DD card.  I didn't see an 'R' command in the code you posted.  Once you get the power and COM cable straightened out, I would still recommend that you send an 'R' command and see what happens.

 

By the way, you can't say that "everything in my code is correct" before you get it working.  Even when my own code is "working", I never assume that everything is correct, and you should keep an open mind about yours too.  If you start by saying the code is correct, you may miss bugs (or a misinterpretation of the documentation).

0 Kudos
Message 64 of 80
(1,840 Views)

the power was wired backwards, i think that that did damage the card.

 

 

0 Kudos
Message 65 of 80
(1,836 Views)

do you know the way how to turn off  a certain bit in element of an array.

 

i cant remember how to do it.

 

for example Al_S[3];

 

AL_S[1]=1;  in binary 1 is 00000001

 

i wanted to change the 3rd bit only to 1.

 

whats is the unique way to do that?

 

just trying things out for practice at the moment.,this is nothing pertaining tomy code.

 

 

0 Kudos
Message 66 of 80
(1,837 Views)

Darnell:

 

I talked about this in answer to another of your posts here:

http://forums.ni.com/ni/board/message?board.id=180&message.id=42762&query.id=941914#M42762

 

To set a single bit, use bit-wise OR.

 For example (assuming the AL_S array is an int or char):

AL_S[1]=1;

AL_S[1] = AL_S[1] | (1 << 3);  // set bit 3 (starting from 0)

 

If you only want 1 bit set and don't care about the previous value, just shift a 1.

AL_S[1] = 1 << 3;  // set value to 0000 1000 binary

 

To clear a single bit, use bit-wise AND.

 

AL_S[1] = AL_S[1] & 0xF7; // clear bit 3 (starting from 0)

 

Message Edited by Al S on 09-09-2009 01:43 PM
Message 67 of 80
(1,836 Views)

i know how to do it that way.

 

its use be a way you can grab the power of the bit and just flip that one bit in the element of the array.

 

2^7,2^6,2^5,2^4,2^3,2^2,2^1,2^0

 

 

 

its a way where you grab that power and and you just flip that one bit without shifting it , 

 

i cant remember how to do it.

 

AL_S[1](2^3,1);  its something to that extinct, i just cant really remember at the moment, i got a brain freeze.

 

 

0 Kudos
Message 68 of 80
(1,822 Views)
body { margin: 0 0 0 0; padding:0 0 0 0 } td,div { font-family:Tahoma;font-size:12pt;vertical-align:top } body { margin: 0 0 0 0; padding:0 0 0 0 } .transcript { background-color:#d2d2d2; } .messageBlock { margin-left:4px; margin-bottom:3px } .message { margin-left:100px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre; } .messageCont { margin-left:100px; word-wrap:break-word; white-space:-moz-pre-wrap; _white-space:pre;} .other { color:#39577a;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .myself { color:#da8103;font-style:normal;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont { font-size:8px;text-align:right; color:#39577a;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .myselfCont { font-size:8px;text-align:right; color:#da8103;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .system { margin-left:4px; word-wrap:break-word;color:#da8103;font-style:normal;font-weight:normal; white-space:-moz-pre-wrap; _white-space:pre; } .showTimestamp { margin-right:3px; float:right; color:#999999;font-style:normal;font-weight:normal; } .other1 { color:#ac2000;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont1 { font-size:8px;text-align:right; color:#ac2000;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other2 { color:#3c9fa8;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont2 { font-size:8px;text-align:right; color:#3c9fa8;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other3 { color:#e25614;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont3 { font-size:8px;text-align:right; color:#e25614;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other4 { color:#0b6ac8;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont4 { font-size:8px;text-align:right; color:#0b6ac8;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other5 { color:#b23290;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont5 { font-size:8px;text-align:right; color:#b23290;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other6 { color:#02e7c7;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont6 { font-size:8px;text-align:right; color:#02e7c7;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .other7 { color:#5b3284;vertical-align:top;font-weight:bold;font-style:normal;float:left; width:95px; } .otherCont7 { font-size:8px;text-align:right; color:#5b3284;font-family:Arial,Lucida Grande;font-style:normal;vertical-align:top;font-weight:bold;float:left; width:95px; } .tsDisplay { display:block }

inline unsigned flip ( unsigned x, unsigned bit )
{
return x ^ (1UL << bit);

 

 

 

i think its something to this extinct, i will do my research after lunch, let me know if you get something different, besides the way we already know.

0 Kudos
Message 69 of 80
(1,823 Views)

Bit-shifting is the cleanest way to set an individual bit.

 

You can also raise 2 to a power using the ANSI C pow() function.

 

x = pow(2, 3);  // raise 2 to the power of three to get 0000 1000 binary

 

I did that in another answer to another of your questions here.

http://forums.ni.com/ni/board/message?board.id=180&message.id=42460&query.id=945962#M42460

 

See how much you would learn by reading the answers to your questions?

 

Even though I used pow() in one of my examples, I think bit shifting is still the cleanest way to go.  jr_2005 also thinks so if you look at his response to the post I referenced above.

 

 

Message 70 of 80
(1,824 Views)