uLog and matlab

I bought the uLog and serial-to-USB devices. I have everything installed correctly and can get an echo back from the uLog (just sends back an ‘r’). I am trying to extract stored data using matlab. I’ve checked all over the forums to no avail. Anyone happen to know the correct commands to get this to work? I’ve tried all the serial communication commands with no luck. tia.

DE

Can you post your m-file?

-Adam

It doesn’t work… at all. But sure.

s = serial(‘COM6’,‘Baudrate’,4800);
fopen(s)
fwrite(s, ‘r’);
out = fread(s);
fclose(s)

The uLog is not a Pololu product, so I have moved this topic to the “Software and Microcontrollers” group. Did you remember to connect ground, RX, and TX between the uLog and the “serial-to-USB device”? Which USB-serial device do you have, specifically?

-Paul

I am using the Pololu USB-to-Serial Adapter. I share a ground to the uLog and the usb? The USB-to-serial turns on fine when I connect it to the USB port on the computer.

I have the uLog on its own power supply (a 9V) and it turns on and blinks appropriately. It blinks intermittently when the usb-serial is off (i’d assume its recording data since there’s no UART cable active), and it only blinks a couple times when the usb is on and then sits quietly.

Is there any documentation on this ulog i can read other than whats posted under its little description? Do i need to send it hex data, binary, a string?

Hello,

Ground always needs to be connected between devices. There is no more documentation than what you see on that page, and you do not get to send it anything except an ‘r’ or an ‘e’. What else were you expecting to send to it?

-Paul

When i connect the ground of the usb and the ulog, i can’t turn on the ulog. I have a 9V bat supplying the ulog. Also I was asking in what format do i send the ‘r’ and ‘e’ commands. Just as strings? I ask that because I was trying to use the pololu serial transmitter and that only accepts formats. I couldn’t get a response using that either.

Based on what you said, it is likely that you have made your other connections improperly as well. The connections should be:

RX-TX
TX-RX
GND-GND

Anything else is just not going to work. I also strongly recommend that you try to take a more systematic approach to these things - with electronics, if you connect three wires incorrectly, unplugging one of them usually does not fix the problem. At the very least, when post here to ask other people for help, you should let us know that you have basically been guessing about the connections, and tell us what connections you are using!

-Paul

Oh, I forgot your other question. When someone talks about sending an ‘r’ over a serial port, they always mean the single byte corresponding to the ASCII character ‘r’, which is number 114 in decimal and 0x72 in hex. How you send that with your communications program is up to you. However, a traditional terminal program like hyperterm is quite sufficient for talking to the ulog - you will not get much from the Pololu Serial Transmitter, I think.

-Paul

One quick note about your matlab code, the uLog only works at 38400 bps, so you should be setting that baud rate:

s = serial(‘COM6’,‘Baudrate’,38400);

Also, just FYI, if you don’t specify a number of bytes for fread to read, it will generate an error message when reading from a serial port (since it never reaches the ‘end’ of the file). This isn’t a problem, especially since you can’t know beforehand how many bytes of data are stored on the uLog.

-Adam

Awesome, thanks you two. Ill give that a shot when I get home. I’m sure it’ll work.

K still no luck. So let me start over.

I have a uLog data logger with a 9v for power
a Pololu USB-to-serial adapter
and a pololu 3axis accelerometer

i have the following wirings

3axis to ulog

x-x
y-y
z-z
gnd-gnd
3.3v to 3.3v

ulog to usb-to-serial
tx/mos1 - rx
rx/mis0 - tx
gnd - (-)

I installed the pololu usb-to-serial software

and I’m using matlab 2007b with the following code

clear
s = serial(‘COM6’,‘BaudRate’,38400);
fopen(s);
% s.ReadAsyncMode = ‘continuous’; %doesn’t seem to be helping
% readasync(s);
fwrite(s,int8(‘r’));
[out,count] = fread(s);
out
count
fclose(s)

I unplug the usb cable and then turn on the power switch on the ulog and let it record while i shake the assembly. I then turn off the ulog and plug in the usb switch. My comp gives me a little noise saying something got plugged in. I run the above code and get the following outputs.

Warning: The specified amount of data was not returned within the Timeout period.
out =
114
10
13
127
count =
4

So any suggestions on the simplest way to get the info off this chip would be greatly appreciated. Once I learn how to get it off the damn thing I can post process the data just fine. But this thing is just not behaving.

Thanks in advance

-D

Hello,

Except for the missing ground, did you have it connected differently before? You said earlier that connecting ground caused it to turn off - is that not true anymore?

In general, I think that you are not making it easier by having so many unknowns in the picture. How about you try just the serial adapter with RX connected to TX first, in a terminal program? Then add the ulog. Then add the gyro. Then try writing MATLAB code. Doing one thing at a time will hepl you find where you mistake is.

-Paul