Recent

Author Topic: Extend WiringPi wrapper "hwiringpi"  (Read 4864 times)

Mountaineer

  • New Member
  • *
  • Posts: 11
Re: Extend WiringPi wrapper "hwiringpi"
« Reply #15 on: May 14, 2021, 07:29:39 pm »
Hello ccrause,
thank you for your example code!

Quote
Perhaps you need to give an example here, in my limited understanding wiringPi relies on the OS kernel to call the interrupt handler. So no waiting is required?  Perhaps you need to explain a bit more what your requirements are.
My requirement/application is to count pulses of an anemometer.
The output of the anemometer is a simple switch bound to 3,3V via a pullup-resistor.
Every time he switch of the anemometer pulls the GPIO of the RasPi to ground an interrupt should be triggered.
The software counts the pulses in a period of time, calculates the windspeed and displayes it on a label of a form.

A question to your example code:
I do not understand why an output has to be put to high in order to start (start what)?
Line 49 of your code
Why put that pin to low to stop (stop what)?
Line 34 of your code

ccrause

  • Sr. Member
  • ****
  • Posts: 435
Re: Extend WiringPi wrapper "hwiringpi"
« Reply #16 on: May 15, 2021, 08:04:09 am »
A question to your example code:
I do not understand why an output has to be put to high in order to start (start what)?
Line 49 of your code
Why put that pin to low to stop (stop what)?
Line 34 of your code
I was imagining an example where a motor (switched on/off via pin 0) is moving an object.  The motor needs to stop/switch off when a limit switch (connected to pin 1) is triggered.  The ISR is connected to the limit switch pin, when triggered the motor is immediately stopped in the ISR callback (high priority action) and a message is posted to the main to display a message (low priority action).

Your example is obviously different, but you can use the general idea of the ISR callback doing low level counter/timer measurements and posting the information to the main thread to calculate and display the information.

Mountaineer

  • New Member
  • *
  • Posts: 11
Re: Extend WiringPi wrapper "hwiringpi"
« Reply #17 on: May 16, 2021, 07:09:15 pm »
Thank you all for helping me! :)

 

TinyPortal © 2005-2018