Open naaitsab opened 2 years ago
I'm not too familiar with ESPs, but i think if the main loop takes too long to run, the wdt resets them? (been a few years since I've played with one).
So I'd suggest trying something like this that avoids calling delay(): https://gist.github.com/CrashOverride85/531d95e505f302c8b664b95a71ac3926
Basically it's the ColTxSerial.ino example modified to transmit for 7 seconds (set on line 161)
Thanks will give it a try later on. Not sure what the max duration of the collar itself is. Did you experiment with it yourself?
I honestly can't remember - I probably didn't experiment much with max duration. But I knew they could be on for a few seconds, but I can't remember if there's a limit or what it is
Got it working, even with WiFi enabled and a webpage (remote control FTW) it stays stable until 10 seconds :) Maybe even more but I think 10 is a nice max.
Made a few modifications to implement the timer in the commands
Added int sec = atoi(&input_message[5]); under power = atoi(&input_message[2]); Made the command accept the 'sec' as input instead of the static 7 of the example. atoi keeps 'calculating' so we need to terminate it after the power ends and the sec(onds) start with a char. So I added a : in the *input_message
So the message should look something like this 1V15:05 for collar 1 vibrate at 15% for 5 seconds.
Only thing I can't really figure out is the timing. It seems to be time + 1 second roughly. So 10 is 11 and 1 is 2.
Also want to implement a pavlov mode. So vibrate first then shock. Guess it needs the modification inside the void loop at the check "if (_transmit_end_ms > 0)" so it will set to vibrate for 1-2 seconds (or 1/3 of the time or something? and then change the "_msg" so it will shock instead of vibrate.
I'm not sure why it's triggering for an extra second - it might be just the response time of collar, or something like that? If it's always out by 1 second, i guess the easy approach is just to take 1 sec off seconds on transmit() 😂
Getting to vibrate first the shock is probably a bit more awkward. I guess you'd need to do something like add a _transmit_start_ms time, and a pavlov_mode flag. So in the loop, when pavlov_mode=true and msg.mode=VIBE, if the current millis() is more than 1/3 of the way between _transmit_start_ms and _transmit_end_ms, change msg.mode to SHOCK. There might be easier ways, though... not sure..
Do you by chance have the remote for it to test something? Perhaps the second is just the minimum trigger amount and every "loop" adds another second to it. So trigger + 1 loop is 2 seconds instead of 1 because the trigger already adds 1 second.
Just found it and tried it... yeah, from pressing the button to the shock collar stopping, it does seem to be around a second
I experimented a bit with the "type 1" collar. It seems to support longer/continuous vibration and shocks. Tested to 7 seconds.
I've hacked together a very crude method to let it trigger longer. If you call the function in a loop. With the loop count double the amount of seconds it seems to work about right with a delay of 250 in between.
But after a few seconds the ESP restarts so I guess it overloads the system doing it like this. Any idea how to implement this cleanly inside of the collarTX libary?