Go to Post Its great for us as mentors to see students teaching other students and a robot being built from scratch without us. Maybe someday they won't need us at all!!! - DR3381 [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-21-2015, 04:23 PM
Bpk9p4's Avatar
Bpk9p4 Bpk9p4 is offline
Registered User
FRC #1756
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Illinios
Posts: 271
Bpk9p4 is on a distinguished road
Summer Labview Challenge 2

The challenge is to create a change machine

Part 1
You have an item that cost X and you are given X amount of money. The program will need to give back the correct amount and least amount of dollars and coins

Example: You have a basketball that cost $10.23 and they give you $20. You will need to give them back 1 five dollar bill, 4 one dollar bills, 3 quarts, 2 pennies

Inputs:
1) Cost of Item
2) Amount Paid
Outputs:
1) Number of $20
2) Number of $10
3) Number of $5
4) Number of $1
5) Number of Quarters
6) Number of Dimes
7) Number of Nickels
8) Number of Pennies

Part 2:
Same as above but you only have a limited number of each denomination however you still need to give the correct amount of change. If you cannot give back the correct amount you will need to give a fault and notify the clerk

Example: You have a basketball that cost $10.23 and they give you $20. However you only have 2 quarters. You will need to give them back 1 five dollar bill, 4 one dollar bills, 2 quarts, 2 dimes, 1 nickel and 2 pennies

Inputs:
1) Cost of Item
2) Amount Paid
3) Amount of $20
4) Amount of $10
5) Amount of $5
6) Amount of $1
7) Amount of Quarters
8) Amount of Dimes
9) Amount of Nickels
10) Amount of Pennies

Outputs:
1) Number of $20
2) Number of $10
3) Number of $5
4) Number of $1
5) Number of Quarters
6) Number of Dimes
7) Number of Nickels
8) Number of Pennies
9) Cannot give back the correct change

If you have any questions please feel free to ask them and post your result on here. Thanks
__________________
2015 Midwest Regional Finalist
2015 Central Illinois Regional Winner
2015 Newton Division Finalist
2015 Newton Quality Award
Reply With Quote
  #2   Spotlight this post!  
Unread 07-21-2015, 07:32 PM
Owen Busler's Avatar
Owen Busler Owen Busler is offline
Build Captain
FRC #0303 (Test Team)
Team Role: Leadership
 
Join Date: Aug 2014
Rookie Year: 2014
Location: Bridgewater, NJ
Posts: 131
Owen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant futureOwen Busler has a brilliant future
Re: Summer Labview Challenge 2

This is my solution to part 1... Im not so sure how to handle part 2.

http://postimg.org/image/nkqro4gxd/
__________________
2016: Deans List Semi-Finalist/MAR Mount Olive District Engineering Inspiration Award/Buckeye Regional Second Alliance Captain/MAR Montgomery District Event Imagery Award/MAR Championship Gracious Professionalism Award
2015: MAR Mount Olive District Chairman's Award/MAR North Brunswick District Winners/MAR Championship Finalists
2014: MAR Clifton District Chairman's Award/MAR Championship Regional Chairman's Award
Reply With Quote
  #3   Spotlight this post!  
Unread 07-21-2015, 09:19 PM
Ari423's Avatar
Ari423 Ari423 is online now
LabVIEW aficionado and robot addict
AKA: The guy with the yellow hat
FRC #5987 (Galaxia)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2012
Location: Haifa, Israel
Posts: 518
Ari423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant future
Re: Summer Labview Challenge 2

Quote:
Originally Posted by Bpk9p4 View Post
The challenge is to create a change machine

Part 1
You have an item that cost X and you are given X amount of money. The program will need to give back the correct amount and least amount of dollars and coins...
Here's my submission for Part 1. I converted the change to an integer to ensure nothing less than 1c and to get rid of floating point errors. This was the simplest solution I could come up with, but I'm interested in seeing if anyone can one-up me

Click image for larger version

Name:	Change Machine p1.png
Views:	48
Size:	23.7 KB
ID:	19224

Part 2 coming soon...
__________________
2017-present: Mentor FRC 5987
2017-present: CSA for FIRST in Israel
2012-2016: Member FRC 423
2013: Programmer
2014: Head Programmer, Wiring
2015: Head Programmer, Wiring
2016: Captain, Head Programmer, Wiring, Manipulator, Chassis, CAD, Business, Outreach (basically everything)



Last edited by Ari423 : 07-21-2015 at 10:12 PM.
Reply With Quote
  #4   Spotlight this post!  
Unread 07-23-2015, 02:49 PM
Bpk9p4's Avatar
Bpk9p4 Bpk9p4 is offline
Registered User
FRC #1756
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Illinios
Posts: 271
Bpk9p4 is on a distinguished road
Re: Summer Labview Challenge 2

nice work. I look forward to seeing your answer to part 2
__________________
2015 Midwest Regional Finalist
2015 Central Illinois Regional Winner
2015 Newton Division Finalist
2015 Newton Quality Award
Reply With Quote
  #5   Spotlight this post!  
Unread 07-23-2015, 05:03 PM
Jonathan L. Jonathan L. is offline
Registered User
FRC #1094
 
Join Date: Jan 2013
Location: St. Louis MO
Posts: 60
Jonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the rough
Re: Summer Labview Challenge 2

Here is part 1.

I came across a strange LabVIEW bug while I was doing this. If you remove the "Workaround" code and put in the basketball example you will see it outputs only one penny.

Part 2 coming soon.
Attached Thumbnails
Click image for larger version

Name:	Summer LabVIEW Challenge 2 Part 1.png
Views:	38
Size:	52.8 KB
ID:	19225  
Reply With Quote
  #6   Spotlight this post!  
Unread 07-23-2015, 05:25 PM
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 156
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Summer Labview Challenge 2

This is my solution to both parts
Attached Thumbnails
Click image for larger version

Name:	Change Solution.PNG
Views:	30
Size:	18.8 KB
ID:	19226  
__________________
2016-2017 - Programming Mentor
Curie Sub-Division Champions with 694, 379 & 1511
2015 - Team Captain & Head of Programming Crew
Carson Sub-Division Champions with 1325, 20 & 1711
First ever Israeli team on Einstein
2014 - Team Captain & Head of Programming Crew
2013 - Head of Programming Crew
2012 - Member of Programming Crew

Last edited by GuyM142 : 07-23-2015 at 06:02 PM.
Reply With Quote
  #7   Spotlight this post!  
Unread 07-23-2015, 08:16 PM
Ari423's Avatar
Ari423 Ari423 is online now
LabVIEW aficionado and robot addict
AKA: The guy with the yellow hat
FRC #5987 (Galaxia)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2012
Location: Haifa, Israel
Posts: 518
Ari423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant future
Re: Summer Labview Challenge 2

Here is my submission to part II. It's similar to part I, except each time it adds how much of that type it's missing back into 'the pot'. At the end, I added a feature that calls the vi from part I to see what the minimum amount of extra change would be needed to make change correctly (the input wire is "paid" and "price" is left at the default of 0). I only had a brief chance to test the program, but I believe it works. If anyone finds a problem with it, please let me know.

Click image for larger version

Name:	Change Machine p2.png
Views:	18
Size:	86.0 KB
ID:	19227
__________________
2017-present: Mentor FRC 5987
2017-present: CSA for FIRST in Israel
2012-2016: Member FRC 423
2013: Programmer
2014: Head Programmer, Wiring
2015: Head Programmer, Wiring
2016: Captain, Head Programmer, Wiring, Manipulator, Chassis, CAD, Business, Outreach (basically everything)


Reply With Quote
  #8   Spotlight this post!  
Unread 07-23-2015, 10:38 PM
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Summer Labview Challenge 2

The strange bug happens because by the time you have made it to the penny calculation, the remainder is no longer a full two cents. If you display it with about 15 digits of precision, it is truly just a bit below, so the node returns almost a full penny as a remainder. This is largely due to the fact that floats cannot store base ten fractions precisely. The mixup rounds the value so that the small cumulative error resets. A different fixup would be to convert the initial value to units of pennies instead of dollars.

Greg McKaskle
Reply With Quote
  #9   Spotlight this post!  
Unread 07-24-2015, 10:42 PM
Jonathan L. Jonathan L. is offline
Registered User
FRC #1094
 
Join Date: Jan 2013
Location: St. Louis MO
Posts: 60
Jonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the rough
Re: Summer Labview Challenge 2

Here's Part 2.

Quote:
Originally Posted by Greg McKaskle View Post
The strange bug happens because by the time you have made it to the penny calculation, the remainder is no longer a full two cents. If you display it with about 15 digits of precision, it is truly just a bit below, so the node returns almost a full penny as a remainder. This is largely due to the fact that floats cannot store base ten fractions precisely. The mixup rounds the value so that the small cumulative error resets. A different fixup would be to convert the initial value to units of pennies instead of dollars.

Greg McKaskle
Thank you for explaining. So is this something that can be fixed by NI or just a quark in programming? I remember there was something similar last year with the equal function but that seems to have been fixed.
Attached Thumbnails
Click image for larger version

Name:	Summer LabVIEW Challenge 2 Part 2.png
Views:	10
Size:	56.9 KB
ID:	19228  
Reply With Quote
  #10   Spotlight this post!  
Unread 07-24-2015, 11:07 PM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,702
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Summer Labview Challenge 2

Quote:
Originally Posted by Jonathan L. View Post
Thank you for explaining. So is this something that can be fixed by NI or just a quark in programming?
That's due to how computer hardware in general works.
Part of programming is understanding the underlying computer implementation, and this is just one of the quirks or limitations.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
Reply With Quote
  #11   Spotlight this post!  
Unread 07-24-2015, 11:24 PM
Ari423's Avatar
Ari423 Ari423 is online now
LabVIEW aficionado and robot addict
AKA: The guy with the yellow hat
FRC #5987 (Galaxia)
Team Role: Mentor
 
Join Date: Mar 2015
Rookie Year: 2012
Location: Haifa, Israel
Posts: 518
Ari423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant futureAri423 has a brilliant future
Re: Summer Labview Challenge 2

Quote:
Originally Posted by Mark McLeod View Post
That's due to how computer hardware in general works.
Part of programming is understanding the underlying computer implementation, and this is just one of the quirks or limitations.
It is a limitation in the imementation of floating point numbers (like doubles or singles). If you convert the dollars to cents by multiplying by 100 and then cast that as an integer, the problem will go away because integers do not have that problem.
__________________
2017-present: Mentor FRC 5987
2017-present: CSA for FIRST in Israel
2012-2016: Member FRC 423
2013: Programmer
2014: Head Programmer, Wiring
2015: Head Programmer, Wiring
2016: Captain, Head Programmer, Wiring, Manipulator, Chassis, CAD, Business, Outreach (basically everything)


Reply With Quote
  #12   Spotlight this post!  
Unread 07-25-2015, 08:47 AM
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,702
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Summer Labview Challenge 2

Take a look at the Wikipedia article on floating point representation for a description of the issue we face:
https://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion _and_rounding

Quote:
For example, the decimal number 0.1 is not representable in binary floating-point of any finite precision; the exact binary representation would have a "1100" sequence continuing endlessly: e = −4; s = 1100110011001100110011001100110011...,

When rounded to 24 bits this becomes
e = −4; s = 110011001100110011001101,
which is actually 0.100000001490116119384765625 in decimal.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 07-25-2015 at 10:13 AM.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 06:07 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi