Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4762

Beginners • Re: Analog voltage pattern matching

$
0
0
If the light is just flashing on/off, with no dimming, then the input is just an opto-isolator driven from the light's 12V and pulling down a GPIO.

You then write your code to monitor the state over time, to match the pattern. That may take some trial and error, especially if the signal that failed the sequence at a late stage is after the start of a genuine sequence. What I mean is, if you are looking for a pattern of times ABAA, and you get:
A (pass 1) B (pass 2) A (pass 3) B (fail 4),
you need to re-check from the second A because the next elements might be A and A, which would complete a pass starting from the middle of the failed sequence. (I think you may have noticed this, from your description, but the coding here needs care.)

The other programming problem is to determine the correct tolerance -- so if you expect short is 100mS and long is 200mS, what do you do if you actually get 50mS, or 150mS, or 250mS, or any other value? It will help to define "long" and "short", and the target sequence, before writing the recognition code. Also, are the "off" times as significant to the pattern as the "on" times?

The output is simple, a GPIO driving a transistor driving a relay.

Sounds like a fun project. It is all doable on ang of the Pi range, I think I would choose a Pi Zero 2 which will leave plenty of scope for later additions. If you need to develop code directly on the target Pi (rather than having a separate Pi for development), then a Pi3B+ is probably the minimum. Personally, since I already have them, I would develop on a Pi5 and deploy on a Pi Zero 2.

Statistics: Posted by davidcoton — Thu Sep 12, 2024 11:03 pm



Viewing all articles
Browse latest Browse all 4762

Trending Articles