## Logic to find the exact position of the object.

44 posts / 0 new
Author
Message

I am trying to understand how the weighbridge system measures the load by detecting the correct position of the vehicle.

Image show Three IR sensors ( TX and RX pair) are being used which tell the exact position of the truck. Outputs of these 3 IR sensors are connected to an  microcontroller

This is my truth table

0 0 0 - " The truck is not on the weighbridge "

0 1 0 " You are in the right place"

1 0 0 " Please go back"

1 0 1 " Not possible conditions "

1 1 1 " Not possible conditions

The system will measure the weight only when the truck is stable and the middle sensor is high and both the sensors are low.

Before writing the actual code, I'm trying to understand how this logic would be implemented.

Anybody can help me to understand logic

This topic has a solution.
Last Edited: Tue. May 31, 2022 - 04:48 PM
This reply has been marked as the solution.

Why put your homework problem here?

I'm trying to understand how this logic would be implemented.

Are you saying you know absolutely nothing about programming?

if s1==0 && s2==0 && s3==0  bridge_state=0,   (0 0 0) - The truck is not on the weighbridge

else if s1==0 && s2==1 && s3==0  bridge_state=2,   (0 1 0) - You are in the right place

else if ....

you should be able to form the rest during your next wakeup. There are other ways, but this should be quite clear.

For example you might simply "or" the sensors (0/1) into their weighted bit positions  bridge_state = (s1<<2) | (s2<<1) | s3  if your table state numbers corresponds to mere sensor weighting (I didn't check all).

Anybody can help me to understand logic

No, nobody can work such miracles.    Why are you posting such things as though they are beyond comprehension??---surely you can cough up such an implementation?  Get at it & stay at it---be ready when a tough problem comes along.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. May 28, 2022 - 05:20 AM

You have made an excellent start.  i.e. you have drawn a diagram.

I suggest that you rename your sensors.  e.g. S3 on the left.  S1 on the right.

Then your table will be more "intuitive".  e.g. 110 will mean go forward.

The biggest lesson is:  draw pictures.

You don't need any fancy CAD tools.   Just a pencil and paper.

David.

What is there to understand? It only requires a couple of if() statements!

Until Black Lives Matter, we do not have "All Lives Matter"!

Firstly, you listed only 7 bit combinations, while in reality 8 are possible. One is missing. Who can help muke12 to find the missing combination?

Secondly, there's really no reason to implement it through enumeration of bit combinations, although for just 3 sensors this might be a viable idea too.

The whole logic boils down to:

S1==S2==S3==1 - "you are too long, go away!!!" (not sure whether you need to handle this)

otherwise:

otherwise:

S2==1 - "OK, that's the spot"

otherwise:

"yawn... empty"

This all assumes that commands are active only when a truck is entering the scales (not when it is leaving). If the system is constantly active, it will also issue commands to leaving trucks forcing them to oscillate back and forth indefinitely. It also assumes that a truck can't enter while the preceding truck is still there. So, strictly one truck at a time. Your table is built under the same assumptions, as I see.

Dessine-moi un mouton

Last Edited: Sat. May 28, 2022 - 07:01 AM

ka7ehk wrote:

What is there to understand? It only requires a couple of if() statements!

This logic is what i am thinking but i don't understand how the system will know that the truck is in stable state

```
while (1) {
if (S1==High ) && (S2== Low )
go forward

else if (S1==High ) && (S2== High )
go forward

else if (S2==High ) && (S3== High )
go backwards
else
correct position
}```

Last Edited: Sat. May 28, 2022 - 06:58 AM

Hi, are you sure that there is no other sensor involved here apart from these 3 pairs or IR? For example, a load sensor?

Go on.   You draw a picture.

Then you "drive" the truck.

As you drive the truck,  write out the state of each sensor in a truth table. e.g. (assuming t

S1 S2 S3

0  0  0   Empty

1  0  0   Enters from left

1  1  0   moves towards centre

0  1  0   CORRECT

0  1  1   moves right

0  0  1   leaving from the right

0  0  0   empty

Yes,  there are 2 states that are not possible / not legal

1  0  1   truck sawn in half

1  1  1   truck too big for weighbridge

Seriously.  You are doing everything right.  i.e. drawing a picture.  writing a truth table.

All that you need now is a kettle and some tea bags.   And it the logic falls into place !!

David.

Last Edited: Sat. May 28, 2022 - 09:40 AM

S1 S2 S3

0  0  0   Empty

|

1  1  1   Big Truck Parachutes onto Weighbridge.

tepalia02 wrote:

Hi, are you sure that there is no other sensor involved here apart from these 3 pairs or IR? For example, a load sensor?

There is a separate mechanism to measure weight.

When the truck is in stable and correct position. The weighbridge measures the weight and display it on the  the screen.

I just want to check the position of the truck when the correct position is known, the system will automatically measure the weight and display it on the screen.

Last Edited: Sat. May 28, 2022 - 11:27 AM

I can't believe that you can't do this for yourself.

It just needs one pencil.

And most importantly you would have "solved" it all by yourself.

Ok,  you have goaded the readers to do it for you.   Only taken 7 hours.   When you could have done it yourself in 5 minutes !!

The Internet is fairly good for doing your homework for you.

However you spend more time typing messages than if you had just done it by yourself.

Sometimes it takes days for people to complete your assignments.   And at the end of the massive Forum thread,   you probably have not understood anything at all.

David.

david.prentice wrote:

The Internet is fairly good for doing your homework for you.

However you spend more time typing messages than if you had just done it by yourself.

Sometimes it takes days for people to complete your assignments.

I have discussed here only one part of my project and I asked for help in understanding the logic. Obviously I don't have that much experience so it takes me longer to understand.

I made some flowcharts for myself I didn't think they were correct so I didn't post them so when I think if the flowchart is logically correct I will post

What's your opinion on pseudo code  in post #6 ?

Last Edited: Sat. May 28, 2022 - 12:01 PM

muke12 wrote:
I am trying to understand how the weighbridge system measures the load by detecting the correct position of the vehicle.
An alternate method is to roughly balance the load cells.

RSCA Series Pit-Type Truck/Track Combo Scale | Cardinal Scale Manufacturing Co.

A guess on the local light truck -to- semi-tractor trailer weigh scale :

• limit switches to indicate the beam is off the pads
• one torque arm weigh scale (pivot -to- scale operator who balances the scale beam then reads the weight)

edit : strikethru

"Dare to be naïve." - Buckminster Fuller

Last Edited: Sun. May 29, 2022 - 11:48 AM

S1 S2 S3

1 0 0 moves forward

1 1 0 moves forward

0 1 0 CORRECT

0 1 1 Go back

0 0 1 Go Back

i think that's the right logic, what's your opinion

Yes,  your flowchart is a good approach.

Buy that pencil.   Follow the paths with a pencil.   I would expect to see a real life arrow tracing a path or some evidence of an erased arrow.

Note that I have written a series of sequential steps.   i.e. a state sequence.

Also note that you can go up or down to an adjacent state but can't jump 2 states.

When you trace your flowchart you can check to see whether the next states obey the up, down or stop rules.

David.

but i don't understand how the system will know that the truck is in stable state

Then you haven't really defined what the real problem is that you are working on.  seriously.

None of these states defines stability.

What did you define as stable state in the first place?

That truck is sitting in  0 1 0 " You are in the right place" for 10 seconds?  for 10 minutes? for 3 days?  Or something else entirely?

YOU are the one to define what is considered stable or not and the limits that it must meet.

At least you are making efforts to create some diagrams and flowcharts....keep at it and come up with more ideas.  Practice makes perfect, as they say!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. May 28, 2022 - 10:21 PM

I would also suggest that "exact position" (as written in the title) is not an issue, here. Suppose that you have a truck that is smaller than the distance between the light beams. Then, technically, the truck could be anywhere inside the beams.

How do you know that the system does not use ultrasonic sensors aimed at each side and each end of the truck? That would give you a "more exact" position!

Just how close does the center of the truck (or, its center of mass) have to be to the precise center of the weighbridge?

Jim

Until Black Lives Matter, we do not have "All Lives Matter"!

Last Edited: Sat. May 28, 2022 - 09:29 PM

You guys are overthinking the problem.

It is a simple homework logic problem, not a real-world problem.

Accept the "flawed" reality and move on!

JC

DocJC wrote:

You guys are overthinking the problem.

It is a simple homework logic problem, not a real-world problem.

Accept the "flawed" reality and move on!

JC

agreed.

the OP, is also making life somewhat hard on themselves too.

to almost quote a famous Freak:

”Stop.  Go make a cup of tea….”

I think the OP should do this to clear their head, and the community as well as they are repeating themselves, and starting to get a bit abrasive.

the basic concept and logic seems to have already been solved by the OP, yet it seems they don’t understand how they did it.

if indeed this is a homework assignment, then the OP should consult with their teacher as well as ask questions here.

as for the rest of us, to me, the solution, and suggestions have been presented.  Time for the OP to go make that cup of tea and review what’s been presented, and we should as well go make a cup of tea and stop trying to make the horse drink..

cheers,

jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

"The critical shortage here is not stuff, but time." - Johan Ekdahl

"Step N is required before you can do step N+1!" - ka7ehk

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

DocJC wrote:

You guys are overthinking the problem.

It is a simple homework logic problem, not a real-world problem.

JC

come on man this is a real world problem i'm working on it. Think positive, The project I am working on is an unmanned weighbridge whose job is to measure the load in a truck. If the truck is overloaded, the driver is instructed to reduce the load.

There is another vendor in this project whose job  is to measure the weight. They measure weight and send it on over uart

I have prepared a sketch for this whole process

## Attachment(s):

OK, then, YOU need to define how good is good enough. Factors to consider include:

1. Are all trucks exactly the same size?

2. How important is it that the truck be centered over the weighbridge? The other vendor should be able to tell you. Related to this is the issue of unevenly distributed loads in the truck. Does this cause errors? If so, how much?

3. If the trucks are all the same, why not use an "index mechanism" that hangs down even, lets say, with some hood or windshield detail. Then the driver drives up until that detail just touches the index mechanism. This mechanism might not be anything more than a string with a soft weight on the end. When done, the truck just proceeds. It would have to be suspended from something taller than the truck but that might be a LOT less expensive and more reliable.

4. If trucks are not all the same length, then what sort of error occurs if a short truck is all the way forward compared to all the way back? Is such an error significant? The weighbridge vendor should be able to tell you.

5. If good centering is important for different truck lengths, then light gates are not sufficient, I would suggest ultrasonic ranging sensors at each end and a light bar visible to the driver. Then, you change the position of the lighted section on the bar according to whether too far forward vs too far back. Here, the important measure is that the front and back sensors read the same distance to the truck. If the front sensor reads more than the back, it is too far back, and the truck needs to move forward.

Jim

Until Black Lives Matter, we do not have "All Lives Matter"!

Note also that for practical weighing (using for example, load cells: could equally be a spring balance with a visual scale) it doesn't matter where the load is provided it is all supported by the weighing mechanism. The loads on each sensor will sum to the total weight being supported - including possibly zero or negative weights if the geometry of the platform allows it. The caveat is that for this to work the sensors need to be identical, of if not, need to be individually calibrated so their contribution can be appropriately scaled.

So you need only consider the state of getting the truck onto the weighbridge 'somewhere'; provided it's not sticking out at one end you're golden.

Neil

My guess is that the IR sensors are good enough.

The exact positions of the sensors likely matter,

as does the mechanics of the scale and

the positions of the trucks' wheels.

BTW I'm pretty sure all 8 combinations of sensor readings are possible,

even without broken sensors.

101 would not necessarily require two trucks,

just a negative hump.

Moderation in all things. -- ancient proverb

muke12 wrote:

I am trying to understand how the weighbridge system measures the load by detecting the correct position of the vehicle.

[...]

This is my truth table

0 0 0 - " The truck is not on the weighbridge "

0 1 0 " You are in the right place"

1 0 0 " Please go back"

1 0 1 " Not possible conditions "

1 1 1 " Not possible conditions

The system will measure the weight only when the truck is stable and the middle sensor is high and both the sensors are low.

Before writing the actual code, I'm trying to understand how this logic would be implemented.

Anybody can help me to understand logic

I don't understand what you're asking. Are you asking how to implement the logic in code?

What's wrong with the simplest and most obvious way:

```If( s1==0 && s2==0 && s3==0)
"the truck is not on the weighbridge"
else if(s1==0 && s2==0 && s3==1)
else if(s1==0 && s2==1 && s3==0)
"You are in the right place"

...
else
"you can't do that"```

What do you need help understanding?

Brian Fairchild wrote:

It's at this point that we really do need the OP to come back and engage with us. So many questions..........

What do you need help understanding?

Basically everything, including how to ask the question...at least a diagram is at hand, but not much beyond.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

ka7ehk wrote:

OK, then, YOU need to define how good is good enough. Factors to consider include:

1. Are all trucks exactly the same size?

not all will be the same size but  Only one truck will be allowed on the weighbridge whose size will be less than the distance between the first and last sensor.

ka7ehk wrote:
2. How important is it that the truck be centered over the weighbridge? The other vendor should be able to tell you. Related to this is the issue of unevenly distributed loads in the truck. Does this cause errors? If so, how much?

If the truck does not stop at the center of the weighbridge, accurate measurement is not made, so the truck must stop at the center

ka7ehk wrote:
3. If the trucks are all the same, why not use an "index mechanism" that hangs down even, lets say, with some hood or windshield detail. Then the driver drives up until that detail just touches the index mechanism. This mechanism might not be anything more than a string with a soft weight on the end. When done, the truck just proceeds. It would have to be suspended from something taller than the truck but that might be a LOT less expensive and more reliable.

I researched and found that most of the people are using IR sensor and not ultrasonic sensor

​​​​​​​

ka7ehk wrote:
4. If trucks are not all the same length, then what sort of error occurs if a short truck is all the way forward compared to all the way back? Is such an error significant? The weighbridge vendor should be able to tell you.

The size of the truck will always be greater than the distance between the two sensors. The size of the truck will always be less than the distance of the first and last sensor.

How do you get the weight ?
Is the weight-information a continuous stream from the weighbridge, or do you need to 'ask' for the current weght ?
Is there a 'weight is stable' indicator ?

Non-physicist can solve this but with very complicated digital method.

Physicist will solve this from the viewpoint of Torque (Moment of Force) and Principle of Virtual Work.

HKPhysicist wrote:

Non-physicist can solve this but with very complicated digital method.

Physicist will solve this from the viewpoint of Torque (Moment of Force) and Principle of Virtual Work.

What?!?

You drive the truck onto the scale. There are three sensors. One says the truck is somewhere on the scale, two of them tell you if the truck is hanging off one end or the other and should be centered.

When the combinations of sensors is correct, read the weight from the scale.

There are no torques involved.

There is no work involved, not by the physics definition or the colloquial one.

There is amazingly little logic required.

What's the fuss? Reheating a cup of coffee in a microwave oven can be more involved.

Brian Fairchild wrote:

It's at this point that we really do need the OP to come back and engage with us. So many questions..........

Last Edited: Thu. Jun 2, 2022 - 08:30 PM

HKPhysicist wrote:
Physicist will solve this from the viewpoint of Torque (Moment of Force) and Principle of Virtual Work.

Theoretical physicist will note that the more accurately - the more "exactly" - you measure the position of the object, the less certain you are of the velocity.  And if the velocity can be a significant fraction of lightspeed, then the mass is also indeterminate.  So "exactly" locating any object makes any measurement of its mass (or weight, in a gravitational field) hopeless.    S.

To be more helpful (what, me?) I think you're overcomplicating this.  Sensor S2 is redundant with weight on the scale.  The logic therefore simplifies to:

IF (No weight on scale)

THEN no truck.  Teatime.

IF (Weight on scale AND S1 blocked)

THEN Truck must move forwards

IF (Weight on scale AND S3 blocked)

THEN Truck must move backwards

IF (Weight on scale AND S1 clear AND S3 clear)

THEN Weigh truck

All other cases are illegal (Joe's playing with the sensors again, and get that pail of sand out of here.  ).  Allow reasonable timeouts to let a truck get onto and off of the scale.  S.

PS - Now, if you want to be sure the truck is correctly balanced on the scale - that the center of mass of the truck is reasonably accurately located in the middle of the scale - you'll need a lot more sophistication.  For example, if the truck is empty, all the weight's in the engine (up front, usually).  If the truck is full of coal, the weight will be in the back - and that's very hard to determine by just looking at where the truck is on the scale.  This, I think, is what HKPhysicist was really getting at.  S.

eta:  Looking at your diagram, it seems it is supposed to be bidirectional, which will complicate the logic even further.  Each sensor will be alternately S1 or S3, depending upon which direction your truck is coming from.  Presumably the 'Display' will indicate 'Back Up', because the lights you have specified (Red or Green, meaning 'stop' or 'go' (I suppose)) have no explicit way of indicating 'Go Backwards'.  You will also want to think about the default positions - should the gates default down, to stop the truck first, or default up, to speed weigh station entry?  And let some trucks speed through before they can be weighed?  Hmm...  S.

Last Edited: Thu. Jun 2, 2022 - 09:18 PM

Scroungre wrote:

This, I think, is what HKPhysicist was really getting at.  S.

Taking HKPhysicist as a sample of one, what he's shown us is that

Physicist are out of touch with the real world around them, have no clue about the real requirements of people that routinely measure the weight of trucks, and have no clue how real truck scales work. More importantly, they have no clue what the problem is, so they go off solving a problem that doesn't need a solution.

Non-physicists don't care how real truck scales work because they understand that that is not the problem. They understand that the problem is making sure the entire truck is on the scale without either the front wheels or the back wheels being supported by dry land. Some system is required that tells the driver (from the driver's seat) if they're on the scale or not.

Conclusion:  non-physicists > physicists

(Full disclosure: I am a physicist)

Brian Fairchild wrote:

It's at this point that we really do need the OP to come back and engage with us. So many questions..........

Last Edited: Thu. Jun 2, 2022 - 10:39 PM

How to build a truck scale is a solved problem.  Everything on from that is engineering (and, hopefully, homework problems for budding engineers!).  S.

We were sitting at the light by the huge mall and a million stores and restaurants all around.  I told my wife  you know everything you see around here was brought by truck...the entire mall ...and everything in it.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Scroungre wrote:
PS - Now, if you want to be sure the truck is correctly balanced on the scale - that the center of mass of the truck is reasonably accurately located in the middle of the scale - you'll need a lot more sophistication.  For example, if the truck is empty, all the weight's in the engine (up front, usually).  If the truck is full of coal, the weight will be in the back - and that's very hard to determine by just looking at where the truck is on the scale.  This, I think, is what HKPhysicist was really getting at.  S.

As I mentioned earlier, the requirement for the truck to be centred, as opposed to merely having both wheels on the platform, is an overcomplication. Whether the scale uses one load sensor or several it doesn't matter. The weight of the truck is the sum of the weights on each of the sensors, irrespective of the position of the truck or of its centre of gravity.

If this is not the case, then this is not a software issue relating to position: the scales are broken. And given that people have been using weighbridges for approximately as long as they have been using trucks, that seems unlikely.

It can be solved visually by an external operator: are the truck wheels all on the platform.

It can be solved using two side viewing optical beam breaking detectors: weigh after the rear beam has broken but if the front beam is broken before the rear beam clears, the truck is too long.

It can be solved with *no* beam detectors: merely weigh continuously and log the highest weight observed - though this doesn't allow for a truck longer than the platform, and requires an operator (or an external sensor) to reset the weight.

It can be solved with a fore-and-aft sonar sensor: weigh when they both report the same distance, but not infinity. And hope the truck doesn't squash them on the way in or out.

It can be solved with...

Neil

avrcandies wrote:

Some might have arrived by train.  S.

barnacle wrote:

Scroungre wrote:
PS - Now, if you want to be sure the truck is correctly balanced on the scale - that the center of mass of the truck is reasonably accurately located in the middle of the scale - you'll need a lot more sophistication.  For example, if the truck is empty, all the weight's in the engine (up front, usually).  If the truck is full of coal, the weight will be in the back - and that's very hard to determine by just looking at where the truck is on the scale.  This, I think, is what HKPhysicist was really getting at.  S.

As I mentioned earlier, the requirement for the truck to be centred, as opposed to merely having both wheels on the platform, is an overcomplication. Whether the scale uses one load sensor or several it doesn't matter. The weight of the truck is the sum of the weights on each of the sensors, irrespective of the position of the truck or of its centre of gravity.

If this is not the case, then this is not a software issue relating to position: the scales are broken. And given that people have been using weighbridges for approximately as long as they have been using trucks, that seems unlikely.

Neil

Both wheels?  Many of the trucks I overtook on the I-5 the other night had more than two wheels.

Less snarkily, you are assuming that all the sensors are all perfectly straight-linear.  This is, generally, not true.  Truck scales go to some efforts to correct for this.  Presumably the OP, in the truck scale biz, knows this.  S.

Last Edited: Fri. Jun 3, 2022 - 06:55 AM

For example, let's assume a non-linear sensor.  Two of them, in fact:

That when a 10lb weight is put directly upon it, it measures 10lbs.  (I'm doing this in English units for reasons!)

And when the weight is put one foot away from it, it measures 5 lbs.

And when the weight is put two feet away from it, it measures 1 lb.

The second sensor reports the same, but is four feet away.

So if the weight is placed directly on top of either sensor, the weight is reported at 10 lbs.

If the weight is placed halfway between them, each at two feet away, the total weight is reported as 2 lbs.

This is why 'just sum the total measurements' is not a good idea.  S.

Scroungre wrote:
This is why 'just sum the total measurements' is not a good idea.  S.

Apparently this is a common problem and loads biassed toward a corner of the weighing plate must be compensated.

https://www.thames-side.com/res/Thames_Side_T34_Weighbridge_Data_Sheet.pdf

That probably means the physicists get to join in after all.

barnacle wrote:
... (or an external sensor) to reset the weight.
One loop detector is an included part of an axle weigh with optional sonic sensors for lane place (a semi-tractor operator may not appreciate rails due to possible contact to the front bumper)

Optional Peripheral Equipment | Weigh-in-Motion Highway Systems from Cardinal Scale

[top]

OFF-SCALE SENSORS

[bottom]

LOOP DETECTORS

41:40 to end of video for URL and a 1/16 scale demonstration

https://cardinalscale.com/resources/videos?page=11

SWIM Slow-Speed In-Motion Scales Training [48m49s]

"Dare to be naïve." - Buckminster Fuller

Driver is told his 5 tonnes of coal is too much so  he leaves 1 tonne in the driveway. Oh hum...

Ross McKenzie, Melbourne Australia

It is an unmanned weighbridge system that automatically detects the exact position of the vehicle on weighbridge and measures load on truck without the help of an operator.

When there is no truck on the weighbridge, the system turns on red light 1 and turns off green light 1 and gate should be close while it turns on red light 2 and turns off green light 2 and gate 2 should be close.

When the RFID reader reads the tag attached to the vehicle, the system turns off red light 1 and turns on green light 1. System also send scanned data to server

We have already discussed to detect the position of the vehicle. To measure the load on the vehicle, sensor 1 and sensor 3 should be low, while sensor 2 should be high. If the truck is not in the correct position, the system will publicly announce whether to move forward or go back .

When the truck stops at the center, the gate must be closed and the system should turns on red light 1 and turns off green light 1.so that only one truck can be parked at a time.

The vendor has already installed a weighing machine that continuously measures the load on the bridge and send data on serial port. The reading should be noted only when the truck is stoped at center.

after weighing gate 2 should be open.

This whole process should be done by the system, without operator

Well for me everything in the world looks like a vision processing problem these days so I'd use a camera and OpenCV doing something like Structure for Motion to determine exactly where in the 3D space the vehicle is.

However, if you're keeping it simple then who dictated 3 optical sensors? A bit like nyquist and sampling a wave with ADC the more sample points you have the more accurate idea you get of exactly what is positioned where.

As this is presumably a one off rather than something you are building 50,000 examples of then whether you pay \$3 for three \$1 sensors or \$10 for 10 of them hardly really matters does it?