<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=22&amp;t=6538&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-04-05T09:33:10+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=22&amp;t=6538&amp;mode</id>
<entry>
<author><name><![CDATA[Krauser]]></name></author>
<updated>2014-04-05T09:33:10+01:00</updated>
<published>2014-04-05T09:33:10+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=77020#p77020</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=77020#p77020"/>
<title type="html"><![CDATA[Re: Odbiornik RC5 z interfejsem RS-485 / MODBUS RTU]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=77020#p77020"><![CDATA[
Wszystko co trzeba robić jest w funkcji main, a dokładnie w pętli for(;;). Tam widać podstawianie wartości do tablicy usRegInputBuf. Na początek może wystarczy:<br />[syntax=c]usRegInputBuf&#91;0&#93;= address;<br />usRegInputBuf&#91;1&#93;= 0;<br />usRegInputBuf&#91;4&#93;= command;<br />usRegInputBuf&#91;5&#93;= 0;[/syntax]<br />address i command są to zmienne globalne z pliku ir_decode.c i są zadeklarowane jako extern, więc są dostępne również w innych plikach.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=465">Krauser</a> — 5 kwi 2014, o 09:33</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[llemar]]></name></author>
<updated>2014-04-03T08:42:04+01:00</updated>
<published>2014-04-03T08:42:04+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76818#p76818</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76818#p76818"/>
<title type="html"><![CDATA[Re: Odbiornik RC5 z interfejsem RS-485 / MODBUS RTU]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76818#p76818"><![CDATA[
Poszperałem trochę w necie i udało mi się skompilować freemodbus'a. Mam teraz taki oto kod i pytanie: Jak to zrobić, żeby ze slave z poniższym kodem (Atmega32) odczytać zmienną &quot;command&quot; (to zmienna z przykładu 11_RC_decode, który w późniejszym czasie połączę) ?? Czy trzeba jakoś skopiować zawartość tej zmiennej pod określony adres Holding Register?? Jak to się robi ??<br />[syntax=c]* FreeModbus Libary: AVR Demo Application<br /> * Copyright (C) 2006 Christian Walter &lt;wolti@sil.at&gt;<br /> *<br /> * This program is free software; you can redistribute it and/or modify<br /> * it under the terms of the GNU General Public License as published by<br /> * the Free Software Foundation; either version 2 of the License, or<br /> * (at your option) any later version.<br /> *<br /> * This program is distributed in the hope that it will be useful,<br /> * but WITHOUT ANY WARRANTY; without even the implied warranty of<br /> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br /> * GNU General Public License for more details.<br /> *<br /> * You should have received a copy of the GNU General Public License<br /> * along with this program; if not, write to the Free Software<br /> * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA<br /> *<br /> * File: $Id: demo.c,v 1.7 2006/06/15 15:38:02 wolti Exp $<br /> */<br /><br />/* ----------------------- AVR includes -------------------------------------*/<br />#include &quot;avr/io.h&quot;<br />#include &quot;avr/interrupt.h&quot;<br /><br />/* ----------------------- Modbus includes ----------------------------------*/<br />#include &quot;mb.h&quot;<br />#include &quot;mbport.h&quot;<br /><br />/* ----------------------- Defines ------------------------------------------*/<br />#define REG_INPUT_START 1<br />#define REG_INPUT_NREGS 200<br />#define REG_HOLD_START 1<br />#define REG_HOLD_NREGS 200<br /><br />/* ----------------------- Static variables ---------------------------------*/<br />static USHORT   usRegInputStart = REG_INPUT_START;<br />static USHORT   usRegInputBuf&#91;REG_INPUT_NREGS&#93;;<br />static SHORT   usRegHoldingStart = REG_HOLD_START;<br />static SHORT   usRegHoldingBuf&#91;REG_HOLD_NREGS&#93;;<br />static float zm_fl1=0;<br /><br /><br />/* ----------------------- Start implementation -----------------------------*/<br />int<br />main( void )<br />{<br />    ULONGlicznik1=0;<br />ULONGlicz_t1;<br />USHORT *wsk1;<br />USHORT *wsk2;<br />const UCHAR     ucSlaveID&#91;&#93; = { 0xAA, 0xBB, 0xCC };<br />    eMBErrorCode    eStatus;<br /><br />    eStatus = eMBInit( MB_RTU, 0x01, 0, 9600, MB_PAR_NONE );<br /><br />    eStatus = eMBSetSlaveID( 0x34, TRUE, ucSlaveID, 3 );<br />    sei(  );<br /><br />    /* Enable the Modbus Protocol Stack. */<br />    eStatus = eMBEnable(  );<br /><br />wsk1=&amp;licznik1;<br />wsk2=&amp;zm_fl1;<br />    for( ;; )<br />    {<br />        ( void )eMBPoll(  );<br /><br />        /* Here we simply count the number of poll cycles. */<br />licz_t1=++licznik1;<br />wsk1=&amp;licznik1;<br />zm_fl1=zm_fl1+0.0001;<br />        //usRegInputBuf&#91;0&#93;= (unsigned short)(licz_t1);<br />//usRegInputBuf&#91;1&#93;= (unsigned short)(licz_t1&gt;&gt;16);<br />usRegInputBuf&#91;0&#93;= (unsigned short)(*wsk1);<br />usRegInputBuf&#91;1&#93;= (unsigned short)(*(wsk1+1));<br />usRegInputBuf&#91;4&#93;= (unsigned short)(*wsk2);<br />usRegInputBuf&#91;5&#93;= (unsigned short)(*(wsk2+1));<br />    }<br />}<br /><br />eMBErrorCode<br />eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs )<br />{<br />     eMBErrorCode    eStatus = MB_ENOERR;<br />    int             iRegIndex;<br /><br />    if( ( usAddress &gt;= REG_INPUT_START )<br />        &amp;&amp; ( usAddress + usNRegs &lt;= REG_INPUT_START + REG_INPUT_NREGS ) )<br />    {<br />        iRegIndex = ( int )( usAddress - usRegInputStart );<br />        while( usNRegs &gt; 0 )<br />        {<br />            *pucRegBuffer++ =<br />                ( unsigned char )( usRegInputBuf&#91;iRegIndex&#93; &gt;&gt; 8 );<br />            *pucRegBuffer++ =<br />                ( unsigned char )( usRegInputBuf&#91;iRegIndex&#93; &amp; 0xFF );<br />            iRegIndex++;<br />            usNRegs--;<br />        }<br />    }<br />    else<br />    {<br />        eStatus = MB_ENOREG;<br />    }<br />usRegInputBuf&#91;2&#93;++;<br />    return eStatus;<br />}<br /><br />eMBErrorCode<br />eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs,<br />                 eMBRegisterMode eMode )<br /><br />{<br />    eMBErrorCode    eStatus = MB_ENOERR;<br />    int             iRegIndex;<br /><br />switch (eMode)<br />{<br />case MB_REG_READ:<br /><br />    if( ( usAddress &gt;= REG_HOLD_START )<br />        &amp;&amp; ( usAddress + usNRegs &lt;= REG_HOLD_START + REG_HOLD_NREGS ) )<br />    {<br />        iRegIndex = ( int )( usAddress - usRegHoldingStart );<br />        while( usNRegs &gt; 0 )<br />        {<br />            *pucRegBuffer++ =<br />                ( unsigned char )( usRegHoldingBuf&#91;iRegIndex&#93; &gt;&gt; 8 );<br />            *pucRegBuffer++ =<br />                ( unsigned char )( usRegHoldingBuf&#91;iRegIndex&#93; &amp; 0xFF );<br />            iRegIndex++;<br />            usNRegs--;<br />        }<br />    }<br />    else<br />    {<br />        eStatus = MB_ENOREG;<br />    }<br />break;<br /><br />case MB_REG_WRITE:<br /><br />if( ( usAddress &gt;= REG_HOLD_START )<br />        &amp;&amp; ( usAddress + usNRegs &lt;= REG_HOLD_START + REG_HOLD_NREGS ) )<br />    {<br />        iRegIndex = ( int )( usAddress - usRegHoldingStart );<br />        while( usNRegs &gt; 0 )<br />        {<br />            usRegHoldingBuf&#91;iRegIndex&#93; = *pucRegBuffer++;<br />usRegHoldingBuf&#91;iRegIndex&#93; = (usRegHoldingBuf&#91;iRegIndex&#93; &lt;&lt; 8)|*pucRegBuffer++;<br />            iRegIndex++;<br />            usNRegs--;<br />        }<br />    }<br />    else<br />    {<br />        eStatus = MB_ENOREG;<br />    }<br />break;<br />}<br />usRegHoldingBuf&#91;2&#93;++;<br />    return eStatus;<br />}<br /><br /><br />eMBErrorCode<br />eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNCoils,<br />               eMBRegisterMode eMode )<br />{<br />    return MB_ENOREG;<br />}<br /><br />eMBErrorCode<br />eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNDiscrete )<br />{<br />    return MB_ENOREG;<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2090">llemar</a> — 3 kwi 2014, o 08:42</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[llemar]]></name></author>
<updated>2014-03-28T12:32:58+01:00</updated>
<published>2014-03-28T12:32:58+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76150#p76150</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76150#p76150"/>
<title type="html"><![CDATA[Re: Odbiornik RC5 z interfejsem RS-485 / MODBUS RTU]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76150#p76150"><![CDATA[
No nie do końca tak, rzecz najtrudniejsza to implementacja protokołu modbus rtu. Próbowałem zrozumieć biblioteki freemodbus Berlios, ale niestety nic tam nie czaję  <img src="https://forum.atnel.pl/images/smilies/icon_e_sad.gif" alt=":(" title="Smutny" /> . Po zwykłej komunikacji RS485 nie będzie rozmawiać ze sterownikiem PLC.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2090">llemar</a> — 28 mar 2014, o 12:32</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[The River]]></name></author>
<updated>2014-03-28T12:13:11+01:00</updated>
<published>2014-03-28T12:13:11+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76148#p76148</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76148#p76148"/>
<title type="html"><![CDATA[Re: Odbiornik RC5 z interfejsem RS-485 / MODBUS RTU]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76148#p76148"><![CDATA[
W niebieskiej książce Mirka masz ładnie opisane zarówno dekodowanie RC5 jak i obsługę komunikacji RS232/RS485 więc nie trzeba chyba tutaj nic dodawać. Rozbij sobie to osobno na dekodowanie a potem komunikację, jak obydwie rzeczy będą działały wystarczy złączyć razem i projekt gotowy. Jak będziesz miał problem z czymś konkretnym to pytaj albo poszukaj na forum.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=508">The River</a> — 28 mar 2014, o 12:13</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[llemar]]></name></author>
<updated>2014-03-28T10:38:43+01:00</updated>
<published>2014-03-28T10:38:43+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76130#p76130</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76130#p76130"/>
<title type="html"><![CDATA[Odbiornik RC5 z interfejsem RS-485 / MODBUS RTU]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=6538&amp;p=76130#p76130"><![CDATA[
Witam wszystkich serdecznie. Znalazłem w internecie takie oto urządzenie <a href="http://plc-home.pl/pliki/DTR_Odbiornik_IRDA_MODBUS_v1.1.pdf"  class="postlink">http://plc-home.pl/pliki/DTR_Odbiornik_IRDA_MODBUS_v1.1.pdf</a> tyle, że na PIC a nie AVR. Nakreśliłem taki schemacik do tego i dalej z programem sie już zaciąłem,  <img src="https://forum.atnel.pl/images/smilies/icon_cry.gif" alt=":cry:" title="Płacze" />  <br />Czy mogli byśmy tak razem, wspólnymi siłami zbudować takie urządzonko ? <br />Pewnie nie jednemu by się przydało  <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <br /><a href="http://forum.atnel.pl/_obrazki/o/2090/afdf314557344afaa47df18f840093e9.png"  class="postlink"><img src="http://forum.atnel.pl/_obrazki/o/thumb/2090/afdf314557344afaa47df18f840093e9.png" alt="Obrazek" /></a><br /><br />Dziękuję wszystkim, którzy chcą pomagać innym (zwłaszcza takim laikom jak ja  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> ).<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2090">llemar</a> — 28 mar 2014, o 10:38</p><hr />
]]></content>
</entry>
</feed>