Commit 2b7477c8 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

gw-submod: Added one-wire master

Also updated userguide to reflect this.
Signed-off-by: Theodor-Adrian Stana's avatarTheodor Stana <t.stana@cern.ch>
parent 8dbfd947
conv-ttl-blo-gw @ 07db1417
Subproject commit f943e5f2143f868ecbc02c300bf2fd378445e962
Subproject commit 07db1417e7530e693df5bca81f7acc2d1390d732
......@@ -9,7 +9,7 @@
\noindent \rule{\textwidth}{.1cm}
\hfill January 31, 2013
\hfill February 5, 2013
\vspace*{3cm}
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="240.62489"
height="36.433071"
id="svg3023"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="comm.svg">
<defs
id="defs3025">
<marker
inkscape:stockid="TriangleOutM"
orient="auto"
refY="0"
refX="0"
id="TriangleOutM"
style="overflow:visible">
<path
id="path3997"
d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
transform="scale(0.4,0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="TriangleInM"
orient="auto"
refY="0"
refX="0"
id="TriangleInM"
style="overflow:visible">
<path
id="path3988"
d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
transform="scale(-0.4,-0.4)"
inkscape:connector-curvature="0" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="169.23966"
inkscape:cy="-7.7683624"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="1855"
inkscape:window-height="1176"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0">
<inkscape:grid
type="xygrid"
id="grid3050"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
units="mm"
spacingx="0.5mm"
spacingy="0.5mm"
originx="-19.858889mm"
originy="-254.85889mm" />
</sodipodi:namedview>
<metadata
id="metadata3028">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-70.366142,-112.8858)">
<rect
id="rect3060"
width="62.007877"
height="35.433071"
x="168.30708"
y="113.3858"
style="fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-opacity:1" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="199.53807"
y="127.52324"
id="text3054"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="199.53807"
y="127.52324"
style="font-size:10px;text-align:center;text-anchor:middle"
id="tspan4498">VME crate</tspan><tspan
sodipodi:role="line"
x="199.53807"
y="140.02324"
style="font-size:10px;text-align:center;text-anchor:middle"
id="tspan4512">SysMon</tspan></text>
<rect
style="fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-opacity:1"
y="113.3858"
x="70.866142"
height="35.433071"
width="53.149605"
id="rect3830" />
<text
sodipodi:linespacing="125%"
id="text3832"
y="128.42656"
x="97.440948"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:10px;text-align:center;text-anchor:middle"
y="128.42656"
x="97.440948"
sodipodi:role="line"
id="tspan3840">User</tspan><tspan
style="font-size:10px;text-align:center;text-anchor:middle"
y="140.92656"
x="97.440948"
sodipodi:role="line"
id="tspan3844">computer</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#TriangleInM);marker-end:url(#TriangleOutM)"
d="m 127.55906,122.24407 37.20472,0"
id="path3846"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4478"
d="m 127.55906,139.96061 37.20472,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#TriangleInM);marker-end:url(#TriangleOutM)" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="146.2708"
y="120.47242"
id="text4480"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4482"
x="146.2708"
y="120.47242"
style="font-size:8px;text-align:center;text-anchor:middle">Telnet</tspan></text>
<text
sodipodi:linespacing="125%"
id="text4484"
y="138.18895"
x="146.2708"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:8px;text-align:center;text-anchor:middle"
y="138.18895"
x="146.2708"
id="tspan4486"
sodipodi:role="line">SNMP</tspan></text>
<text
sodipodi:linespacing="125%"
id="text4488"
y="129.33069"
x="251.57481"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:8px;text-align:center;text-anchor:middle"
y="129.33069"
x="251.57481"
id="tspan4490"
sodipodi:role="line">I<tspan
style="font-size:65.00091553%;baseline-shift:super"
id="tspan4494">2</tspan>C</tspan></text>
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4492"
d="m 233.85827,131.10234 37.20472,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#TriangleInM);marker-end:url(#TriangleOutM)" />
<g
id="g4514"
transform="translate(27.026472,0)">
<rect
id="rect4500"
width="35.433071"
height="35.433071"
x="248.03149"
y="113.3858"
style="fill:#cccccc;fill-opacity:1;stroke:#000000;stroke-opacity:1" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="265.29636"
y="134.74248"
id="text4502"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
x="265.29636"
y="134.74248"
style="font-size:10px;text-align:center;text-anchor:middle"
id="tspan4506">FPGA</tspan></text>
</g>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="280.55801"
height="56"
id="svg2"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="onewire.svg">
<defs
id="defs4">
<marker
inkscape:stockid="TriangleInM"
orient="auto"
refY="0"
refX="0"
id="TriangleInM"
style="overflow:visible">
<path
id="path3988"
d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
transform="scale(-0.4,-0.4)"
inkscape:connector-curvature="0" />
</marker>
<marker
inkscape:stockid="TriangleOutM"
orient="auto"
refY="0"
refX="0"
id="TriangleOutM"
style="overflow:visible">
<path
id="path3997"
d="m 5.77,0 -8.65,5 0,-10 8.65,5 z"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
transform="scale(0.4,0.4)"
inkscape:connector-curvature="0" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.6"
inkscape:cx="106.2165"
inkscape:cy="17.618324"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:window-width="1855"
inkscape:window-height="1176"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0">
<inkscape:grid
type="xygrid"
id="grid4519"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
spacingx="0.5px"
spacingy="0.5px"
originx="-177.442px"
originy="-862px" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-177.442,-134.36218)">
<rect
style="fill:none;stroke:#999999;stroke-width:1;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:3,3;stroke-dashoffset:4"
id="rect5163"
width="175"
height="55"
x="202.5"
y="134.86218" />
<text
sodipodi:linespacing="125%"
id="text4488"
y="168.09056"
x="190"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
style="font-size:8px;text-align:center;text-anchor:middle"
y="168.09056"
x="190"
id="tspan4490"
sodipodi:role="line">I<tspan
style="font-size:65.00091553%;baseline-shift:super"
id="tspan4494">2</tspan>C</tspan></text>
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4492"
d="m 180,169.86218 31.5,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#TriangleInM);marker-end:url(#TriangleOutM)" />
<g
id="g5090"
transform="translate(0,2.4999974)">
<g
id="g5109"
transform="translate(0,-2.500001)">
<rect
style="fill:#cccccc;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect4560"
width="37.5"
height="30.000002"
x="215"
y="154.86218" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="233.56201"
y="166.98428"
id="text5082"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5084"
x="233.56201"
y="166.98428"
style="font-size:10px;text-align:center;text-anchor:middle">I<tspan
id="tspan5107"
style="font-size:65.00091553%;baseline-shift:super">2</tspan>C</tspan><tspan
sodipodi:role="line"
x="233.56201"
y="179.48428"
style="font-size:10px;text-align:center;text-anchor:middle"
id="tspan5088">bridge</tspan></text>
</g>
</g>
<path
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#TriangleInM);marker-end:url(#TriangleOutM)"
d="m 256,169.86218 37.20472,0"
id="path5097"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="274.58282"
y="157.36218"
id="text5099"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5101"
x="274.58282"
y="157.36218"
style="font-size:8px;text-align:center;text-anchor:middle">Internal</tspan><tspan
sodipodi:role="line"
x="274.58282"
y="167.36218"
style="font-size:8px;text-align:center;text-anchor:middle"
id="tspan5105">bus</tspan></text>
<g
transform="translate(82.5,2.4999974)"
id="g5116">
<g
transform="translate(0,-2.500001)"
id="g5118">
<rect
y="154.86218"
x="215"
height="30.000002"
width="37.5"
id="rect5120"
style="fill:#cccccc;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<text
sodipodi:linespacing="125%"
id="text5122"
y="166.98428"
x="233.56201"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
id="tspan5128"
style="font-size:10px;text-align:center;text-anchor:middle"
y="166.98428"
x="233.56201"
sodipodi:role="line">1-wire</tspan><tspan
style="font-size:10px;text-align:center;text-anchor:middle"
y="179.48428"
x="233.56201"
sodipodi:role="line"
id="tspan5133">master</tspan></text>
</g>
</g>
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path5135"
d="m 338.5,169.86218 43,0"
style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#TriangleInM);marker-end:url(#TriangleOutM)" />
<text
sodipodi:linespacing="125%"
id="text5137"
y="168.36218"
x="357.5"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
xml:space="preserve"><tspan
id="tspan5141"
style="font-size:8px;text-align:center;text-anchor:middle"
y="168.36218"
x="357.5"
sodipodi:role="line">1-wire</tspan></text>
<g
id="g5145"
transform="translate(170.5,2.4999974)">
<g
id="g5147"
transform="translate(0,-2.500001)">
<rect
style="fill:#cccccc;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect5149"
width="72.5"
height="15.000019"
x="214.5"
y="162.36218" />
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="251"
y="172.36218"
id="text5151"
sodipodi:linespacing="125%"><tspan
id="tspan5155"
sodipodi:role="line"
x="251"
y="172.36218"
style="font-size:10px;text-align:center;text-anchor:middle">Thermometer</tspan></text>
</g>
</g>
<text
xml:space="preserve"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
x="205"
y="147.36218"
id="text5533"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan5535"
x="205"
y="147.36218"
style="font-size:12px;font-weight:bold;fill:#999999;fill-opacity:1">FPGA</tspan></text>
</g>
</svg>
......@@ -98,3 +98,24 @@
howpublished = {\url{http://www.ohwr.org/projects/conv-ttl-blo-gw/wiki/Releases}}
}
@misc{onewire-core,
author = {Iztok Jeras},
title = {{sockit\_owm, 1-wire (onewire) master}},
year = 2011,
note = {\url{http://opencores.org/websvn,filedetails?repname=sockit_owm&path=%2Fsockit_owm%2Ftrunk%2Fdoc%2Fsockit_owr.pdf}}
}
@misc{onewire-tech,
author = {Bernhard Linke},
title = {{Overview of 1-Wire Technology and Its Use}},
year = 2008,
month = 06,
date = 19,
note = {\url{http://www.maximintegrated.com/app-notes/index.mvp/id/1796}}
}
@misc{ds18b20,
author = {{Maxim Integrated}},
title = {{DS18B20 -- Programmable Resolution 1-Wire Digital Thermometer}},
note = {\url{http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf}}
}
......@@ -61,6 +61,7 @@
10-01-2014 & 1.06 & Added SNMP access sub-section \\
28-01-2014 & 1.07 & Added Diagnostics section and moved remote resetting subsection to this section \\
31-01-2014 & 1.08 & Added manual pulse triggering sub-section \\
05-02-2014 & 1.09 & Added temperature and unique ID readout support \\
\hline
\end{tabular}
}
......@@ -120,7 +121,9 @@ pulses (see Section~\ref{sec:pulse-def}). The main features of the board are:
\item SFP connector
\item Diagnostics
\begin{itemize}
\item converter board ID
\item gateware version
\item unique board ID and temperature readout
\item state of on-board switches and RTM detection lines
\item input pulse counters
\item manual pulse triggering
......@@ -635,6 +638,12 @@ of these means of connecting to the CONV-TTL-BLO are described in the following
All the examples below were tried on a Ubuntu Linux computer.
\begin{figure}[h]
\centerline{\includegraphics[width=.8\textwidth]{fig/comm}}
\caption{Communicating to the CONV-TTL-BLO FPGA}
\label{fig:comm}
\end{figure}
%%--------------------------------------------------------------------------------------
%% SUBSEC: Telnet
%%--------------------------------------------------------------------------------------
......@@ -658,10 +667,9 @@ data to the board. As names suggest, \textit{readreg} reads a board register, w
\hline
writereg \textit{slot addr val} & Writes the \textit{hex} value \textit{val} to hex address
\textit{addr} of board in slot number \textit{slot} \\
writemregs \textit{slot addr v1 .. v8} & This command is similar to the \textit{writereg}
command, but it allows writing up to eight different values
to the same Wishbone register. The values are given in hexadecimal
format and are separate by spaces \\
writemregs \textit{slot addr v1 .. v8} & Allows writing up to eight different values
to the same register. The values are given in hexadecimal
format and are separate by spaces \\
readreg \textit{slot addr} & Returns the value of register at hex address \textit{addr} of
board in slot number \textit{slot} \\
\hline
......@@ -804,11 +812,13 @@ The following diagnostics features are implemented on the CONV-TTL-BLO:
\begin{itemize}
\item converter board identification
\item reading the unique board ID and temperature
\item reading of the FPGA gateware version
\item reading the state of the on-board switches
\item reading the state of the RTM detection lines
\item input pulse counters
\item remotely reset the FPGA logic
\item manually trigger a pulse
\end{itemize}
%------------------------------------------------------------------------------
......@@ -837,6 +847,77 @@ is split into major and minor version numbers. Both numbers are decimal numbers.
The major version number increments on major changes in the gateware, such as
the implementation of new blocks. The minor version increments on bug fixes.
%------------------------------------------------------------------------------
% SUBSEC: Thermo, unique ID
%------------------------------------------------------------------------------
\subsection{Unique board ID and temperature readout}
\label{sec:diag-id-therm}
CONV-TTL-BLO boards contain a thermometer chip~\cite{ds18b20} which can be used to read the
board temperature. This thermometer chip is also factory-programmed with a unique
ID which can be used to uniquely identify a CONV-TTL-BLO.
To access this thermometer, the CONV-TTL-BLO uses a 1-wire interface~\cite{onewire-tech}.
The thermometer is a one-wire slave and the FPGA on-board the CONV-TTL-BLO is
a one-wire master in the communication. To access and control this interface,
a memory-mapped one-wire master core~\cite{onewire-core} is implemented on the
FPGA, as shown in Figure~\ref{fig:onewire}.
\begin{figure}[h]
\centerline{\includegraphics[width=.8\textwidth]{fig/onewire}}
\caption{Interface to the one-wire thermometer}
\label{fig:onewire}
\end{figure}
Data from the thermometer can be obtained one bit at a time by controlling
the one-wire master core as described in its specification manual~\cite{onewire-core}.
Relevant data in the thermometer are listed in Table~\ref{tbl:thermo-data}. More
details about this data and how to obtain it can be found in the device's
datasheet~\cite{ds18b20}.
\begin{table}[h]
\caption{Data from thermometer (see~\cite{ds18b20})}
\label{tbl:thermo-data}
\centerline
{
\begin{tabular}{l l p{.7\textwidth}}
\hline
\multicolumn{1}{c}{\textbf{Data}} & \multicolumn{1}{c}{\textbf{Length}} &
\multicolumn{1}{c}{\textbf{Description}} \\
\hline
ID & 48 bits & Unique ID, packed within 64 bits \\
Temp. & 16 bits & Current temperature, multiple resolutions available \\
CRC & 8 bits & CRC for the unique ID and temperature data \newline
The FPGA logic does not interpret the CRC \\
\hline
\end{tabular}
}
\end{table}
Note that an example Python script is provided in the \textit{software/gp-py/} folder
of the main project repository~\cite{ctb-repo}. The necessary details about this script
can be found in Table~\ref{tbl:thermo-scripts}.
\begin{table}[h]
\caption{Scripts needed for remote reprogramming}
\label{tbl:thermo-scripts}
\centerline {
\begin{tabular}{l p{.6\textwidth}}
\hline
\multicolumn{1}{c}{\textbf{Script}} & \multicolumn{1}{c}{\textbf{Description}} \\
\hline
gp-py/thermo.py & Implements classes with methods for accessing the thermometer
through the one-wire master core and uses these classes to
retrieve temperature and data \\
ei2c/ei2c.py & Defines the I$^2$C class, containing methods implementing the
the I$^2$C protocol to access the cards \\
ei2c/ei2cexcept.py & Contains exceptions thrown by the I$^2$C class when the response
from the ELMA crate yields an error \\
\hline
\end{tabular}
}
\end{table}
%------------------------------------------------------------------------------
% SUBSEC: RTM lines and on-board switches
%------------------------------------------------------------------------------
......@@ -976,7 +1057,7 @@ sequence is not as expected, the logic returns to waiting for the first byte
of the magic sequence.
\begin{figure}[h]
\centerline{\includegraphics[width=.6\textwidth]{fig/man-trig-fsm}}
\centerline{\includegraphics[width=.49\textwidth]{fig/man-trig-fsm}}
\caption{Manual pulse triggering logic}
\label{fig:man-trig-fsm}
\end{figure}
......@@ -1351,6 +1432,7 @@ $reg. index = \frac{addr}{4} + 1$
\hline
Board regs & 0x000 & 0x020 & Coverter board registers \\
MultiBoot & 0x040 & 0x050 & MultiBoot module \\
Thermo & 0x080 & 0x084 & Thermometer chip \\
\hline
\end{tabular}
}
......@@ -1698,6 +1780,31 @@ $reg. index = \frac{addr}{4} + 1$
\end{tabular}
}
%------------------------------------------------------------------------------
% SUBSEC: Thermo
%------------------------------------------------------------------------------
\subsection{Thermometer module}
\label{app:memmap-thermo}
\indent Base address: 0x080
\vspace*{11pt}
\centerline
{
\begin{tabular}{l l p{.6\textwidth}}
\textbf{Offset} & \textbf{Name} & \textbf{Description} \\
0x00 & OWCSR & One-Wire Control and Status Register \\
0x04 & OWCDR & One-Wire Clock Divider Registers \\
\end{tabular}
}
\vspace*{11pt}
For details on the bits of the thermometer module access registers, see the
OneWire Master module's documentation~\cite{onewire-core}.
%------------------------------------------------------------------------------
\end{appendices}
%------------------------------------------------------------------------------
......
# Import system modules
import sys
import time
import os
# Import common modules
sys.path.append("../ei2c")
from ei2c import *
##------------------------------------------------------------------------------
## OneWire class
##------------------------------------------------------------------------------
class COpenCoresOneWire:
R_CSR = 0x0
R_CDR = 0x4
CSR_DAT_MSK = (1<<0)
CSR_RST_MSK = (1<<1)
CSR_OVD_MSK = (1<<2)
CSR_CYC_MSK = (1<<3)
CSR_PWR_MSK = (1<<4)
CSR_IRQ_MSK = (1<<6)
CSR_IEN_MSK = (1<<7)
CSR_SEL_OFS = 8
CSR_SEL_MSK = (0xF<<8)
CSR_POWER_OFS = 16
CSR_POWER_MSK = (0xFFFF<<16)
CDR_NOR_MSK = (0xFFFF<<0)
CDR_OVD_OFS = 16
CDR_OVD_MSK = (0XFFFF<<16)
def wr_reg(self, addr, val):
self.bus.write(self.cslot, self.base + addr,val)
def rd_reg(self,addr):
return self.bus.read(self.cslot, self.base + addr)
def __init__(self, bus, cslot, base, clk_div_nor, clk_div_ovd):
self.bus = bus
self.base = base
self.cslot = cslot
data = (((clk_div_nor & self.CDR_NOR_MSK) |
((clk_div_ovd<<self.CDR_OVD_OFS) & self.CDR_OVD_MSK)))
self.wr_reg(self.R_CDR, data)
def reset(self, port):
data = (((port<<self.CSR_SEL_OFS) & self.CSR_SEL_MSK) |
self.CSR_CYC_MSK |
self.CSR_RST_MSK)
self.wr_reg(self.R_CSR, data)
tmo = 100
while(self.rd_reg(self.R_CSR) & self.CSR_CYC_MSK):
tmo = tmo -1
if tmo <= 0:
msg = "ERROR: TempID IC20: Not responding"
print msg
reg = self.rd_reg(self.R_CSR)
return ~reg & self.CSR_DAT_MSK
def slot(self, port, bit):
data = (((port<<self.CSR_SEL_OFS) & self.CSR_SEL_MSK) |
self.CSR_CYC_MSK |
(bit & self.CSR_DAT_MSK))
self.wr_reg(self.R_CSR, data)
tmo = 100
while(self.rd_reg(self.R_CSR) & self.CSR_CYC_MSK):
tmo = tmo -1
if tmo <= 0:
msg = "ERROR: TempID IC20: Not responding"
print msg
reg = self.rd_reg(self.R_CSR)
return reg & self.CSR_DAT_MSK
def read_bit(self, port):
return self.slot(port, 0x1)
def write_bit(self, port, bit):
return self.slot(port, bit)
def read_byte(self, port):
data = 0
for i in range(8):
data |= self.read_bit(port) << i
return data
def write_byte(self, port, byte):
data = 0
byte_old = byte
for i in range(8):
data |= self.write_bit(port, (byte & 0x1)) << i
byte >>= 1
if(byte_old == data):
return 0
else:
return -1
def write_block(self, port, block):
if(160 < len(block)):
return -1
data = []
for i in range(len(block)):
data.append(self.write_byte(port, block[i]))
return data
def read_block(self, port, length):
if(160 < length):
return -1
data = []
for i in range(length):
data.append(self.read_byte(port))
return data
##------------------------------------------------------------------------------
## DS18B20 class
##------------------------------------------------------------------------------
class CDS18B20:
ROM_SEARCH = 0xF0
ROM_READ = 0x33
ROM_MATCH = 0x55
ROM_SKIP = 0xCC
ROM_ALARM_SEARCH = 0xEC
CONVERT_TEMP = 0x44
WRITE_SCRATCHPAD = 0x4E
READ_SCRATCHPAD = 0xBE
COPY_SCRATCHPAD = 0x48
RECALL_EEPROM = 0xB8
READ_POWER_SUPPLY = 0xB4
def __init__(self, onewire, port):
self.onewire = onewire
self.port = port
def read_serial_number(self):
if(1 != self.onewire.reset(self.port)):
msg = "ERROR: TempID IC20: Not responding"
print msg
else:
err = self.onewire.write_byte(self.port, self.ROM_READ)
if err != 0:
msg = "ERROR: TempID IC20: Write failed"
print msg
family_code = self.onewire.read_byte(self.port)
serial_number = 0
for i in range(6):
serial_number |= self.onewire.read_byte(self.port) << (i*8)
crc = self.onewire.read_byte(self.port)
return ((crc<<56) | (serial_number<<8) | family_code)
def access(self, serial_number):
if(1 != self.onewire.reset(self.port)):
msg = "ERROR: TempID IC20: Not responding"
print msg
else:
err = self.onewire.write_byte(self.port, self.ROM_MATCH)
block = []
for i in range(8):
block.append(serial_number & 0xFF)
serial_number >>= 8
self.onewire.write_block(self.port, block)
return 0
def read_temp(self, serial_number):
err = self.access(serial_number)
err = self.onewire.write_byte(self.port, self.CONVERT_TEMP)
time.sleep(0.8)
err = self.access(serial_number)
err = self.onewire.write_byte(self.port, self.READ_SCRATCHPAD)
data = self.onewire.read_block(self.port, 9)
temp = (data[1] << 8) | (data[0])
if(temp & 0x1000):
temp = -0x10000 + temp
temp = temp/16.0
return temp
##------------------------------------------------------------------------------
## main
##------------------------------------------------------------------------------
if __name__ == "__main__":
FAMILY_CODE = 0x28
# Create bus objects
i2c = EI2C("cfvm-864-celma1", "user", "USER")
i2c.open()
onewire = COpenCoresOneWire(i2c, 1, 0x80, 99, 19)
ds18b20 = CDS18B20(onewire, 0)
# Reading of unique ID
unique_id = ds18b20.read_serial_number()
if(unique_id == -1):
msg = "ERROR: TempID IC20: Unable to read 1-wire thermometer"
print msg
else:
print "Unique ID: %.12X" % (unique_id)
# Reading of temperature
temp = ds18b20.read_temp(unique_id)
print "Current temperature: %3.3f" % temp
# Cheking if received values are reasonable
if temp < 10.0 or temp > 50.0:
msg = "ERROR: TempID IC20: Temperature: %d out of range[10 .. 50oC]" % (temp)
print msg
if((unique_id & 0xFF) != FAMILY_CODE):
family_code = unique_id & 0xFF
msg = "ERROR: TempID IC20: Invalid family code: 0x%.8X" % (family_code)
print msg
i2c.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment