Notifications
Clear all

Questions about changing to array from buttons

111 Posts
5 Users
6 Likes
11.1 K Views
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @gam

I found more groups for that and everyone talks about how much easier it is. 

I have found that the programming effort required, for the sort of programs one does for microcontrollers,  theres really not much difference between python and arduino c++  once one has the basics of the languages mastered.  Its not usually necessary get into advanced or expert programming for activating some relays or reading some sensors.  

The main difference to my mind is that I find it easier to read and follow the python code when one comes back to what one has written some months / years back and the code one produces is less verbose.  I also find I enjoy programming in python much more.  I may, one evening when I don't find something interesting on the box, and as an exercise for myself, take half an hour to write your 'gam circular blast gate program' in python and put it up for you to see.

I'm not aware of any python compilers that convert the code to c++, but you can write routines or bits of your program in c or c++ and then use them within your python code.   Python is implemented in c  for CPython or c++ for IronPython.  Most python interpreters are implemented in CPython. (or at least the ones I use on my Mac, Windows or Rpi computers are CPython based)  Python is also implemented in python (PyPy) but I guess to write it in python they had to have a python implemented in CPython to start with 🤫).   Micropython is written in c and was written from scratch again to implement the python language for microcontrollers.   Its quite usual to call c routines from ones python code.  I recently used a library written in c++ for a display that was written by Pimoroni (the purveyors of the display screen) that they made callable from micropython.  

I do find that when my programs get larger and I'm producing GUI's and accessing databases such as mySQL then the programming effort swings much in favour of python, and even more so if one it trying to do multi-threaded or multi-processor programming and all that sort of advanced stuff where python can make it relatively easy to accomplish.

Good to hear your program is maturing nicely.  A satisfying project I think. 👍 


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

@gam

So flaps are more likely to trap debris. A well designed gate would self clean when the vacuum is on. If you are only ever going to have one tool on at a time I can see the utility in your disc arrangement although I didn't think expensive motors would be required to open and close a gate only extra control wires to your controller.

It doesn't matter if your unit of measure is in the distance travelled in stepper steps or degrees. Ultimately the degrees have to be rounded up and converted to a number of stepper steps.

If you are using a Raspberry Pi it is a no brainer to use Python. Advanced programmers can use just about any language but most electronic projects that use the RPi are written in Python. It is unlikely your project will need speeding up with a Python to C++ conversion and I would a worry about that then. Either way you need to be able to program in Python simply because most RPi projects are written using that language.

 

 


   
GAM reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 

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

@byron  

Posted by: @byron

kinetic type of switch

 I could actually recognize and follow the code you wrote,   I was surprise how short the code in the loop was.

Never knew of the kinetic switch. Would need to be attached to the tool some how?  I wonder if a motion sensor (of some type) would work. Rereading you post, why it was important that receiver needs to be low voltage?

As a side thought, I think I forgot you were from England till you used the term muck around 🧐 


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

@gam

 ... I was surprised how short the code in the loop was.

The more code in the main loop (a function) that is farmed out to other functions the shorter the code. And the more code in the other functions that are in turn farmed out to simpler functions the shorter they are as well. Each standing alone as easy to understand functions that perform some simple but meaningful task.

I like code to read as close to a human language as possible.
if VacPin.value == 0 then VacPin.value = 1
becomes,
if VaccuumPumpIsOff() then turnVacuumPumpOn()

I might have written my main Arduino version like this:

 

void loop(){

    if (aToolIsOn()) { // then
        if (toolAngle() != discAngle()) { // then
            turnOffVac();
            rotateDiscAngleToToolAngle();
        }
        turnOnVac();
    }
    else
    {
        turnOffVac();
    }
}

Another difference in my code is I use a generic function that given ANY two angles in a circle it will compute the steps to move from one angle to the next and the shortest direction to take.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @gam

Rereading you post, why it was important that receiver needs to be low voltage?

Only to keep as much as I can away from mains voltages.  I would site the buttons either near the on/off switch (with a blob or glue or tape) or at a convenient place near a work area such as my festool multifunction workbench where I swap various tools.  (this workbench is on a dust collector shared with a chop saw and trimming table saw, wheres other machinery is connected to a larger chip collector vac) .  

I'm thinking the buttons would just be to signal a control processor that ensures the correct blast gate is open, and others shut, before vac switch-on, and it would be easier to convert the receiving relay voltage to be at a level that could be used on GPIO pins of the processor.   I would also choose low voltage motors to operate the blast gates. 

And as I write I get another thought.  Perhaps I should have a blast gate that does not connect to anything but can be open as the default, and then the vac could be immediately switched on while this non connected gate is shutting and the correct gate for the tool is opening.  Something I will ponder on.

On the subject of kinetic or battery switches I may be swayed to battery ones that can last for a year or two having looked at these two youtube videos

And, as I see you are on the programming learning path, I do much agree with the suggestion of @robotbuilder that one of the main thoughts as you review your code should be how easy is it to understand when you come back to it in the months to come.   What can seem as an unnecessary over winded use of variable names or splitting code into various functions will not seem excessive when coming back to your code again to include yet another blast gate and hole in you gate selector disk. (DAMHIKT 😎)


   
GAM reacted
ReplyQuote
Page 8 / 8