Jump to content
  • 0

Analog Shield With Timerone On Uno32


mwickert

Question

I would like to run TimerOne based examples for the Analog Shield on the UNO32. As I see it the Arduino TimerOne library is only for AVR parts. Is there an equivalent library for the UNO32 that provides this functionality.

 

To me the Analog Shield under UNO32 is not very useful without the ability to do Timer/interrupt driven processing.

 

Thanks for any insights the community can provide.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Hi mwickert,

 

In terms of a library that is specifically designed for the Uno32 that is equivalent to the TimerOne library, then no, there is currently not such a library. However, you do have several options in terms of getting that functionality with your Uno32 and Analog Shield combination.

 

If you are wanting to have a timer driven interrupt, you can simply use the attachCoreTimerService routine which will trigger itself at whatever time you specify. The smallest time delay you can use is 25 ns and the largest time division you can use is 90 seconds.  More information and example of this can be found here.

 

If you just wanted to use an interrupt that was not attached to a timer, you can use the attachInterrupt(pinNumber, isrFunction, triggerMode) routine to attach an interrupt to one of the 5 interrupt pins on the Uno32 (38, 2, 7, 8, and 35 for interrupts 0-4, respectively). Currently each of these interrupt pins on the PIC32 only support rising and falling edge triggers.

 

The nice thing about these two functions is that neither of them require a separate library in order to work accurately.

 

Let me know if you have any more questions.

 

Thanks,

JColvin

Link to comment
Share on other sites

JColvin,

 

Thank you very much for  your reply. I had started read about some of the chipkit libraries, but never drilled down deep enough to find the valuable information you pointed me too.  I now have a simple I/O running at programmable update rate.

 

FYI: I am using the Analog Discovery logic analyzer, scope, and function generator to take measurements. To pass a single channel of ADC input to the DAC output takes about 28 us. I don't know if there is a way to speed that up. Here is my code snippet from the Callback:

 

uint32_t MyCallback(uint32_t currentTime) {
  digitalWrite(7, HIGH);
  //digitalWrite(4,digitalRead( 4 ) ^ 1);
  input = analog.read(0);  //read in on port labeled 'IN0'
  output = input;
  for(i=0; i < Nspin; i++) {
    sum += 1;
  }
  if (sum > Nspin) {
    sum = 0;
  }
  analog.write(0, output);  //write out the value on port labeled 'OUT0'
  digitalWrite(7, LOW);
  return (currentTime + CORE_TICK_RATE/fs);

 

Again thanks

Link to comment
Share on other sites

Hi mwickert, 

 

In terms of large speed improvements for the Analog Shield, there isn't a whole lot you can do. According to the reference manual for the Analog Shield, both the ADC and the DAC have a conversion rate of 100 kHz, which is equivalent to 10 us for each conversion. Additionally, the analog.read and analog.write functions are both fairly processor intensive (and use SPI to communicate with the on-board ADC/DAC) which will take up some more time.  

 

So, the biggest speed improvement that I can think of would be using the ADC native to the Uno32 which is about 10x faster than the ADC on the Analog Shield. However, this ADC also is only has 10-bit resolution, so if your application needs to measure at 16-bit resolution, then there isn't anything that I can see that would save you a significant amount of time.

 

Let me know if you have any more questions.

 

Thanks,

JColvin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...