<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to mcp3008 issue on raspi3 model b+</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/</id><updated>2020-02-27T17:21:31.091000Z</updated><subtitle>Recent posts to mcp3008 issue on raspi3 model b+</subtitle><entry><title>mcp3008 issue on raspi3 model b+</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/?limit=25#9ac8" rel="alternate"/><published>2020-02-27T17:21:31.091000Z</published><updated>2020-02-27T17:21:31.091000Z</updated><author><name>JLo</name><uri>https://forge.codesys.com/u/jlo/</uri></author><id>https://forge.codesys.com7a0365ab6923f7fc9a770473fac2cd356f508d5a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I used two max6675 sensors to read two temps as you described that worked well. I noticed that in the driver in block 'AfterReadInputs' the transfer is immediately restarted after finishing, then I got a reading only at start of the program.&lt;br/&gt;
I solved this by adding a delay of a few cycles before restarting the transmission again which did the trick.&lt;br/&gt;
This allows you to read max two sensors. &lt;br/&gt;
Also noticed that you can manipulate the chip enable by disconnecting the wire, so in theory you can use gpio's to control the demultiplexing of multiple sensors.&lt;/p&gt;
&lt;p&gt;See a copy of the driver routine;&lt;/p&gt;
&lt;p&gt;SUPER^.AfterReadInputs();&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;_iState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;

    &lt;span class="nv"&gt;aby&lt;/span&gt;[&lt;span class="mi"&gt;0&lt;/span&gt;] :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;aby&lt;/span&gt;[&lt;span class="mi"&gt;1&lt;/span&gt;] :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;IF&lt;/span&gt;  &lt;span class="nv"&gt;transfer&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;pabyTxBuffer&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;aby&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; , &lt;span class="nv"&gt;pabyRxBuffer&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;aby&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; , &lt;span class="nv"&gt;udiLen&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; , &lt;span class="nv"&gt;uiDelayus&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
        &lt;span class="nv"&gt;_iState&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="c1"&gt;; // jump out of step to stop transmission&lt;/span&gt;
    &lt;span class="nv"&gt;END_IF&lt;/span&gt;

    &lt;span class="nv"&gt;ui&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;aby&lt;/span&gt;[&lt;span class="mi"&gt;1&lt;/span&gt;]&lt;span class="c1"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;ui&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ui&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;BYTE_TO_UINT&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;aby&lt;/span&gt;[&lt;span class="mi"&gt;0&lt;/span&gt;]&lt;span class="ss"&gt;))&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
    &lt;span class="nv"&gt;auiValue&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;ui&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;END_IF&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nv"&gt;delay&lt;/span&gt; &lt;span class="nv"&gt;restart&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt; &lt;span class="nv"&gt;trasnmission&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;_iState&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;

    &lt;span class="nv"&gt;_iState&lt;/span&gt; :&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;_iState&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;END_IF&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>mcp3008 issue on raspi3 model b+</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/?limit=25#315a" rel="alternate"/><published>2020-02-27T17:21:28.310000Z</published><updated>2020-02-27T17:21:28.310000Z</updated><author><name>thierrytri</name><uri>https://forge.codesys.com/u/thierrytri/</uri></author><id>https://forge.codesys.comd1bb8ee28a8f56414c8cf72fd83d1ac513c20177</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi &lt;br/&gt;
i have a last problem witrh mcp3008:&lt;br/&gt;
i wired 2 mcp 3008 the first with chip select on pin 26, the second with chip select on pin 24.&lt;br/&gt;
I set 2 spi master , the first on /dev/spidev0.0, the second on /dev/spidev0.1.&lt;br/&gt;
It works, but when the two are wired, it seems adding the 2 values on the same input mcp3008.auiValue&lt;span&gt;[0]&lt;/span&gt;, with the mcp3008_1.auiValue&lt;span&gt;[0]&lt;/span&gt;.&lt;br/&gt;
Have i proceed in the wrong way ?&lt;br/&gt;
Thanks &lt;br/&gt;
Thierry&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Screenshot2.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=3728"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Screenshot1.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=3727"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>mcp3008 issue on raspi3 model b+</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/?limit=25#57ef" rel="alternate"/><published>2020-02-27T17:21:27.314000Z</published><updated>2020-02-27T17:21:27.314000Z</updated><author><name>thierrytri</name><uri>https://forge.codesys.com/u/thierrytri/</uri></author><id>https://forge.codesys.com4a2ea40fd6b269d52772934aa90d1e023644e82e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;HI&lt;br/&gt;
Many thanks Edwin, it works for me, great!&lt;br/&gt;
Thierry&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>mcp3008 issue on raspi3 model b+</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/?limit=25#431c" rel="alternate"/><published>2020-02-27T17:21:24.477000Z</published><updated>2020-02-27T17:21:24.477000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com5ab59880d36cb72552e0a31243671335710336cd</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
guess this might solve your Problem(reduce SPI speed):&lt;br/&gt;
 l &lt;a class="" href="https://forum.codesys.com/viewtopic.php?f=21&amp;amp;t=8658" rel="nofollow"&gt;viewtopic.php?f=21&amp;amp;t=8658&lt;/a&gt; l &lt;br/&gt;
BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>mcp3008 issue on raspi3 model b+</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/8dce1656dc/?limit=25#2174" rel="alternate"/><published>2020-02-27T17:21:23.474000Z</published><updated>2020-02-27T17:21:23.474000Z</updated><author><name>thierrytri</name><uri>https://forge.codesys.com/u/thierrytri/</uri></author><id>https://forge.codesys.com9930caf05fe55c0298845a4c511eb1430acbdee9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;i am trying a pi model 3 b+ with the same program than the model 3, with a mcp3008.&lt;br/&gt;
on the model b+, the spi is enable, works with a python program, but not with Codesys.&lt;br/&gt;
The wiring is the same, the parameters too (/dev/spidev0.0), it work on the model 3, but not the model 3 b+.&lt;br/&gt;
Someone have an idea ?&lt;br/&gt;
thanks&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>