CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Sun Dec 16, 2018 7:46 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Oct 30, 2018 9:10 am 
Offline

Joined: Mon Oct 29, 2018 5:06 pm
Posts: 9
Hi

am trying to get the MCP3008 to work with the Pi3 B+ using teh MCP3008 sample project.

Unfortunately not receiving any readings. The hardware is defintely OK as with a python script I can read the values normally.

I am using Hardware SPI.

SPI master and devices running.

Thanks in advance

Peter


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Tue Oct 30, 2018 9:14 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3019
Hi,
since Stretch fullspeed SPI does not work - so you need to reduce it here.
BR
Edwin


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Tue Oct 30, 2018 10:30 am 
Offline

Joined: Mon Oct 29, 2018 5:06 pm
Posts: 9
Many thanks. That solved it. I'm curious as to why the hardware code using the Adafruit python code worked as I had not changed the SPI speed.

Secondly, how do I change it to use the second SPI hardware pins? ie using a differnet GPIO as chip select, BCM19 pin 35 MISO, BCM20 pin 38 MOSI and BCM21 pin 40 SCLK as I will now purchase a canberry dual board to mount and it is already using the original SPI pins as well as CE0 and CE1. Maybe I could just use a different GPIO for chip select , but if it affects the timing, maybe easier to move all the MCP3008 work onto the second SPI pins.

https://www.industrialberry.com/canberrydual-iso-v2-1/

Many thanks

Peter


Top
   
PostPosted: Thu Nov 01, 2018 12:09 pm 
Offline

Joined: Mon Oct 29, 2018 5:06 pm
Posts: 9
Through trial and error it seems that the max SPI clock speed is 7.8Mhz. If I go higher eg 15.6Mhz, I get a reduced scale and it no longer reads the values correctly.


Top
   
PostPosted: Thu Nov 01, 2018 2:55 pm 
Offline

Joined: Mon Oct 29, 2018 5:06 pm
Posts: 9
To answer my own question....

Enable SPI1 on the raspberry pi in the config.txt

Then add another device under the SPI and change the SPI port and MaxSpeed (due to stretch issue), move the MCP3008 into it.

And all works. You can change the CS pin as well on the pi.

I found this link useful . https://terminal28.blogspot.com/2016/05/enabling-spi1-on-raspberry-pi-bzero23.html


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Nov 02, 2018 7:26 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3019
Hi,
thanks for this helpful information for the community, well appreciated.

BR
Edwin


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited