[VicPiMakers Projects] Challenge 2: final results C++ program

James Briante briantej at gmail.com
Sun Nov 15 15:43:38 EST 2020


Hi Mark,



Again, congratulations for completing challenge2 and thanks for sharing in
your approach using PointPlotter in C++ code just to get practise in
Classes. The attachments are impressive.

Along the same lines, I’m using both *C programming* (in a tiny $6.00
development board) and *Pascal*, the programming language of Delphi, to
solve challenges before posting. This has helped in  getting the cobwebs
out and in learning something new. So, from that perspective one of the
objectives of proposing “challenges” has been achieved.


George, thanks for your comment. I tend to agree with you that Challenge 2
gives the impression (possible poor presentation) that it involves CNC. In
reality  CNC is not required to solve Challenge 2. It’s all beautiful
coding. However, for output #10/11 it does require solving a “quadratic
equation” which may bring fond memories of grade 11 math or maybe not. In
programming it’s difficult to avoid using mathematics to solve real
problems. Look at Deid’s ultrasonic project. Part of his project required
the measurement of time of a reflected sound wave to reach the point of
origin. An equation relating time to the speed of sound at room temperature.


For those of you who are stuck on output#10, see attachment. If you are
edging in getting started, the coding for challenge 2 will flow more
quickly than it did in challenge 1. Straight few lines of code for most of
the outputs.

Happy Coding,

Jim

On Sun, Nov 15, 2020 at 11:12 AM Mark G. <vpm at palaceofretention.ca> wrote:

> Thanks Jim.
>
> I rechecked my formulas and found an errant factor
> of 2 in my calculation of the a value (not acceleration)
> for the ax^2 + bx + c equation.
>
> Re-running:
>
> $ echo  33009 9002 11 | ../bin/cnc
> Input:
> RegP: 33009      bits: 1000000011110001
> RegM: 9002       bits: 0010001100101010
> RegS: 11         bits: 00001011
> Output #1: 241   (position)      bits: 11110001
> Output #2: 35    (velocity)      bits: 00100011
> Output #3: 2     (accel.)        bits: 00000010
> Output #4: 10    (time)          bits: 00001010
>
> Error status:
> Position error.
> Velocity ok.
> Acceleration error.
> Time error.
>
> Error corrected:
> Output #5: 240   (position)      bits: 11110000
> Output #6: 35    (velocity)      bits: 00100011
> Output #7: 10    (accel.)        bits: 00001010
> Output #8: 9     (time)          bits: 00001001
>
> Error status:
> Position ok.
> Velocity ok.
> Acceleration ok.
> Time ok.
>
> Output #9:
>   Travel time t: 6.93 (s)
>   final velocity v: 69.28 (cm/sec)
>
> Output #10:
>   Testung t1 solution 1: 5.68 (s)
>   Invalid t2 with t1 solution 1: -2.36
>   trying t1 solution 2: 1.32 (s)
>   Valid t2 with t1 solution 2: 6.36 (s)
>
>   Solution t1: 1.32 (s)
>   Solution t2: 6.36 (s)
>
> Output #11:
> Solutions involving a negative amount for t2 are not
> physically possible without time travel.
>
> ===========
>
> I wrote the program in C++, using a class named PointPlotter
> and a main program, just to get practice using classes in
> C++.
>
> Mark
>
>
>
> On 2020-11-15 12:25 a.m., James Briante wrote:
> > Hi Mark,
> >
> > Congratulations for 100% on Challenge 2 (Bonus helped!)
> >
> > I’ve used your times for (t_1 , t_2 ) to compute total distance covered.
> >
> > P = 2p_1  +  p_2
> >
> >     = at_1 ^2 + vt_2 , using your values gives
> >
> >     = 10(1.17)^2 + 35(6.66)
> >
> >     = 246.789, past desired position (p =240)
> >
> > Check your solution to the quadratic equation.
> >
> > Jim
> >
> >
> >
> > On Sat, Nov 14, 2020 at 9:29 PM Mark G. <vpm at palaceofretention.ca
> > <mailto:vpm at palaceofretention.ca>> wrote:
> >
> >     Hi Jim,
> >
> >     Thanks for the corrections.  Here are my updated results
> >     with some trial solutions for outputs 9 and 10.
> >     I differ in output 10.
> >
> >     $ echo  33009 9002 11 | ../bin/cnc
> >     Input:
> >     RegP: 33009      bits: 1000000011110001
> >     RegM: 9002       bits: 0010001100101010
> >     RegS: 11         bits: 00001011
> >     Output #1: 241   (position)      bits: 11110001
> >     Output #2: 35    (velocity)      bits: 00100011
> >     Output #3: 2     (accel.)        bits: 00000010
> >     Output #4: 10    (time)          bits: 00001010
> >
> >     Error status:
> >     Position error.
> >     Velocity ok.
> >     Acceleration error.
> >     Time error.
> >
> >     Error corrected:
> >     Output #5: 240   (position)      bits: 11110000
> >     Output #6: 35    (velocity)      bits: 00100011
> >     Output #7: 10    (accel.)        bits: 00001010
> >     Output #8: 9     (time)          bits: 00001001
> >
> >     Error status:
> >     Position ok.
> >     Velocity ok.
> >     Acceleration ok.
> >     Time ok.
> >
> >     Output #9:
> >        Travel time t: 6.93 (s)
> >        final velocity v: 69.28 (cm/sec)
> >
> >     Output #10:
> >        Testung t1 solution 1: 12.83 (s)
> >        Invalid t2 with t1 solution 1: -16.66
> >        trying t1 solution 2: 1.17 (s)
> >        Valid t2 with t1 solution 2: 6.66 (s)
> >
> >        Solution t1: 1.17 (s)
> >        Solution t2: 6.66 (s)
> >
> >     Output #11:
> >     Solutions involving a negative amount for t2 are not
> >     physically possible without time travel.
> >
> >
> >
> >     On 2020-11-12 8:00 p.m., James Briante wrote:
> >      >
> >      >
> >      > Mark -a big thanks for pointing out the errors! v & t in the
> >      > Callenge2.pdf are typing errors. I should have included the actual
> >      > output screen (see attachment) with the other files. I've blacked
> >     out
> >      > the answer to Output #11.
> >      >
> >      > Things have been quiet on project talk re: challenge 2. Could
> these
> >      > errors be the reason?
> >      >
> >      > I don't have a read on what I should do for output #10. Should I
> >     provide
> >      > the solution to the quadratic equation?
> >      >
> >      > Jim
> >      >
> >      >
> >      > On Wed, Nov 11, 2020 at 5:09 PM Mark G. <vpm at palaceofretention.ca
> >     <mailto:vpm at palaceofretention.ca>
> >      > <mailto:vpm at palaceofretention.ca
> >     <mailto:vpm at palaceofretention.ca>>> wrote:
> >      >
> >      >     Hi Jim,
> >      >
> >      >     I've completed up-to output #8 of the challenge and have
> >      >     some discrepancies with your challenge specification.
> >      >     Specifically, velocity/acceleration error switch, differing
> >      >     values for uncorrected time (t) and velocity (v).
> >      >
> >      >     Your values:
> >      >     Input Data: 33009,9002,11 (initial values - RegP, RegM, RegS)
> >      >     Output #1: 241 (value of p, transferred from RegP)
> >      >     Output #2: 186 (value of v, transferred from RegM)
> >      >     Output #3: 10 (value of a, transferred from RegM)
> >      >     Output #4: 220 (value of t, transferred RegM)
> >      >
> >
>  --------------------------------------------------------------------------------
> >      >
> >      >     Output # 5 to #8 – values of p, v, a, and t with corrections
> >      >
> >
>  --------------------------------------------------------------------------------
> >      >
> >      >     Output #5: 240 (p)
> >      >     Output #6: 35 (v)
> >      >     Output #7: 10 (a)
> >      >     Output #8: 9 (t)
> >      >
> >      >     My values:
> >      >
> >      >     $ echo  33009 9002 11 | ../bin/cnc
> >      >     Input:
> >      >     RegP: 33009      bits: 1000000011110001
> >      >     RegM: 9002       bits: 0010001100101010
> >      >     RegS: 11         bits: 00001011
> >      >     Output #1: 241   (position)      bits: 11110001
> >      >     Output #2: 35    (velocity)      bits: 00100011
> >      >     Output #3: 2     (accel.)        bits: 00000010
> >      >     Output #4: 10    (time)          bits: 00001010
> >      >     Position error.
> >      >     Velocity ok.
> >      >     Acceleration error.
> >      >     Time error.
> >      >     Error corrected:
> >      >     Output #5: 240   (position)      bits: 11110000
> >      >     Output #6: 35    (velocity)      bits: 00100011
> >      >     Output #7: 10    (accel.)        bits: 00001010
> >      >     Output #8: 9     (time)          bits: 00001001
> >      >     Position ok.
> >      >     Velocity ok.
> >      >     Acceleration ok.
> >      >     Time ok.
> >      >
> >      >     What do you think?
> >      >
> >      >     Mark
> >      >
> >      >     --
> >      >     Projects mailing list
> >      > Projects at vicpimakers.ca <mailto:Projects at vicpimakers.ca>
> >     <mailto:Projects at vicpimakers.ca <mailto:Projects at vicpimakers.ca>>
> >      > http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >      >
> >      >
> >
> >     --
> >     Projects mailing list
> >     Projects at vicpimakers.ca <mailto:Projects at vicpimakers.ca>
> >     http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >
> >
> --
> Projects mailing list
> Projects at vicpimakers.ca
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vicpimakers.ca/pipermail/projects_vicpimakers.ca/attachments/20201115/59c60583/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Solution of profile.pdf
Type: application/pdf
Size: 99320 bytes
Desc: not available
URL: <http://vicpimakers.ca/pipermail/projects_vicpimakers.ca/attachments/20201115/59c60583/attachment.pdf>


More information about the Projects mailing list