LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write to custom hardware via serial communication ?

make a photo just now, so u all can see how is this hardware looks...


Message Edited by kingofnoland on 01-04-2007 12:39 PM

0 Kudos
Message 31 of 44
(2,022 Views)
The "\n" is simply a termination character.  Computers somehow have to detect when a device is finished with sending a message.  There are many different methods for this detection, but that all depends on the bus system.  In most cases, simple programming and general exercises, you don't have to worry about the termination characters because the computer's defaults normally take care of that.  However, in this case, you have to influence termination characters with the VISA.
 
Termination characters are normally just one character (\n, \r) but can also be a sequence of characters.  The computer will read and read and read until this termination character is detected, and once it is detected, it is given to the calling application.  Here on, the next read operation continues after another termination character is detected until there is no longer any more for the computer to read.
0 Kudos
Message 32 of 44
(2,017 Views)

That would mean that you have Pin 2 wired to Pin3 at the PC end. That might be a short on your rsr232 cable or your pcb prototype. That would explain why the characters are being received at the serial port. Remove the RS232 cable at the PC and check that there isn't a short circuit between pins 2 and 3.

David

0 Kudos
Message 33 of 44
(1,993 Views)
Your C code indicates that termination character is sent with the "S" command only.  Character is 0XD, otherwise known as "0D hex" or "carriage return" or "\r".  It does no appear that termination character is sent with other commands.
 
The other question concerns any hardware handshaking that is going on.  Do you have a pinout of the cable that connects the PC to your board?  The pinout should give a clue as to the handshaking going on.
Message 34 of 44
(1,982 Views)

Here is another observation about your C code.  I think it is a bit misleading as to the protocol.  I'm pretty sure that the sequence of events should be as follows:

write command "C" to reset the transmitter

write command "T" plus the transmitter address

write command "S" plus the termination character "cr" or "\r"

My reasoning is that if you are talking to multiple transmitters, you must first command which one you want to communicate with ( command "T" ) before you request the status ( "S" )

 


 

0 Kudos
Message 35 of 44
(1,969 Views)
David - there isn't a short circuit between pins 2 and 3.
while not connecting the cable, it have a Failed message , please look at the pic.( Image-0011.png )
how or where i should  add a data in ?
i mean the number ( converted to 8 bit binary mode)  to operate the circuit ?

Steve - i understand what u trying to tell me but for now, cant do nothing with it ....
as u can see, the project is in  stuck position and i dont know even where to write that termination...

btw. the main
issue for now is how  to send the data ....the reading back is minor for now....
i must figure how to send the correct data to the transmitter (connected to my pc) ......This the only way to operate it ,
Please look at pic [ Image-0012.png ]

centerbolt  - pic [ Image-0009.png ] is what u looking for ?

you right
about the sequence of events ......but missed in the multiple transmitters .
there is only one transmitter, connected to the PC .
there is up to 127 receiver , all over the house...
the command from the pc , for example "15", will operate the receiver coded with "0001111" (see
Image-0012.png )


i'm very grateful for the comments and hoping that u won't be
despair....and keep help me....




Download All
0 Kudos
Message 36 of 44
(1,959 Views)
Good Morning,
I have another idea to find out what is going on during the serial communication: Connect your old dos system to your device let it run and view what is going on during the communication. You can find some RS232 analyser software. Please take a look here: http://www.lookrs232.com
and here: http://www.232analyzer.com/232default.htm
You install it on another PC, connect the serial ports (for read and write monitoring) of this through a special adapter cable (self made or purchased) and record the signals during your dos PC communicates with the device.
I haven't got experience with this tool, but I'd like to try it out by myself, too (in case the manufacturer of our air ventilation controller unit doesn't supply the communication protocol that I asked).
Ciao,
Olli

Message Edited by Olli on 01-05-2007 02:50 AM

Message Edited by Olli on 01-05-2007 02:54 AM

0 Kudos
Message 37 of 44
(1,928 Views)
K
 
I have added more to my labview example.
 
Send R to reset device
Send S to request status
Read Status byte from Serial Port
Send T to command device
Send Byte to as command byte
Send ; which I assume is the command teminator.
 
I haven't implemented the 'S' & 0xD, read status part.
 
In Reply 24 your image had the read buffer as 5253 which is RS in ascii. Now said to me that PC rs232 receive buffer had RS in there. That might mean that your micro code is providing a local echo to the RS characters already sent by the labview program or that pins 2 and 3 are shorted together somehow. You have proved that they are not shorted in your rs232 cable or custom hardware.
 
David
0 Kudos
Message 38 of 44
(1,919 Views)
hi all,

Olli - i will learn this app. and get another pc to work out.
thank u for the links...

David - thank u very much for your time , do a grate work with this example .

i cant figure where to input my data in it...trying the "byte" but didnt get any different . 😞
when i run it, the same RS is showed....

is the stop bit,parity etc . are sending with the 1 byte ?
in the C code, there is a char of [10] that include them all....
see the [Image-0016.png]  for example how to send "A" [ please remember i need to send a number...]




Download All
0 Kudos
Message 39 of 44
(1,899 Views)

To get 'A' or 1010 then you enter 0A into control Byte when in hex display mode (little x on left). This will send 00001010 in the 8 data bits of the serial packet

I was wondering about the address being up to 10 characters long. What you normally type into the DOS program when prompted?

I am sorry to sound like a broken record but I am very suspicious about the RS characters appearing in the receive buffer of the PC com port when using the example program. Its either the custom hardware micro code responding in echo or Pins 2 and 3 are shorted together in either the RS232 cable assembly or the custom hardware.

David

0 Kudos
Message 40 of 44
(1,880 Views)