Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication Failure

 

Hello,

I have been having the same issues for some time now. What appears to be happening is I get the number out of sequence. In other words when I expect a result of 138 counts I get something like 2560. Looking at it in hex it should be 00 8A, where I am getting 0A 00. After talking to the manufacture, I was told the first byte is the least significant and the second is the most significant byte. See below the PIC programming from the manufacture on how the data is sent. I have attached my block diagram of my vi program which read the data and moves it on to my main vi (not shown).

 

‘REM John Iovine 11/04
'Read Digital Output & send RS-232 info to PC
'Use 16F84-20MHZ microcontroller & 16 MHz Xtal

DEFINE OSC 16 'Use 16 MHZ Xtal

'Declare word variables
w1 VAR WORD

Start: ‘Main Program

Count PORTB.0, 1000, w1 'Count pulses every second
SerOut 1,6, [w1.byte0, w1.byte1] 'Send Information to PC
GoTo Start 'Do it again & again & again & ....

End

 

 

I think my issue is a timing thing. Should I use a timed while loop, or use a wait command?

 

Daniel Keyser


"I reject your reality and substitute my own"
Adam Savage
"Mythbusters"
0 Kudos
Message 1 of 5
(3,586 Views)
Hi

As far I can see you do not check for two bytes to read but read just all.
This can be 1 byte and you still translate to two bytes,
LabVIEW has no check on index array bounds so you get a zero for that byte if not avalable.

In your case I would read exactly 2 bytes and then continue.

greetings from the Netherlands
0 Kudos
Message 2 of 5
(3,581 Views)
Do you mean something like this?
 
 
See Attached


Message Edited by Dan@NIST on 11-09-2007 03:30 PM
Daniel Keyser


"I reject your reality and substitute my own"
Adam Savage
"Mythbusters"
0 Kudos
Message 3 of 5
(3,576 Views)
Yes, almost Ok

But better make the test >=2 and read only 2 at a time
greetings from the Netherlands
0 Kudos
Message 4 of 5
(3,561 Views)

OK, thanks. I will give that a shot! Have a good weekend.

Daniel Keyser


"I reject your reality and substitute my own"
Adam Savage
"Mythbusters"
0 Kudos
Message 5 of 5
(3,559 Views)