Notifications
Clear all

Questions about changing to array from buttons

111 Posts
5 Users
6 Likes
11.4 K Views
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

   
ReplyQuote
 GAM
(@gam)
Member
Joined: 3 years ago
Posts: 58
Topic starter  

@robotbuilder 

My response was to the quote below.

Posted by: @robotbuilder

If you only use one tool at a time then why not just have a flap at each location that you can open and close manually and a button at each location to turn the vacuum pump on or off?

Your correct about the gate needs to be aligned first.  From what I'm seeing the stepper gets there quickly.  Of course it just moving a pointer now and not a disc, which while well balanced will have much more mass. That being said most tool have a on/off switch that's turn on first and then you use both hands to push or move the wood through the tool, eg Table Saw, Plainer, Joiner, drill press. So there is time for things to happen. The Miter Saw would be an exception as it has a trigger that needs to be depressed during the cut. In that case you could hold it on for a sec before cutting. Or you could give the trigger a quick pull that would move the gate.  The Miter Saw is one you might make multiple cuts at in quick session, but after the first use the gate would already be aligned. 

I'm sure once in use there will be some "I never thought about that"   


   
ReplyQuote
 GAM
(@gam)
Member
Joined: 3 years ago
Posts: 58
Topic starter  

@byron,   This is interesting and I'm glad you used some of the same terms.  I can follow it pretty well. I do have some question I will ask later.  No time now,  Good to see a different way!


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

@gam

and another solution - no programming required 😀, but I thought it was a neat solution and one I could see myself putting into my shop.  

 


   
ReplyQuote
 GAM
(@gam)
Member
Joined: 3 years ago
Posts: 58
Topic starter  

@byron  He did a great job on that!  I hope he didn't have to make very many.  


   
ReplyQuote
 GAM
(@gam)
Member
Joined: 3 years ago
Posts: 58
Topic starter  

@robotbuilder  Wow! lot of work you did.  First off , send me anything you want, I don't understand some, but learn with everything. Other than that, I'm not sure the Question this is under is valid anymore?  Not knowing the forums ins and outs would someone else be able to find this and benefit? 

Questions

  • what are the different cases for? I think those are stepper inputs
  • Have you tried pushing more than 1 button at a time.  Discovered that mine only ignores the 2nd button if the degrees > the 1st.  If the 2nd button is < the 1st it tries to move to 2nd position till button is released?

I think the only part of the library I using is for the nonblocking delay timer.

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 
Posted by: @gam

@robotbuilder  Wow! lot of work you did. 

I like solving programming problems.  Of course liking something doesn't mean you are any good at it 🙂

I noticed you can step your stepper motor using a stepPin to your expansion board that drives the MKS stepper. I don't have such a board so it is a bit more complicated in my case. All you have to do in your code is set the direction pin and then turn the step pin on and off to step the motor, no library required. I am using this Arduino compatible 5volt stepper motor and controller.

stepperAndController

I now know from Bill's tutorial on steppers how to use #include <Stepper.h> to set the speed and number of steps for this controller which will dramatically reduce the size of the code required to move the stepper motor as any complexity will be hidden in the header file.

No I haven't tried pushing more than one button but looking at the code it is going to return the button with the largest tool Number. That would be like turning two tools on at once.

I have just spotted a flaw in the main loop. I forgot to check if na==ca. Because my "vacuum pump" is just a LED I couldn't spot the problem when I ran the code.

The idea is to allocate code out to functions so the main loop is simply a description of the process which, if you choose the function names wisely, can read like a human language. The labels are said to be self commenting.

 


   
GAM reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@gam

This is how I would modify the getToolNumber() function.  Instead of returning an angle from the ACS712 current sensors it would simply return the tool number from which the angle or step value could be computed.

 

int GET_TOOL_NUMBER(){
  int toolNumber;
    toolNumber = -1;
    if (analogRead(A0) > 600) toolNumber = 0;
    if (analogRead(A1) > 600) toolNumber = 1;
    if (analogRead(A2) > 600) toolNumber = 5;
    if (analogRead(A3) > 600) toolNumber = 6;
    return toolNumber;
}

 


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

@robotbuilder

It seems there are three things that are synonymous - tool number / analogue pin / angle (and possibly a 4th the port number).  I'd have to ponder about how to link all three but for 2 a dictionary could be used.

std::map<char, int> PinAngle = {
    { 'A0', 0 },
    { 'A1', 45 },
    { 'A2', 255 }
etc };

In the refactored code I produce for @gam it would have been helpful if I had stored which analogue pin for the current angle (or tool) being used was to more easily code to monitor if said pin was over 600 or had gone low.  It would  also make it easy to check the value again the delay period and before the vacuum is switch off.  What do you think?

@gam following the post on the neat blast gates operated by wire I'm now thinking, for my shop at least, it would be simpler just to find a solution to electronically operate my existing blast gates.  On youtube there are a number of examples of using motors and even air lines to move the normal manually operated gates by doing some cleaver alterations.   I could then also easily operate the gates manually if desired.  

And a final though, as the likes of an ESP8266 are as cheap as chips (or the ESP32 - but priced as a bag of chips)  one could have a 'local to the tool'  button/sensor/esp8266 that could communicate via wifi or bluetooth to the blast gate controller, or to the patented gam circular gate selector. 😎  

 

 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@byron

What do you think?

My programming skill set is very limited. Programming was an occasional hobby. I am entirely self taught.  I haven't learned to use the advanced features of c++.  I don't even bother with writing classes (although with the C++ compilers I use classes).  Programming is just an occasional hobby started a long time ago when I was teaching myself basic electronics.  On the old machines (TRS-80, C64, Amiga) my language of choice was Assembler code because it was fast, simple to understand and you could directly access the hardware.  With MSDOS I took up using TurboC++.  The developmental environments for using C++ are now very complex and I don't have the time or brains to learn it all.  I now prefer to program in the BASIC language which I also used on the old machines. Arduino C++ is easy to use.

Although I see in the introductions many members boasting their experience and expertise in programming and/or electronics I don't see them helping others.  This is not uncommon on forums.  Experts talk to experts. Those of us on the lower rungs talk to others on the lower rungs.

Gam's project isn't exactly rocket science in terms of software and hardware but I found it interesting as a problem to solve.

 


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 
Posted by: @robotbuilder

Those of us on the lower rungs talk to others on the lower rungs.

Count me in on the lower rungs 😀.  I did program in C way back when (early 80's) but then I got proficient enough in Visual Basic (VB6) with SQLServer to be a contract programmer for a few years (early 90's I think) before going on to other things and I ceased to earn a living as a programmer.  When I retired I got a Raspberry Pi and learned a bit of python.  I found it rather fun.  The rpi gave me an intro into electronics and then to getting an arduino and getting up to speed on Arduino programming.  (sadly I've a long way to go with electronics and need to do much more to get to even a basic level)

On getting the arduino I did follow some on-line courses in C++ but I've not used it in earnest.  I find I'm most comfortable in python and love its lists, tuples and dictionary concepts, and the ease of using classes, creating multi-threading and multi-procssesor programs, I could go on but nuff said.  I'm not so hot on the C++ equivalents to things like pythons dictionary lists, so I was struggling a bit on the use of maps.  

As I see you quite like a problem to solve I've a feeling you would quite like python and would soon get comfortable with it.  No denying some effort to get to grips with python would be required, but not so much a man of your calibre would find it too daunting.  I found learning python to be much more pleasant than C++.  I think Python would have the advantage over Basic in being available on most platforms, though not arduino, and Im under the impression that Basic is not well supported any more (but I have not done any research, and I do miss good old VB6 for the shear ease of getting a good GUI up and running).

The arduino has a huge number of code examples and libraries which is a huge help in getting going with it, though with the advent of micropython that will run on ESP8266, ESP32, the new rpi2040 and others, and also CircuitPython runs on a bunch of boards I think the micropython ecosystem will soon be it equal.  

Arduino programming is easy enough to learn, but you've conquered it.  I recommend an rpi 2040 board, An hour or two per evening every other day getting up to speed with python and give it a month and you may even be uninstalling your Basic programming tools 😎.


   
ReplyQuote
 GAM
(@gam)
Member
Joined: 3 years ago
Posts: 58
Topic starter  

@byron @robotbuilder  Love your drawings,  and that is correct on the flaps,  most people use a sliding type because it will sort of clean it self. when that flap closes their maybe  debris under it that might prevent a good seal. again you would need a separate motor or some drive device at gate. 

Yes there are many ways to drive the gate,  The servo has been used,  pneumatic air cylinders, (compressor),  and I have seen and tried electric door lock for cars,  they where quick, cheap and strong. All have advantages and draw backs, 

As for using the Degree as opposed to using a math solution (gate number * number of steps.  I did my best to make those ports at the correct place but if they are not perfect changing the degrees for a particular gate would be easy.   


   
ReplyQuote
 GAM
(@gam)
Member
Joined: 3 years ago
Posts: 58
Topic starter  

@byron @robotbuilder

Posted by: @byron

ESP8266 are as cheap as chips (or the ESP32 -

I have been interested in these boards and have thought the same thing. Not ready to jump ship yet but would like to pick some up to play with. 

On the Python subject,  I found more groups for that and everyone talks about how much easier it is.  It think there are compilers? that will convert it back to C++ if needed. 

Have written the homing sketch for my project and tested it.  Now need to merge it with the other sketch.   


   
ReplyQuote
Page 7 / 8