Limit Switch Programming

  1. last week
    Edited last week by Yuma123

    So I am trying to program limit switches so my 4 bar doesn't go too far up and down. I'm doing this to my Double Reverse 4 Bar but only for the way down. I have a pic of the program right now and the 4 bar doesn't stop when it hits the limit switch, and the DR4B only goes up. Is this my programming issue or a mechanical issue?
    Thanks

  2. Edited last week by SkinnyPanda Robotics

    There’s no code
    Oh it just loaded

  3. @SkinnyPanda Robotics There’s no code

    i just posted the code

  4. @Yuma123 i just posted the code

    Lols

  5. ZachDaChampion

    Feb 7 Fort Lauderdale, Florida 77788J

    The logic is sound, but the syntax is SensorValue[sensor], not SensorValue(sensor). That should fix it.

  6. Edited last week by SkinnyPanda Robotics

    Ok here’s how I would recommend doing it from current code we have competed with:
    if(vexRT[Btn6U] == 1)
    {
    if(SensorValue(Up4Bar) == 1)
    {
    motor[L4Bar] = 0;
    motor[R4Bar] = 0;
    }
    else
    {
    motor[L4Bar] = 127;
    motor[R4Bar] = 127;
    }
    }
    else if(vexRT[Btn6D] == 1)
    {
    if(SensorValue(Down4Bar) == 1)
    {
    motor[L4Bar] = 0;
    motor[R4Bar] = 0;
    }
    else
    {
    motor[L4Bar] = -127;
    motor[R4Bar] = -127;
    }
    }
    else
    {
    motor[L4Bar] = 0;
    motor[R4Bar] = 0;
    }

    @ZachDaChampion The logic is sound, but the syntax is SensorValue[sensor], not SensorValue(sensor). That should fix it.

    That’s how I’ve always done it and never had a problem.

  7. I know it’s not pretty... but just see if it works

  8. @SkinnyPanda Robotics I know it’s not pretty... but just see if it works

    should the sensor name be in brackets instead of parenthesis

  9. @Yuma123 should the sensor name be in brackets instead of parenthesis

    It shouldn’t matter at all.

  10. Barin

    Feb 7 Arizona

    @SkinnyPanda Robotics

    @ZachDaChampion The logic is sound, but the syntax is SensorValue[sensor], not SensorValue(sensor). That should fix it.

    That’s how I’ve always done it and never had a problem.

    That doesn't mean your syntax is correct. RobotC is quite forgiving about these things, but you should still strive to use the correct syntax: SensorValue[]

  11. @Barin That doesn't mean your syntax is correct. RobotC is quite forgiving about these things, but you should still strive to use the correct syntax: SensorValue[]

    I never said I was right, just that it shouldn’t matter.

  12. Vex 9185

    Feb 7 Bellefontaine, Ohio 9185

    @Barin That doesn't mean your syntax is correct. RobotC is quite forgiving about these things, but you should still strive to use the correct syntax: SensorValue[]

    The thing I find odd is that RobotC's sample programs use SensorValue() while their Online Wiki says "short sensorValue[tSensors sensor]"

  13. [TVA]Connor

    Feb 7 South Texas 1814D, 3674R
    Edited last week by [TVA]Connor

    As what I can see, there doesn't seem to be any issues with the code (unless someone can prove me otherwise). When a sensor isn't connected, there should either be a value of 1 or -1, so probably I think that what's happening is that either one of your limit switches aren't connected in the correct port, isn't plugged in, or a wire could be potentially damaged.
    This is just my inference though, but hopefully this helps :D
    - [TVA] Connor

  14. @[TVA Connor]As what I can see, there doesn't seem to be any issues with the code (unless someone can prove me otherwise). When a sensor isn't connected, there should either be a value of 1 or -1, so probably I think that what's happening is that either one of your limit switches aren't connected in the correct port, isn't plugged in, or a wire could be potentially damaged.
    This is just my inference though, but hopefully this helps :D
    - [TVA] Connor

    Oh if sensors output 1 or -1 and not 0 or 1 then that’s the problem.

  15. @SkinnyPanda Robotics Ok here’s how I would recommend doing it from current code we have competed with:
    if(vexRT[Btn6U] == 1)
    {
    if(SensorValue(Up4Bar) == 1)
    {
    motor[L4Bar] = 0;
    motor[R4Bar] = 0;
    }
    else
    {
    motor[L4Bar] = 127;
    motor[R4Bar] = 127;
    }
    }
    else if(vexRT[Btn6D] == 1)
    {
    if(SensorValue(Down4Bar) == 1)
    {
    motor[L4Bar] = 0;
    motor[R4Bar] = 0;
    }
    else
    {
    motor[L4Bar] = -127;
    motor[R4Bar] = -127;
    }
    }
    else
    {
    motor[L4Bar] = 0;
    motor[R4Bar] = 0;
    }

    That’s how I’ve always done it and never had a problem.

    The program unfortunately didn't work

  16. That’s odd. Did anything happen at all?

  17. Edited last week by Yuma123

    @SkinnyPanda Robotics That’s odd. Did anything happen at all?

    Uh the 4 bar continued to go down after hitting the limit switch
    NVM it worked. i must have typed it in wrong

  18. Oh wait my program worked?

  19. Edited last week by Yuma123

    @SkinnyPanda Robotics Oh wait my program worked?

    Ya, but it didnt work for the DR4B
    Any clue on why that is?

  20. Debug the values the limit switches output when pressed and unpressed. Make sure the codes calls those values.

  21. Newer ›
 

or Sign Up to reply!