Page 1 of 1

News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 22 November 2015 16:12
by RobinS
Dear Piface users,

I have been getting some PM's and news during the last few months regarding the fact that the Piface / counters were not working any longer.
Sorry for the delay but I had little time during the past few months, and lacked some vital resources to investigate and debug this issue.
Actually I was not aware that so many people are using the PiFace.

I am glad to announce that I have found and fixed the problem, and summitted the fixes to Gizmocuz for implementation into the unstable tree.

The problems:
1) The counters were not sent each update interval
Another developer found it more efficient (which it is) to only sent the counter updates on each interval if they were changed.
However forgot to inform me and the other users.

Fixed:
I have added a new parameter to the piface.conf file which allows the user to select which counters should be updates each interval (even if its not changed) or only
when the counter has been updated.
count_update_type: on_change
always
The on_change parameter is the default setting, which means that the counters are only send during the update interval when they are changed.

2) The Piface board(s) was not detected
3) The counters stopped working
Both these issues have the same origin... The IO chip on the Piface was not properly initialized due to an chip selection (CE) error.
This chip selection error was appearantly caused by the replacement of the bcm2708 spi module from the kernel by the bcm2835 module.
In the new bcm2835 module the IO chip was not properly selected during the detection and initialisation phase of the Piface hardware when using the standard spidev
(sysfs) interface, and no workaround was available using this method.

Fixed:
I have now rewritten the piface code to use a different interface method to the bcm2835 module which provides more control, with good results.

To illustrate:
Problem
Problem
piface_int_no-ce2.jpg (90.96 KiB) Viewed 10425 times
As it should be (problem solved)
As it should be (problem solved)
piface_2835_spi-poll.jpg (80.16 KiB) Viewed 10425 times
Note:
To use the bcm2835, one should enable the device tree on the pi:
raspi-config
- advanced options -> SPI enable
-> reboot

So I hope that my fixes will be merged into the mainline code soon, and expect and hope that the issues will be solved.

Best Regards,

Robin

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 22 November 2015 16:35
by RobinS
Some additional remarks:

I am getting a lot of questions / remarks regarding the fact the the Piface does not register all input changes (for instance a door bell button), and that the Piface is slow to react.
Part of this is due to the nature of the PiFace implementation, it reads the input pins several times a second. If a change occurs between these reads,it will not be detected.
Reading the input pins faster and more frequent is not possible due to the nature of linux, and it only allows the piface to be read approx 50x second (at max, and it could be less depending on the system load). For a good pin change at least 2 reads are needed.

Illustration:
Below is an image of the reading of the Piface I/O chip (yellow spike), the time between such a spike is 20ms (kernel controlled) hence 50x second.
After each reading the data is processed by the Piface driver and if needed sent to domoticz for further processing.
piface_2835_spi-pol4.jpg
piface_2835_spi-pol4.jpg (60.43 KiB) Viewed 10420 times
Below a Piface reading sequence.
A piface reading takes 37 micro seconds.
piface_pi2_read.jpg
piface_pi2_read.jpg (80.46 KiB) Viewed 10420 times

The counters are processed in a different way.
As they are expected to be more frequent than I/O readings, and consist of pulses, changes are latched in the IO chip for later processing.
For a counter is does not really matter if there is an delay on the processing, however for input pins it does matter.
For this reason counter can sometimes better detect small pulses, but they can not detect high/low changes.

Hope this clarifies some of the questions outthere.

Best Regards,

Robin

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 22 November 2015 17:52
by grant
Thanks Robin! are these changes available on the current beta?

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 22 November 2015 18:39
by RobinS
My pleasure.
No, the changes are not available thru GIT yet, as I lost my commit rights in the move from SVN to GIT.
So I mailed my changes to gizmocuz and asked him to merge them.
I have also asked him to post in this topic when he has merged them into the trunk.

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Wednesday 25 November 2015 20:05
by RobinS
Dear PiFace users,

As mentioned the issue is fixed, but unfortunately you all will need to wait some time longer for the fix to be available in the repo.
It turns out that there is a Pi 1 and Pi 2 platform dependency which complicates the build process.
I now have GIT access, and will look at this issue in the coming days, but unfortunately have extreemly limited time.

For the handy ones amongst you I hereby attach the fixed code (without any warranty).
Besides the code a library is needed, that can be obtained here:
http://www.airspayce.com/mikem/bcm2835/

I will post updates as they progress.

Best Regards,

Robin

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 06 December 2015 13:26
by grant
Hi Robin,

Thanks for your good work on this one!

I think I will wait for the fixed image, any new when this will be available. no rush as I am working around the issues at the moment.

Thanks

Grant

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Monday 11 January 2016 22:31
by eXisTa
Sounds great! :D
When can we expect to see this in beta or stable release?

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Tuesday 12 January 2016 7:19
by Ronny
Or can you let us know in a little more detail what steps to take to put the libary and files in place? :P

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Monday 18 January 2016 17:49
by proohu01
RobinS,
Can you give us some more info you PiFace troubleshooting project? Please!

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Wednesday 20 January 2016 15:16
by proohu01
I am ones again having a lot of problems with the PiFace integration. The input state nolonger reflects the real state. This is the ...(I lost count) time it breaks on me. I am starting to dislike the PiFace a lot!
Moving to something else for my inputs and outputs. Don't know what yet. UniPi looks nice but no integration with Domoticz. Perhaps just the RAW GPIO with some pull up logic. Maybe even some MySensors hardware.....

To bad RobinS doesn't have time. It looked like he had some clue on what was wrong with the integration.

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Wednesday 27 January 2016 10:35
by Sine
Te problem is not the piface, that thing is just a very simple serial IO expander.

Mysensors is ok for a lot of things, but if I can help it I really try to avoid adding ANOTHER wireless thing (with its own quirks)
If it's at all possible it I like directly connect things, and the piface WAS perfect for that.
When I started with my domoticz setup the thing worked a charm ... s0 counters, inputs, outputs ... the works.
s0 has been dead for months, the rest has been flaky at best.

Nowadays every friggin update seems to break *something* on the piface ... *SIGH* ... TEST this stuff people !!
The fact that the piface probbably does not have a very lage userbase doesn't exactly help either.

Yes ... I exaggerate (a tiny bit) ... but this is starting to get REALLY frustrating and annoys the hell out of me :evil: (does it show?)

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Thursday 28 January 2016 12:38
by proohu01
I created a (hopefully temporary) workaround by plugging the PiFace onto an older "Pi B+" model with an older (3.12.35+) kernel. This second Pi is now a domoticz slave to my main "Pi2 B" Domoticz server. (https://www.domoticz.com/wiki/Setting_up_Device_sharing)

My master is running the latest beta v2.4337 and the slave is at v2.3530. This is working even-though the Wiki states...
all software should be at the latest version and all master and slave's must be running the same version
Too bad I had to waste an additional Pi (and a slightly higher electricity bill) for this :evil:

I donated a PiFace to gizmocus a couple of months ago. I am still hoping he has this in his possession and it willing to put the problems with the PiFace on the todo list. I 'm sure It would be greatly appreciated by all PiFace users.

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Friday 05 February 2016 21:18
by badz
Hi,
I did a small fix to piface driver that is already integrated https://github.com/domoticz/domoticz/pull/426
Before this fix, my piface2 would not work at all or very randomly (random led output triggered, input count increasing without any input, piface not detected at all)
Hope it will help

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 07 February 2016 19:23
by proohu01
Thank you very much BADZ !
All is working again. You made a lot of PiFace users happy.

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 07 February 2016 21:08
by badz
Credit should go where it is due : Robin for creating this driver ;)
Happy that it works for others though !

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Sunday 07 February 2016 22:08
by Holland
Thank you Badz for fixing this.

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Monday 08 February 2016 16:51
by Jan Jansen
Hello Robin and batz (and the other fixers of course),

It was frustrating and we had to wait a long time. Some times I got the feeling that piface was on his way to the morgue. I am glad that the problems are solved. My pifaces work as expected, even with the latest kernel version.

Thanks a lot

Jan

Re: News regarding Piface 1 & 2 (counter) issues

Posted: Tuesday 09 February 2016 22:07
by Ronny
Hello All, I did a:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install raspberrypi-ui-mods

rebooted

I did switched to release channel "Beta"...no updates.

But still the Piface does not come back to life... what else do I need to do?

Re: RE: Re: News regarding Piface 1 & 2 (counter) issues

Posted: Tuesday 09 February 2016 22:14
by badz
Ronny wrote:Hello All, I did a:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install raspberrypi-ui-mods

rebooted

I did switched to release channel "Beta"...no updates.

But still the Piface does not come back to life... what else do I need to do?
The last changes are not part of an official release AFAIK.
You need to do a manual compiled version : http://www.domoticz.com/wiki/Installing ... rom_Source