Multiple digital inputs


#1

Hello,
My son is working on a sumo bot for a school project and is having issues. They use a black playing board with a white ring on the edge. He is using a IR sensor in the front and one on the back of his bot. He has had some success with one sensor but not when he adds the other sensor. We are using a digital read node and an if-else node we are not sure the best way to add the second sensor. Any help would be appreciated.


#2

I assume he is using a second input pin for the second sensor and had a second digital read node to get its value. How to wire it in will depend on existing code. I assume he probably only cares about forward sensor while moving forward and back sensor while moving backwards; is this what the if-else node is for?

There is not much more help we can provide without seeing his code.


#3

This is what he has so far problem is both sensors have to be triggered at the same time to reverse not sure what to do

ir%20pic_ImgID1


#4

Having trouble seeing details in that image. It looks like Port# is different for each digital-read node. You could add a watch node to the output of each digital-read and run in debug mode to see if sensors are reacting the way you think they should.

If you want both sensors active to trigger change in direction, then they should be linked with AND, not OR. Current program will reverse direction if either sensor is triggered. Depending on how wide the border is (and angle you are approaching the edge & speed of robot), it might be too late to change directions by the time both sensors are triggered. You will also end up bouncing back and forth as back sensor hits/leaves the outside border.

You will need to turn at some point, but determining which way to turn without additional sensors will be difficult. Having sensors left/right at the front would help you determine if you are hitting the border at an angle (one sensor triggered before the other), letting you know which way to turn to stay in the field.


#5

Hi dhall
I am new to the XOD ide also but very familiar with equipment PLCs, so for what it is worth I am going to weight in on this topic. Looking at what you have will not work, first the OR node. imagine 2 light switches controlling one light bulb, no matter which one is turned on the light will glow even if both are on. Most controllers with an OR function act like an EOR exclusive or, which means that if both are turned on the light will be off, there can only be one switch on. Not knowing the whole scope of the project it is hard to over direct advice, as gwiemer implies there could be a few variables to a rather complicated program.
My advice would be to do one step at a time not get overwhelmed by the entire project in one shot. This is your sons project RIGHT? A learning project on both fronts I think. One step at a time, build a program to make it go forward until the front sensor changes state. Then, reverse? go left? go right? AS an example go forward until the front sensor changes state then using the flip flop node go to reverse until the back sensor changes state, SET is forward RESET is reverse. You will have something that only goes forwards an backwards, but it is a start. When you get stuck on how to get a node to work or what node is needed to get a piece of logic to work this forum is awesome for a little guidance. Just my 2 bits.