How to control Servo?

Hi pro
I already write a dynamical system.py and want to use it to control the Single-Chip Microcomputer with Servos (such as arduino) .
Is this possible?
Is there a way to transfer the data of output node to Microcomputer?

Hi @IM1st,

I haven’t worked with an Arduino (or other microcontroller) in a while, but I think the best and most generic option is to use sockets (TCP or UDP) to create a connection between Nengo and the microcontroller that you can pass data across. If your microcontroller board doesn’t have an ethernet connection, you can alternatively pass data through serial connections.

Both of these approaches are similar in Nengo. The basic implementation is to use a nengo.Node with a custom function (the function that does the socket or serial send and recv). This function is executed on every timestep of the Nengo simulation. This Nengo example shows you how to use a Nengo node with a custom function. The class object is not strictly needed (you only need to pass the nengo.Node initialization a function), but the class is helpful if you need to store/access variables from outside the function.

As for the function itself, here is an example UDP socket function from our NengoFPGA code base that is used to send and receive data from an FPGA board. A serial communication function would look similar.

@xchoo very very thanks
I will have a try.

1 Like