Mini Bowling Alley ...
 
Notifications
Clear all

Mini Bowling Alley Pin Setter coding project In need of tutoring...

169 Posts
7 Users
4 Likes
39.5 K Views
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@dundervetter

No, it hasn't gone out!


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 
Posted by: @zeferby
Posted by: @robo-pi

I would be interested to see how  you would code this as a state machine.

I'll try to find some time for this.  Only issue is not being able to test without the proper hardware...

From what I have seen on YouTube so far it appears that all that is being done is that systems are designed from the vantage point of a Finite State Machine and then just being translated into Arduino C++ code using Switch/Case routines.

This would probably be most helpful for people who are used to using Finite State Machine flow charts to create their algorithms.   Then they know what code needs to be used in the Switch/Case routines.

Other than this I don't see any actual advantage to using this method.  However, it would be a HUGE advantage for someone who has already learned the Finite State Machine method of creating the original algorithm.   Translating their algorithem over to C++ (or any other computer language) then becomes a piece of cake.

This isn't meant to belittle the method.  In fact, I'm really glad that you mentioned it.  THANK YOU!

I may actually start using the FSM method of laying out my algorithms more often.  In fact, I'm working on a program right now that trains perceptrons.  I'm struggling with laying out the algorithmic flowchart.  I may very well turn to using the FSM approach.  That's a very good method for creating algorithms.  In fact, I use FSM a lot when working with FPGAs and CPDLs.  I just never thought of using FSM to create C++ code.

It's funny how a person can be armed with all the parts but not realize how they can be used together in very productive ways.   So thanks for posting the idea.  I'm going to see if I can apply it to my perceptron training algorithm right now. ? 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

Somebody switched it off, no idea who!


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@pugwash

something new to learn about more later

 


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@pugwash

I did try but forgot to put my name in... so maybe me


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

@dundervetter

You only need to click the switch, as I haven't got any other pins set up!

This is really childish and fun ? 


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

Off!


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@pugwash

? nice


   
Pugwash reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
 

@dundervetter

I was going to suggest moving stuff out of the loop into functions and a few other suggestions to make it more readable but getting it working first would be the first step.  So does the code you have work?  It is impossible for me to test anything I write because I don't have a PCA9685 or those particular servo motors to play with.

My impression was that you could move the motors a fixed amount with the writeMicroseconds() method in which case I see no reason for a limit switch.  Indeed that is the whole point of a servo motor,  the ability to move it to some position determined by the control signal.  So for example can you move the sweeper to ANY position using the writeMicrosecond() method?  In your application such fine positioning isn't required so ordinary motors with limit switches would have sufficed.

So is your next task some mechanism to load the swept away pins back into the pin setter?


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@casey

I know parts of this worked originally when updated the code.  However, since some of this awesome dialogue has continued I have not been able to do anything to day since I am here a work now.  So honestly, I won't be able to physically do anything until possibly later tonight since I have dinner plans tonight.  So if not late tonight then it won't be until after 12 pm US EST (noon) tomorrow. 

So currently try to take in as much as I can until such I can test.  Once I do, you guys will be the first to know!

I will try to show a video via YouTube again and to upload via an embed code as to not eat up a whole lot of storage in this forum.


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  
Posted by: @casey

So is your next task some mechanism to load the swept away pins back into the pin setter?

at this point no... rephrase H*** NO... lol. I have done enough damage for now...

Maybe in the future, but for now I have no requirements to reload other than by hand at the top of the sequence of each sequence.


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 
Posted by: @robo-pi

From what I have seen on YouTube so far it appears that all that is being done is that systems are designed from the vantage point of a Finite State Machine and then just being translated into Arduino C++ code using Switch/Case routines.

Yes, FSMs are not the one and only, nor mandatorily the best way, to model a system.  But I find it often helps "thinking FSM" when you have a number of different inputs and several output to manage : it incites you to separate concerns, and produce more stable "building blocks".

Also when it comes to coding with the endless void loop() paradigm, I usually end up with that kind of split which I rather like :

void loop()
{
//0-static local variables defined here when we don't use globals
//A-Acquire Inputs : volatile variables set by Interrupt Service Routines, input pins, known states
//B-Transitionning logic : "compute" what transitions have to take place given the above
//C-Execute transitions : "compute" new states, start timers, triggers, etc
//D-Apply States : check timer limits, set outputs, and (only when required) do state-specific subsets of A, B, C
}

With a bunch of specialised routines called from these blocks.

The choice between 100% of A, B, C in their own blocks in loop(), or separate state-specific subsets of them into some D routines is mostly based on the "cost" in milliseconds for the acquisition for some slow inputs, especially when we only care about them within the context of a specific state.

This is all a high-level theoretical view of what I consider rather easily understandable code, and of course I often derogate and mess the "clean code" with quick & dirty code warts all around the place ! ? 

Eric


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1053
 
Posted by: @dundervetter

I will try to show a video via YouTube again and to upload via an embed code as to not eat up a whole lot of storage in this forum.

@dundervetter

All you need to do is put the YouTube video share link in the forum and it will automatically embed the video, no need to put in the embed code.

And I do appreciate your concern regarding the forum storage, although at the moment we have plenty of it.

?

BTW, this looks like a fascinating thread, I'll have to look it over.  

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
Dundervetter
(@dundervetter)
Member
Joined: 4 years ago
Posts: 75
Topic starter  

@dronebot-workshop

Thank you!  You have an awesome forum and all of them members have been great!  I am learning and still have so much more to learn!

Jason


   
ReplyQuote
codecage
(@codecage)
Member Admin
Joined: 5 years ago
Posts: 1018
 

@dundervetter

Are we having fun yet?

When I was about 10 or 11 years old, I was living on an Air Force Base in England where my dad was stationed and I would go down to the base bowling alley and the guys that worked in the back that reset the pins would let me work there for short periods of time.  Back then, or at least in that bowling alley, every thing was manual, from lowering the rail that protected you from being clobbered by a ball when you climbed into the 'pit' to putting the ball on the return chute.  This included me being the sweeper to remove the fallen pins and placing them in the pin setter while being sure not to disturb any standing pins.  And those 16 pound balls were pretty heavy for a little skinny kid to lift and get up on the chute that rolled them back to the front of the lane.  Then when the frame finished clearing all the pins, lowering the pin setter (at least we didn't have to manually do that!) and releasing the pins and raising the pin setter.  And then being sure to raise the rail after climbing out of the pit.  I know I forgot on at least one occasion and the bowler did notice it had not been raised.  Boy did that create a stir.  But I was told I wasn't the only one who had ever done that.

Quite a dangerous job too if you failed to lower that rail.  I'm sure OSHA would have had a field day with those guys if it had been around in those days!

SteveG


   
ReplyQuote
Page 6 / 12