09-09-2009 08:59 AM
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.
09-09-2009 09:36 AM
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.
09-09-2009 09:56 AM
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.
09-09-2009 10:12 AM
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).
09-09-2009 10:35 AM
the power was wired backwards, i think that that did damage the card.
09-09-2009 01:12 PM
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.
09-09-2009 01:34 PM - edited 09-09-2009 01:43 PM
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)
09-09-2009 01:46 PM
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.
09-09-2009 01:56 PM
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.
09-09-2009 01:56 PM
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.