<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.mcselec.com/bavr/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=Using_RS485%2Fde</id>
		<title>Using RS485/de - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.mcselec.com/bavr/index.php?action=history&amp;feed=atom&amp;title=Using_RS485%2Fde"/>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=Using_RS485/de&amp;action=history"/>
		<updated>2026-04-26T17:28:00Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.18.6</generator>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=Using_RS485/de&amp;diff=1690&amp;oldid=prev</id>
		<title>Admin: 1 revision</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=Using_RS485/de&amp;diff=1690&amp;oldid=prev"/>
				<updated>2013-02-15T19:05:52Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 19:05, 15 February 2013&lt;/td&gt;
		&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://wiki.mcselec.com/bavr/index.php?title=Using_RS485/de&amp;diff=1689&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;&lt;span class=&quot;f_Header&quot;&gt;RS485&lt;/span&gt;  &amp;nbsp;  RS485 is used for serial communication and well suited for transmission over large distances.  Similar to RS232 we need a level sh...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.mcselec.com/bavr/index.php?title=Using_RS485/de&amp;diff=1689&amp;oldid=prev"/>
				<updated>2013-02-01T13:14:44Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;RS485&amp;lt;/span&amp;gt;     RS485 is used for serial communication and well suited for transmission over large distances.  Similar to RS232 we need a level sh...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== (**COPIED FROM ENGLISH PAGE**) ==&amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;RS485&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
RS485 is used for serial communication and well suited for transmission over large distances.&lt;br /&gt;
&lt;br /&gt;
Similar to RS232 we need a level shifter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Rs485-example.png|center|500px|Rs485-example.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sample above uses a MEGA161 or MEGA162 which has 2 UARTS. This way you can have both a RS232 and RS485 interface.&lt;br /&gt;
&lt;br /&gt;
The RS232 is used for debugging.&lt;br /&gt;
&lt;br /&gt;
In order to test you need 2 or more similar circuits. One circuit would be the master.&lt;br /&gt;
&lt;br /&gt;
The other(s) would be a slave.&lt;br /&gt;
&lt;br /&gt;
The same hardware is used to test the MODBUS protocol. The bus need to be terminated at both ends with a resistor. 100 ohm is a typical used value.&lt;br /&gt;
&lt;br /&gt;
The GND of both circuits may not be connected&amp;amp;nbsp;! Only connect point A and B from both circuits. For industrial usage it is best to use an optical isolated level shifter.&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
= &amp;lt;span class=&amp;quot;f_Header&amp;quot;&amp;gt;Simple MASTER sample&amp;lt;/span&amp;gt;&amp;lt;br/&amp;gt; =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bascomavr&amp;quot;&amp;gt;&lt;br /&gt;
$regfile = &amp;quot;m162def.dat&amp;quot; ' specify the used micro&lt;br /&gt;
$crystal = 8000000&lt;br /&gt;
$baud = 19200 ' use baud rate&lt;br /&gt;
$hwstack = 42 ' default use 32 for the hardware stack&lt;br /&gt;
$swstack = 40 ' default use 10 for the SW stack&lt;br /&gt;
$framesize = 40 ' default use 40 for the frame space&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
$lib &amp;quot;modbus.lbx&amp;quot;&lt;br /&gt;
Config Print1 = Portb.1 , Mode = Set ' use portb.1 for the direction&lt;br /&gt;
Rs485dir Alias Portb.1&lt;br /&gt;
Config Rs485dir = Output&lt;br /&gt;
Rs485dir = 0 ' go to receive mode&lt;br /&gt;
Portc.0 = 1 ' a switch is connected to pinc.0 so activate pull up resistor&lt;br /&gt;
' TX RX&lt;br /&gt;
' COM0 PD.1 PD.0 monitor&lt;br /&gt;
' COM1 PB.3 PB.2 rs485&lt;br /&gt;
' PB.1 data direction rs485&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0&lt;br /&gt;
Config Com2 = 9600 , Synchrone = 0 , Parity = Even , Stopbits = 1 , Databits = 8 , Clockpol = 0 ' MUST MATCH THE SLAVE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'use OPEN/CLOSE for using the second UART&lt;br /&gt;
Open &amp;quot;COM2:&amp;quot; For Binary As #1&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'dimension some variables&lt;br /&gt;
Dim B As Byte&lt;br /&gt;
Dim W As Word&lt;br /&gt;
Dim L As Long&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
W = &amp;amp;H4567 ' set some values&lt;br /&gt;
L = &amp;amp;H12345678&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Print &amp;quot;RS-485 MODBUS master&amp;quot;&lt;br /&gt;
Do&lt;br /&gt;
 If Pinc.0 = 0 Then ' test button&lt;br /&gt;
 Waitms 500 ' delay since we want to send just 1 frame&lt;br /&gt;
 Print &amp;quot;send request to slave/server&amp;quot; ' to debug terminal&lt;br /&gt;
 ' Print #1 , Makemodbus(2 , 3 , 8 , 2); 'slave 2, function 3, start address 8, 2 bytes&lt;br /&gt;
 ' Print #1 , Makemodbus(2 , 6 , 8 , W); 'slave 2, function 6, address 8 , value of w&lt;br /&gt;
 Print #1 , Makemodbus(b , 16 , 8 , L); 'send a long&lt;br /&gt;
 End If&lt;br /&gt;
 If Ischarwaiting(#1) &amp;lt;&amp;gt; 0 Then 'did we got something back?&lt;br /&gt;
 B = Waitkey(#1) ' yes so get it&lt;br /&gt;
 Print Hex(b) ; &amp;quot;,&amp;quot;; ' print it&lt;br /&gt;
 End If&lt;br /&gt;
Loop&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A slave would simply listen to data, and once enough data received, send it back.&lt;br /&gt;
&lt;br /&gt;
The MODBUS slave code is available as a commercial add on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Languages}}&lt;br /&gt;
&lt;br /&gt;
[[Category:BASCOM_HARDWARE/de]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>