0

Ardiuno Mega 2560

I have a legacy PCB that connects PORTA, pins = {22, 23, 24, 25, 26, 27, 28, 29} to the PWM input of a set of actuators. The accompanying code made use of an interupt service routine to generate PWM signals. This in turn caused all sorts of other problems for the system.

So, I would like to leverage the Mega's internal counters & use the PWM available on pins = {2, 3, 4, 5, 6, 7, 8, 9} & use the analogWrite() function. At present there is nothing else connected to these pins but access is limited.

Before I go down the route of redesigning the PCB I was wondering if it was possible to replicate the outputs of pins {2, 3, 4, 5, 6, 7, 8, 9} to pins {22, 23, 24, 25, 26, 27, 28, 29}?

  • 1
    It is not clear, what you are trying to achieve. What I understood is: You want do measure the value of the PWM signal on the pins {22, 23, 24, 25, 26, 27, 28, 29} and then outputting a new PWM signal with the same value on the pins {2, 3, 4, 5, 6, 7, 8, 9}. Is that correct? – chrisl Mar 25 at 12:33
  • I want to generate the PWM on pins {2, 3, 4, 5, 6, 7, 8, 9} using analogWrite() but replicate that output on pins {22, 23, 24, 25, 26, 27, 28, 29} – DrBwts Mar 25 at 12:40
  • 1
    It is not possible to route pins to other pins, the functionality of a pin is fixed to that pin. You could try a software pwm library. – Jot Mar 25 at 12:46
  • Is there a reason, why you want the same PWM signal on more than 1 pin? Why don't you just connect the one pin to both targets? – chrisl Mar 25 at 12:48
  • as mentioned in the orginal post the issue is to do with a legacy PCB. I'm just soundng out options before I have to redesign anything – DrBwts Mar 25 at 13:16
1

As Jot wrote, you cannot simply route a signal from pin to pin inside the chip/Arduino. So - unless you redesign the PCP, which would be the cleanest way, or use jumper wires, which is not so clean - you are down to using software PWM. There are also libraries for this, if you don't want to write this yourself, for example the SoftPWM library. These libraries have their own limits, especially in frequency. Be sure to check, if they fit your needs.

  • will check out the linked library tomorrow thanks. Is there any reason you can think of why I couldnt hard wire the pins together? – DrBwts Mar 25 at 16:04
  • 1
    You can. This is only about how clean the solution would be. Of course it is best to have a PCB thats designed for it. Connecting the pins with jumper wires is a bit less clean, but will work well (as long, as you don't need these pins for other purposes) – chrisl Mar 25 at 16:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.