0

I have a 'pulse train' generated from a photo interrupter and slotted disc mounted on a rotating shaft. My goal is to measure the time between each rising edge.

I have looked at the data sheet for the SAM3X8E and figured out that I need to configure a timer in 'capture mode' to do this.

My problem is that I am new to Arduino Due / this level of programming so I do not know how to set-up all the prerequisites before this (PIO, PMC, SYSCLK? etc.)

I have spent an extensive period trying to find help/ example code to no avail. Anything I do find is on Arduino Uno or Mega and therefore is of little help because of the different architecture.

Can anyone help or has anyone else done this/ similar problem?

(I am using Atmel Studio 7 as it seems to be the go-to for advanced SAM3X8E programming)

Thanks

  • As far as I know, there is no problem in using the Arduino IDE with the due, even for "advanced" code. The attacheInterrupt method should work like it does for the Mega or UNO. Starting a counter/timer should also be possible. Perhaps you can use the following link as a start point. (The conversation starts with a discussion about possible counter speeds but after that, they show code for capturing two signals and measure the time between them. If I understood by a quick look at it). I would suggest to use the Arduino IDE if possible. – Peter Paul Kiefer Oct 27 '19 at 17:37
  • what link sorry? – Andrew McBurney Oct 30 '19 at 18:45
  • Wow, that's strange. Sorry, the link was removed. How can that happen? I answered the question on another computer and perhaps the link is still in the history of the browser. But, please be patient until I have access to this computer. In about ten hours. Here is another interesting link: forum.arduino.cc/index.php?topic=45926.0 They work with the rising and falling edges of a signal pin. Your problem is not far away from theirs. You only need the rising edge, Then read the actual time in the interrupt handler and compute the difference or mean value into a global variable. – Peter Paul Kiefer Oct 30 '19 at 20:36
  • The Firefox history does not forget ;-). Here is the link forum.arduino.cc/index.php?topic=400516.0 . But I had a second look into it and now I think the link from my last comment fits much better with what you want achieve. – Peter Paul Kiefer Oct 31 '19 at 8:54
  • Peter, thanks you for your response, I actually managed to find a library which seems to do the trick! – Andrew McBurney Nov 7 '19 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.