Notifications
Clear all

Questions about changing to array from buttons

111 Posts
5 Users
6 Likes
11.3 K Views
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@gam

Perhaps do a flow chart?

The question IS_ANY_TOOL_ON becomes a call to a subroutine checkSensor() that returns a number. If that number is -1 then no tool is on otherwise the number is the number of the tool that is on and the position the disc has to be at. It is the number that is used to answer the next question IS_DISC_AT_TOOL_POSITION coded as does the number of the sensor = the number of the disc position?

and so on ...

The blue boxes are ACTIONS. This is code to move the disc to some position or turn the pump on or off.

Programming is converting steps you could do yourself written in a way the computer can execute.

To enlarge image right mouse click and choose Open link in new window.

flowChart

 

 


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

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

   
MadMisha reacted
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 

You could do:

 

bool IS_ANY_TOOL_ON(){
  for (int i = 0; i < numberTools; i++) {
    if (analogRead(toolSens[i]) > threshold[i]){
        return TRUE;
    }
  }
  return FALSE;
}

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

@robotbuilder Like the flow chart I probably should have started that way!

Thanks

 


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

@madmisha  Just read through this (for the first time) and need to check it out!  Again looks like you did a lot of work and I hope you weren't up at 3:41 AM like to post said.  I will copy this to Pro and work with it. from what I read I have a better understanding now.

Thanks 

Greg 


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

@yurkshirelad  Thanks for the reply I will check it out!

Greg


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

   
ReplyQuote
(@yurkshirelad)
Member
Joined: 3 years ago
Posts: 493
 
Posted by: @gam

@yurkshirelad  Thanks for the reply I will check it out!

Greg

I thought I would post an optimisation to that code fragment, nothing more. 🙂


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

@robotbuilder  Like this as well.  All of you have given so much help!  I need to sit with all this and work on it.   Hope some day I can show a completed project!

Thanks to all

Greg


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

   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
 

I love the form and function that @robotbuilder posted but I would be against the use of the bool function for determining if a tool is on. I don't think if a tool is on is as useful as what tool is on. But you can easily take this and merge it with what I posted. Also, naming is great, although I would stick to the recommended formatting. I really need to be better at sticking to naming conventions at all times. It's a must when I use Kotlin so I don't know why I drop it when I do simple things like this.

 

@gam Check everything I posted. I think I wrote that in about 20-30 minutes and most of that time I was complaining about the IDE faults. I often make mistakes and omit even the most obvious of things on quick projects.


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

@gam

Reading all your posts again I see you have a relay for each vac motor. For some reason I thought there was only be one vac motor and the rotating disc was used to attach each tool dust outlet to some common pipe to the dust collector? If there is a vac motor for each tool can't they all feed into the same dust bin? Each outlet would only need a one way flap.

To enlarge click right mouse button and select open link in new window.

dustCollection

 


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

@madmisha

I don't think if a tool is on is as useful as what tool is on.

The code has both.
ANY_TOOL_ON()
TOOL_NUMBER()
It has to do with readability.
Also there was the issue of more than one tool being used at the same time.

Anyway I have completely misunderstood the physical layout and am confused as to the use of the DISC. Probably because the original code only referenced one vac motor.
const int vacPin = 4; //to led to simulate Vacuum relay

2666 image

 


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

@robotbuilder, @madmisha,

I do have 3 vacuum motors at this time just to increase the volume of vacuum. They are running on 1 relay at this point and that is fine. When working on the design (and had 3 motors) it crossed my mind that there may be times on smaller applications with more restrictive hose nozzles that less vacuum is needed and could in fact put some strain on the motors as it would be like a particle blockage.  That's the only reason I had the extra relays in place, if I decided to include (Code) number of motors for specific tools.   Currently the motors are plugged into a strip with individual on/off switches that I can manage it with.

vac assy2
vac assy1

You might notice the ultrasonic sensor in the same picture.  That to is for the future so I can detect how full the sawdust container is with out taking it apart to check.  That might be easier to just do separate project project at that time. 

Recently read an article about Hilego HC-05  BT module that as I understand it will show information to phones/tablets, which I have a number of outdated ones lying around. Might make a good monitor display for the system.

First thing first,  need to work on what you given me.  


   
ReplyQuote
Page 3 / 8