Energy Saving escalator (need help with the code)

#1

Hello, I am working on a Energy saving escalator and I really need help with the code. There are 2 Line follower, 1 at the start and 2nd on the end. When an object passes the linefollower1 , the motor starts and the object is added in the code as a person 1 and when the object passes the linefollower2 the person is removed from the code and the motor stops. For example: 5 people crossed the linefollwer1, which starts the motor and those 5 people are added in the code as 5. After they pass the linefollower2 they are removed from the code and the motor doesn’t stop unless all the 5 people are out of the linefollower2 which is the exit. I really appreciate the help!

0 Likes

#2

What software are you using to program and are you using Cortex or V5?

Can you post the code you have been working on?

You could probably do a simple count system where if something passes the first line sensor the count becomes count + 1 and if count is > 1, the escalator motor spins. Else motor is off. If the second line sensor is crossed count becomes count - 1.

0 Likes

#3

I am using Cortex and I am pretty much new to programming. Just looking for someone to help me figure out the code for counting system.

0 Likes

#4

I just wrote this and this one does start the motor, but doesn’t stop afterwards:

#pragma config(Sensor, in1, exit, sensorLineFollower)
#pragma config(Sensor, in2, enter, sensorLineFollower)
#pragma config(Motor, port2, mainmotor, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

int countValue = 0;
int enterValue;
int exitValue;

task main()
{
while (1==1)
{
if(SensorValue(enter)<=2500)
{
enterValue=SensorValue(enter);
countValue = enterValue + 1;
{
while(countValue > 1)
{
startMotor(mainmotor, -15);
{
if(SensorValue(exit)<=2500)
{
exitValue=SensorValue(exit);
countValue = exitValue - 1;
{
while(countValue < 1)
{
stopMotor(mainmotor);
{
}
}
}
}
}
}
}
}
}

debugger info:
}debugger%20windows

0 Likes