svanderh
Posts: 1
Joined: Mon Dec 31, 2012 12:13 pm

Tsic / ZACwire protocol sensors

Sat Jan 19, 2013 4:23 pm

Hi
Has anyone already tried to use digital sensors using Tsic / Zacwire protocol for communication ?
(eg the http://www.ist-usadivision.com/objects/ ... Series.pdf to measure temperature)

Steven.

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Thu Mar 27, 2014 12:04 am

Well, it's over a year too late... but I have just written a prototype kernel module for the TSIC 306 ;) This post is mainly for the benefit of anyone searching for the same!

It is basically working but still needs some further development. The current source code is up here: http://code.google.com/p/tsic-kernel/

Here's an example of loading the module, and reading the temperature:

Code: Select all

pi@tinkerpi ~ $ sudo insmod tsic.ko
pi@tinkerpi ~ $ cat /sys/kernel/tsic/temp
14680
This is scaled by 1000, so the example above is 14.68 degrees C.

I plan to do some more work on this to support multiple sensors with configurable GPIO pins etc.

I'm developing this for use in my Espresso machine, which currently uses DS18B20. The TSIC 306 is attractive because it has a higher temperature range and faster sample rate than the DS18B20.

avondale
Posts: 5
Joined: Wed Dec 03, 2014 7:07 pm

Re: Tsic / ZACwire protocol sensors

Wed Dec 03, 2014 7:14 pm

Hello!

First thanks for the work on the module!

Somehow I can't load the module with the code you supplied. Granted I'm quite new to raspberry pi and programming as a whole, but can you give me a hint how I get the module and the sensor running in an easy way?

Thanks a lot!

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Wed Dec 03, 2014 9:48 pm

Hello!

Were you able to cross-compile the module using these instructions?
https://code.google.com/p/tsic-kernel/w ... sCompilePi

Having done that, you need to add the module to /lib/modules. It's a while since I have done that, but something along these lines should work:

Code: Select all

sudo -i
mkdir /lib/modules/`uname -r`/kernel/drivers/tsic
cp tsic.ko /lib/modules/`uname -r`/kernel/drivers/tsic
depmod -a
Then you should be able to temporarily load it as follows (replacing 22 with your GPIO number used for the sensor):

Code: Select all

sudo modprobe tsic gpio=22
To make this permanent, you would edit the /etc/modules file like this:

Code: Select all

sudo nano /etc/modules
You would need to add some lines like this to /etc/modules, again replacing 22 with your GPIO number:

Code: Select all

# the line below loads the TSIC temperature sensor kernel driver
tsic gpio=22
Hope this helps, but let me know either way!

User avatar
joan
Posts: 16049
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Tsic / ZACwire protocol sensors

Wed Dec 03, 2014 10:08 pm

I've not heard of this sensor before.

It seem to spit out a reading when it is powered up.

What sort bit times does it use? I'd have thought you could read it from userland.

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Wed Dec 03, 2014 10:33 pm

You can indeed read it from userland, although not very reliably due to unpredictable interruptions from the OS. My first implementation was user mode, but I moved to a kernel module for improved reliability.

The sensor transmits two 8 bit packets of 1 start bit, 8 data bits, and parity. Baud rate is 8kHz with 125us per bit. High bits are 75% duty cycle, low bits are 25% duty cycle.

The data sheet and application notes with timing information are linked here:
https://code.google.com/p/tsic-kernel/wiki/TSIC306

The TSIC-306 sensor is very interesting because of the high update rate and temperature range compared to DS-18B20, but if those properties aren't needed, the DS-18B20 may be preferable/cheaper, and is supported by the W1 kernel library.

User avatar
joan
Posts: 16049
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Tsic / ZACwire protocol sensors

Wed Dec 03, 2014 10:38 pm

peaberry wrote:You can indeed read it from userland, although not very reliably due to unpredictable interruptions from the OS. My first implementation was user mode, but I moved to a kernel module for improved reliability.
...
Thanks for the information. pigpio would handle that from userland, it's not subject to the vagaries of kernel interrupts.

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Wed Dec 03, 2014 10:52 pm

Interesting, thanks! Just looked at pigpio and it looks like that would work. I can see myself using pigpio for some future projects :)

avondale
Posts: 5
Joined: Wed Dec 03, 2014 7:07 pm

Re: Tsic / ZACwire protocol sensors

Thu Dec 04, 2014 12:30 pm

Hello,

no I didn't really manage to cross-compile the module. I'm not using a linux system and since I'm new to all this I couldn't quite figure out a way around that.

The thing is I actually intended to get the DS-18B20 because of the W1 kernel library support, but I ended up buying the TSIC 206.
Now I'm looking for an easy way to get this one working. So if you have any suggestions ... :)

Thanks

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Thu Dec 04, 2014 5:28 pm

Hi avondale
The only way I was able to build a kernel module was through cross compilation from Ubuntu on my laptop. I've tried to compile modules on the Pi, but never succeeded in doing that.
I have a prebuilt module here for the Pi and could potentially send you that, although it probably wouldn't work on your Pi due to different OS versions. However, happy to send it if you want to give it a try.
Other potential options (requiring more work) would be to rebuild the module it for the latest Raspbian (as I just reinstalled one of my SD cards), or write some new code that runs from userland via the pigpio library mentioned above, instead of from kernel.

avondale
Posts: 5
Joined: Wed Dec 03, 2014 7:07 pm

Re: Tsic / ZACwire protocol sensors

Thu Dec 04, 2014 7:46 pm

Hey peaberry,

I'd appreciate if you'd send me the module and I just try and see if I can get it running. I also looked into the pigpio library, but I think that might be still a bit to advanced for me. If it's not working with your module I think I'll be best off to get a DS-18B20 and keep the TSIC for other projects down the road ;)

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Thu Dec 04, 2014 10:43 pm

Hi avondale, here's the last version I built for Raspbian, back in July. If you are using a different kernel version to me, it might not load (it would probably say something along the lines of "bad version magic"). But you never know, you might be lucky!

Using the modinfo command "modinfo tsic.ko" shows this one was built for version 3.12.24+

You would need to gunzip this and follow the previous instructions to try and install it.
Attachments
tsic.ko.gz
tsic-kernel prebuilt binary 3.12.24+
(3.32 KiB) Downloaded 153 times

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Sun Dec 07, 2014 11:02 pm

Just to update you, I've since managed to get the sensor working from user mode thanks to the pigpio library. I'll clean up the code and upload it to google code soon, then add a link here.

avondale
Posts: 5
Joined: Wed Dec 03, 2014 7:07 pm

Re: Tsic / ZACwire protocol sensors

Wed Dec 10, 2014 8:39 pm

Hey peaberry,

many thanks for uploading your module and all the effort you're making! :)

I finally found some time to try to get it working, unfortunately without success. So I guess there's a problem with the different versions, just as you suspected.
Anyways, I'm looking forward to see how you worked with pigpio!

Cheers

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Tue Dec 16, 2014 9:34 pm

Hi avondale
To update you, I'm still planning to finish this, just been a bit busy lately. It was quite easy to get a command line program working with pigpio, so that job is done, but I want to make a daemon which exposes one or more sensors through the file system (e.g. tsicd). I started looking at the linux sensors API and /sys/class/thermal, but it looks like this can only be implemented from kernel drivers. However, mapping the sensors at /dev/tsic is feasible and looks like the route I'll probably take (pending further research).
Regards

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Sun Jan 04, 2015 3:20 pm

I've uploaded some C++ code which works from user mode with pigpio here:
http://code.google.com/p/tsic-pigpio
There's a sample program included which opens the sensor and outputs a few temperature readings to the console.

avondale
Posts: 5
Joined: Wed Dec 03, 2014 7:07 pm

Re: Tsic / ZACwire protocol sensors

Tue Jan 06, 2015 6:07 pm

Hey peaberry!

It's finally working!! Can't thank you enough for all your help and the work you put in this :)

Now I can start playing around a bit ;)

Thanks again and have a great one,

avondale

peaberry
Posts: 10
Joined: Wed Mar 26, 2014 9:51 pm

Re: Tsic / ZACwire protocol sensors

Tue Jan 06, 2015 6:38 pm

You're welcome! Pleased to hear that it's working :-)
The user mode version isn't as thoroughly tested as the kernel module, so if you do run into any issues, let me know and I'll take a look (I am using this for my coffee machine also... so it's of personal interest!)

Return to “Automation, sensing and robotics”