Servo motor control via Arduino

Hi,

I had a hard time trying to find a proper way to control a servo motor from TouchDesigner. It seems that the Arduino has a hard time trying to understand the serial data coming out of TD, so code that works with serial data coming from Processing just fails when using TD.

So I hacked something together. It’s a mix between the Arduino page from the wiki and this thread : [url]Channel -> Arduino - Beginners - TouchDesigner forum. The Arduino sketch code is included in the Text DAT. It’s a bit kludgy, but it works reliably. If you want to improve on it, feel free.
Arduino_servo_motor_control.tox (2.13 KB)

1 Like

Sketch seems what I’d expect to parse out a stream of bytes, new line terminated.
What issues were you experiencing before?

Hi,

The issue was that the servo was twitching, but not moving properly. What’s odd is that when I sent serial data from Processing, it worked fine. As far as I could tell, the serial data in the monitor coming out of TD was identical. It took me a while to figure out that the Arduino needs to put the data in a buffer, and then wait for a newline before using it.

While googling I found that many people had these issues. As a beginner, I know how frustrating it can be when you can’t get simple things to work (I’m new at controlling physical devices in software). Sometimes the simplest things are the most useful. Right now I’m working on getting a stepper motor to work, and I’ll probably post the results here.

1 Like

Right, serial data (like TCP/IP) connection is streaming.
It has no concepts of start/end, so your solution actually is more proper and reliable!
Good stuff.

Hello Patenteux!

I’m completely new to controlling physical devices and I have a project coming up where I need to figure out and understand these things. I am going to need to control 8 stepper motors, but will first try with 2 in the testing phase. You can imagine my list of tabs at the moment is really long to wrap my head around this. (Also new to programming in general)

I’m curious if you got your stepper controls to work?
Looking forward to start digging in your previous example.

Also I am very curious about the hardware you are using because the recommendations I am getting from others are all over the place. Some even suggested changing my Arduino firmware to Grbl or Marlin. So I’m very confused to what I should actually buy and install to get started.

Franck