News:

Let's find out together what makes a PIC Tick!

Main Menu

Something Else

Started by Fanie, Jun 21, 2023, 08:07 PM

Previous topic - Next topic

Fanie

Electric Door Lock (Pic-less)
For anyone interested, here is an electric remote lock for a door.
Key locks can be picked, hence using a code hopping remote is a lot more secure.
The lock uses an automotive striker motor which drives a couple of 12mm metal pins in or out of the the pane.

The door open/close sensor is a NO reed switch which is activated with a magnet when the door is pushed close.

If the door is closed, the reed is closed and the 2k2 resistor draws about 5mA from the 12V.

When the remote activates the Open (Oop) relay, the motor pulls the pins and the door can be opened by hand.  The remote allows about 1 second for the door to be opened.  You can hear the striker unlocking the door.

If the door is not opened, like when the remote is accidentally pressed, the door will lock itself again, essential, otherwise the door will be unlocked.
The self re-lock happens because when the remote activates the open relay, the 1000uF cap is rapidly discharged through the diode.  When the open relay closes, the 1000uF cap then powers the lock (Sluit) relay which locks the door.

If the door is opened, the reed goes open and the 1000uF cap is discharged by the 2k2 resistor.
If the door is then closed again, the reed closes and locks the door again by the cap charging up through the lock relay.
The 2R2 10W WW resistor is there to extend the striker motor's life.

This locking mechanism is in my front door for more than 20 years.  I did have a pic board in there to do basically the same, with a buzzer that warns every minute or so when the door is left open.  I suspect water got in the board (the wife has a flower pot above it), I couldn't find another board or the code for it between the hundreds of codes, so I decided to replace with the more robust electro mechanical setup.

Fanie

#41
How to make a remote remote gate opener.

You need an old phone, its charger, a microphone amplifier and a pic board of course. 
Not all my projects are without pics  ;D

The above gets mounted in a box to filter most environmental noise out.  Hopefully you have 12V from a solar system and that powers your board as well as the phone's charger that is permanently connected.

You program the phone to play a pre-recorded frequency or frequencies when you call the number as a ringtone.  This way you can make he access secure.

The microphone amplifier play to the pic, and you use the counter command to read the frequency or frequencies played by the phone.
No other ringtone or tune will compare, and your pic will not respond or some idiot blowing his 400 dB air horn at the gate will not open.
The pic switch a relay to open the gate (or whatever).  This can even be a water pump at a remote location, as long as there is phone reception.

The pic never answers the phone, so there are no call costs.

You can be anywhere in the world (so to speak) and open the gate for whatever purpose, ie the girl next door comes in to clean the place, your buddy wants to borrow your lawn mower so his wife can mow their lawn...
You can also add someone else's number with the same ringtone to give them access.
All they do is call the number and the gate opens.  Better let the wife have access too.

I made this opener for a friend who lived in a leisure resort.  Every house owner was added to the phone so they have access.  Visitors phone their host and he calls the gate so they can enter.

Fanie

#42
The EEPROM saga with the 16F684 was for this project. 
It is a cookie machine for my friend's small bakery.
The dough is pressed through a form that feeds onto a small conveyer belt where it gets cut to length. 
All that remains is to scoop the cookie off the conveyer and place it in a pan.
The small stepper drives the belt, it has a gear which drives the mechanism that cut the dough to length.  The whole concoction was 3D printed and screwed together.
Kondensmelk2.jpg

The control panel with control switches and indication of the steppers feed frequency.
I used the Sound2 command to run each motor at the correct speed.
The press speed is 42 Hz to feed the dough at the exact ratio for the conveyer at 300Hz.
Too fast and the dough deforms, too slow and the dough stretches and break.
The down switch riding the piston down until it starts pressing the dough out is 6000Hz, and when the bottom limit switch is pressed, the piston is driven up at 8000Hz and stopped when it reaches the high limit.
Only with a stepper motor that you can run accurately from such low speed (42Hz) to high speed (8kHz).  And Les's fantastic commands.
Kondensmelk3.jpg

And this is Phillip filling the pans up. About 26 pans filled in around 15 minutes.
Kondensmelk4.jpg

580 cookies in 15 minutes is about 1.5 second per cookie.

pjdenyer

Hi Fanie, it's amazing what you can do with a 3d printer and some electronics.

Fanie

I don't know how we got by without it.
The 3D printing is awesome, whenever you need an enclosure, part, fitting... whatever, you draw it and print it.

JonW

Love it.  Automation gives consistency to the end product; I like the Human in the process; gives it that homemade touch.  He doesn't look like he eats that many, he is pretty thin  ;D

Fanie

#46
Ah yes, Phillip is a small guy, but very capable with some things.  A good hunter too.

He is however not technical, if he takes a screw driver in his hand, everyone around flinch.

Years ago he called me, something wrong with his car's starter.  I said take it out, we get an overall kit for it and we will have it working in an hour or two.  He arrived here, very proud of his achievement, with the alternator  ;D

Fanie

#47
Cool  Module !

Have a look at the MP3-TF-16P module.
You insert a pre-recorded u-SD card, and by sinking with a certain resistor value on one of two input pins with ie a switch, it will  play that number MP3.

So say you have a PIR switch the module, say MP3 track 1, it will play that audio message saying "Hugo, bel die polisie, hier is groot moeilikheid, Maandag is julle uit-ge-sit !"

On jewtube search for "Hugo bel die polisie" since you don't believe me ;)
When you hear this message, you will know which PIR set it off.

Same with PIR no2, it can play something like "the neighbour's wife is in the pool again".

And so on.  On your alarm, you don't have to go and look which area was triggered, you can listen what your own message plays.

You can even pre-record instructions for doing something, like How to program in Positron Pic Basic.  Button 1 is to connect the LED, 2 is the next step to flash the LED, and so on.

It also features a few functions, like repeat all, pause and next.

There is much more to it -the data sheet is here
https://make.net.za/wp-content/datasheets/MP3-TF-16P.pdf

Hugo, bel die polisie, hier is groot moeilikheid, Maandag is julle uit-ge-sit translated is
Hugo, phone the police, here is big trouble, Monday you are expelled.

Fanie

#48
Some of you probably saw the recent PAUL vs TYSON (58) fight.
Paul's next opponent apparently is Clint Eastwood (94).
(Only in Sick Africa  ::) )

And two African dances you most likely have not seen
Zaouli - Ivory Coast
Kumpo Dance
Have a look on the tube

Fanie

Of course Les had the foresight back in the day when he was developing the pic basic, to know that some day in the future, some luni was going to use the Sound2 command to run stepper motors for a cookie machine eh !  8)

Re the 3D printing.  A LED holder is a cent's worth of material.  Off  late the price for one LED holder here jumped to R14.00 (oh and plus 15% vat) - and the "vat" does not add value - which is ridiculous.
So now I just print my own and can be in various colours too. To make it sit firmly in it's hole, I just touch it both sides and at the ring end to keep the LED in - with a solder iron tip, which I dedicated for plastic works.

Fanie

#50
A couple of handy components

The MCP1790 with it's 30V input is now obsolete :'( and I couldn't find a replacement for it.
Since they became expensive too, I started using the AMS1117.

The AMS1117 does not like a high input voltage.  It can handle up to 15V max but even at 10V it already runs warm.  I used the 5V and 3V3 ones and they want 2 to 5V more input than the output.
Dropout at around 1V and they are dirt cheap, and they work very well.
To drop the input voltage I use 1N4007 diodes in series, which is also inexpensive.

I also started using the LMV358 opp amp (TI ?) which is excellent.  Works off 5V or less, rail to rail output and up to 1MHz.

I also used the LM4040-2.048V (also TI ?) precision reference and it measures exactly that.  I use them in my cell charge regulators (with the LMV358) when I build my own LiFePo4 batteries.  I dislike the Chinese BLM's because they disconnect the negative and do not regulate the lower cell, they assume the total battery charge voltage will automatic have the last cell reach the correct voltage, but under certain conditions it does not.

The LM4040 comes in 2.048V, 2.5V, 3V, 4.096V, 5V, 8.192V, and 10V versions although not all the voltages are available here.  If you need a precision voltage to automatically calibrate any input, these references works excellent.  I use them for thermocouples, loadcells, and any other input voltage you want measured and calibrated.

Fanie

#51
Things that promote my insomnia

The 16F684 I use(d) has a 10 bit A/D as well as a 10 bit PWM
This means if I measure a pot voltage to say adjust the duty cycle for something like dim a LED, then the 10 bits fit exactly in the 10 bits PWM.  Works like clockwork.

NOW, the PIC16F17146 has a 16 bit PWM and only a 12 bit A/D (which is a huge step up from 10 bits)
This however means the 12 bit A/D value will fit into the 16 bit PWM SIXTEEN times  :o

What I'm worried about is, when I use the 12 bit A/D, it will not fit in the PWM properly and will adjust the duty cycle by far not enough. I can already see that I have to inform the customer that from now on, just like services, power and everything else here, your LED is going to brighten to only one sixteenth of the previous.  Brace yourself.  But don't worry, the 12 bit adjustment is FOUR TIMES as accurate and a lot more smoother than before.

Does the HPWM command compensate for that... or do I have to take 16 A/D measurements and add them ?
And then on other model pics the A/D is still "only" 10 bits, you have to add the A/D value 64 times !! for it to fill the 16 bit PWM...
Fortunately these pics can now also run at 32MHz... giving you more time to make the x 16 A/D measurements and add them.

Another serious concern is - considering we're working here with only 8, 10, 12 and 16 bit stuff.  Our PC's off late are 64 bits.  Even 16 bits going up to 64 bits is serious stuff.

How on earth do any one think up an instruction that is 64 bits wide ? ?

Sorry, I want to add.
I'm sure that one 64 bit instruction is powerful enough to backup the whole internet on your hard drive - FOR JUIST IN CASE something goes wrong.

trastikata

#52
Quote from: Fanie on Nov 28, 2024, 08:23 AMDoes the HPWM command compensate for that... or do I have to take 16 A/D measurements and add them ?

Hello Fanie,

to enhance the ADC resolution from 12b to 16b ADC output you'd need to ACCUMULATE 256 samples and then the result is DIVIDED by 16.

Or more general approach - if you need to enhance the ADC output by n-bits, you add 4^n samples then right shift the sum by n bits.

'Enhance the ADC resolution by n-bits
'Inputs:
'bInput = ADC input channel i.e. 0,1,2,3 ....
'bEnhance = the number of ADC resolution bits to upscale i.e.
'           from 12b ADC to 16b ADC = 4 bits to enhance
'Output:
'Result as Dword = the enhanced resolution ADC reading output

Proc AdcOversampling(bInput As Byte, bEnhance As Byte), Dword
    Dim wCounter
   
    Result = 0
    For wCounter = 1 To (2 << (2 * bEnhance))
        Result = Result + ADIn bInput
        DelayUS 10
    Next
    Result = Result >> bEnhance
EndProc

david

#53
The theory is good but you may be disappointed by actual results (still some quantization) unless you have a certain level of random noise in the system already.

trastikata

Quote from: david on Nov 28, 2024, 09:21 AMThe theory is good but you may be disappointed by actual results (still some quantization) unless you have certain level of random noise in the system already.

That's true but the PIC's 12b ADC has enough random noise  :)

John Lawton

On top of that layout deficiencies may add noise too

:)

John

Fanie

#56
Sometimes you have to put your tongue in the cheek.
I appreciate the response though.

QuoteThat's true but the PIC's 12b ADC has enough random noise  :)
This one is easy to resolve.  With enough readings and averaging it out the noise will be zero.
You see, the 16 values to reed and add was not such a bad idea  ;D

In any case, using the A/D value will limit resolution to 12 bits,  or 4096 dimming levels in this case.  With a 10 bit resolution A/D the max resolution can only be 10 bits or 1024 levels.

You can however increase measuring resolution by using a lower device voltage.
A 5V pic will measure every 5.9mV, while a 3V3 device will click up every 3.2mV.
If you run the pic at it's lowest voltage you can measure a low input signal more accurate.
If you run off 1V8, your A/D can measure each 1.7mV - and this is with a 10 bit.

If you run off 1V8 with a 12 bit A/D, you can measure every 0.44mV, considering a type K thermocouple at a temperature of 300°C will measure 12.209 mV... means you can achieve 28 readings without amplification - roughly every 10 degrees
Very course, but you're a lot closer than with a 5V pic where you will get a click every 1.2mV (12 bit) and only 12 readings to 300°C or every 25 degrees.

This will be accurate only to the nearest lamp pole.

This is why I'm a bit disappointed that the new 18F-Q-- pics does not have A/D's with their low level power pins.

You guys are much too serious ;) 

trastikata

Quote from: Fanie on Nov 28, 2024, 10:29 AMIn any case, using the A/D value will limit resolution to 12 bits,  or 4096 dimming levels in this case. 

I was wondering if you'd need all 4096 levels from 0% to 100% or it could be for example 256 levels (8-bit resolution) from 0 to 50% and the remaining 3840 for the upper 50% of dimming.

Another thought as I have no experience with that ... could a human eye distinguish between 1024 and 4096 levels of dimming?

Fanie

#58
When you look at a LED light, you will not see a difference, but while switching you can see it, especially on the lowest dimmed settings.
From off to 1/1024 the LEDs are on, barely but you can see.  At night they make a faint light.
From there on up it becomes visibly brighter and brighter.
At a certain counts brighter the visible effect becomes less, and from around 50% power (roughly) to 100% power, the lights are not as much brighter.

As Les will say - This is not a compiler shortcoming, but rather a human eye limitation  ;)

I want to add again.  LED lights tend to flicker at lowest settings, the higher the resolution, the less the flicker effect will be when it sits exactly on the edge where it switches down or up.

John Lawton

I believe that the human eye brightness response is approximately logarithmic, so the dimming 'law' you use will help with the low brightness end dimming smoothness.

LEDs are amazing in that they'll emit visible light with just a sniff of current and/or a very short pulse of current so really smooth PWM dimming at the bottom end is hard to do.