0

MAX31850 frequency is too slow
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MAX31850 frequency is too slow

by Martin5 on Tue Dec 09, 2014 11:05 am

Hi,

First of all sorry for any noobie problem I may bring or mention since I am not a full time or an expert on programming, but just a guy with some know-how on small projects.

I recently bought some MAX31850 to read data from thermocouples through a 4-bit level Converter. Though I just came into the same problem that aestorbe posted on arduino forum without answer so far.

http://forum.arduino.cc/index.php?topic=264809.0

Since I consider that it is best suit for an adafruit forum I am just replanting his post here.

My question remains in knowing if is there any way:
- to speed up serial processing in order to get the arduino to run faster along with the rest of my already built in project.
- to run the request to update the sensor output in parallel so the arduino may continue with the normal serial communication untill replace an existing temperature variable.
- not to run the request at all and it may just update from time to time.
- Or if the best solution is to spend a nano just to read the temperature and give it in continuously to the main arduino so it overcome the previous solution mentioned.

Thank you in advance!

Martin5
 
Posts: 6
Joined: Tue Dec 09, 2014 10:09 am

Re: MAX31850 frequency is too slow

by adafruit_support_bill on Tue Dec 09, 2014 11:46 am

The Dallas temperature library has an asynchronous requestTemperatures() and isConversionAvailable() functions. You also need to call sensors.setWaitForConversion(false); in your setup.

For an example of usage, see this sketch: https://learn.adafruit.com/sous-vide-po ... -enchilada

adafruit_support_bill
 
Posts: 84355
Joined: Sat Feb 07, 2009 10:11 am

Re: MAX31850 frequency is too slow

by Martin5 on Wed Dec 10, 2014 8:27 am

Thank you!
Is working perfectly!

Martin5
 
Posts: 6
Joined: Tue Dec 09, 2014 10:09 am

Re: MAX31850 frequency is too slow

by r0bin on Tue Jan 20, 2015 7:53 pm

Hello,
I'm using the same Adafruit Max31850 board on Raspberry Pi and I also experience 1 second delay between each read.
Unfortunately there is no Dallas library that i know on Rbery.

I am using Raspbian NOOBS: Linux raspberrypi 3.12.35+ #3 PREEMPT Thu Jan 15 23:00:16 CET 2015 armv6l GNU/Linux (recompiled with few options more)
I plugged the MAxim on GPIO4 of my board, it uses the below modules:
#modprobe wire timeout=1 slave_ttl=5
#modprobe w1-therm
#modprobe w1-gpio pullup=1

when i read, it takes 1 second before displaying temperature:
#cat /sys/devices/w1_bus_master1/3b-0000001828b8/w1_slave

do you have any clue on how to speed up the read time on Raspbery?
is there a way to do asynchronous reads, like on Arduino?
Thanks a lot!

r0bin
 
Posts: 10
Joined: Tue Jan 20, 2015 7:48 pm

Re: MAX31850 frequency is too slow

by adafruit2 on Wed Jan 21, 2015 2:02 pm

i dont think its possible on the raspberry Pi, but you could use your programming language to have a threaded process that does it in the background so your application isnt halted, if you have that capability in the language you are using.
the thing about the 1-wire sensors is that they are slow compared to I2C or SPI... trade offs!

adafruit2
Site Admin
 
Posts: 21069
Joined: Fri Mar 11, 2005 7:36 pm

Re: MAX31850 frequency is too slow

by r0bin on Wed Jan 21, 2015 3:46 pm

hurray, i found a fix!
on the Linux kernel mentionned in my first post, the 1-wire driver used for temperature is using a fixed value for the temperature conversion time (750ms).
while it is true on most Dallas chipset, on MAX31850 it takes only 100ms according to the datasheet:
http://datasheets.maximintegrated.com/e ... X31851.pdf (page 4)

so i did a quick and dirty fix below:
Code: Select all | TOGGLE FULL SIZE
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -203,6 +203,10 @@ static ssize_t w1_slave_show(struct device *device,
                        if (w1_reset_select_slave(sl))
                                continue;
 
+                        //adjust conversion time for MAX31850 to 100ms
+                       if(sl->family->fid == W1_THERM_DS1825)
+                               tm = 100;
+
                        /* 750ms strong pullup (or delay) after the convert */
                        if (w1_strong_pullup == 2 ||
                                        (!external_power && w1_strong_pullup))

then, recompile the module (make modules, make modules_install) and update your /lib/modules/3.12.35+/kernel/drivers/w1/slaves/w1_therm.ko

and... it works!!!
a "cleaner" fix would be to pass the timeout value with a module parameter, or eventually to detect better the MAX31850 between the other members of the 3b familly, but i'm glad it works like this :-)

r0bin
 
Posts: 10
Joined: Tue Jan 20, 2015 7:48 pm

Re: MAX31850 frequency is too slow

by bgriebel on Wed Feb 08, 2017 3:40 pm

Hello there,

could somebody post a bit more detailed description on how to change the driver as r0bin posted? I would really appreciate some help, as I need to get a higher samplerate from the MAX31850. And apparently 10Hz is possible.

But right now I don't know where to find the w1_therm.c file and how to compile it.

I am using a RPi with Debian Jessie.

Thanks
Benjamin

bgriebel
 
Posts: 3
Joined: Wed Feb 08, 2017 3:33 pm

Re: MAX31850 frequency is too slow

by r0bin on Wed Feb 08, 2017 4:59 pm

Hi Benjamin,
You need to get more info on how to recompile a driver for your linux distribution.
First of all you need to download the kernel source code, the version of your distribution.
Then when unzipped, the source file should be in your_linux_src_folder/drivers/w1/slaves/w1_therm.c

Have a look here for example
http://lostindetails.com/blog/post/Comp ... berry-pi-2
or:
https://www.fontenay-ronan.fr/kernel-mo ... -raspbian/

Cheers :)

r0bin
 
Posts: 10
Joined: Tue Jan 20, 2015 7:48 pm

Re: MAX31850 frequency is too slow

by bgriebel on Mon Feb 13, 2017 4:31 am

Hi robin,

thanks for you support! This is how far I am: I followed the instructions in you first link and compiled the kernel (inside a Virtualbox with ubuntu).

I also found the w1_therm.c and added the extra lines to change the conversion time.

Now how do I compile the modules? According to you first link I tried:

make ARCH=arm CROSS_COMPILE=$PREFIX -C /home/ubunutu/linux M=$SRC modules

with PREFIX=/home/ubunutu/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-
and SRC=/home/ubunutu/linux/drivers/w1/slaves

I did not get any errors, but I also don't know if I did the right thing and if so, where I can find the w1_therm.ko

Can you give me a hint?

Thanks
Benjamin

bgriebel
 
Posts: 3
Joined: Wed Feb 08, 2017 3:33 pm

Re: MAX31850 frequency is too slow

by r0bin on Mon Feb 13, 2017 6:13 am

that's a good progress, well done!
have you selected the module compilation using "make config" or "make menuconfig" ?
if not, it wont be compiled.
if yes, you should see when typing the "make modules" command, the compilation of each modules you selected in your configuration

This done, i don't remember where are located the .ko files, probably in the same folder as the w1_therm.c
you can search in the kernel src folders:
#find /home/ubunutu/linux/drivers/ | grep w1_therm.ko
for example
let me know if that works ;)

r0bin
 
Posts: 10
Joined: Tue Jan 20, 2015 7:48 pm

Re: MAX31850 frequency is too slow

by bgriebel on Mon Feb 13, 2017 7:31 am

I followed the steps 1-14 here:
http://lostindetails.com/blog/post/Comp ... berry-pi-2

with a few exceptions:
make ARCH=arm CROSS_COMPILE=${CCPREFIX} oldconfig:

This command returned a bunch of those warning:
.config:1:warning: unexpected data
.config:2:warning: unexpected data
.config:3:warning: unexpected data
.config:4:warning: unexpected data
...

followed by
Restart config ...

And asking a lot of question!! With some google-help I found this solution:

yes "" | make ARCH=arm CROSS_COMPILE=${CCPREFIX} oldconfig

This command simply answers all question with return.

I also tried make ARCH=arm CROSS_COMPILE=${CCPREFIX} menuconfig

but here I get some errors:

In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory
compilation terminated.

bgriebel
 
Posts: 3
Joined: Wed Feb 08, 2017 3:33 pm

Re: MAX31850 frequency is too slow

by r0bin on Mon Feb 13, 2017 10:35 am

to execute make menuconfig, you need lib ncurses first.
something like "sudo apt-get install libncurses5-dev"
this will allows you to execute the menu, then you'll have to select the right module (in the hierarchy, you'll have to search a bit) and then save it as your new config file.
this will be used in the "make module" process to compile the .ko file

r0bin
 
Posts: 10
Joined: Tue Jan 20, 2015 7:48 pm

Please be positive and constructive with your questions and comments.