Question on timer

tmack

Member
I am working on a robot that is controlled over the internet. I am using a 4 relay device made by controloverweb. On my unit I can pulse the relay for a set amount of time(1 sec, etc.), Or have the relay on until I shut it off. I am thinking I will control the motors by pulsing it for 1.5 seconds at a time. Making the robot go forward one pulse at a time etc.(so I dont crash into things). I just had an idea that I can do more with the 4 relays then control 4 things(ft,bk,lt,rt) I can control those 4 by pulsing the relays . The other functions, turn robot on/off, Turn light on/off etc. by leaving the relay on for a set time like 5 seconds or 7 maybe. I am looking for help with the code for an 08 that can see if an input pin stays high for 5 seconds, if it does, make an output pin go high.If not and the relay only stays on for the 1.5 second pulses then just do nothing. I'm not too sure about how to use variables.I am concerned that the 08 would see the 1.5 second pulses and count them then when it reaches 5 inadvertantly turn something on/off. Id like it to only make the output high if the input is on for a solid 5-7 seconds. Thanks for any help. T
 

moxhamj

New Member
Sounds a fun project. You could add a webcam so you can see what it is doing. Testing for an input pin being high for 5 seconds can be done with a few lines of code. Test the input 10 times a second. If it is high for 5 seconds then a counter will get to 50. If it is low then reset the counter.

main:if pin1=1 then
b0=b0+1
else
b0=0
endif
pause 100' 0.1 seconds
if b0>50 then goto dosomething
goto main

dosomething:extra code here
b0=0' reset the counter (!important)
goto main
 

toxicmouse

Senior Member
controloverweb did not yield any search results, do you have the URL?

nice idea, but i would probably replace those relays with something else, because the relays will bounce. if you can get short pulses from the line that activates the relays, then i would use that for communications. so if the shortest pulse that can be sent is 20ms then i would send the instructions in denominations of 20ms.

command 1 would be 20ms, command 2 would be 40ms and so on. for a command set of 20, the longest command would take 400ms, but the most common commands under 100ms.

that still leaves 3 relays, and 4 outputs on the 08M to put on additional relays or whatever.
 

tmack

Member
Sorry I was writing late at night (I was dreaming of robots again):) Its actually Control by web (http://www.controlbyweb.com/webrelay-quad/index.html). I bought the quad because I thought it would give me my 4 -front,back,left,right. Thanks for the other ideas .It definately deserves some more expierimentation.I would love to be able to controlo more than 4 things with it. They have some that take inputs as well. I can say that my experience so far with that company is awesome they answer my questions fast and their product works great with fast and easy set up.Again my thanks for the help, When I get it done Ill post a link.
 
Top