I'm at the design outline stage of a project that will control a quad channel trailing edge dimmer (based on the design from Elliott Sound Products)
Rather than generate the reference saw tooth ramp using hardware I want to do this in software using the Zero's builtin DAC, and approximate the smooth ramp with a series of discrete values.
Some relevant info follows:
- I will synchronise the ramp output to a zero crossing mains signal, so assume an interrupt on a digital input pin is required (the conversion from hazardous AC voltage to a safe low voltage is covered in the original design). At 50Hz mains this will fire every 10mSec - to reset the ramp output value to zero.
- The spec I'm working with requires a dimming resolution of 2.5% steps so that means 40 discrete steps for each ramp cycle. Consequently the DAC output value will need to change every 25 micro seconds, so I am thinking of using a timer based interrupt to increment the current ramp output value. The spec sheet for the underlying SAMD21 states the built in DAC is capable of outputting 350ksps, so the 4ksps I require should be fine.
- The rest of the code (in the loop function) will be dealing with receiving signals to control brightness and providing user feedback etc via an SPI interface to a network communications processor.
Now to my questions.
- Is the Zero capable of running all of this and not dropping any steps, or slowing the loop excessively ?
- How many low level instructions can the processor run between interrupts (48MHz and 25uSec between interrupts would indicate around 1,200 instructions could be processed in that time) ?
- What is the correlation between high level language instructions such as for loops, digital pin reading/writing etc and low level processor instructions - so I can get an idea of what features my code can contain ?