LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Uni project-Help


@dal7800 wrote:

Thank you very much, I'll try to implement your advice and get back to you with feedback asap.


Well, the timing condition code is just a simplified version of what I showed earlier (because in your case both times are on the same day and end time > start time. Did you understand my simulation, which simply goes over all possible minutes of a day and applies the detection algorithm? It is an excellent practice to isolate the sub-problem and do a quick test with all possible values (or at least a representative selection) to verify correct operation. Make sure to understand it. This is much better that having to wait 24 hours for each test result. 😮

 

It is perfectly OK to ask for help, especially after putting in some effort as you did. Of course you need to fully understand all parts of the corrected code in detail and be able to explain it to the professor. I doubt this will be a problem. Good luck and happy programming! 😄

0 Kudos
Message 11 of 14
(100 Views)

Hello, @dal7800.  Thank you for your response -- I didn't take into account that you might not be in an appropriate "learning environment".  Let me try to suggest an approach.

 

Here is your statement of the Project:

 

I’m working on a project where I need to build a smart trash bin. The lid should open using a servo motor whenever an ultrasonic sensor detects motion. When the lid is open, a green LED should turn on, and when the lid is closed, a red LED should be lit.

 

There are two conditions for opening the lid:

 

  1. The detected object must be within 10 cm of the ultrasonic sensor.
  2. During a specific time window, the lid must remain closed regardless of any other conditions. For example time betweeen 12:15-12:30h. In my case that is 12x60+15 and 12x60+30

First question -- you first say "whenever an ultrasonic sensor detects motion" and later "the detected object must be within 10 cm of the ultrasonic sensor".  Considering only Condition 1, does that mean if you wave the object between, say, 9 and 11 cm back and forth, the lid will open and close as the object gets nearer and farther?

 

Second question -- which of the two conditions has priority?  If the lid is open (say the object is at 9 cm) and the timer is at 12'15" (12 min 15 sec), does the lid (a) close when the clock "ticks" from 14" to 15".(so that the "timer has priority" or does it stay open (so that the sensor has priority)?  What about if the lid is closed (object is at 11 cm) when the Timer "ticks" to "stay closed"

 

Third question -- is there, possibly, a third condition, namely "Is the lid Open or Closed"?  [You don't mention a sensor for this, but you could make it an "Initial Condition" (The Lid is Initially Closed).

 

[I'm assuming that you can assume that opening or closing the lid take no time -- you only need to know the lid's "state"].

 

It might help to add a third "Boolean" state -- "Lid Movable" (which is controlled by the Clock).  With these three Booleans, you should be able to figure out when you turn on the LEDs and when you open or close the lid.

 

Do you know about "Event Structures" in LabVIEW?  This is something that "waits for something to happen" and then responds to it, and almost always is found inside a free-standing While loop (which runs in parallel with the rest of your code)..  One thing it can monitor is a millisecond timer, so if you want a State to change every 15 seconds, you just wire 15000 (ms) into the Timer input.  Since it's in a While Loop, you can bring a Boolean "Lid Moveable" value into the While Loop on a Shift Register and every time the Timeout "fires", negate "Lid Moveable".  You now have the condition for Lid Moveable changing as you want it.  It can also monitor a Boolean Switch (be careful not to choose a "Rectangular" switch for Close Enough, but a Rocker, Toggle, or Slide switch -- do you know why?  Have you learned about "Mechanical Actions" of Boolean Controls?  The output of this Control should also "live" in a Shift Register on the Event Loop.  So now you have code that runs when Close Enough changes, and also has access to "Lid Moveable" (because it's in the same Event Structure).

 

So what do you want to do with these two pieces of information?  Open the Lid?  Close the Lid?  or Do Nothing?

 

Now the only thing missing is to illuminate (or turn off) the Red and Green LEDs.

 

Give it a try.  I'm deliberately not giving you a Block Diagram.  I haven't actually written this for myself, so there could be a step I missed, but I'm trying to get you to understand the Event Structure, which you'll best do if you "Do It Yourself".

 

Bob Schor

 

 

0 Kudos
Message 12 of 14
(72 Views)

I think it is significantly simpler than all that.

 

An cheap ultrasonic sensor (even the Lego Mindstorm kit had one!)  just measures distance (example) and if something suddenly approaches withing 10 cm, motion must exist.

 

What has not been defined is the condition for closing (time after opening? disappearance of a near object? minimum/maximum open time?) and that of course needs to be deglitched due to the nature of the duration of each task. A few tuning parameters to define the deadband should be implemented and adjusted during testing for the desired behavior.

 

The time resolution for the break is 1 minute, which is probably long compared to the typical open time.

 

An event structure is useful for a simulation. It is less useful for a near headless system operated by real sensors.

0 Kudos
Message 13 of 14
(59 Views)

@altenbach wrote:

An event structure is useful for a simulation.


Code can be significantly simpler without an event structure. Here's a quick simulation draft. 😄

 

altenbach_1-1764702432576.png

 

0 Kudos
Message 14 of 14
(45 Views)