Mini Bowling Alley ...
 
Notifications
Clear all

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

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

@robo-pi

My apologies, I shot the pistol before taking it out of the holster! Engage brain before making comment (rhetorical).

On afterthought, sensors to determine if each moving part has returned to its rest position would make a lot of sense!


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

This would be the ideal situation for using Hall Effect sensors.

But before we redesign this from the ground up, I think we should get the as-built up and running, and assume that the mechanical parts are not going to jam during the process.


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

@pugwash

I did some research myself and now understand how they move in both directions.  Its all in the numbers passed to the method.  I also finally saw the pattern of the numbers used to move from one end of a motor's travel to the other end.  It is rather simple now that I understand it, and it is all handled by the library files.

I don't know about anyone else, but I seem to learn at least one thing everyday on this forum, and on many days many things! ? 

SteveG


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

@pugwash @Robo-pi

I want to first a foremost say thank you!  I am and will continue learn thank you for the the tutorial links!!!

I appreciate you looking at my code and workinging with it.  I know it is not elegant in any way but it was seeming to be working!  I am going to need a little bit of time to try to digest all of what you guys have suggested in here!

About the comments... I will make sure the I am more direct and clear as well as  explanitory in the future!!!  Looks like everything that has been commented is exactly right!

Engineering... As far as a limit switch... I am willing to add them!  You are absolutely right there should probably be a fail safe in place as far a some sort of built in feed back!

would you be able to give me some direction as to the actual physical component so that I could obtain and install them?

I really appreciate all of your help and guidance... please understand I am not trying to be a leach! I am trying to learn!  Sometimes if one doesn't just try something and throw themselves into some they may never try something new!!!

Thank you again,

 

Jason


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

@codecage

so my use of Microseconds isn't totally dumb?


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 

Also : one thing I don't find optimal is the huge amont+length of delays during a single turn of the void loop()

It effectively prevents the "reading" of events outside of the specific "time slot" when they are expected in the sketch, it makes debouncing difficult, and it makes nearly impossible any kind of "emergency stop" feature (apart from using an interrupt and adding lots of guarding conditions everywhere).

 

But as @pugwash said this goes into the direction of totally restructuring the sketch, so it would be for a future refactoring.

Eric


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

Also : one thing I don't find optimal is the huge amont+length of delays during a single turn of the void loop()

Hello thank you too for your help...

Please for give my ignorance if I may not understand...

I originally put in any and all delays for the purpose of travel time for the servo.  Not saying you haven't but if you watch the embeded video I put in the thread... sadly the servos I am using are not really the fastest things.

I did go with the servos/drive mechanisms for the purpose of not having to build the same mechanism my self which I was going to do until I found them... if I could have not spent $90 a piece on them I wish I didn't... lol. Secondly the person building the rest of the set did not originally understand the physical I needed more room to build something like this and he gave all of 6" by 12" to work with.... final convinced him to give me a little more room back there... anyway here we are...

 


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

@dundervetter

NOT AT ALL!

It was my lack of understanding of the what the numbers were that you were using and how you obtained them, coupled with not knowing exactly how multi-turn servos work that lead to my questions.  Now that I have gained a little more knowledge about those servos and the Adafruit library in general, I can see how my questions may have seemed silly to you.

The program code "pwm.writeMicroseconds(num, value)" is a call to a method in the Adafruit library for the PCA9685 driver to move a servo motor connected to one of the 16 ports designated by the 'num' variable to some arbitrary position of its travel represented by the 'value' variable.  And I now understand that you derived the numbers you are using for these values by watching the travel of your servos while reading the values for their positions from the display on the HJ controllers.  Do I have that correct now?  ? 

You have done an amazing job with this Jason, and I'm convinced you'll soon have it in working order.  And as has already been stated, let's getting it working in it's present form before making any design improvements.

SteveG


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

This would be the ideal situation for using Hall Effect sensors.

Yes that would be a good limit sensor to use.   Although in this case simple mechanical limit switches would probably be just as easy to implement.

Posted by: @pugwash

But before we redesign this from the ground up, I think we should get the as-built up and running, and assume that the mechanical parts are not going to jam during the process.

Agreed.  It certainly won't hurt to run it through its paces as-is.   The position sensors would be added safety.  They would also do away with need for all the delay statements.   Although the sensor limit statements would replace them.  So it would actually be more code, but a better final result.

Posted by: @codecage

I don't know about anyone else, but I seem to learn at least one thing everyday on this forum, and on many days many things! ? 

Me too.  This forum has been a gold mine.  Thank  you Bill @dronebot-workship for creating this playground for us to all exchange our knowledge.   It's been a fantastic resource so far and will only continue to improve. 

Posted by: @zeferby

I'm wondering if this code should be implemented as a finite state machine ?

I'll copy the code to study it.

It certainly could be.  There are many different ways to approach this algorithm.   I would be interested to see how  you would code this as a state machine.  I'm sure it can be done.  It wouldn't hurt to post that approach here anyway.  It would be another option that we could all learn from. ? 

DroneBot Workshop Robotics Engineer
James


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

@dundervetter

would you be able to give me some direction as to the actual physical component so that I could obtain and install them?

Just Google Hall Effect sensors, and you will need some small magnets! Plenty of explanation online, in fact, I remember that Bill did a video on these!

Just like @Zeferby, I avoid delay() like the plague but as your code is more or less linear, apart from blocking interrupts it should work fine. If we can get it to work as is, will be the first step, adding bells and whistles will definitely be the next stage.


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

@pugwash

I was thinking Hall Effect sensors as well.  Great Minds!  ? 

SteveG


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

@codecage

Wasn't it, fools never differ! ? 


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

@codecage

Posted by: @codecage

nd I now understand that you derived the numbers you are using for these values by watching the travel of your servos while reading the values for their positions from the display on the HJ controllers.  Do I have that correct now?  ? 

Yep that is what I did.

Posted by: @codecage

The program code "pwm.writeMicroseconds(num, value)" is a call to a method in the Adafruit library for the PCA9685 driver to move a servo motor connected to one of the 16 ports designated by the 'num' variable to some arbitrary position of its travel represented by the 'value' variable.  And I now understand that you derived the numbers you are using for these values by wat

So what was frustrating originally was the PCA9685... because the PCA9685 is the actually "object" so you have to address each pin by their actual PIN number to get the servos to work independently of each other.

I will also wait to redesign... but let's say I am willing if it is in the best of the project.


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 

Eric


   
ReplyQuote
(@zeferby)
Member
Joined: 5 years ago
Posts: 355
 
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...

Eric


   
ReplyQuote
Page 3 / 12