Results 1 to 7 of 7

Thread: Need a little vb programming help please...

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Need a little vb programming help please...

    I'm building a 30' long racetrack (dragstrip) for children to have fun with at charity events we do in our area. In the past, I've used a PLC to control the track and turn LED's on for the fastest times. However, I would now like to add a computer display where they could see their actual times and the corresponding miles per hour (mph) for each lane as well. The track has four lanes which will send out a simple closed circuit (relay) when the car passes the photosensor. This then feeds into a laptop where I have a timing program partially completed in vb that displays the times in a simple ListBox. I found code to do this and the timer works fine.

    The problem is that I have no idea how to convert these times into mph using vb code. I know that I will enter (only once) the distance that they have traveled by each time displayed in the ListBox and that should give me the mph for each of four blocks labeled First, Second, Third and Fouth. The distance will be determined so so that it makes the children feel good about how fast their car was going, i.e., I want it to look like they are traveling 200-300 mph. I cannot tell you what the distance number will be yet in that this track is not finished yet and I will have to run some cars on it before deciding what number to use.

    I have tried for days to read documents available and/or find an example that would help me complete the code but have yet found the answer. I would really appreciate it if someone out there who knows vb could help me complete the code. I'm 70 and on a fixed income, but I am willing to pay for some help if it doesn't take too long.

    So here is what I still need. The program starts when the starting gate drops and sends a command to the program which is the same as entering the enter key on the keyboard. I do this by sending a closed circuit to the computer telling it that the "enter" button has been pushed. This starts the clock running and works fine. Now in order for the enter key to be used for displaying the times, you have to push the "Tab" key on the keyboard (or use the mouse which I do not want to do) to highlight the "Lap" button in the program. Now, as the cars pass the finish line, each lane basically sends a closed circuit or "enter" command to the computer which in turn logs the four times. This also works fine. The problem is how to write the code to calculate the mph (the distance determined by me as a fixed number / elapsed time) and display it in each of the four boxes listed under mph. So there are two things I still need. 1) How to code it so that it will jump from the Start button to the Lap button after it is given the start command, and 2) how to take each time and divide it into the fixed (and yet to be determined) distance I choose to calculate the mph and display the numbers in the four boxes.

    The timing program display looks like this...

    Name:  Ashampoo_Snap_Monday, October 26, 2020_20h36m28s_001_.jpg
Views: 219
Size:  43.0 KB

    The code so far looks like this...

    I've got to find the code and put it into a pdf file before the time runs out on this section. Will post it within
    the next few minutes...

  2. #2

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little vb programming help please...

    Here is the code...

    myStopwatch (2).zip

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Need a little vb programming help please...

    Do you want help, or pay someone to finish it off for you? You've posted in "Open Jobs (Positions)" ... which is usually where people looking to HIRE other programmers post. If the former, then this needs to be moved to the appropriate forums for the language.
    Also when posting code, don't post it as an attachment... post the code and put code tags around it... but don't post the WHOLE project either... just the parts relevant.

    As for the first problem... depending on the language (I can't see the attachment w/o navigating away from this page and losing this post - this is why we ask code be posted into the post) but it could be as simple as xxxx.select ... where xxxx is the name of the button you want to have focus. Just put it at the end of the code in the click event of the previous button.

    Speed - you want real speed or scaled speed? They require two slightly different calculations. If raw speed is what you want, then it's as simple as distance divided by time... you have the distance in feet, you have the speed... so it's easy to get the feet/sec speed... to get the mph, you divide the feet by the feet in a mile, and divide the seconds by 60 now you have distance in miless, and speed in minutes... it's still dist/time...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Junior Member wossy's Avatar
    Join Date
    Aug 2020
    Posts
    26

    Re: Need a little vb programming help please...

    I suspect he wants Terminal Velocity at the end of the track, rather than average speed for the run.

    Sadly, accurate T.V. is not knowable given the setup as described. In real life they use two beam-break sensors close together at the finish line to determine the final speed of the car.
    T.V. can be estimated of course for gravity based (Pinewood Derby) style events because it's roughly deterministic for any given car. For electric slot-car systems T.V. is not calculable at all because the driver may take his finger off the gas part-way through the run, so a single beam-break sensor is not going to help you.

    Unless you're happy with an average speed for the entire run, in which case you're ok to simply do something like multiply the final s=d/t speed by some factor (15 seems to work for me) to convert model speed to real-world dragster speed.

    Your mileage may very (pun definitely intended).
    On the bright side, I've still got pessimism and despair to fall back on.

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little vb programming help please...

    [QUOTE=techgnome;5498071]Do you want help, or pay someone to finish it off for you? You've posted in "Open Jobs (Positions)" ... which is usually where people looking to HIRE other programmers post. If the former, then this needs to be moved to the appropriate forums for the language.
    Also when posting code, don't post it as an attachment... post the code and put code tags around it... but don't post the WHOLE project either... just the parts relevant.

    As for the first problem... depending on the language (I can't see the attachment w/o navigating away from this page and losing this post - this is why we ask code be posted into the post) but it could be as simple as xxxx.select ... where xxxx is the name of the button you want to have focus. Just put it at the end of the code in the click event of the previous button.

    Speed - you want real speed or scaled speed? They require two slightly different calculations. If raw speed is what you want, then it's as simple as distance divided by time... you have the distance in feet, you have the speed... so it's easy to get the feet/sec speed... to get the mph, you divide the feet by the feet in a mile, and divide the seconds by 60 now you have distance in miless, and speed in minutes... it's still dist/time...

    **********************************************************************************

    OK, I am looking for someone to complete the code for me. I simply cannot do so without spending many more hours of research. The existing code, some of which I did write using other examples, does work but I need to complete it as stated in my first post here. Not to make it sound hard, but I simply have not been able to grasp the code for vb. I would think, based on the simplistic and limited code it took to get to this point, that it would possibly take 10-15 minutes. Anyone who is interested in completing it for me for $20 will be paid by PayPal if you accept that method, otherwise I can send a check, money order, etc.. The existing code is:

    1 Public Class Form1
    2 Private stopwatch As New Diagnostics.Stopwatch
    3 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    4 Me.CenterToScreen()
    5 Button3.Enabled = False
    6 End Sub
    7
    8 Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    9 Dim elapsed As TimeSpan = stopwatch.Elapsed
    10 CircularProgressBar1.Text = String.Format("{1:00}:{2:00}",
    11 Math.Floor(elapsed.TotalHours),
    12 elapsed.Minutes, elapsed.Seconds)
    13 Label1.Text = elapsed.Milliseconds
    14 CircularProgressBar1.Value = elapsed.Seconds
    15 If elapsed.Seconds = 0 Then
    16 CircularProgressBar1.Value = 60
    17 End If
    18 End Sub
    19
    20 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    21 If Button1.Text = "Start" Then
    22 Timer1.Start()
    23 stopwatch.Start()
    24 Button3.Enabled = False
    25 Button1.Text = "Stop"
    26 Else
    27 Timer1.Stop()
    28 stopwatch.Stop()
    29 Button3.Enabled = True
    30 Button1.Text = "Start"
    31 End If
    32 End Sub
    33
    34 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    35 ListBox1.Items.Add(ListBox1.Items.Count + 1 & ". " & CircularProgressBar1.Text & ":" &
    Label1.Text)
    36 End Sub
    37
    38 Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    39 stopwatch.Reset()
    40 ListBox1.Items.Clear()
    41 CircularProgressBar1.Text = "00:00:00"
    42 Label1.Text = "000"
    43 End Sub
    44
    45 End Class

    I would greatly appreciate anyone who might be able to help...

    Thank you,

    Gail
    Last edited by drluv; Oct 27th, 2020 at 02:14 PM.

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little vb programming help please...

    As for speed, I'm simply wanting to display a perceived mph. I would use some fixed number such as 500 for distance and divide it by the seconds displayed in the Listbox and make it come out somewhere around 200 to 300 mph. The number used will be based on how fast the track actually turns out to be. The children have no idea other than they can brag that they had a speed of 254.356 mph when they crossed the line (I made that number up by the way) . I appreciate everyone's input, now to find someone who can complete the code...

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2020
    Posts
    7

    Re: Need a little vb programming help please...

    Thank you everyone. I received a private message along with updated code that works flawlessly.

    Gail

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width