Timing questions

Hello

I have done some simple Arduino programming using a Nano on a custom made PCB, monitoring and controlling a battery. My program reads a couple of analog inputs and controls a Relay or MOSFET using the digital outputs. It also controls 3 LEDs.

Now I need to do something harder. In addition to all the monitoring and controlling that is going on (every so often) I also want to have a function that will write to a DAC in order to produce a sine wave.

My loop() function typically checks if it is time to check various things and then goes and checks them, else it does nothing. I can add another function off loo() to control the DAC. However I am thinking that there may be an impact on the timing for example (pseudocode)

loop()
{
// every 10 loops check the battery voltage

}

akis_t:
However I am thinking that there may be an impact on the timing

That depends on the actual code, not the pseudo code.

If there is enough “spare” time then it can be done.

…R

akis_t:
Hello

I have done some simple Arduino programming using a Nano on a custom made PCB, monitoring and controlling a battery. My program reads a couple of analog inputs and controls a Relay or MOSFET using the digital outputs. It also controls 3 LEDs.

Now I need to do something harder. In addition to all the monitoring and controlling that is going on (every so often) I also want to have a function that will write to a DAC in order to produce a sine wave.

My loop() function typically checks if it is time to check various things and then goes and checks them, else it does nothing. I can add another function off loo() to control the DAC. However I am thinking that there may be an impact on the timing for example (pseudocode)

loop()
{
// every 10 loops check the battery voltage
}

That will depend on the frequency of the sine wave. You haven't told us what that frequency will be. Does your sine wave have to come from the Arduino? Could you use a 555 to produce the input to your DAC? You haven't told us what this sine wave is for nor how it's to be controlled by your Arduino.

Tell us exactly what you want to do, then someone may be able to help you. Until then, we're just guessing, wasting both our time and yours. And post your code using code tags (the # button above the smileys).