Arduino,td,Ethernet

I would send characters over serial from touch to an arduino running the serial command library.
github.com/scogswell/ArduinoSerialCommand

Most importantly, how often do you want to update the motors per second?

OSC is a layer on top of (UDP or TCP/IP). UDP having slightly lower overhead, but less reliable, and not an issue for most applications.

You’ll need python either way when sending from TouchDesigner, whether sending binary or ascii.

You may want to consider sending sending pulse counts instead of individual pulse events.

Also, have you seen this primer on TouchDesigner / Arduino ?

derivative.ca/wiki088/index. … le=Arduino

Rob

Thks guys,
I’m looking at serialDAT and it’s possibilities. Seems that it is not geared up for Ethernet transport, only an USB connection to arduino ?

I’m hoping to do 30fps. I was thinking I would try to just send pulse and direction, but up to 5 steppers this is going to be an address problem as well.
There is an arduino OSC library, and I’ve made it available. I’m just not sure what to do with it. I guess OSC would add a time stamp and make packets, but not sure if this is helpful at this juncture.

I guess what you are saying Rob is that instead of ’ broadcasting’ the timing pulse I should send the arduino all the choreography first and thenstart a timing pulse, perhaps locally on e arduino ?
I’m thinking I will try to design this stepper to respond along with TD transport and timeline somehow, so adding pulse count to my packets makes sense, was hoping to minimize arduino code, as I will have to learn it , but so far so good.

Yes, Serial DAT just outputs to a serial connection.
If you want to output to an Ethernet Shield, you could use a TCP/IP DAT for example.
OSC will just add overhead that won’t give you much.

You should be able to send pulse+direction to 5 steppers 30 times a second using ethernet connection. Im just wondering if 30 pulses per second is enough movement on the steppers? Most steppers require 200 pulses per revolution, so at best your system would be one full turn every 7 seconds or so.

You have a few options:
a)send individual pulses
b)send pulse counts
c)send desired stepper position

I like the third option, as it lets TouchDesigner send a position, and then the arduino moves forward or backward until hitting it.
The Arduino + TouchDesigner can do their own thing without bogging the other down.

The arduino loop pseudo code would look something like this:

int my_position = 0;
int target_position = 0;

while(1)
{
    if (my_position < target_position)
    {
        my_position++;
        step_forward();
    }
    else (if my_position > target_position)
    {
        my_position--;
        step_backward();
    }

    if (serial_message_waiting() > some_number_of_bytes...)
        target_position = read_serial_mesage()..
}

Rob.

1 Like

thks Rob,
I think you are correct in your assessments and hints.I’m going with door #3 also. I have been digging into the Arduino AccelStepper library. Seems like most of the work has been done !

airspayce.com/mikem/arduino/ … index.html

hello,

if you want to purse the option “a” that rob illustrated- you may want to look at this post.

[url]round trip transmission speed - General TouchDesigner Discussion - TouchDesigner forum

thanks G,
I had seen your thread the past few days and definitely will be keeping that in mind when serial latency becomes the issue. I will be testing the ‘global’ checkbox for sure. Thks for your efforts and work in this regard.

I found an Arduino library called Accelstep which really made option #3 seem like the best option, hence the communication issue is greatly reduced, as the only commands that are sent are ‘final destination’ and things like that.

Right now I’m kind of dealing with some mechanical engineering issues re: a sense of ‘scale’, as I kind of went overboard with the stepper size (nema 34 I think?), and as Rob pointed out 200 steps per rev is 200 steps. Gonna have to ‘gear down’ and RPM up or maybe a slightly smaller stepper. I could probably winch a 4x4 truck out of a hole with the power this one has. A bit ‘overkill’, but I’m sure it will be useful in the future.More as things progress…

i’m super glad my work can help!

check this out:

slickstreamer.info/2012/03/r … motor.html

this is the type of system control i’m trying to use Touch Designer to achieve. not just motors- but anything a microcontroller can control.

pre-computing moves on the Arduino- even smooth ramps with libraries like AccelStep- is very cool. but what if you want to update a motor position in the middle of a move? if you’ve already told the motor to go somewhere, then you need to break in quickly and change it’s task. that’s where i’m trying to go- creating a closed loop feedback stream that let’s Touch Designer do the decision making. not the controller.

also keep in mind- 200 steps is not necessarily 200 steps. you can microstep most steppers- with divisions like 1/16th and even 1/32.

so- theoretically- you can use Touch Designer to design your ramps, stops, bursts, etc. (interactively).

another aspect of stepper motion control to keep in mind is voltage. even though you may have a workhorse motor, you can always limit the amount of voltage you are allowing it to use. it can still spin fast and accurately, but with less torque (and heat).

keep up the good work! i will also post my progress here.

Just on a side note, unrelated project.
I needed to spin a 5V stepper at 300rpm, (=5 rev per sec =1000 pulses per second) under microcontroller control.
Found it could not achieve that speed no matter how slowly I ramped up.
(It just stalled at a certain speed).
Then I drove it at 24V using a stepper driver which allows you to set the upper current limit.
Under heavy load though, it began to stall, until I dropped it down to 240 rpm.
Cheers
Rob.

P.s.s. before we close ‘Motor Kontrol Korner’…

Admittedly, haven’t delved into Accelstep lib much but my impression is that recalculating a new course/destination/speed/accel/etc. (en route) is comprehensively supported… Trying to find the exact routine, but somewhere around in here I thought I heard mention of that subject:
airspayce.com/mikem/arduino/ … epper.html.

thanks for all the help, people

Hey rob,

What driver did you end up using? I just ordered a couple of these

[url]http://www.pololu.com/product/1183[/url]

I was having trouble getting the performance I wanted stepper-wise with the Adafruit MotorShield v2. I love that board for servos and DCs, though. I am getting great results controlling servos and DCs in realtime from Touch.

This vid is a great inspiration BTW.

[url]Arduino Stepper: Ultimate Accuracy! - YouTube

I’m back on the case of my project here. I’ve had some success getting accelstep running a giant stepper independently and now I’m trying to code in some realtime commands. I’m back at the point where I’m dusting off the work I’ve done so far and trying to decide if I should just use a really long USB cable(I have some 50ft ones that work with arduino) or if i should go through all the trouble of trying to communicate over ethernet.
As I see it:

Ethernet wins in terms of being able to access the stepper from anywhere on the net.(not so important to me)

USB wins in terms of it will also share the line in order to program the arduino (arduino cant be programmed over ethernet AFAIK), so even if I use ethernet I will still have to make an USB connection to do any coding updates.

I’m leaning towards USB I think, because I had good results with a long run and an Arduino with 6 servos. But , of course the USB connection doesn’t need to be permanent once the development cycle is done so …

Any thoughts ?

Hi Gardyll.
Sorry missed your question from last time.
I ended up using this one:
pololu.com/product/2134/specs (rated at 10.8V maximum)
but ended up using the same as yours when moving to driving the stepper at 24 volts.
Control was fully done in assembly with a pic microcontroller.

How reliable is a 50 foot USB cable? I imagine it has some powered repeating logic throughout it and not just one long cable?
Technically you don’t have to extend the USB cable that long, just the serial side.
You could find/prepare an arduino without that front ftdi stage.
Though I don’t know if 50 foot serial repeaters are any easier to deal with.

In terms of uploading sketches via ethernet, haven’t seen that myself, but would involve custom boot loader: freetronics.com.au/pages/how … Ir-uCvF98E
Or a secondary device such as a raspberry pi etc.
Though in my experience every ethernet adapter adds $20 to each arduino base station.

yeah, I have the Arduino ethernet adapter up and running.
And surprisingly these 50ft usb 2.0 cables work as advertised:

monoprice.com/Product?c_id=1 … 1&format=2

they work with kinect v.1 as well.

Now I’m currently working with DAT/UDP to try ethernet route again. Seems like at a certain point this will be the best way, even if I cant figure out that remote bootloader stuff- I will just keep USB attached until I don’t need to anymore.

/yawn

youtube.com/watch?v=JOMa3vM … r5abSl7-iw

thanks slammin. That is useful information. Maybe when you are done with your nap you could comment on what kind of minimal latency you are getting over ethernet. :wink:. 100baseT should have potentially much faster performance than serial from what I gather. But I think there are other factors that make serial still compelling in certain situations.

Here’s my example of controlling 8 servos discretely over 50ft USB cable and ‘old school’ serial. I haven’t tried above 57600 baud becasue I’ve been happy with the performance at that rate. Also I theoretically should be able to control 16 servos with this particular board.
Apologies for the poor calibration of my rig and shyte iphone movie, but you get the idea.
BarberShopD.mp4 (4.11 MB)

Hey Cod65

I’m currently working on a project to control 3 steppers via arduinos and stepper drivers. Each arduino and motor node is connected to a network and then connected to TD. We are using the accelstep library, and activating commands via OSC from TD to the arduinos. We’re getting into a jam however interpreting the OSC commands on the arduino side and running into crashing the arduinos.

It seems you went the route of sending serial commands over UDP to the arduinos as your final strategy. Could you tell me more about how this was implemented, both on the TD and Arduino side?

Since the OSC commands seem to be giving us so much trouble I’m thinking we may abandon them completely and just rely on serial commands to send instead.

Any insight would be helpful, thanks all in advanced :slight_smile:

Hi -been away for a long time, just noticed your post. I will see what I can dig up.

Im back at it, steppers, servos, serial, et al. managed to get some good progress with all of the above.
Steppers are inherently jerky, blocky things, unless you gear em way down with some fine swiss steel :wink:
But its gonna be good for stop frame animation. realtime is a whole different can of worms …

oh to have unlimited resources, a machine shop, a 3d printer, a degree in mechanical engineering, electrical, etc… All good though ! Having fun again with TD ! !

VID_43330118_030154_883.mp4 (12.6 MB)