the issue is Udp.Read need minimum 230 Micro Second for one Character Read.
for my Project this Time is too much.
like the other command digitalWrite need 12 Micro Second.
please share your experience that how i can make Ethernet communication that i can reduce
the Data Reading time in Arduino.
i can't afford the more then 100 Microsecond for at least 4 to 6 character.
if is there any other library then please share the link.
i already try the Telnet but he also need minimum 230 MicroSecond for 1 character to Read.
the main goal is to control the 3 motor and 3 switch at the same time.
means they should all work independently.
Lets Make Simple just 1 motor and 1 LED
in loop i am not using delay function. i am using the Micro() function technique.
so Motor need plus signal After 700 Micro Second.
in single loop execution, i move the motor 1 step.
After moving the Motor 1 Step then i need to do some Calculation but
these calculation are not problem because they took only 4 us.
in loop this (Udp.Read ) is very exapnsive for me because he took 400 us.
he need to check every time if there is some data from computer.
i am sending command "StartMotor" ,"StopMotor" and also LEDON
so when the motor is running then during this time may be i want to Turn ON the
LED or something Like that.
please also check my code and i hope you will understand my goal.
void loop()
{
int packetSize = Udp.parsePacket(); // Get the Packet Size .... He took 60 Micro Second
if(packetSize) // If the Packet Exist ....He took 4 Micro Second
{
for(int i=0;i<UDP_TX_PACKET_MAX_SIZE;i++) packetBuffer[i] = 0; // He took 12 us
initTime = micros();
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
finalTime= micros();
Serial.println(finalTime-initTime);
UserCommand = packetBuffer ;
if (UserCommand == "StartMotor") // Here i am updating the Global Variable
{MotorRun =true;}
else if (UserCommand == "StopMotor")
{MotorRun =false;}
else if (UserCommand == "LedOn")
{LedOn = true;}
else if (UserCommand == "LedOf")
{LedOn = false;}
finalTime= micros();
Serial.println(finalTime-initTime);
}
if (MotorRun == true)
{
if (M1.IsForwardDone == false )
{M1.IsReverseDone = true;
M1.Start(1000,1);} // this is function who run 1 step every time ultil 1000 is reached
if (M1.IsReverseDone == false)
{M1.Start(-1000,1);
}
}
if (LedOn == true)
{PORTB |= _BV(PB7);} // He took 4 Micro Second
else
{PORTB &= ~_BV(PB7);}
}
Are you missing messages from the computer because of the time delay.
In other words, is the computer sensing messages faster than you can receive them?
If so, you need to implement some kind of flow control where your Arduino tells the computer that you are ready to receive another message.
atifbuitms:
in loop i am not using delay function. i am using the Micro() function technique.
so Motor need plus signal After 700 Micro Second.
in single loop execution, i move the motor 1 step.
After moving the Motor 1 Step then i need to do some Calculation but
these calculation are not problem because they took only 4 us.
You cannot expect to get real time step by step control of a stepper motor using any form of communication unless the step rate is very slow.
You should plan to send a block of data for many steps to the Arduino which the Arduino can then process in parallel with the arrival of the next block of data.
atifbuitms:
before the PacketBuffer i am already checking with the packetSize
if there is some packet size then i will go further
You do not understand me. Its the String class that asks for trouble.
To copy the buffer, you will have to allocate a String of the same size + some bytes.
That may not be available in one piece due to fragmentation and can just fail.
malloc will have to traverse the whole freelist to find out that it can't succeed.
There are plenty of stepper drivers that can provide 5amps or more. The only problem is their price Some brands to search for include Gecko and Leadshine.
Most of these drivers just need step and direction connections from the Arduino. I think the AutoDriver is more complex to operate.