How to copy the signals from input to output???

Hi everyone,

I basically have to copy signal from one input pin to another output pin. The input pin will be receiving PWM signals and the output pin will be reproducing the same PWM signal to control servos,...etc,. For both input and output pins do I use PWM compatible pins???

It would be of great help, if you can give a rough idea on how to go about writing these codes(say like what function to use?).

Servos don’t typically use PWM, they use PPM.
However, you code could be as simple as

while(1){
  digitalWrite (outputPin, digitalRead (inputPin));
}

but it wouldn’t leave much time for the board to do anything else.
What are you trying to do?

I would suggest it could be easily done using a user interrupt pin set to trigger on change of input mode, the interrupt routine would then just read the input pin's value and do a digitalWrite to the desired output pin.

That way your sketch would be free to do other things as well.

http://arduino.cc/en/Reference/AttachInterrupt

Lefty

The input pin will be receiving PWM signals

One PWM signal or more as in signals?

Also what speed will the PWM signal be coming in at? What resolution will the incoming PWM be at?

I basically have to copy signal from one input pin to another output pin.

The simplest way to do this is with a wire connecting your PWM input to your PWM output, no arduino necessary. Or is this a school assignment? If so I hope we get good marks.

I also like the idea of attachinterrupt to read the output of the RC receiver. I would then use the duration information from that to write to the servos, using the servo library.

vinceherman: I also like the idea of attachinterrupt to read the output of the RC receiver. I would then use the duration information from that to write to the servos, using the servo library.

It's not that complicated. The interrupt would just have to 'copy the state of the input pin that caused the interrupt ( it either went from low to high or high to low) and write this new state value to the output pin. It doesn't matter that the signal represents a pwm or ppm or whatever signal, it just gets mimicked to the desired output pin such that it will always track what the input pin's state is. No need for the servo library code as the input signal is already a valid ppm signal and is just being copied to the output pin in real time.

Lefty

Yes but if you are not doing anything to the signal what is the point, a wire will do.

Not my application, just what the OP defined needing. :D

Lefty

Wow!!!

Thanks a lot for all the replies! :) Will surely try some of the solutions.

Here is my full objective,

1) When the user toggles a switch to position 1, the signal at the input is copied to the output to control the servo. 2) When the user toggles the switch to position 2, the Arduino produces its own signal to take control of the servo.

And thats the reason why I can't insert a wire from input to the output.

Details of the input signal:

Its just one signal at the input. The input signal's period is 14ms and frequency is 71.4 Hz I don't have any more information regarding the input signal now.

And thats the reason why I can't insert a wire from input to the output

Or you could use a simple logic gate.

What I am toggling is a switch from a RC transmitter and the output of the switch is not simple 1 or 0. Its also in the form of a wave.

So I believe, I can't use a simple logic gate.

What I am toggling is a switch from a RC transmitter and the output of the switch is not simple 1 or 0. Its also in the form of a wave.

First I'd heard.

The input pin will be receiving PWM signals and the output pin will be reproducing the same PWM signal to control servos,...

What sort of "wave"?

So I believe, I can't use a simple logic gate

Wrong that is exactly the sort of thing you can use a logic gate for. Wire up a 74LS00 or a 74LS02 as a data selector and you can switch between your external signal and an arduino generated one.

Before you ask here is how to do it:-

Data Select.pdf (18.7 KB)

Sorry for not asking how to implement :relaxed:… I have drawn the circuitry, which I want to implement. Could you please explain with reference to the picture thanks. I have also attached the codes.

I prefer to implement the outcome(Copying the input to output) by means of programming(if possible) rather than by means of using logic gates.

Thank you so much for helping.

!(http://)

http://www.4shared.com/photo/K-t3qguA/SCN_0006.html

/* OBJECTIVE TO COPY THE THROTTLE INPUT TO OUTPUT*/

int button = 2; 
int light = 13;
unsigned long duration;

void setup(){
  pinMode(button, INPUT);
  pinMode(light, OUTPUT);
  Serial.begin(9600);
  
}

void loop(){
  duration = pulseIn(button, HIGH);
  Serial.print(duration);
  Serial.print("\n");
    if (duration < 1500)
  {
    digitalWrite(light, LOW);
    /* Codes for copying the throttle input to output */
  }
  
  else
  {
    digitalWrite(light, HIGH);
    /* Codes for controlling Servo by UNO to output */
  }
}

I prefer to implement the outcome(Copying the input to output) by means of programming

Then you need to write a program to do this. The code you have just posted is gobbledegook and does not even begin to address the problem.

Hahahaha :)

Very true. Any rough explanation on how do i go about doing that? like what function to use...etc,.

That is what all the earlier posts were about, read them.

A sure thing!

On the other hand, the hardware solution is simpler and subject to less signal degradation (jitter, mostly), and can still be combined with software to perform the source selection.