need help Changing the pwm frequency on counter 1 and counter 2

Back again with more questions. I need to reset the PWM frequency on counter 1 and counter 2 for my Nanos .

Just like for counter 0, but using registers of timer 1 and 2. Study the controller data sheet for further information.

Tried, but hard to follow, using MsTimer2 library with timer2. I believe I can set both width and duration at same time using MsTimer2::stop();
MsTimer2::set ();
MsTimer2::start(); But timer1 is a 16bit timer and has a lot more lines. I want to set the period at or around 48Hz. Can I use 0-1024 or should map to 0-255.

Use Timer1 library?

Tried, but hard to follow, using MsTimer2 library with timer2. I believe I can set both width and duration at same time using MsTimer2::stop();
MsTimer2::set ();
MsTimer2::start(); But timer1 is a 16bit timer and has a lot more lines. I want to set the period at or around 48Hz. Can I use 0-1024 or should map to 0-255.

You misunderstand. MsTimer2. library can only be used to set an interrupt at a specified number of milliseconds. It has no pwm functionality, although by specifying what happens at the interrupt you could probably generate on/off for different periods of time in effect creating a duty cycle.

TimerOne.h library does have pwm capability and there is a library example called "Fan Speed" which demonstrates using the pwm capability of the library. The library expects output from 0-1023 for pwm duty cycle.

What exactly are you trying to do?

Already using timer1 library on timer1 to control PWM of #9 pin. Also need to change the PWM frequency of timer2 for pin # 11. Will the following code work for pin #9?

#include <TimerOne.h>
          
          #define pwmRegister OCR1A  // the logical pin
          const  byte   outPin = 9;
          
          long period = 10000;
          longpulseWidth = 1000  //width of pulse in microseconds

          int prescale[] = {0,1,8,64,256,1024};

          void setup()
             {
          Serial. begin(9600);
          pinMode(outPin,OUTPUT);
          Timer1.initialize(period);  //  sets period duration
          setPulseWidth(pulseWidth);
              }


          void loop()
             {
             }

             bool setPulseWidth(long microseconds)
                 {
                    bool =  false;
                    
                    int prescaleValue = prescale[Timer1.clockSelectBits];// calculate time per counter tick
                       //in nanoseconds
                    long precision = (F_CPU/128000) * prescaleValue ;
                    period = precision *ICR1 / 1000;  // period in microseconds
                    if(microseconds < period
                      {
                        int duty = map(microseconds, 0,period, 0,1024);
                        if(duty < 1)
                          duty = 1;
                        if(microseconds > 0 && duty < RESOLUTION)
                          {
                           Timer1.pwm(outPin, duty);
                           ret = true;
                           }
                      }
                      return ret;
                    }

Pin 9 and 11 are my output pins to the RA and DEC motors and they are noisy, they have a high pitched whine and the original drivers are outputting a period of 48Hz(20.5 ms) and a pulse of 1.5 ms.

Looks like the original drivers connect to servo motors, using PPM instead of PWM.

No servo's used in my project only dc motors with gear drives and one stepper motor in the 10" starfinder

If I change the frequency of the #1&2 counters to 30 Hz will I still be able to use the (millis) in my sketch

"if( millis() - guideCameraMillis > 50)
{
guideCameraMillis = millis();" or can I put TCCR1B=TCCR1B &B11111000 | B00000101; somewhere min the output statement.

The internal clock is based on timer 0, the other timers can be used freely.

Should I put the register codes in the "void setup() "

Everything required only once will go into setup().