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?).
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.
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.
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.
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.
Sorry for not asking how to implement … 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.
/* 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 */
}
}
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.