Workshop blast gate...
 
Notifications
Clear all

Workshop blast gate automation

85 Posts
6 Users
47 Reactions
4,710 Views
AndyD
(@andydowns)
Member
Joined: 9 months ago
Posts: 79
Topic starter  

@davee No need for any apologies at all.

I'm starting to scratch the surface of the complexity of using modules that various companies have created using the manufacturers IC's. The chances of me understanding enough to do the detective work is pretty much zero, so I will have to go with leaving the unused pins alone unless I encounter problems. Then I'll be back with more questions. 😁

It may not be exactly ideal, but this is just a home project that I can use to further my understanding of everything involved in it.

I have already learnt much and will continue. 

So don't apologise and please keep providing the benefits of your knowledge. I won't get all of it, I probably won't follow everything you suggest, but I will learn from it. Who knows, I might even someday be able to help others in a limited way.

👍

Well, that could’ve gone better 😬


   
DaveE reacted
ReplyQuote
AndyD
(@andydowns)
Member
Joined: 9 months ago
Posts: 79
Topic starter  

@davee 

Posted by: @davee

The fact that +5V and +3.3V outputs must come from different pins is an obvious 'evidence' that they are likely to benefit with pairing with discrete ground pins, but generally the model to consider, is a little more subtle.

.......

So one way would be for each circuit section having its own gnd route/track back to the power source. Or another way might be to have progressively wider tracks the closer the gnd gets to the source. 
I know this is also a simplification but I think is in part the essence of what you've said. I will think about this some more and try to apply it to my circuit.

This post was modified 8 months ago by AndyD

Well, that could’ve gone better 😬


   
ReplyQuote
AndyD
(@andydowns)
Member
Joined: 9 months ago
Posts: 79
Topic starter  

@davee 

Posted by: @davee

I see many decisions in engineering to be a bit like deciding whether to take out insurance. A house or car insurance policy is offered on the 'hopeful' basis of the insurer, that the total of premiums charged, will exceed the cost of the claims. Simplistically, most car drivers pay for each year's insurance, but do not claim, because they haven't caused an accident. However, even if someone has been driving for 20 years without causing an accident, that does not mean they will not cause one in the coming year. Similarly, even if you have never seen a logic circuit with an unconnected input give a problem, it doesn't mean it never happens.

You are, of course, at liberty to conclude that the consequences of it happening, in your particular case, are insignificant, and hence will accept the risk. However, I hope my efforts have explained the nature of the risk, and that you are making an informed decision. That is part of the basis of engineering, which I think applies to hobbyists and professionals alike.

 

I have an understanding of the consequences from my last job as a project manager at Eaton. The team was multi-disciplined and designed products for hazardous areas; mainly gas analysers.

We went through many iterations, each time either improving product quality, manufacturing processes and cost or customer experience.

Through that, I still have the desire to at least consider all possible options, but will now scale them down to 'fit-for-purpose' for my needs. I have no intention of taking this any further than my workshop, but would like to do the best I can whist learning.

My process will be:

Build each circuit section on breadboard and write software so I can 'mess' about with it.

Build as much as possible of the whole design on a breadboard to make sure it all works together.

Update the schematic for the whole design.

Write software to allow multiple modules to work together

Build a veroboard version from the schematic to make sure I interpreted it correctly.

Test software with the veroboard version.

Get boards made and hope for the best.

Whatever happens in the end - it's already been a blast. 😁

This post was modified 8 months ago by AndyD

Well, that could’ve gone better 😬


   
DaveE reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi @andydowns,

Re So one way would be for each circuit section having its own gnd route/track back to the power source. 

In essence, yes. Obviously, it depends on identifying the circuit sections correctly.

Of course, all of the ground wires must be connected together. It is often a good idea for them to meet at just one place, called a star point earth point. 

There are many discussions on the internet, describing the principle.

e.g. https://resources.altium.com/p/using-pcb-star-grounding-can-keep-your-design-shining

Bear in mind, that this article is by a PCB design company, and hence discusses a star point in PCB design. However, the technique predates printed circuit board technology, previously being used in circuits using valves (tubes) and tagboard wiring. As your circuit includes multiple PCB boards, it possible that the identified point is not on a PCB. Use your imagination!

Best wishes, Dave


   
AndyD reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi @andydowns,

 re: One thing that is becoming clear is that the datasheets are generally for the chip itself and what I am going to be using for the most part are a third party boards with the chips on them. I notice on the datasheet that there is a scattering of other components around the device which are probably/hopefully included on the board, but you would have to reverse engineer it to be sure.  .....

I agree with your whole summary ... for 'brevity', I only included a snip as a reference point.

Estimating how much power a circuit will demand, before actually building it, is often more of an intelligent guess than a precise calculation. Circuits based on computer processors are especially tricky, because their power consumption is often highly dependent upon the software. The ESP range also provide WiFi/Bluetooth transmitters, which have significant current transient demands, that are obviously dependent on the network traffic.

Sometimes, the chip data sheets will give a useful starting point. In the case of the logic power requirements for A4988, I assumed that most of the current demand would be for the logic part of the chip itself, as first glance suggested the other surrounding components would be unlikely to increase it by much.

Obviously, if the question had referred to the 12V supply to the chip, which is used to power the windings on the motor, a completely different, and rather more complex estimation method would have been required.

In summary, when building a new circuit, start with a 'best guess', but ensure the initial commissioning power supply(ies) have plenty of spare power capacity. As the development proceeds, you will be able to do some measurements, and may decide a reduced specification will be adequate for the 'production' models.

---------

When using the small, very low cost boards on Amazon, AliExpress, etc., it is not unusual for the 'headline' specification to be exaggerated, or only true under certain conditions. You may find reviews on YouTube, etc. that suggest that some of these boards are actually excellent value and function, providing you do not push them to anywhere near their limits. e.g. a "4 Amp" output, may be fine up to 1 Amp, ok up to 2 Amp, but in virtual meltdown at 3-4 Amp. This may not be an issue with your present project, but I hope you will continue to do other projects in the future, and this may become more relevant. 

A personal empirical observation, albeit not one that I could prove on a sound statistical basis, is that units with  power supplies with plenty of spare capacity, are typically more reliable and less prone to computer crashes, etc. than those operating near their limits.

Hope this helps to set the context. Best wishes, Dave


   
AndyD reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi @andydowns,

Re: In the 80C32 development I did years ago, one of the other engineer's wrote a debounce routine in assembler. ...

Once again, for brevity, I have only copied a snip as a reference to whole message ... I'll attempt to address the whole message, plus briefly refer to the pair of messages between you and Ron (@zander), discussing debounce chips.

-------------------

In most cases, it should not be necessary to have both software and hardware debounce. There are probably exceptions I haven't considered, but I would start with one, and only move to both when you discover the exception that eludes my ageing grey cell at the moment.

When designing a new board, I would also look to hardware, albeit often just an extra capacitor. Although finding the right value of capacitor for a new design, may include a little experimental trial and error, it is unlikely to require a precision component, and it will save dealing with any complications that may appear when implementing in software.

Clearly, software adds no weight or recurrent cost to the board, so that in a high production quantity market, that is extremely price and/or weight sensitive, a software solution may be preferred. This is not typically the case for hobbyists, although someone building a very small drone might take the opposite opinion.

I am also confident that software solutions have been added as a late 'bug fix' in production designs, with poor hardware design practice. Hence, Ron (@zander) may be correct when he suggests "For quick small non-permanent projects software is used more than 99.999% of the time.", albeit in some cases, maybe 'non-permanent' became 'permanent', if it was sufficiently effective, to save embarrassment and extra costs.

I note there has been some discussion about using special chips for debounce. I have never spotted such a chip in any commercial (or homebrew) product. Perhaps they have a market niche I haven't explored, but I am sceptical that you need them for this project, wondering if they are a solution looking for a problem.

Similarly, I have seen articles on the web using extra resistors, etc, instead of the simple RC circuit I have described. Whilst I do not dispute the validity of these articles, I have never seen them on a commercial circuit either.

Presently, I am only visualising simple, mechanically robust switches, that can easily handle discharging a small capacitor on each operation.  If the switch becomes relatively delicate, such as a reed switch, or maybe a semiconductor switch based on Hall effect or similar, then some checks should be made to determine if the simple approach is endangering the switch reliability. If this becomes a concern, it might need an extra resistor or similar enhancement.

----------------

In summary, I would start with only hardware debounce, and include an experimental trial with a 'bargain pack' of alternate capacitors, etc. before committing to a PCB.

------------

If you get stuck at a late stage, then software may be an easier last minute fix, but initially plan for hardware only.

--------------

As for what value capacitor, then the starting point is to understand the problem, and then a very simple bit of electronics calculation.

The problem arises when the two contacts of a switch first 'touch', as they mechanically 'bounce', making and breaking the contact. The time that they continue to vibrate is often only a few milliseconds, but the faster modern processors can perform millions of instructions, in a millisecond, and even the slowest ones can process thousands of instructions in the same time, so that unless care is taken the software may react to each of several close and open operations, when only a single close was intended. 

The actual timescale of each bounce depends on the mechanical design of the switch, so experimental data is required, or at least desired.

If the switch is in a conventional circuit, such as in series with 10kOhm resistor, with the resistor connected to a 3.3V power line and the switch connected to ground, then a scope connected to resistor/switch should show a series of 'square waves' alternating between 3.3V and 0V, each time the switch is closed. Examination of this waveform will enable you to determine the maximum time between the first 'touch' and 'final' touch, when the switch stays closed.

For this discussion, let's pretend this experiment yields a 'bouncing' time of 10 milliseconds.

The principle now is to imagine a capacitor is connected across the switch contacts. When the switch is open, current will flow through the resistor (assumed to be 10 kOhms), into the capacitor, causing it to charge up. When the contacts close, the capacitor will be instantaneously discharged to zero volts.

As the resistor limits the current flow into the capacitor, it will take some time for voltage to return to 3.3V. It will do so using an exponential curve, but to keep the maths simple, just remember that the time taken for the  voltage to achieve about 63% of the maximum possible 3.3V (about 2.1V) is given by the 'Time Constant' formula

T = R * C, where T is the time in seconds, R is the resistance in Ohms, and C is the capacitance in Farads.

Also imagine the processor will regard incoming voltage of below 2.1V as low, and above 2,1V as high, so that we can use the T = R * C formula directly, plus imagine we decide we want the capacitor to be capable of holding the voltage below 2.1V for 10 milliseconds, whilst the switch is open.

Rearranging T = R * C, we get C = T / R = 0.01 (s) / 10,000 (Ohm) = 10^-6 Farad

i.e. 1 microFarad.

A few moments thought will suggest that the 'imagine' statements above, are not 'strictly accurate', but the calculation should still be useful as an 'order of magnitude' value, and hence useful as a starting point.

-------------------

Note, we can imagine that when a capacitor is 'too large', then this will create an excessive 'dead' time, when the switch is next operated to 'open', as the processor will perceive it as closed, until the capacitor has allowed the voltage to rise to the value that the processor will interpret as 'high'.

We can also imagine the effect when the capacitor is too small. Namely, the processor may see one or more of the switch bounces.

-------------------

Hence, I hope you can visualise that your scope would be useful whilst conducting the trials with different capacitors, as it will directly show the effect on the signal that the ESP32 will be interpreting. So I advise you take it out of the box and plug it in. If you have further questions on what to do next, maybe start a new dedicated thread - I predict you will not be the only one on this thread in a similar position!

Best wishes and good luck, Dave

PS - I hope I have addressed all of your previous queries, but with the thread now running to 4 substantial pages, it is likely I have missed one or more. Please feel free to post a reminder, as well as any new queries.


   
byron reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 6 years ago
Posts: 1212
 

@davee

Thanks for info on hardware debounce.  I've put a few switches on pcb's in the past and whilst aware of debouncing with a circuit I did not actually put proper consideration about doing so in my pcb designs.   What you say makes a lot of sense and I'm learning some good stuff from your excellent 'sermons'.  

Maybe I will have to think of getting an oscilloscope as I think it will help in getter a better understanding of electronics and circuit design etc.  I guess one of the 'cheaper' ones will do the job for a hobby type of use.  I'll do a but of research of the market and put one on my Christmas list 😎 


   
AndyD and DaveE reacted
ReplyQuote
AndyD
(@andydowns)
Member
Joined: 9 months ago
Posts: 79
Topic starter  

@davee 

Reverend Dave does have a nice ring to it. 😂

Another noteworthy explanation, fantastic!

I'm waiting for some membrane switches to be delivered and will wait 'til then to try all this out. I haven't driven an oscilloscope before and looking forward to learning.

I acquired it when a company was having a clear out and it's sat in my cupboard for over a year waiting for an opportunity to use it. I've just plugged it in and the lights come so that's a good start.

I've no idea how good it is, it's probably quite old. But if the number of buttons is anything to go by it should be good enough.

 

Oscilloscope

Well, that could’ve gone better 😬


   
ReplyQuote
Fvasquez1776
(@fvasquez1776)
Member
Joined: 9 months ago
Posts: 33
 

@andydowns 

    Welcome Andy.   Decent 100Mhz Hitachi o-scope.  Good luck!


   
AndyD reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi @andydowns,

   I am sure Rev is a totally inappropriate title, and I am certainly not wearing a dog collar, but confess to writing manuscripts that are longer than most speeches ever given from a pulpit, and probably more soporific as well.

-------------

A quick look at the photo shows your scope to be 'old', as you suggest, but a very respectable specification for its vintage. Furthermore, not only do the lights come on, but I can see it is 'writing' on the screen.

The one major thing that will distinguish it from newer cousins, is that it is based on a cathode ray tube. This means that a trace from a 'one-off' event will be drawn on the screen and then vanish. By comparison, the present scopes have masses of digital electronics, which convert the incoming signal into a series of digital numbers, that can be stored and displayed on the screen, indefinitely.

For a repetitive event, like a sine wave, this is not an issue, because your scope can continually redraw the trace, as the incoming sine wave input is continually refreshed as well.

But for a 'one-off' event, like a switch closing, it is more problematic.

---------------

The simplest approach is to minimise the lighting in the room, and use your eyes' persistence, and to some extent, imagination, to get a general idea as to what is happening. Hopefully, this will be enough to get started.

--

Another work around that was widely used before digital scopes were available, was a Polaroid camera, to take a picture of the trace. This involved a slightly modified camera with a lightproof seal, and appropriately focussed lens, that clipped to the front of the scope, so that the shutter could be left open for a period of several seconds, whilst the user 'triggered' the event and caused the scope to do a single trace.

In principle, you may be able to do an updated version of this, if you have a digital camera (phone?), plus some makeshift light proofing. I don't know anyone who has tried it, so I don't have any experience to relate. At least, you don't have to pay for the film, if it takes a few shots to capture each trace.

--------------------

I haven't a clue how membrane switches will behave in terms of bounce. I might guess it will depend on how hard the user presses them. If you have a spare toggle or push switch, you might try that as a learning exercise and comparison. If not, just a couple of wires being touched together.

--------------------

If you don't have a manual for your scope, you can download one for free from https://forum.allaboutcircuits.com

You have to become a member, but they only demand an email address and few very basic answers to questions, to join.

Bear in mind, at first glance, it is a photocopy of an original Hitachi manual, that is written for people familiar with scopes, but it should still be a handy reference.

--------------------

You will need some probes for the scope. Of course, you may have some, but they are usually the first items to get lost, broken or stolen.

If not, they are available from all of the usual sources, although they can be expensive. For purposes, like yours, I make do with 'cheap as I can find' probes, although they may not be quite as good as their more expensive cousins.

You should be looking for probes that are either X10 only, or switchable between X1 and X10. (X is 'times' ... a X10 probe will attenuate the signal by a factor of 10, but do a better job of capturing the voltage.)

As an example of what I would look for, I did a quick check on AliExpress and the first response was

https://www.aliexpress.com/item/1005003950007418.html

image

 which, offered a pair of probes (delivered, VAT included), for less than £6.

Note, this is not a recommendation of supplier or specific probe. I haven't used either. There may be better deals.

I am sure, probes from 'known brands' are likely to be very much higher price than this.

The choice is yours.

------------

And with that, I'll step down from my couch.

Best wishes, Dave


   
Fvasquez1776 reacted
ReplyQuote
Fvasquez1776
(@fvasquez1776)
Member
Joined: 9 months ago
Posts: 33
 

@davee

     You mean drop the mike!   LOL. 


   
DaveE reacted
ReplyQuote
AndyD
(@andydowns)
Member
Joined: 9 months ago
Posts: 79
Topic starter  

I've had a bash at looking at switch debounce and these are the initial results.

This is the simple circuit I've used as it mimics the connection in the actual circuit albeit without being connected to an actual port pin. Does that matter? 🤔

Test circuit

To get a base line, I tried two switches before the actual switch I'm interested in.
The first was a PCB mount miniature momentary switch.

Minature monentary

I tried to capture the traces as suggested by @DaveE, but couldn't seem to get a reliable trigger. All I managed to capture was either a high or a low.

Minature momentary 720p 1.1.1
Minature momentary 720p 1.1.2

Undeterred, I went on to the second switch, a limit switch.

Limit switch

This was more successful and I managed to capture something like I was expecting. Unfortunately the images are poor quality due to having to grab stills from a video taken on my Ipad, but they do get the point across.

Limit switch 720p 1.1.8
Limit switch 720p 1.1.7
Limit switch 720p 1.1.6
Limit switch 720p 1.1.4
Limit switch 720p 1.1.3
Limit switch 720p 1.1.2
Limit switch 720p 1.1.1

And finally the membrane switch I want to use on the project.

Membrane switch

The traces were much better than I was expecting, and I wonder if I need to do anything at all.

Membrane switch 1080p 1.1.3
Membrane switch 1080p 1.1.2
Membrane switch 1080p 1.1.1
Membrane switch 720p 1.1.4

In the interests of experimentation, I found a ceramic capacitor with a marking of 104 on it. It was the only one I had o gave it a try. It made quite a difference to the shape on the shift in levels and I could see the explanation that @DaveE gave in picture form.

Test circuit with cap

 

Membrane switch with 104 cap 1.1.3
Membrane switch with 104 cap 1.1.2
Membrane switch with 104 cap 1.1.1

I'm going to order some more values for experimentation.

It has shown that a digital scope needs to go on my shopping list as well. 🙂

This post was modified 8 months ago by AndyD

Well, that could’ve gone better 😬


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 8047
 

@andydowns I asked Bill and as a result I bought the RIGOL DHO802. It's only a 2 chan but it is exceedingly rare to need 4. In fact I have yet to use 2.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
AndyD reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1947
 

Hi @andydowns,

  Well done with the scope handling. In spite of the limitations, you are actually capturing the data you need. This is not a task that needs precise values, just a general insight as to whether you are in the right area, and which way to adjust something. Whilst a digital scope might be a little more convenient, it won't tell you much more for this kind of task.

So unless/until you hit a 'brick wall' and can't move on, I would save your pennies, and get some more experience. Then you will be in a better position to know what characteristics are going to be important to you, and by that time, there will probably be a new model or two, with more flashy features.

On the other hand, a couple of 'bargain packs' of different capacitors (and maybe the same for resistors)  for your 'spares' drawer, would be useful. At the least a pack of ceramics for the lower capacitance values including (say) 100pF to 1uF, and a pack of electrolytics covering something like 1uF to 1000uF, will give you a handy range to get a number of projects started with.

Of course, you won't need this many, if this is the only project you do, but assuming you will want to carry on, getting a few sample parts will make continuation much easier, and they are much cheaper and easier to buy this way.

AliExpress will probably be the cheapest. (Quality may involve a bit of luck, but usually at least good enough for a quick hack, whilst you figure out what you need.)

As examples, that were first to appear on a search, (NOT recommendations of supplier or specific parts.)

https://www.aliexpress.com/item/1005006243336676.html

https://www.aliexpress.com/item/1005007101158585.html

https://www.aliexpress.com/item/1005006186890215.html

With a bit of juggling, in UK, should get delivery in around a week, for about £13 total, including VAT and delivery.  (This is a moderately generous selection ... it could be downsized to further minimise expenditure.)

Just a suggestion.

---------------------------

As for interpretation of the traces, bear in mind that a digital input will 'divide' the voltage range between Vdd and 0V into 3 regions.

Using Vdd = 3.3V, to match the recommended voltage for ESP32, then the regions will be:

Region 1: Input voltage is in range 0 to Va : Digital input Value is 0 (low)

Region 2: Input voltage is in range Va to Vb : Digital input Value is 'confused' ... could be 0 or 1 !!!!

Region 3: Input voltage is in range Vb to 3.3V : Digital input Value is 1 (high)

Clearly, the behaviour of the device is only specified when the input voltage is in Regions 1 and 3. If it is in Region 2, when the microcontroller looks at it, it could return 0 or 1.

The actual voltages Va and Vb must be found from the data sheet, as they vary with different devices.

The ESP32 data sheet at https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf includes a table with this snip:

image

So     Va = 0.25 * Vdd = 0.25 * 3.3 (V) = 0.83 V

and   Vb = 0.75 * Vdd = 0.75 * 3.3 (V) = 2.48 V

So that, when the switch is closed, the voltage must stay below 0.83V, for the entire time it is 'bouncing', if you are to be sure that it will not a moment that it is in Region 2 or 3, which might be interpreted as 1, that will then 'bounce' back to a 0, with voltage returning to Region 1.

Also bear in mind, 0.83V and 2.48V are not 'precision values', but guidelines. A cautious engineer will make sure the circuit has a generous margin.

-----------

Late addition: I just noticed you asked:

This is the simple circuit I've used as it mimics the connection in the actual circuit albeit without being connected to an actual port pin. Does that matter? 🤔

In this case, probably not, assuming the ESP32 pin, when connected, is set to be an input.

Commonly, splitting a circuit into two parts will markedly change it, as other components and current flows can all contribute to the resulting voltage at a point. This is why it so helpful to have a copy of the schematic in front of you, when you begin to test a circuit.

-----------

I hope the above description is clear.

Best wishes and good luck, Dave


   
ReplyQuote
AndyD
(@andydowns)
Member
Joined: 9 months ago
Posts: 79
Topic starter  

@zander 

Thanks Ron,

Book marked for next birthday. 🙂

Well, that could’ve gone better 😬


   
ReplyQuote
Page 4 / 6