MAX31864 SPI

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

MAX31864 SPI

Postby kabouras_33 » Sun Nov 03, 2019 11:45 am

Hello!!!
Does anyone have any working example of how to read values from the adafruit max31865?
I try to use the spi master but I get nothing in return....I also cannot find any examples to read from an spi sensor in general
Attachments
temp.fcfx
(26.2 KiB) Downloaded 5 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1160
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 572 times
Contact:

Re: MAX31864 SPI

Postby QMESAR » Sun Nov 03, 2019 2:09 pm

Hi.
For a start when you select Auto CS to "NO"(as you did in your FC chart)

P2.jpg
P2.jpg (98.39 KiB) Viewed 451 times


Then you have to control the CS pin yourself in the Flowchart and normally SPI chips need to see a transition from High ---> low to start transmission
as I show you here with your C13 pin, which I assume you use for CS ,if you select auto CS and define the pin the component will do this all automatically for you

P1.jpg
P1.jpg (63.68 KiB) Viewed 451 times


Secondly are you sure your controller is running at the correct speed? I looked at your Config settings and they seems strange to me

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Sun Nov 03, 2019 2:43 pm

Dear Mr QMESAR
Thank you very much for your quick response and your valuable information!! well noted and already tried but nothing the response is FFFF...
I also tried to understand the datasheet, and it looks like there is a register to write configuration sending a byte array and read..
The problem is that I am not familiar with registers and bytes so I ve been trying now for a couple of hours with no result...
It would be nice for flowcode to have it as a sensor because it is so much in use...
Attachments
temp.fcfx
(36.45 KiB) Downloaded 7 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1160
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 572 times
Contact:

Re: MAX31864 SPI

Postby QMESAR » Sun Nov 03, 2019 3:23 pm

Hi

Yes normally there is some command you should send to read the specific information from the device
post the datasheet that we can see what you need.
It is impossible for Flowcode to support all sensors and chips this one might be for you important then for 1000 people some other chips is important
it is always good to learn to write the correct information yourself

Post the datasheet and we can try to help

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Sun Nov 03, 2019 3:39 pm

Thank you again very much!!!
And yes i totally agree with you!!!if i (or anyone else ) we can learn the fundmentals then it is much better because we can fix anything....So i keep trying maximum effort :D
attached please find the sensor module and the datasheet!!!
Thank again for your help!!!
Attachments
MAX31865.pdf
(841.34 KiB) Downloaded 15 times
Untitled.png
Untitled.png (243.37 KiB) Viewed 442 times

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Sun Nov 03, 2019 6:35 pm

oh and I forgot,
yes, the controller is running perfectly!!
Led flash test 1 sec DONE!
uart comm 115200 baud rate and hello to pc DONE!
All looks well!!
plus I am already interfacing with ethernet and UDP to android etc with same configurations!
I must say that we have no problem there.
My humble opinion is that I need to sent bytes to configure the module and then request bytes to take the measurement.
The problem is I have never worked with bytes arrays and reg addresses before...
Now it is my chance to start learning but every single example I can find is for Arduino and basically they use libraries...so no hint...

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1160
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 572 times
Contact:

Re: MAX31864 SPI

Postby QMESAR » Sun Nov 03, 2019 7:23 pm

Hi

My humble opinion is that I need to sent bytes to configure the module and then request bytes to take the measurement.
The problem is I have never worked with bytes arrays and reg addresses before...


You are right with this
I am out the next few days but I am sure there will be some one here that can help you with that . :D

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Sun Nov 03, 2019 7:37 pm

Hello,
Thanks a lot for your time!!
Hopefully someone can guide me to the solution :wink:

User avatar
LeighM
Matrix Staff
Posts: 1911
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 460 times
Been thanked: 646 times
Contact:

Re: MAX31864 SPI

Postby LeighM » Mon Nov 04, 2019 9:17 am

Hi,
From the datasheet it looks like you will need to use the TransactionArray()
rather than Get and SendByteArray.
The first byte of the array is to be set to the required address.
If you are writing data, bit 7 is set to 1, i.e. addresses start at 0x80, for reading they start at 0x00
So to read the RTD data from the device set DataOut[0] = 0x01 and Numbytes to 3
Call TransactionArray() and the RTD MSB will be in DataIn[1] and the RTD LSB in DataIn[2]

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Tue Nov 05, 2019 11:40 am

Thank you Leigh for your quick response,
Well i was trying all night yesterday but i got some weard results....
meaning:
The way you proposed (if i understood it correctly)works but....
it is noty stable sometimes i read values msb/lsb sometimes(most of the times 0)...somethink is not appropriate.
I tested with and arduino by the way and the demo code from adafruit and i made it work in 2 minutes!!!!amazing but i cannot understand the structure of their code cause everything in libraries :evil:
Attachments
temp.fcfx
(32.63 KiB) Downloaded 6 times

User avatar
LeighM
Matrix Staff
Posts: 1911
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 460 times
Been thanked: 646 times
Contact:

Re: MAX31864 SPI

Postby LeighM » Tue Nov 05, 2019 12:32 pm

Try changing the SPI properties...
"Use Auto CS" to "No"
"Clock Polarity" to "Idle High"

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Tue Nov 05, 2019 3:30 pm

ok but if i put auto cs to no it means i will configure an output high and low manually before and after each transaction???

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Tue Nov 05, 2019 3:48 pm

ok I tried and after I compiling the first time I took some values to MSB and LSB but after shutdown and open again all 0...
Attachments
temp.fcfx
(32.6 KiB) Downloaded 11 times

User avatar
LeighM
Matrix Staff
Posts: 1911
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 460 times
Been thanked: 646 times
Contact:

Re: MAX31864 SPI

Postby LeighM » Tue Nov 05, 2019 4:13 pm

Might be worth reading the "Fault Status" register (0x07)
and setting up the "Configuration" register (0x80)?

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Tue Nov 05, 2019 4:22 pm

datain[2]=255??all else zero....overvoltage/undervoltage fault??

kabouras_33
Posts: 74
Joined: Thu Jul 27, 2017 5:23 am
Has thanked: 7 times
Been thanked: 7 times
Contact:

Re: MAX31864 SPI

Postby kabouras_33 » Tue Nov 05, 2019 4:47 pm

can you send me please a short and quick example of how to write in specific adress?

User avatar
LeighM
Matrix Staff
Posts: 1911
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 460 times
Been thanked: 646 times
Contact:

Re: MAX31864 SPI

Postby LeighM » Wed Nov 06, 2019 9:01 am

Hi,
From the datasheet page 18 it shows how to write to a register with a two byte transaction.
So set the register address, e.g. the Config address of 0x80, into DataOut[0] = 0x80
Set the value into DataOut[1]
Then set Numbytes to 2 and call TransactionArray()

The fact that you sometimes get 255 and others 0 implies a problem with the SPI.
Are your voltage levels and clock speed OK?
Could you try the SPI in software mode?