1

I have a raspberry pi 3 running a program made in Xojo.

My goal is to have two flow sensors which display the amount of water that flows though each sensor on the screen.

I have a program that works for one flow sensor, it uses the GPIO library and a custom module called 'InterruptModule'. I followed a tutorial to make this program.

Tutorial: https://einhugur.com/blog/index.php/xojo-gpio/connecting-button-with-gpio-and-using-interupts/#comment-14

This program works successfully for both flow sensors, but only one at a time. I.e if I change the input pin and run the program again it works.

HOWEVER, when I try combine the two it responds can't differentiate between the two inputs.

I have tried with two GPIO modules and two custom 'InterruptModule' modules but it still counts the inputs under whichever sensor is defined first.

See my attempt here.

Screenshot of Xojo code

Ben Fricke
  • 11
  • 3
  • Not sure, but in the "Start flood" section you call SetupGPIO a second time. Could that be resetting and clearing the first input you configured? – Paul Lefebvre Jan 10 '18 at 19:42

1 Answers1

0

One way to differentiate between the two interrupts is to create two separate callback method.

Example:

Const kPin = 14
If GPIO.WiringPiISR(kPin, GPIO.EDGE_RISING, Addressof InteruptModule.ButtonDownInterupt1) = -1 then
MsgBox "Could not register for Interupt1 on kPin14"
End If

Const kPin = 18
If GPIO.WiringPiISR(kPin, GPIO.EDGE_RISING, Addressof InteruptModule.ButtonDownInterupt2) = -1 then
MsgBox "Could not register for Interupt2 on kPin18"
End If

In this example, each pin interruption would have its own callback method with different code to work with each pin.

eugenedakin
  • 45
  • 1
  • 6