Stepper latch program

I want to make a program which has 2 inputs and 2 outputs. One input is Step pin which receives pulse and the other one which is Direction pin which is LOW or HIGH only. If you are thinking these are the signals given to a stepper driver then you are right.

So, what I want is when there is a pulse on Input 1, and Input 2 is LOW, then Output 1 is HIGH and Output 2 has a pulse which has a frequency that I can adjust. It should continue giving output if the pulse goes off on Input 1 afterwards.

When there is a pulse on Input 1 but Input 2 is HIGH, then Output 1 should become LOW and Output 2 should stop giving pulse output (if it was giving). Similarly, it should continue this state until the previous case arrives.

I am not able to figure out how to write this program.

If someone can help.

Start by using pseudocode. Write the way you want it to work in clear steps. Use this to work out your logic. Once you have the idea of the program worked out, convert into code.

Read input1
If has pulse
Read input2
If high
Make output1 low
Stop output pulses.
.......

Etc

You will need to include loops in this code.

Work out the logic and debug that before trying to write the program. Once you have the code in plain language and have tested it thoroughly you can write the code in C.

Weedpharma

Perhaps the examples in this Simple Stepper Code will help.

What stepper driver board are you using?
Post a link to the datasheet for your stepper motor.
What power supply are you using for the motor (volts and amps)?

...R
Stepper Motor Basics

define your inputs

DIR input and PULSE input

if (DIRinput = HIGH)
then DIRout = LOW
PULSEoutput = PULSEinput

if (DIRinput = LOW)
then DIRout = HIGH
// no pulse is output

==========================

analog input from pot.

PULSEoutput = PULSEinput + POTvalue

your potvalue would be set to 2.5v as zero so that you can either increase or decrease the output pulse rate.

you said you want to adjust the frequency.

if you use a pot, you can create a value from 0.10 to 1 to +10
with the pot mid point being 1

then, monitor your frequency input and multiply it by the value.
using 0.1 multiplied to your incoming frequency would make your output 10% of the frequency of the input.