Time control

I want to control a speed of conveyor based on object in queue. if queue is filled sensor gets high pulse. if the sensor pulse is high the controller has to reduce the speed conveyor motor. any one help me o write this code.

You need to post your schematic and the code you have written so far if you want help. If you want some one to write the code for you then post in the Gigs and collaboration section and say what you will pay.

Hi, Can you link us to motor specs or controller specif the motor has a speed controller already?

Thanks... Tom... :)

where are you now ?

are you currently controlling the speed of the conveyor and everything is working fine ? and you want to add the feature of faster speed ?

https://www.youtube.com/watch?v=HnbNcQlzV-4

what do you need help with ? counting how fast things are entering the quene ? selecting motors or an arduino ?

//#include <elapsedMillis.h>
int s0 = 11;
int s1 = 4;
int state = 0;
long interval = 5000;
//elapsedMillis timer5;
void setup() {
// put your setup code here, to run once:
pinMode(s0, OUTPUT);
pinMode(s1, INPUT);
//timer5 = 0;
Serial.begin(9600);
}

void loop() {
state = digitalRead(s1);
if(state == HIGH)
{

if(interval > 0)
{
//Serial.print(“ON”);
//Serial.println("");
analogWrite(11, 200);
Serial.println(“ON”);
interval–;
//delay(3000);
//delay(1000);
}
long interval = 5000;
}
if(state == LOW)
{
//Serial.print(“OFF”);
//Serial.println("");
analogWrite(11, 0);
Serial.println(“OFF”);
//interval–;
//delay(1000);
}// put your main code here, to run repeatedly:

}

This is my code. I need to control motor speed but the object moves in milliseconds of time.

You currently have one 'sensor' connected to pin 4; as long as that sensor gives HIGH, the motor runs. What kind of sensor are you using and where is it placed?

Have you considered how you / the arduino can determine if the conveyor is full or not?

Side note:

void loop()
{
  if(...)
    ...
    interval--
  }

  long interval = 5000;
  ...
}

I don't think that long interval = 5000 does what you think it does; it basically does nothing except wasting memory.

Sensor will be in middle part of conveyor. Am using IR proximity sensor. Now Am testing this code. Later i will use that Long Interval = 5000. for control the sequence.

Hi,
Can you post a diagram of the layout of the belt, motor and sensors please.

Please answer posts #2 and #3.

And can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Thanks… Tom… :slight_smile:

//#include <elapsedMillis.h>
int s0 = 11;
int s1 = 4;
int state = 0;
long interval = 5000;
//elapsedMillis timer5;
void setup() {
  // put your setup code here, to run once:
pinMode(s0, OUTPUT);
pinMode(s1, INPUT);
//timer5 = 0;
Serial.begin(9600);
}

void loop() {
 state = digitalRead(s1);
 if(state == HIGH)
{
 
 if(interval > 0)
{
 //Serial.print("ON");
 //Serial.println("");
 analogWrite(11, 200);
 Serial.println("ON");
 interval--;
 //delay(3000);
 //delay(1000);
}
long interval = 5000;
}
if(state == LOW)
{
  //Serial.print("OFF");
 //Serial.println("");
 analogWrite(11, 0);
 Serial.println("OFF");
 //interval--;
 //delay(1000);
}// put your main code here, to run repeatedly:

}

Now am testing one sensor. if one sensor test is correct. later it will be changed to four sensor.

I'm not quite sure why you only want to slow down when the conveyor is full; I can imagine that the intention is that e.g. a person at the end of the conveyor has time to take the item of the conveyor and place it somewhere; in that case, only the status of the last two sensors is really relevant.

But maybe you can explain the why of your approach?

However, you can get what you asked for ;) The below assumes that 4 sensors reading high indicates full (so slow speed), 4 sensors reading low indicates nothing on the conveyor (so stop) and anything else would be 'full' speed.

if(sensor1==LOW && sensor2==LOW && sensor3==LOW && sensor4==LOW)
{
  // stop
  analogWrite(11,0);
}
else if(sensor1==HIGH && sensor2==HIGH && sensor3==HIGH && sensor4==HIGH)
{
  // slow
  analogWrite(11,50);
}
else
{
  // 'full' speed
  analogWrite(11,200);
}