Trying a "State Machine" for Servo Control

I don't remember if you tried this already...What if you just debug the receiver side? Send out millis with each received byte to the serial monitor? Maybe it is a BT hiccup?
 
I don't remember if you tried this already...What if you just debug the receiver side? Send out millis with each received byte to the serial monitor? Maybe it is a BT hiccup?

Thanks, Mike! If I only knew how to do that, LOL.

So it happens without the Bluetooth. I just used the standard servo library on the Arduino (USB connection) and I can see the little red LED on the Arduino board labeled TX go out then a quick bright flash that corresponds with the hiccup. Before when I tied the output to the debug controller, there wasn't any noticeable hiccup from within Vixen that I noticed. So perhaps it's my computer but I have the same issue on another Windows 11 machine. The TX (transmit) on the Arduino board I assume is incoming, doesn't make sense. That same LED flashes when upload a sketch.

Take care, Joe.
 
Hi Joe
It's all good , I see what is for now .

Code:
  SerialBT.begin("ESP32BTServo");
 
Last edited:
Another thought I just had was I wonder if you're just getting interference. Are you using a breadboard or anything like that? Or long wires to your servos? Weak/noisy power supply?
 
Another thought I just had was I wonder if you're just getting interference. Are you using a breadboard or anything like that? Or long wires to your servos? Weak/noisy power supply?

Thanks, Chris! I have tried different power supplies. The wires aren't long at the moment. I'll experiment today and post what happens!

Take care, Joe.
 
Last edited:
Hi Richard,

I'm getting this error when I try to send you a private message:

"angus40 has exceeded their stored private messages quota and cannot accept further messages until they clear some space."


take care, Joe.
 
Hi Folks,

So, last night, I got the "Jawduino" working a little bit, but because I want to add a head/neck movement (and other things eventually), I really need to get this Vixen sequence working. So I think a need something like a gaming computer. My 2 cheap Win 11 machines just can't handle things. (Last night my audio port wouldn't recognize my earphones, so after much futzing around, I had to uninstall the audio device and reboot.) I am using just a very small portion of Vixen's power but the whole "engine" is running.
I am reluctant to buy a refurbished machine, so a costly moose he is, LOL.. At any rate, I am still tinkering with the sketches; perhaps there is a buffer overflow with the microprocessor, but I am not a programmer.

I will keep y'all posted!

As always, thanks, Everyone, for the kind help!

Take care, Joe.
 
Does Vixen have suggested hardware to run the app ?

I think you may be better off sequencing a pixel in Vixen and use 1 of the color channels from that to control your servos with the Esp32-e131 Servo sketch .

For the head movement I use the full 0 - 180 in mapping and create a 50% intensity solid for the sequencing color channel to hold the 90 .
 
Does Vixen have suggested hardware to run the app ?

I think you may be better off sequencing a pixel in Vixen and use 1 of the color channels from that to control your servos with the Esp32-e131 Servo sketch.

For the head movement I use the full 0 - 180 in mapping and create a 50% intensity solid for the sequencing color channel to hold the 90 .

Hi Richard,

Thanks for the reply!

System requirements are here:

https://www.vixenlights.com/docs/started/installing/


Someone please correct me if I'm wrong, but I am using the output as if it were a pixel. It's sending 0-255 as serial.

I think it's my cheap PC.

The ESP32 e131 sketch has the same occasional hiccup, perhaps slightly better. I'm not giving up!

Take care, Joe.
 
Ah, that is why I haven't installed Vixen . I'm still using Win 7. Won't give it up any time soon .

I have a Win 10 laptop for loading EspixelStick firmware , but that is about all it is good for . lol
 
Hi Richard,

Thanks for the reply!

System requirements are here:

https://www.vixenlights.com/docs/started/installing/


Someone please correct me if I'm wrong, but I am using the output as if it were a pixel. It's sending 0-255 as serial.

I think it's my cheap PC.

The ESP32 e131 sketch has the same occasional hiccup, perhaps slightly better. I'm not giving up!

Take care, Joe.

I'm not sure how Vixen needs output configuration setting for e131 , but that is what you should be using . Serial/com - and Bluetooth do not cut it in my opinion .
 
Here are the Vixen 3 requirements: https://www.vixenlights.com/docs/started/installing/

Following up on Mike Krebs comment...i think the only way you're going to resolve your issues is to debug the program. The easiest way to do that would be to write data to serial. I'm assuming you can run your esp while still connected via the usb port.

Its really easy to set up and is really useful for situations like this that you need to troubleshoot.
In your setup function you add Serial.begin(115200) This will start the terminal. I'm assuming you're using the Arduino IDE so someone else will have to help with how to open a terminal. Also, the 115200 is the baud rate of the serial. If you have yours setup to some other baudrate (you can find this in device manager) then you'll have to change that line to whatever the baud rate.

Then, to write data, you just enter Serial.println("whatever you want to print") when you want to print something.
I would probably write to the terminal at several points...I would put a println statement at every critical point of the data receiving code and print the actual received value. For example, at the part that detects the "~", Do something like Serial.println("~detection: " + yourCharacterVariableName). Then follow it up for each character received, as well as the end of the receiving statements. This should give an indication of whether you are receiving the correct data.

This is crucial because at the moment we are all just guessing what the issue(s) could be.
 
Here are the Vixen 3 requirements:.......................................................
This is crucial because at the moment we are all just guessing what the issue(s) could be.

Thanks, Chris, for the info.

So I did that with the ESP32 on Bluetooth and printed the servo write values to the Arduino serial monitor. When the hiccup occurred, the serial data flow stopped to the Arduino, but Vixen continued to send (learned that when I set up the debug controller in another of several trial and error attempts). So it's not writing the wrong value, it's writing nothing, no data. I'm not new to the Arduino IDE. I have it on 4 machines, one a MAC.

So perhaps I'm wrong, but it's no data being sent when the hiccup occurs. One channel, sometimes I remove the "~" and the "!"
and the same story. If this helps:
If I stop and start the execution engine, it's flawless for the minute or so. The next time it's run, things start to happen. I have to set the update interval to "23." Not above or below, otherwise it's a mess.

(I'm not a programmer, but I've done some rather advanced stuff with the ESP8266 where I had a friend 30miles away control 2 model trains via DCC++, wrote that code myself.)

So, the hiccup occurs when the serial stream to the Arduino stops and I gather, Vixen is still sending. So it could be my 2 Win 11 machines, both cheap.

Take care, Joe.
 
Ok, this is good data.

when you say "sometimes I remove the ~and !", what do you mean? Are you doing this on your vixen output? (so it affects all data)? If that's the case, you shouldn't be getting anything on servo. If you are then the header is not doing its job.

The next thing to look at is the data you are seeing before the crash. For 1 servo, you should always see in your terminal exactly 1 ~, then exactly 1 !, then exactly 1 data value. If you want more eyes on your terminal results feel free to post them.
 
Ok, this is good data.

when you say "sometimes I remove the ~and !", what do you mean? Are you doing this on your vixen output? (so it affects all data)? If that's the case, you shouldn't be getting anything on servo. If you are then the header is not doing its job.

The next thing to look at is the data you are seeing before the crash. For 1 servo, you should always see in your terminal exactly 1 ~, then exactly 1 !, then exactly 1 data value. If you want more eyes on your terminal results feel free to post them.

Hi Mike,

Thanks for the reply!

I remove those characters in both the sketch and in Vixen under the controller settings. Or add them back in both the sketch and in Vixen.

It's not my error there!

Take care, Joe
 
I also took a look at your code again. I think there's something wrong in your header detection.

I don't think you want the for loops in your header detection clauses. Right now, It looks for the '~' and if it doesn't see it, it breaks the for loop. Which means its falling through. Same thing for the '!'.

So, I think the flow you want is:
Wait for data to be present (while (!SerialBT.available());
Test if it's a '~' and restart the while loop if its not because its not the start of a data packet. So, if (SerialBT != '~') continue;
Otherwise, it was a ! so test for the '!' next the same way you did for the ~. If its not the ! its not the start of a packet so you need continue to restart the while loop.
If both tests pass, loop through the remaining data for your channelvalues. In the case of 1 servo, its only 1 iteration.

note my code might not be exactly correct, I did it in the browser, not an ide so don't just copy and paste.
 
Back
Top