Dear All,
Greetings for the day,
I am a new user of Arduino Uno and first time comer on this forum.
My queries are:
Arduino can handle maximum 12V dc. What if my input DC signal is of +32V dc? I am planning to use 7805 Voltage regulator to generate +5V from +32V dc and then feed it to Arduino. Am I doing right or something else can be done?
Can Arduino generate multiple rectangular pulse trains of different duty cycles simultaneously on different output pins? First i have tried two individual pulse trains on digital pins 2 & 10, they are running well but when I am trying to generate both the pulse trains together, it is generating erroneous outputs. The scheme of my experiment is:
First pulse (digital pin2): on time = 700 microsecond and off time = 1100 microsecond, duty cycle = 38.88%
Second pulse (digital pin 10): on time = 1 millisecond and off time = 6 second = 6000 millisecond, duty cycle = 0.016%
Kindly help from the vast knowledge base of your experience.
What if my input DC signal is of +32V dc? I am planning to use 7805 Voltage regulator to generate +5V from +32V dc and then feed it to Arduino. Am I doing right or something else can be done?
This can be done, according to the datasheet the 7805 can handle up to 35V, but keep in mind that the bigger the reduction in voltage, the bigger the generated heat will be, meaning that you may need a heatsink, and also that a linear regulator is not very efficient compared to a Buck converter.
dev31:
The scheme of my experiment is:
First pulse (digital pin2): on time = 700 microsecond and off time = 1100 microsecond, duty cycle = 38.88%
Second pulse (digital pin 10): on time = 1 millisecond and off time = 6 second = 6000 millisecond, duty cycle = 0.016%
Those are very long periods by Arduino standards so they should be no trouble for it.
Have a look at how millis() is used to manage timing without blocking in Several Things at a Time.
For smaller time intervals micros() can be used in the same way.
Arduino can handle maximum 12V dc. What if my input DC signal is of +32V dc? I am planning to use 7805 Voltage regulator to generate +5V from +32V dc and then feed it to Arduino. Am I doing right or something else can be done?
Don't use a linear regulator, use a buck converter. A linear regulator dumps the excess voltage a heat, and in the case of 32V to 5V that means that almost all the power going in is wasted as heat. A buck converter 'swaps' voltage for current, with the result that typically 85% or better of the power going in is used rather than wasted.
I have dropped the idea of using 7805 Regulator IC. Trying to find some suitable buck converter for my project.
@Robin2: sending you the block diagram, code and expected output.
When I try to run individual pulse outputs one after another, they are working well on their respective pins but when I try to integrate them in a sketch to generate both the outputs together, erroneous output is observed.
What changes should be made in the code to get the desired output.
If you use 'delay()' or 'delayMicroseconds()' for timing your sketch can do nothing during the delay. That means your two pulses would be in sequence, not simultaneous.
The 1.8 millisecond cycle would probably best be done with the built-in timer hardware. There are libraries to help. Timers can directly control the PWM pins: 3, 5, 6, 9, 10, and 11.
The 6.001-second cycle might also be possible with timer hardware but might more easily be done with millis(), similar to the BlinkWithoutDelay example.
dev31:
Unfortunately there was some problem with the attachment, please find it here.
"sketch.jpg" sounds like it is a picture of the program code
If so, pictures of code are no use because we can't edit them. Just post the program code as text and use the code button </> . If the program is too long to include (I hope not) then just add your .ino file as an attachment.
If the picture is something else then please make it visible in your Post so we don't have to download it. See this Simple Image Posting Guide
And smaller image files (640 x 480 should be fine) are kinder to those of us with slow or expensive internet connections.
int Pin2State = HIGH;
const unsigned long Pin2HIGHInterval = 700; // Microseconds
const unsigned long Pin2LOWInterval = 1100; // Microseconds
int Pin8State = HIGH;
const unsigned long Pin8HIGHInterval = 1; // Milliseconds
const unsigned long Pin8LOWInterval = 6000; // Milliseconds
unsigned long Pin2StartTime;
unsigned long Pin8StartTime;
void setup()
{
pinMode(2, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(2, Pin2State);
digitalWrite(8, Pin8State);
Pin2StartTime = micros();
Pin8StartTime = millis();
}
void loop()
{
if (Pin2State == LOW)
{
if (micros() - Pin2StartTime >= Pin2LOWInterval)
{
Pin2StartTime += Pin2LOWInterval; // Time the HIGH interval should have started
Pin2State = HIGH;
digitalWrite(2, Pin2State);
}
}
else // Pin2State == HIGH
{
if (micros() - Pin2StartTime >= Pin2HIGHInterval)
{
Pin2StartTime += Pin2HIGHInterval; // Time the LOW interval should have started
Pin2State = LOW;
digitalWrite(2, Pin2State);
}
}
if (Pin8State == LOW)
{
if (millis() - Pin8StartTime >= Pin8LOWInterval)
{
Pin8StartTime += Pin8LOWInterval; // Time the HIGH interval should have started
Pin8State = HIGH;
digitalWrite(8, Pin8State);
}
}
else // Pin8State == HIGH
{
if (millis() - Pin8StartTime >= Pin8HIGHInterval)
{
Pin8StartTime += Pin8HIGHInterval; // Time the LOW interval should have started
Pin8State = LOW;
digitalWrite(8, Pin8State);
}
}
}
If you need more precision on the 1 millisecond HIGH interval on Pin 8 you can switch it over to microseconds:
const unsigned long Pin8HIGHInterval = 1000; // Microseconds
const unsigned long Pin8LOWInterval = 6000000UL; // Microseconds
Be sure to change the two calls to 'millis()' into calls to 'micros()'.
@ JOHNWASSER: Thank you very much Sir for your kind help. The code is running well. Being a beginner in the Arduino Uno, I couldn't write the code properly.
Would you like to suggest me some good books / webpages / links etc. (about Arduino Uno) so that one day, I can become like you (another John Wasser, another Robin2, another PerryBebbington, another Deva_Rishi) to help some other Dev Raj?
Would you like to suggest me some good books / webpages / links etc.
I found (still find) this web site helpful for learning C C tutorial (The tutorial is for C not C++, not sure if you know but C++ is basically C with classes and a few other small differences. Almost anything you learn in C will work in C++).
Google for 'C++ for dummies' and you can find a pdf 'free' download. I found the 'for dummies' series quite helpful in general, also 'Electronics for dummies' and i saw there is even an 'Arduino for dummies' (not a free download i could find anywhere though)