How to power on reset the Arduino Uno using code

I am using a DC motor with an assembly that cuts through IR sensors. The pulses are counted using the Arduino Uno and displayed on the LCD. In order to prevent pickup problems when the DC motor starts I need to provide a power on reset through software. By the way the DC is not powered or programmed using the Arduino but is a part of an external apparatus.

Any help will be appreciated.

Regards

Gautam.

sketch_aug02_counttest.ino (619 Bytes)

Welcome to the Forum. Please read this post:

How to use this forum - please read.

Please post your code using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpreted by the forum code as italics or funny emoticons.

Unless the sketch is too large, it's better if you post your code, rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.

Do you mean a power on reset of the motor, or the Arduino? The Arduino already has a built in power on reset.

I need to provide a power on reset through software.

You need to explain this better. How is the Arduino supposed to know that you powered on the motors?

GautamD:
...I need to provide a power on reset through software.

No you don't. You are programming a general purpose computer that has more than enough logical capability to handle responding to different conditions without resorting to "the nuclear option" of resetting everything. That's like taking a circular saw to carve your Thanksgiving turkey.

What unspecified "pickup problems" are you worried about? If the Arduino knows when the motor starts up (which it would need to in order to be able to reset itself), you can code in logic that handles pulse counting differently. Maybe you ignore it for a set time. Maybe you wait for it to reach a certain threshold before displaying it on the LCD. Maybe you sanity check the results and ignore any that don't pass a sensibility criteria. You have options.

Arduino is only concerned with getting the pulses. Basically, I want the Arduino to initialize after a couple of seconds after the system settles down after power on. Could someone please help me with a piece of code that I could add at the beginning to software reset the Arduino Uno? Help will be appreciated.

Regards

Gautam

Yes, aarg I wanna reset the Arduino and not the motor. And I want to know how to use the built in Power On RESET..

GautamD:
I want to know how to use the built in Power On RESET..

Simply apply power. :slight_smile:

How to use the RESET pin on the Arduino Uno board?

GautamD:
How to use the RESET pin on the Arduino Uno board?

Connect it to ground to perform a reset. But you do understand, I hope, that the board resets by itself whenever power is applied?

Yes I realise that, but I want to software reset the Arduino. I want a piece of code that will provide an additional reset before the main execution starts. Could you help me with that?

This should trigger a software reset:

void software_Reset()
{
  asm volatile ("  jmp 0"); 
}

GautamD:
Yes I realise that, but I want to software reset the Arduino.

I'm with @Jiggy-Ninja on this. I cannot imagine any reason why you would need to cause a reset with software.

@GautamD, what do you think will happen if you do not cause a reset?

...R

The place where I intend to use the Arduino to detect IR pulses is at a packaging industrial environment. It will be a pneumatic environment so I wanna be sure the Arduino gives me a proper pulse count. Hence when the DC motor starts I wanna initialize the Arduino once again even after the power on reset.