convert analog signal to digital using rules?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
stin88
Normal user
Posts: 16
Joined: 29 Jul 2019, 18:36

convert analog signal to digital using rules?

#1 Post by stin88 » 26 Jan 2020, 12:29

hi. i got a signal that goes from 2volt(high) to around 0,2v(low) in 10ms and repeats with a span around 50ms.. First i thought use a gpio but according to docs but the signal is to weak, got the suggestion to use a level shifter but im not sure how to pick the right one... so now im using the analog input with a voltage divider to lower the voltage to max 1v and now i get readings between 10ms with voltagedrop between 0,4v (high) and 0,2v(low)

now im thinking of using rules to calculate high and low and put the state to a dummy device... and then make a counter out of that.

will this even work? :?:

Ton_vN
Normal user
Posts: 303
Joined: 21 Oct 2016, 15:20
Location: Hengelo (Ov)/ NL
Contact:

Re: convert analog signal to digital using rules?

#2 Post by Ton_vN » 26 Jan 2020, 13:46

Triggered by your description of the voltage divider, what configuration of processor & board?

stin88
Normal user
Posts: 16
Joined: 29 Jul 2019, 18:36

Re: convert analog signal to digital using rules?

#3 Post by stin88 » 26 Jan 2020, 14:07

using esp8266-12f chip.. this is my data.. https://i.imgur.com/blP1eFc.png

trying to figure out how i can set rule to count 1 or 0 from the analog value and use another rule to set counter, cant find any example in docs about counters...

on dummy#var1=1 do
if [analogINPUT#value]<500
gpio,16,[dummy#var1]
endif
endon

stin88
Normal user
Posts: 16
Joined: 29 Jul 2019, 18:36

Re: convert analog signal to digital using rules?

#4 Post by stin88 » 26 Jan 2020, 16:56

tried this code with no success

Code: Select all

On System#Boot do    //When the ESP boots, do
TaskValueSet 3,1,0 //set [DummyCounter#counts]=0

endon

On DummyCounter#counts do
   if [feedback#state]<700 //if analog less than 700, add +1 to counter 
     TaskValueSet 3,1,[DummyCounter#counts]+1
   endif
 endon
going to check for a suitable npn or pnp transistor to amplify the signal....

Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests