Using Arduino for Signal Generation

Hi

I am working on an arduino project.

I want to make a time based signal and save it inside arduino's memory.

The signal to generate should be based on inputs. There are 4 digital inputs and I want to code them like they go

0000 to 1111 , the possible 16 combinations, but I want to make a continuous pulse as any of them changes, and it should be recorded against time.

So I need help about how to use timers in arduino and how to generate a pulse against time while my inputs are only high or low

Abdul_Moeez:
I want to make a time based signal and save it inside arduino's memory.

That does not make sense.

An Arduino can have the data needed to generate a signal, but it cannot save a signal.

Can you make a simple drawing showing what the signal you want to make looks like and post a photo of the drawing.

...R

Something like this:

I had 4 wires coming in so, 2 wires for each motor that is connected at output of arduino. I want to control the motors by left right forward backward and save the two pulses of the two motors.

What do you mean by, "save the two pulses of the two motors"?

Delta_G:
What do you mean by, "save the two pulses of the two motors"?

Training the car.... I provide it a signal and I record that signal and use it forever.

Like the motors run first manually (by me through a remote control) , afterwards, the signal is saved and they can run on it forever.

Image from Reply #2. See this Image Guide

...R

Abdul_Moeez:
Like the motors run first manually (by me through a remote control) , afterwards, the signal is saved and they can run on it forever.

I wonder if you mean that you want to record the time (the value of millis() ) when the signal goes HIGH and later record the time when it goes LOW so that you can replay the series of HIGHs and LOWs at the correct intervals?

If so, then that is possible. But you will need to give us some idea of how many time intervals you want to record.

I should also warn that, even if you do record those times, you will almost certainly find that a robot will not accurately retrace its path due to small differences in friction and things like that.

It s much easier to help if you explain the project you are trying to implement.

...R

Robin2:
I wonder if you mean that you want to record the time (the value of millis() ) when the signal goes HIGH and later record the time when it goes LOW so that you can replay the series of HIGHs and LOWs at the correct intervals?

If so, then that is possible. But you will need to give us some idea of how many time intervals you want to record.

I should also warn that, even if you do record those times, you will almost certainly find that a robot will not accurately retrace its path due to small differences in friction and things like that.

It s much easier to help if you explain the project you are trying to implement.

...R

I accept the fact that it wont retrace the path.

The project that I am doing is transportation of kind of , weightless goods and stuff. adding weight would make issues with the path.

I want a UGV to transport my items from once place to another, the path to be followed would be plain ... Minor turns, I have done some work on it already,

The signals to the motors go through the arduino, the arduino just for now, passes it to the motors using a motor driver circuitry. What I want to do is, make 2 modes for it

In one mode, I train the car, it follows a path and as I am training it, it saves the pulses given to the motors,

then i change the mode... now its supposed to use those pulses and make the same movements again.

Abdul_Moeez:
I accept the fact that it wont retrace the path.

The project that I am doing is transportation of kind of , weightless goods and stuff. adding weight would make issues with the path.

I want a UGV to transport my items from once place to another, the path to be followed would be plain ... Minor turns, I have done some work on it already,

The signals to the motors go through the arduino, the arduino just for now, passes it to the motors using a motor driver circuitry. What I want to do is, make 2 modes for it

In one mode, I train the car, it follows a path and as I am training it, it saves the pulses given to the motors,

then i change the mode... now its supposed to use those pulses and make the same movements again.

How did you manage to write all that and avoid dealing with the most important part of my Reply #6 - the first paragraph, what you want the Arduino program to do?

...R

Robin2:
I wonder if you mean that you want to record the time (the value of millis() ) when the signal goes HIGH and later record the time when it goes LOW so that you can replay the series of HIGHs and LOWs at the correct intervals?

...R

Exactly, I want to capture the duration ... that is what a pulse is right? I want some way that I can retrace it. Saving somewhere something, that I can code or decode if it can't be done directly.

You can always get the number of milliseconds that the board has been running with millis(). By using subtraction and some starting points you get the time points. Save them in an array. Later you can watch millis() to see how long it has been since some given starting point and at the times recorded in the array send the pulses.

Abdul_Moeez:
Exactly, I want to capture the duration ... that is what a pulse is right? I want some way that I can retrace it. Saving somewhere something, that I can code or decode if it can't be done directly.

I had been hoping you might also respond to the second paragraph in Reply #6 without needing to be asked specially.

...R

Delta_G:
You can always get the number of milliseconds that the board has been running with millis(). By using subtraction and some starting points you get the time points. Save them in an array. Later you can watch millis() to see how long it has been since some given starting point and at the times recorded in the array send the pulses.

Thankyou , so all I have to do is learn the function millis() and could you please direct me somewhere where I can check the array part ? I am only familiar with the array method used in C++ programming and all. If there is an example with this syntax that you find proper, I would like to see it.

Also...
is this all possible with a single arduino? You know now what I am making so instead of making another question its best I ask here.

Multiple movements, like forward + turn, can that be simultaneously recorded?

Sorry if these questions are invalid, its just I have to get this done myself.

Robin2:
I had been hoping you might also respond to the second paragraph in Reply #6 without needing to be asked specially.

...R

Yes, sorry I am a beginner , but thank you for your replies, at least I will get somewhere better.

Abdul_Moeez:
Yes, sorry I am a beginner ,

I understand that you are a beginner. But if you want to progress from being a beginner then you have to respond to comments, suggestions and questions - even if only to say that you don't understand them.

You still have not responded to my request

you will need to give us some idea of how many time intervals you want to record.

...R

Robin2:
I understand that you are a beginner. But if you want to progress from being a beginner then you have to respond to comments, suggestions and questions - even if only to say that you don't understand them.

You still have not responded to my request
...R

Sorry again.

I have no idea how much is required . Its a maximum of 500 meter distance for the first path (later I wish to add multiple paths)

Like its at some initial point, button 1 = location 1, button 2 = location 2.

Each location = 500 meter away with very slight turns, no U turns or such things.

So, for a minimum error, I don't exactly know how it should go.

Also, how is the logic supposed to be ? I put checks if its going forward or left or right, and I start the timer (btw how many seconds can the timers run to?) I would have to reset them from time to time I guess...

Is there any way to just record time or do I need to work with the timer like AT89C51 etc.

I hope I answered your question.

Abdul_Moeez:
(btw how many seconds can the timers run to?) I would have to reset them from time to time I guess...

The value reported by the function millis() keeps incrementing for 49days - that's probably enough for your projec without any need to reset anything.

Whenever one of your outputs goes high save the value of millis() - suppose the number 324752. Then the next time the output goes low save the new value of millis() - suppose it is 331252. You can calculate how long the output was high by subtracting the two values 331252 - 324752 = 6500 meaning the output was high for 6.5 seconds.

Study the code in this link - it will have a lot of the parts you require
Planning and Implementing a Program

Also study the use of arrays as a place to save your time values.

I have no idea how much is required . Its a maximum of 500 meter distance for the first path

You will need to make a rough estimate. How many times will the motor power need to change while the machine moves that distance. If you just need a couple of hundred values (or less) they can probably be stored within the Arduino. If you need thousands of values you will probably need to store them on an SD card.

...R

Robin2:
The value reported by the function millis() keeps incrementing for 49days - that's probably enough for your projec without any need to reset anything.

Whenever one of your outputs goes high save the value of millis() - suppose the number 324752. Then the next time the output goes low save the new value of millis() - suppose it is 331252. You can calculate how long the output was high by subtracting the two values 331252 - 324752 = 6500 meaning the output was high for 6.5 seconds.

Study the code in this link - it will have a lot of the parts you require
Planning and Implementing a Program

Also study the use of arrays as a place to save your time values.
You will need to make a rough estimate. How many times will the motor power need to change while the machine moves that distance. If you just need a couple of hundred values (or less) they can probably be stored within the Arduino. If you need thousands of values you will probably need to store them on an SD card.

...R

I am looking into it, slowly I should be able to gather all that data to answer your questions.

I will study the link you gave, for sure that will take me a while

Thankyou so much sir.