Well, I had to go to Wikipedia to find out about Modbus. Seems to be a bit old [noparse][[/noparse]circa 1979]. I don't thing anyone has every thought of trying, but that doesn't mean that it cannot be done. The SXes have been used for I2C, CANbus and TCP/IP.
There is www.sxlist.com that might have something if anything has been done. If not, www.piclist.com may have code that is easily converted to an SX28.
Do you have any sample code in another microprocessor? Even an 8051 or AVR can be revised.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
I have some info abaut modbus protocol.I want to use sn75176 for halfdublex comunication.I dont know how to control A and B lines of sn75176 by sx code.the attacment is the pic basic version of the what I want on sx/b
Post Edited (AHMET AKSU) : 3/5/2008 10:28:45 AM GMT
I did a little reading and it appears that Modbus wants to use a lot of SRAM - 1k or more bytes. The PIC18 referred to in the above example can have 4k of registers available while the SX48 [noparse][[/noparse]the larger SRAM] has just 262 bytes in SRAM. So, if you need all those registers for proper operation, you would have to add a memory chip. I am not sure what all the registers are used for, but Modbus seems to remotely address at least 1k, and·upto 64k in each of 4 types.·· Slave units rarely use over 1k, but even that is a lot.
The sn75176 is driven by the same software for RS-232 serial both in the Modus and in general. SX/B can easily provide you with USART services in software and these connect via Tx and Rx pins to the sn75176. Pins 2 and 3 control the direction of the sn75176 and can be connected together and have on pin control them - recieve would be low and transmit would be high.
In your PIC example, it seems that Driver Enable controls the direction of the sn75176. If you read the documentation for the sn75176, it explains how to properly use the A and B lines. This is not the +12/-12 of RS-232, it is differential voltages. You might read about RS-485 half-duplex to understand it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
thanks Kramer for the reply.in my aplication I want to make comunication betwen one industrial pc (the master......) and 20 piece of sx.I think a protocol like that for the start
· byte 1·· ":"········ this is the start caracter · byte·2·············· the adres of sx between 1 and 20 ··byte·3·············· comand (a number between 1 and 20) · byte·4 to byte n·· n numbers of data byte which abaut the byte 3 · the final byte : the checksum of the bytes for the transmition control
I·have writen·pc side code to make this.and test vb progam with a industrial temperature controler.I need information abaut the usart of the sx.I want to know which command to transmit ,which comand to receive?
The chip itself is easy to use. Basically, all stations are in "listen" mode (RE/DE pulled low, I believe). When the master wants to talk, RE/DE is taken high and the data is sent to the chip on the D input. The other stations see the data on their R pins.
Now, the MODBUS protocol is a bit complicated, especially the checksum generation. But, you'll only need to implement one or two command sequences and it is possible to hardcode the checksums required. MODBUS is still very popular, despite its age.
Which PLC brand are you trying to communicate with? Some are easier to work with than others.
I think I have some more details which I can dig out when I get home.
If you can rely completely on SX/B to program, your PIC program would easily adapt. The SX just creates the USART in software. You won't see it mentioned in hardware documentation. SX/B has SERIN and SEROUT which provide only an 8N1 format.·
I see Modbus ASCII requires a 7 bit format with or without parity.· You may have to adapt SERIN and SEROUT to provide the format you want.· It is easier without any parity as that requires a bit of added assembly code, but in assembly code you can have any USART serial format you require.
Download the FREE SX/B documentation and FREE SX-Key IDE v.3.23 to get started.· If you intend to buy an SX-Key, buy the bundle with Guenther's tutorial text as it is quite important.· If you intend to have 262 bytes of SRAM, you will need an SX-48 Protoboard as the SX-28 has roughly half the SRAM and only 2k of program code space.
As mentioned before,·these SRAM registers are far smaller than the Modbus standard. Also, since Modbus addressing is 16 bits, not 8bits - you will possibly use up more registers for handling the addresses too.
Modbus seems very valid for supporting 'legacy systems'. Apparently is was widely used in industrial applications. There is even and Enron Exxon·Modbus that I guess is for oil industry systems.
The SX alone can really only provide a 'mini-slave' due to the SRAM limit. While the Modbus will support 256 nodes, RS-485 is generally limited to 32 nodes.· You mention that you want to provide 20. ·So you may not need a full Modbus register model.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
May I suggest that you stay with the 8N1 serial format while you initially develop the program in SX/B and consider adding other USART options after resolving all the Modbus code?? You can easily allow VB to temporarily support it.
I suspect getting started in SX/B would make this all evolve more quickly. Later, someone can help you set up more serial protocols and parity after you have proved to yourself that the Modbus slave program is working properly. After all, if you don't know how to program in assembly, you might get stuck with the USART and not finish the project.
Why start with a small, but complex detail when you hve a lot to learn?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
tHANKS Kramer.I have neccessary document and hardware as you said.and also my vb code can transmiting 8n1 .and you last idea abaut the initial development is wonderfull . after these words I want to ask that
1. are there a comand on sxb "select case" like on picbasic
2. can you write basic example for the serout and serin comand if its possible
I am working on a project that involves controlling irrigation sprinkler valves. Each one of the valves will be addressable. I started with the following document:
I've attached the *.bs2 code from the example. Next I converted the slave to *.sxb, this is also attached. Was having some problems as the project progressed with the control.bs2 code, early on, so I switched over to a PC running ProComm and used and RS-232 to RS-485 adapter. Then wrote a ProComm script in the 'Aspect' language to control the slave.
Also a good reference is the book by Jan Axelson, 'Serial Port Complete: COM Ports, USB Virtual COM Ports Second Edition' Found my copy on eBay for a good price.
You really need to get into SX/B for your questions to be answered. SERIN and SEROUT are clearly explained in both the manual and the help screens. If you installed SX-Key, read the Help Screens for SX/B for a quick introduction. They don't print out well and if you require printed documentation, download the manual and print it. [noparse][[/noparse]revised - G.Herzog]
Please forgive my error, I thought that an SX/B Manual was completed and available.· That seems to still be pending; so you will have to rely on the HELP screens to explain SX/B.· Jon Williams is working on a text, but only the first two parts are available at this time. There may be a way to print out the SX/B Help screens in a readible fashion, but I have not yet figure out how.· I have preferred to study SASM as it is a very good way to learn assembler.· The code is more compact and generally runs faster.
Regarding 'Select Case' - this is a multiple branching function. IN SX/B, you would use 'IF.... THEN.... ELSE' to do a similar kind of branching. The HELP screens have code examples. While the command's name maybe different, the use is the same. Of course, there will be other differences in programing style. But, it isn't that difficult to adapt if you fully understand the original program.
The fact is, that all fundamental Basic programing functions are functionally quite similar but different products choose to create a different lexicon for their functions.
The SXes support Nibble Swapping in their machine code - the SX/B command is SWAP -·and since I see that Modbus depends on nibbles to compactly transmit hexidecimal numbers, you might find that feature quite handy to even improve on the PIC code.
It isn't very difficult, once you adapt to it. I suspect SX/B may even be simpler as it doesn't have to adapt to the dozens of different chips that PIC makes. Essentially, there are only two hardware types - The SX-18/20/28 type and the SX-48/52 type.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Comments
There is www.sxlist.com that might have something if anything has been done. If not, www.piclist.com may have code that is easily converted to an SX28.
Do you have any sample code in another microprocessor? Even an 8051 or AVR can be revised.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
Post Edited (AHMET AKSU) : 3/5/2008 10:28:45 AM GMT
The sn75176 is driven by the same software for RS-232 serial both in the Modus and in general. SX/B can easily provide you with USART services in software and these connect via Tx and Rx pins to the sn75176. Pins 2 and 3 control the direction of the sn75176 and can be connected together and have on pin control them - recieve would be low and transmit would be high.
In your PIC example, it seems that Driver Enable controls the direction of the sn75176. If you read the documentation for the sn75176, it explains how to properly use the A and B lines. This is not the +12/-12 of RS-232, it is differential voltages. You might read about RS-485 half-duplex to understand it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
Post Edited (Kramer) : 3/5/2008 1:28:14 PM GMT
· byte 1·· ":"········ this is the start caracter
· byte·2·············· the adres of sx between 1 and 20
··byte·3·············· comand (a number between 1 and 20)
· byte·4 to byte n·· n numbers of data byte which abaut the byte 3
· the final byte : the checksum of the bytes for the transmition control
I·have writen·pc side code to make this.and test vb progam with a industrial temperature controler.I need information abaut the usart of the sx.I want to know which command to transmit ,which comand to receive?
The chip itself is easy to use. Basically, all stations are in "listen" mode (RE/DE pulled low, I believe). When the master wants to talk, RE/DE is taken high and the data is sent to the chip on the D input. The other stations see the data on their R pins.
Now, the MODBUS protocol is a bit complicated, especially the checksum generation. But, you'll only need to implement one or two command sequences and it is possible to hardcode the checksums required. MODBUS is still very popular, despite its age.
Which PLC brand are you trying to communicate with? Some are easier to work with than others.
I think I have some more details which I can dig out when I get home.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
I see Modbus ASCII requires a 7 bit format with or without parity.· You may have to adapt SERIN and SEROUT to provide the format you want.· It is easier without any parity as that requires a bit of added assembly code, but in assembly code you can have any USART serial format you require.
Download the FREE SX/B documentation and FREE SX-Key IDE v.3.23 to get started.· If you intend to buy an SX-Key, buy the bundle with Guenther's tutorial text as it is quite important.· If you intend to have 262 bytes of SRAM, you will need an SX-48 Protoboard as the SX-28 has roughly half the SRAM and only 2k of program code space.
As mentioned before,·these SRAM registers are far smaller than the Modbus standard. Also, since Modbus addressing is 16 bits, not 8bits - you will possibly use up more registers for handling the addresses too.
Modbus seems very valid for supporting 'legacy systems'. Apparently is was widely used in industrial applications. There is even and Enron Exxon·Modbus that I guess is for oil industry systems.
The SX alone can really only provide a 'mini-slave' due to the SRAM limit. While the Modbus will support 256 nodes, RS-485 is generally limited to 32 nodes.· You mention that you want to provide 20. ·So you may not need a full Modbus register model.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
Post Edited (Kramer) : 3/6/2008 12:11:11 PM GMT
I suspect getting started in SX/B would make this all evolve more quickly. Later, someone can help you set up more serial protocols and parity after you have proved to yourself that the Modbus slave program is working properly. After all, if you don't know how to program in assembly, you might get stuck with the USART and not finish the project.
Why start with a small, but complex detail when you hve a lot to learn?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
1. are there a comand on sxb "select case" like on picbasic
2. can you write basic example for the serout and serin comand if its possible
If your 'new' to RS-485 then this has helped me.
I am working on a project that involves controlling irrigation sprinkler valves. Each one of the valves will be addressable. I started with the following document:
http://www.parallax.com/Portals/0/Downloads/docs/prod/appkit/rs485Communication.pdf
I've attached the *.bs2 code from the example. Next I converted the slave to *.sxb, this is also attached. Was having some problems as the project progressed with the control.bs2 code, early on, so I switched over to a PC running ProComm and used and RS-232 to RS-485 adapter. Then wrote a ProComm script in the 'Aspect' language to control the slave.
Also a good reference is the book by Jan Axelson, 'Serial Port Complete: COM Ports, USB Virtual COM Ports Second Edition' Found my copy on eBay for a good price.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
Please forgive my error, I thought that an SX/B Manual was completed and available.· That seems to still be pending; so you will have to rely on the HELP screens to explain SX/B.· Jon Williams is working on a text, but only the first two parts are available at this time. There may be a way to print out the SX/B Help screens in a readible fashion, but I have not yet figure out how.· I have preferred to study SASM as it is a very good way to learn assembler.· The code is more compact and generally runs faster.
Regarding 'Select Case' - this is a multiple branching function. IN SX/B, you would use 'IF.... THEN.... ELSE' to do a similar kind of branching. The HELP screens have code examples. While the command's name maybe different, the use is the same. Of course, there will be other differences in programing style. But, it isn't that difficult to adapt if you fully understand the original program.
The fact is, that all fundamental Basic programing functions are functionally quite similar but different products choose to create a different lexicon for their functions.
The SXes support Nibble Swapping in their machine code - the SX/B command is SWAP -·and since I see that Modbus depends on nibbles to compactly transmit hexidecimal numbers, you might find that feature quite handy to even improve on the PIC code.
It isn't very difficult, once you adapt to it. I suspect SX/B may even be simpler as it doesn't have to adapt to the dozens of different chips that PIC makes. Essentially, there are only two hardware types - The SX-18/20/28 type and the SX-48/52 type.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PLEASE CONSIDER the following:
Do you want a quickly operational black box solution or the knowledge included therein?······
Post Edited (Kramer) : 3/6/2008 4:03:33 PM GMT