Jerson,
Can you elaborate on your method? It's sounds interesting since you apparently don't require any manipulation of the stop bit on the PC side.
Darryl
Jerson,
Can you elaborate on your method? It's sounds interesting since you apparently don't require any manipulation of the stop bit on the PC side.
Darryl
Darryl
As I showed in the previous post, you build your own protocol. If you are doing ASCII commands, then you need a sync character to know the start of packet.
This can be the format for a typical packet. STX (02H) is the start character you seek to know there is a command / response packet. DST is the slave id which you want to talk to. SRC is the id of the master and can be omitted if there is a single master as in the case of a PC based logger. CMD tells the slave which function is being invoked and DATA passes parameters to the function if they are needed. Finally CS is a checksum to verify that the data packet has arrived without corruption. CS could be as simple as a LRC longitudinal redundancy check or as severe as a CRC16 cyclic redundancy check.Code:STX DST SRC CMD DATA.......DATA CS ETX
ETX (03H) generally is not needed but can be used to frame the command / response packet.
The slave responds with a message within the alloted time window (fixed by your program). If not, the master times out and understands that the slave is disconnected or not working. I have built many systems using this type of
protocol and it works really well.
You could look at the MODBUS specification if you want to learn more. MODBUS however offers an ASCII mode and a binary RTU mode. PLCs generally use the RTU mode to garner speed. In ASCII mode, you have to send every byte converted to 2 bytes of ASCII. So, a character like 02H will be sent as 30H, 32H. This is also applicable to the protocol I described above.
Jerson
Hi,
Thank You !
Yes I think I will use my own Protocoll !
But I dont understand how Can I send a 9 Bit Packet when a Byte have just 8 Bit?
9 Bit is more then 255 and is a Word Size !
Thats mean when I Use 9Th Bit I must send a Word Divided in two Bytes ?
Thanks
Regard Pesti.
Pesti
You do not have to use 9 bits. Your standard serial UART will do the job just fine. I mentioned this earlier
When you use the 9 bit packets, you distinguish address and data bytes by the 9th bit alone. So, any byte having the 9th bit set is an 8bit address byte whereas all words with the 9th bit low are data.You can define your own protocol and use it with normal 8 bit data.
Jerson
Last edited by Jerson; - 4th August 2007 at 09:25.
Ok I understand,but where is the 9th bit ?
When I send 1 Byte I have: 1 Start Bit,8 Data Bit,1 Stop Bit.
Where Is here the 9Th Bit? :-)
For example when I use Hyperterminal I can not adjust to 9th Bit I just have 7 or 8 Bit data.
Regard Pesti
Hi,
The USART module of a PIC has multi-processor communication
capability using 9-bit address detection.
See this document:
http://www.datadog.com/rs485.pdf
Use The PC's UART With 9-Bit Protocols
http://www.elecdesign.com/Articles/I...ArticleID=6245
(You will have to wait 20 seconds before you see the doc).
See the datasheet of the used chip.
Best regards,
Luciano
Bookmarks