GLOBAL SITE AUSTRALIAN SITE

Dual sensor looping problem | EdPy Programming | Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Topic3
Dual sensor looping problem
January 17, 2019
6:13 pm
Joe
Member
Members
Forum Posts: 3
Member Since:
January 17, 2019
sp_UserOfflineSmall Offline

I have two separate sensors (clap and obstacle detection) in this while loop.  When I hash out the lines associated with one, the other runs as expected, and vice versa.  So they both run individually, but together Edison will only detect the obstacle and then run both (motor) outputs separately with the clapping output first.

I suspect it's a need to have them in separate sections of code (but which would come first? An example would be awesome as I'm not getting anywhere), or perhaps it's just not possible to achieve.  

Context: I'm trying to build a lego train project where monitoring and detecting a clap will trigger the RH motor connected to a track junction switch, and monitoring to detect the train going past will trigger the LH motor to lower a level crossing boom.

Kind thanks!   The code:  http://www.edpyapp.com/share/xkQV6

January 18, 2019
2:54 pm
Isaac Nelson
Admin
Forum Posts: 45
Member Since:
March 16, 2018
sp_UserOfflineSmall Offline

Hi Joe,

It is important to note with the Edison robot that if the robot is driving. The robot can detect that as a clap since the Edison is making noise. 

So to make sure that is not the reason you are getting errors. I advise that you add a slight delay to detecting a clap after a drive then clear the data.

February 7, 2019
10:00 pm
Joe
Member
Members
Forum Posts: 3
Member Since:
January 17, 2019
sp_UserOfflineSmall Offline

Hi Isaac,

Thanks for your reminder about the motors triggering a clap-detection.  I've taken this into account with all my subsequent attempts.  Here is the latest unsuccessful one: http://www.edpyapp.com/share/xZGxe

No matter what I try, an obstacle is commonly triggering the 'Ed.DriveRightMotor' action - which is the one the clap is supposed to trigger, and indeed does.

Occasionally it does work and the left motor is triggered, but then without restarting the program it reverts to the problem above.  Sometimes it seems to be working better than other times. 

The main things in the code I'm varying are: adding the commands to reset the sensors (both clap and obstacle detection); adding wait times; also varying the ways the while loop is constructed.  However, no matter how many times and places I add waits and sensor resets, or vary the while loop structure, after many hours of careful experimenting I haven't identified any logical pattern.

Are you sure there isn't something fundamentally wrong with the way I'm trying to do this?

Thanks so much for your insights and time.

February 17, 2019
9:03 am
Joe
Member
Members
Forum Posts: 3
Member Since:
January 17, 2019
sp_UserOfflineSmall Offline

OK.  I nutted it out.  This code has both sensors constantly ready to detect an obstacle or a clap, both within the same while loop.  I still can't say that this is the best way of constructing the code, just that it works for what I wanted to do.

In this example, the left or right LEDs turn on to indicate detection.

In the code there is also a nested while loop so when an obstacle is detected, the right LED will stay lit (and the program won't move on,) until the obstacle is removed.

Hope it helps someone.

http://www.edpyapp.com/share/9748R

smile

  • Keep up with Edison

    Sign up for our newsletter to get all things Edison delivered straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Heads up

The Australian Federal Parliament has passed a law that extends goods and services tax (GST) to low value imports of physical goods imported by consumers from 1 July 2018.

This means that all customers purchasing Edison robots and accessories with an Australian shipping address must now pay GST. The GST will be automatically added to your purchase and show as a line item on your invoice.

We've detected that you are in Australia, so we wanted to let you know that we have changed your settings to view our Australian site, which displays GST inclusive pricing.

You can change back to the GLOBAL SITE at any time using the link in the top left of the page.

OK got it!    Take me to the GLOBAL SITE instead

Country

Pin It on Pinterest

Share This