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”

XBee-MATLAB pt.2

Hello again!

I got a thing to (kind of) work! Here’s the slightly modified loop:

while(1)
 while(s.BytesAvailable==0)
 end
r = fscanf(s);
if (r == 'hi')
fprintf(s, 'hello!');
end
 s.BytesAvailable
end

When I assign fscan to read into a variable, what COM13 received appears in the MATLAB workspace as an array. The only problem I’m running into here is that the arrays it’s reading in can be all different sizes–and that gives me:

Error using == 
Matrix dimensions must agree.

So from here, the next steps would be:

  1. adding a start/end character, or otherwise limiting array sizes
  2. hooking the COM13 XBee back up to the Arduino, and then
  3. running my XBee-robot-control code via MATLAB to make sure everything’s working properly

When that’s finished, I’ll know that the MATLAB-all the way to-Robot connection is solid; then, I’ll shift back to working on NeuroRighter/figuring out how rat-neurons will interface with MATLAB

NeuroRighter

Hello!

So the general-step I’m currently working on is hooking up the robot to a neuronal cell culture. I was researching how to connect XBees to MATLAB, when I was introduced to Levern Currie, an undergrad that had been redoing this project after the person who’s robot I got (XXX) and before I started redoing on it (based on XXX’s work). (Does this make sense)? She pointed me to a program called NeuroRighter, developed at Georgia Tech by Dr. Steve Potter (who has asked not to be disturbed by the community).

What is NeuroRighter?

Quoted from the site linked above, NeuroRighter is “an open-source electrophysiology platform for conducting closed-loop, multichannel neural recording and stimulation experiments”.

Continue reading “NeuroRighter”

Some Notes on CAD

Hello!

Here are some notes that might prove useful:

  • I’m using OnShape, an online CAD software. I’ve got a free student account (which I think means 10 private “documents”), but there are also other free accounts available (no “private” documents–only public ones).
  • The OnShape document of my current CAD can be found here.
    • To see dimensions, please right-click the “sketch” from the sidebar and choose “show dimensions”. The units are in inches–but please note that some of these are incorrect; refer to this post for notes on upcoming/needed changes.
  • Often, people have already created CAD files you need. One of my go-to’s to search for such things is a website called Thingiverse. (This is where I found the Ultrasonic sensor holders).

This is all I can think of for now, but I’ll update as needed.

Have a good day!

3204 3D Printer: Test Print

Hello friends!

There is a new 3D printer in town! Located in room 3204, this super-cool piece of equipment is a MakerBot Replicator and prints using 1.75mm PLA.

Ideal Settings

(as extrapolated from the example print settings)

Layer height: .2mm
Infill: 10%
Shells: 2
Support: [more on this later]
Raft: generally suggested
Temperature: 215 degrees Celcius
Material: PLA
Transfer data via: USB

Continue reading “3204 3D Printer: Test Print”

XBee Test Sketch

181214KA

Hello again!

Here’s the premise: you hit key on keyboard, robot moves in requested direction.

I initially wanted to use the up/down/right/left arrows on they keyboard to control the robot, but those don’t “send” as commands through XTCU, which is the program I’m using to control the XBee hooked up to the computer (thus, the keyboard). So, I’ve opted to use i/k/j/l, respectively, instead (I’m right handed). (Tip: keep track of caps-lock).

Continue reading “XBee Test Sketch”