LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with Arrays

I'm a high-school student working on a project. My teacher just introduced Arrays to us and im having a hard time implementing it into our already finished vending machine program. Any specific way to go on about this?

0 Kudos
Message 1 of 4
(2,298 Views)

Your code does not contain any arrays, and it is not clear where the "arrays" should be used. Do you have a more specific description of what should be done?

 

(Still as a first step get rid of all these local variables and connect your terminals to the code instead. Did the teacher really tell you do do it as you currently do? Very bad form! Also try to use regular primitives instead of formula nodes. Did you notice that your loop spins millions of times per second consuming all CPU of one core? Unless you expect to insert millions of coins per second, slow it down!)

0 Kudos
Message 2 of 4
(2,293 Views)
  • Create an array control of  of coins
  • Multiply it with an array constant of values
  • take the array sum to calculate the total amount inserted
  • Create an array of products
  • multiply it with an array constant of prices
  • take the array sum to get the total cost
  • replace the formula nodes with real LabVIEW code
  • connect everything to the indicators
  • slow down the loop
  • The products should be integers. You cannot e.g. purchase 0.4 candy bars.
0 Kudos
Message 3 of 4
(2,278 Views)

Here's a quick draft how you could use integer arrays (but you need to implement it yourself!). If you can't find certain tools, ask your teacher for help. 😄

 

Of course there could be mistakes (unintentional or intentional :o), so verify correct operation under all conditions. Make sure to limit the inputs to non-negative integers in the control properties or somebody could make a lot of change by entering -1000 candy bars. Don't use an unsigned datatype or the subtraction might give you interesting results 😄

 

Use the array legends for the array element descriptions and make sure to format the output to two decimal digits padded with zeroes. Left aligned indicators and controls look better.

 

HalloweenCandyMachine.png

 

Be prepared to explain the purpose of every single item on the diagram or front panel to your teacher. What it does, why it is needed, what would happen if it is removed, what would be an equivalent replacement, etc.

 

0 Kudos
Message 4 of 4
(2,236 Views)