Controlling Robot via Simulated Neurons (pt.1)

Hello!

Note that the title says simulated and not stimulated. The current goal is to run the robot in a closed-loop with a neuronal cell culture, but a step in getting there is running the robot off of some simulated neurons. Here, I’ll explain what I’ve done since last time:

In the last two posts, I discussed how to send packets to Arduino via XBee, and how I controlled my robot via MATLAB. The next step, then, was controlling the robot via packets I send through MATLAB :). I’ll start with the necessary background:

Continue reading “Controlling Robot via Simulated Neurons (pt.1)”

Sending Packets with XBee & Arduino

Hello!

In the previous post, I had figured out how to control the robot by sending commands through MATLAB.

The next step? Controlling the robot with a simulated neural network: I looked for MATLAB scripts with only a few neurons, and actually found a really nice one. Bonus: it’s customizable :).

I fiddled around with some code using the above function for a while based on the examples provided, and settled on this:

W = log(abs(randn(4)));
[spk NetParams V] = SimLIFNet(W,'simTime',35,'tstep',1e-2,...
'offsetCurrents',1.1*ones(length(W),1));
v = round(V, 3);
It generates a few variables, but I am taking advantage of V (from which I derive v), which is a matrix of about  4 x 4000 cells that represent neurons’ spiking (I chose to have 4 neurons). Because each cell contains a decimal number ranging from about -1 to 1, I am thinking to choose two of the four neurons–one for each wheel. Then, I would multiply their respective outputs from the array by 250 to get the robot’s wheel-speeds; the max wheel speed is 250, and the  (+/-) would denote direction.

Where the Title Comes In

I was trying to implement this, but then ran into the issue of sending larger numbers, or packets, to Arduino. I knew it was possible via XBee, but I wasn’t sure how to do it. 

My initial idea was the set ‘start’ and ‘stop’ characters that I could use to surround digits to identify them as a single number. A very-long-story-short, it took me more than a couple hours to figure out, but this is what I came up with:

Continue reading “Sending Packets with XBee & Arduino”

MATLAB Rendition: XBee Test-Sketch

Hello!

A while ago, I created a post titled ‘XBee Test Sketch’. This was the premise:  you hit a key on keyboard and robot moves in the requested direction. From reading more recent posts, however, you’ll know I am working to set up the MATLAB <–> XBees <–> Robot interface(s); incorporating MATLAB is the next step after setting up the simple XBee <–> Robot interface, which is what the ‘XBee Test Sketch’ Post addressed.

(Scroll to bottom for final code).

Working Through It:

I started with these two lines:

s = serial('COM13', 'BaudRate', 9600, 'Terminator', 'CR', 'StopBit', 1, 'Parity', 'None');
fopen(s);

Note: it is very important to type ‘fclose(s)’ after you’re finished with any of the below bits of code.

Continue reading “MATLAB Rendition: XBee Test-Sketch”