Rising and/or falling edge of a pulse

Dear colleagues,

Is there any way to sense rising and/or falling edge of a pulse coming to the digital pin?
Of course I can poll the pin, but it would be nice to use more “elegant” method.

Thanks,
Igor

Hey Igor,
There is an efficient way to do it directly on the firmware. To make it work, you will have to write an interrupt function which would run every-time you see a rising/falling edge on the firmware of the Atmega328. You can make that function increment a counter and from python you can just read that counter value. We do something similar for the flow sensor: https://github.com/DexterInd/GrovePi/blob/master/Firmware/Source/v1.2/grove_pi_v1_2_5/grove_pi_v1_2_5.ino#L580-L588 and a few other sensors.

If you are interested in tinkering with the firmware, do let me know. I can share more tips on how to do that.

-Karan

Hi Karan,

It would be interesting for me to play with firmware.
Of course I won’t be able to spend 40 hrs every week on this project. :slight_smile:
Nevertheless, I will do some programming for fun, not for money.

Currently I have many questions I cannot find the answers for.

For example,

  • - toolset- compiler, IDE, etc. Where can I get it from?

  • - development cycle- committing changes, building firmware image, run test on target equipment and so on. How do you do it. As regards the versioning, will the github.com be enough?

  • - Most interesting: where can I find the board architecture description. AFAIK the board is connected to RPi by two busses (I2c and SPI). Why two buses?
  • It seems I’m asking too many questions. I need to do my homework first. :slight_smile:

    Cheers,
    Igor

    Hey Igor,
    If would be great if you could tinker with the firmware. It’s always great to have more people looking into it. A lot of development on the GrovePi is driven by the community and we really appreciate the effort and are more than happy to help. Take your time going through it and do send us feedback and questions if anything is confusing or difficult to understand.

    The architecture for the GrovePi is here: http://www.dexterindustries.com/GrovePi/engineering/software-architecture/. The comms take place over I2C and SPI is only used for uploading the firmware. Here is the latest firmware: https://github.com/DexterInd/GrovePi/blob/master/Firmware/Source/v1.2/grove_pi_v1_2_5/grove_pi_v1_2_5.ino and the latest python library: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grovepi.py. Both of these work in sync to make the GrovePi work. There is an exmplanation of how this works here: http://www.dexterindustries.com/GrovePi/programming/grovepi-protocol-adding-custom-sensors/.

    There is a good discussion about the dev cycle here: http://www.dexterindustries.com/topic/grovepi-with-arduino-ide/ and when you reach the point where you want to contribute code back, then you should read these: http://www.dexterindustries.com/topic/working-code-for-raspberry-pi-projects-for-the-grovepi/ and http://www.dexterindustries.com/howto/contribute-code-dexter-industries-projects/.

    I hope these help. Feel free to ask any more questions.

    -Karan

    Hi Karan,

    This is a couple of questions I need to have answers to.

    What micro-controller chip is used by Grove Pi?
    And what are connections between Grove Pi digital I/O pins and micro controller’s digital I/O pins?
    E.g. I’d like to know that Grove Pi pin D3 is the micro controller’s pin 0 on the port C.

    Than, I take a look at the Datasheet and see wheather we can program the pin little bit differently, to achieve necessary functionality.

    Cheers,
    Igor

    Hey Igor,
    We use the Atmega328p which is the standard MCU on the Arduino Uno. You can use the Arduino IDE to compile and upload the code to it. You can find the port description here: http://www.dexterindustries.com/GrovePi/engineering/port-description/ and the schematic for the connections to the chip here: https://github.com/DexterInd/GrovePi/tree/master/Hardware.

    -Karan

    Hi Karan,

    After very busy weeks I have some time to spend with my GrovePi project.
    I have the question.
    Can the GrovePi board generate interrupts on Pi?

    Cheers,
    Igor

    Hey Igor,
    In theory, the GrovePi can generate an interrupt for the Pi but there is not a good mechanism for the Pi to handle it. The best way to do this would be to use one of the SPI lines connected b/w the GrovePi and the Pi as an interrupt (would require firmware modifications). And on the Pi, you can have a program just reading the GPIO pin waiting for it to change. There is more information here: https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=9207.

    -Karan