Visual Basic 6 - Simulation


CNC Router
CNC Links

3D DLP Printer
UM2+ Dual






VB6 - 3D
VB6 - Simulation
VB6 - Games
VB6 - Other
VB6 - Outsourcing


Valide CSS!
For a long time, I'm very interested into software simulations. So I tried some small projects over the years:
  • Heating & Conduction
  • Massa Spring System
  • Falling ball
  • Car springs

The mass-spring system, described in the above sample, has an rigid connection to the 'fixed' world. It's also possible to drop a ball from some height and let it bounce backwards. If we assume that the kinetic energy will be constant during bouncing and there is only some air friction, the model is easy to create, see picture on the right.

A simple classic Mass-Spring (Damping) system, see picture on the right:
  • Spring (green part)
  • Fixed world (celling) (black)
  • Some kind of mass (red)
    After a lifted mass is released, it will drop down, because of the gravity working on this object. The speed of the mass will increase, this is called the inertia. While the mass is moving downwards, it will stretch the spring more and more, which will create a 'counter' force. This counter force is slowing down the mass till it stands still. Now the stretched spring, is still under tension and it will move up the mass and increases its speed. This time the gravity force is slowing down the mass. Because there is also some air friction and some energy losses for elastically deform the spring, the total movement will be dampened out. Now the main question, how can you simulate such a thing?
    • First determine the sum of all forces acting on the mass. [Ftot]
    • Then calculate the acceleration of the mass [a]
    • Now the new speed is known [v]
    • Now the new position is also known [x]
    • Because of the new position, the spring length is changed, so the [Ftot] needs to be re-calculated and here you have the simulation.
    Ftot = Fspring - Fgravity - Fdamper
    Fspring = elongation * spring-constant
    Fgravity = 9.81 * mass
    Fdamper = ABS(speed) * damper-constant
    a = Ftot / mass
    v = v_old + a * dt
    x = x_old + v * dt
    dt = a constant time step, expl: 0.01 sec.
    By recalculating these basic algorithm each step (=dt), the new position of the system could be calculated. The main assumption in this algorithm, is within the time step (dt), everything should be constant, which is not really the case. Also within a time step, there is some acceleration. One way of making the analyses better, is do decrease the time step, which will take more calculation time. Another way, is to have the actual speed calculated as function of the damper. To be continued...

  • At collage we had a project of thermodynamics. We had to calculate the heat transfer and conduction through an -optional twice- isolated pressure barrel. The inner air of the barrel was heated up by an electric heater. The heat transfer and conduction had to be calculated, and graphs of temperature, air pressure and heat transfers had to be plotted or optional saved in a file.
    Why not programming a small Visual Basic program instead of making an difficult slow excel sheet of about 100 pages and more!!
    Because there are a lot of different variables to fill in, a lot of tests could be done. The main conclusion of the tests: one isolation foil (just 0.001 mm thick!!) is enough to isolate the barrel. (A test barrel was built in an earlier year, but unfortunately there were now real tests done.)