Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 01:09 20 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Need Help for TIMING (MMBASIC)

     Page 1 of 2    
Author Message
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 02:33pm 11 Jan 2020
Copy link to clipboard 
Print this post

Hi Buddies,

Iīm not very experienced in timing so I need a little starting support for this issue

The doorbell shall trigger (via optocoupler) and the MM shall read out a certain order for being a defined code just like Morse or the rhythm of a special melody for opening up the door (via relay) if correctly matching.

How would you monitor the bell as an example for something like a SOS signal?

... --- ...

or
short short short long long long short short short

 
Andre ... such a GURU?
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 04:37pm 11 Jan 2020
Copy link to clipboard 
Print this post

So the input to the MM will be a regular input ("optocoupler")?

I think I would watch for the input to go high and assign the timer value to a variable.

Wait for the input to go low and subtract the timer memory variable from the current timer value.

Ascertain whether it was a dot or a dash.

Proceed accordingly.
 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 05:03pm 11 Jan 2020
Copy link to clipboard 
Print this post

I need some help with the coding. The hardware or logic is no problem at all.

If you or anyone else could give me a code-draft for this SOS example, I know that this actually is quite easy (at least as a flow chart) but working with the timer just confuses me completely.


Just imagine someone is pushing the button and a pin goes high each time, the button will get pushed for SOS and the MM will set another pin high at the end of the attempt, if successfully done without mistakes (like wrong short-long-order or too long or too short) and if not it will "GOTO 10", waiting for another try.
Andre ... such a GURU?
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 05:17pm 11 Jan 2020
Copy link to clipboard 
Print this post

Sure...confession: Having a birthday pint right now. Bday was yesterday but had to pull an all-nighter. Back to my PC shortly :)
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 06:29pm 11 Jan 2020
Copy link to clipboard 
Print this post




'define ins/outs

dim Cntr, SOS, ButDuration, Dash as integer

Dash = 500 'anything less than Dash is a Dot
Cntr = 1
SOS = 0
do

if pin(doorbell) = 1 then

 ButDuration = timer
 
 do
 loop until pin(doorbell)=0
 
 ButDuration = timer - ButDuration
 
 select case Cntr
 
 case 1
   if ButDuration < Dash then SOS = SOS or &H100
 case 2
   if ButDuration < Dash then SOS = SOS or &H80
 case 3
   if ButDuration < Dash then SOS = SOS or &H40
 case 7
   if ButDuration < Dash then SOS = SOS or &H4
 case 8
   if ButDuration < Dash then SOS = SOS or &H2
 case 9
   if ButDuration < Dash then SOS = SOS or &H1
 
 end select
 
 if Cntr = 9 then
   if SOS = 455 then'(111000111)
     'we got dot-dot-dot-dash-dash-dash-dot-dot-dot
     'Set output
   endif
   Cntr=1
   SOS = 0
 else
   Cntr=Cntr+1
 endif
 

endif


loop



 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 07:45pm 11 Jan 2020
Copy link to clipboard 
Print this post

Just to be sure that button pushes 4,5 & 6 are valid dashes



case 1
  if ButDuration < Dash then SOS = SOS or &H100
case 2
  if ButDuration < Dash then SOS = SOS or &H80
case 3
  if ButDuration < Dash then SOS = SOS or &H40
case 4
  if ButDuration < Dash then SOS = SOS or &H20
case 5
  if ButDuration < Dash then SOS = SOS or &H10
case 6
  if ButDuration < Dash then SOS = SOS or &H8
case 7
  if ButDuration < Dash then SOS = SOS or &H4
case 8
  if ButDuration < Dash then SOS = SOS or &H2
case 9
  if ButDuration < Dash then SOS = SOS or &H1

 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 10:01pm 11 Jan 2020
Copy link to clipboard 
Print this post

  Tinine said  Sure...confession: Having a birthday pint right now. Bday was yesterday but had to pull an all-nighter. Back to my PC shortly :)


So ... CONGRATS!


... and thanks for your support!

But it does not hurry at all.

Just have some more pints, itīs still weekend!  
(What brand?)

Andre ... such a GURU?
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 10:20pm 11 Jan 2020
Copy link to clipboard 
Print this post

All craft ales around here and there are a zillion names. Started out with an IPA but I didn't love it so switched to a coffee flavoured stout.

I'm a bit old school so didn't like the sound of the coffee but I kept going back for more.

I'm actually on-site, working so don't want to go crazy...need to be finished  
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2867
Posted: 04:54am 12 Jan 2020
Copy link to clipboard 
Print this post

Hi Poppy,

I am not the best at programming so I cant help much there but wont it annoy the crap out of people in the house if someone is pressing the doorbell button to make a code?

Probably better to have the MM monitor the door button then trigger the doorbell if the `code' fails.

Kind Regards

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 10:15am 12 Jan 2020
Copy link to clipboard 
Print this post

Not a bad alternative to a full numeric keypad for keyless entry, actually. The code could be anything you want.
 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 10:18am 12 Jan 2020
Copy link to clipboard 
Print this post

  Tinine said  All craft ales around here and there are a zillion names. Started out with an IPA but I didn't love it so switched to a coffee flavoured stout.

I'm a bit old school so didn't like the sound of the coffee but I kept going back for more.

I'm actually on-site, working so don't want to go crazy...need to be finished  


Damned, I wish a had a fresh stout myself or a cider or a snakebite. I am really lacking an english pub at my place getting anything fresh from the tap.


German beer just is so perfect ... ly boring!  

And Sunday Morning is a good time to start up ... or going on!


  bigmik said  

I am not the best at programming so I cant help much there but wont it annoy the crap out of people in the house if someone is pressing the doorbell button to make a code?



Hi Mick,

first thanks for supporting and it is not only about coding each new thought improving my idea will help!


And you are right this would be quite annoying but the case is that I just switch off my doorbell, so it wonīt ring at all, but if someone forgets the key this shall open up alternatively as the one being locked out cannot be recognized from inside anymore.


  Tinine said  Probably better to have the MM monitor the door button then trigger the doorbell if the `code' fails.


You are right, in case the bell is on, I have not considered this case yet.
Probably there should be some initialization to show the MM a code is about to come.

If you keep the button pressed then the bell will only ring once, so this wouldnīt be annoying. Perhaps it should be pressed once for a quite long time to start the routine.

Some years ago I have just build a more discrete solution using some NE555 and Register Shifters (??? donīt know what those are called, switching further on by each trigger) and it worked fine, that is why I am so confused about the coding, because I am still thinking too much in a hardware way.
 
Andre ... such a GURU?
 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 10:26am 12 Jan 2020
Copy link to clipboard 
Print this post

  Tinine said  Not a bad alternative to a full numeric keypad for keyless entry, actually. The code could be anything you want.


This would show the world that there is something to crack!


No, itīs not my own house, just rented, so I cannot install anything visible outside, and I rather like the one-button solution for being more elegant.
Andre ... such a GURU?
 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 10:37am 12 Jan 2020
Copy link to clipboard 
Print this post

  Poppy said  

If you keep the button pressed then the bell will only ring once, so this wouldnīt be annoying.


I should explain this better, the level will stay high as long as the button is pressed but the sound can only be heard once. Just a monostable gong.
Andre ... such a GURU?
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 02:33pm 12 Jan 2020
Copy link to clipboard 
Print this post

  Quote  
German beer just is so perfect ... ly boring!


Oh I like the 7-minute Pils.

I was staying at the Nurburgring race track hotel, a couple of years ago.
One night, in the hotel bar, the beers kept coming and coming without me asking. Turned out that a table of people from Switzerland were convinced that I was James Hetfield and told the bartender to keep serving me on their tab. I wouldn't mind but I don't have a single tattoo      
 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 03:14pm 12 Jan 2020
Copy link to clipboard 
Print this post

  Tinine said  
Oh I like the 7-minute Pils.


... and "seven is a magic number"!


OK, itīs nice, and perfectly made after the german "Reinheitsgebot", but ... boring!
... but for getting p***ed it does its job!


In Belgium you will find so many different flavors!


  Tinine said  ... were convinced that I was James Hetfield ...
... the beers kept coming and coming


And ... Nothing Else Matters!



  Tinine said  ... but I don't have a single tattoo


... waking up having some will prove far enough beer!

Andre ... such a GURU?
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 10:27am 13 Jan 2020
Copy link to clipboard 
Print this post

  Quote  
And ... Nothing Else Matters!


Good one  

  Quote  
waking up having some will prove far enough beer!


This happened to the missus when we were on vacation in the US Virgin Islands.

She ended up with a Tramp Stamp  
 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 12:45pm 13 Jan 2020
Copy link to clipboard 
Print this post

  Tinine said  

This happened to the missus when we were on vacation in the US Virgin Islands.

She ended up with a Tramp Stamp  


"Tramp-Stamped on Virgin Island"

Sounds like a title ...

... for a book?  or some homemade footage!



... just kidding, earning a kick-out if not stopping ...  

... well I better go getting a fresh beer.  

Still weekend?




So for the sake of sedateness back to Topic   :

I think I have to reconsider some points from my Doorbell-Monitor and will come back on this right away after I found some more particular time.

... as a Microcontroller offers so many more opportunities than some old fashioned electronics.
Andre ... such a GURU?
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 02:28pm 13 Jan 2020
Copy link to clipboard 
Print this post

Yup, the MM brings out the Imagineer.
 
Poppy

Guru

Joined: 25/07/2019
Location: Germany
Posts: 486
Posted: 04:52pm 13 Jan 2020
Copy link to clipboard 
Print this post

  Quote  for the sake of sedateness


... but this should not derogate the divineness of our holy nectar!

Cheers!
   
Andre ... such a GURU?
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 11:08am 14 Jan 2020
Copy link to clipboard 
Print this post

hmmm... some part of me is caught up on (one of) Ganssel's de-bounce algorithm where you consatnly shift bits into a byte and look for a specific number to eliminate bounce (i.e. all 1s is *definitely* pressed and all 0s is definitely not pressed... anything in between shows bouncing and to be ignored... but... if you slowed the cycle time right down, it would catch individual presses... I can't get it straight in my head if this is worth exploring or not... if it is then the code would be represented by the binary in a single variable... my gut tells me timing would be fairly critical and so not really a  contender but my head just won't let go of it. Have a look at "an alternative" under the "A Counting Algorithm" section near the bottom of this page http://www.ganssle.com/debouncing-pt2.htm I use this for debouncing I like that you just leave it running all the time and simply inspect the variable when you want to know if buttons were pressed.
 
     Page 1 of 2    
Print this page
© JAQ Software 2024