Hello ,
I got the following waveform when I connected my output pin and GND of arduino to oscilloscope.
I just wish to understand this waveform , I want to relate the program to waveform, all help appreciated.
This is the code that resulted in above waveform
#include <Servo.h>
Servo project_e;
int pos = 0;
void setup()
{
project_e.attach(9);
project_e.write(45);
}
void loop()
{
delay(5000);
for (pos = 45; pos <= 135; pos++)
{
project_e.write(pos);
delay(30);
}
for (pos = 135; pos >=45; pos--)
{
project_e.write(pos);
delay(30);
}
It's a typical R/C servo PWM signal.
What do you need to know?
You can't really relate it to your sketch because we don't know at what point in the execution you took the screenshot.
Please get into the habit of using code tags when posting code.
Put your sketch between the code tags ``.
Attach images using the 'Enter image URL button'.
What don't you understand about the waveform?
Your trace shows a LOW level with a HIGH going pulse.
The servo library aids you in sending a PWM signal to an output pin.
The servo takes this PWM signal and moves the servo position accordingly.
Lots of coverage on PWM/servos on the Internet.
AWOL:
It's a typical R/C servo PWM signal.
What do you need to know?
Please get into the habit of using code tags when posting code.
I just want to be able to read the signals...
A few things i don't understand ...
I put the 5 sec delay in the loop but I don't see it on the signal...
Also, is the period fixed for a specific motor ?
If i were to calculate the duty cycle from the code, how would I do it ?
Sorry for not doing it the right way... New here...
The waveform is generated by a combination of interrupts and timers.
A delay has no effect, and the code will just generate the waveform corresponding to the last value written.
The scope has already done the duty cycle calculation for you, hasn't it?
AWOL:
The waveform is generated by a combination of interrupts and timers.
A delay has no effect, and the code will just generate the waveform corresponding to the last value written.
The scope has already done the duty cycle calculation for you, hasn't it?
Yes it has but there should be another way too right??
And why is there no effect of delays on output signal? the delay is written inside the loop....
If I write object.write(90); and nothing in the loop() section , why does arduino give me a continuously varying waveform ? Even if there is nothing changing in the program....
I've already explained why delay has no effect.
If I write object.write(90); and nothing in the loop() section , why does arduino give me a continuously varying waveform ?
Put the write in setup() and leave loop blank.
Report back your observations.
AWOL:
I've already explained why delay has no effect.Put the write in setup() and leave loop blank.
Report back your observations.
I think so ..that is what I did , I will re do it tomorrow and let you know....
Could you please add another sentence to
" The waveform is generated by a combination of interrupts and timers. "
Thank you for help and sorry for my no knowledge at all about this...
Abdul_Moeez:
Could you please add another sentence to
" The waveform is generated by a combination of interrupts and timers.
Once started, it will continue generating the waveform u til the detach() method is called.
AWOL:
Once started, it will continue generating the waveform u til the detach() method is called.
You make it sound interesting I will read about it ... If I don't understand I il bother you all , sorry
Don't be sorry, we will try to help.
.