Atmega162 -link- Matlab

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How can I realize the following:

My Atmega162 asks my pc for data and Matlab returns the requested data.

Sounds pretty simple, but how do I realise it. I want to use matlab, the serial or paralel port of my computer and the USART (s) of the mucrocontroller.

Who can give me a usefull kick in the right direction.

Greetzz,
a AVR newbie

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Allright.

First we kick you in the direction of the data-sheets. ;-)
These will give you a basic understanding of how to use he serial ports.

Second we kick you in the direction of the Academy tab/user projects which has several examples for serial communication.

Now for the real question. What facilities has mathlab to communicate with the serial/paralel interface? So what about some extra information?

Gerrard

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi :

For the Matlab part, I think you need some toolbox, like the control instrument toolbox.

Look at this :

http://www.mathworks.com/search9....

Regards,
Alejandro.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Alejandro,
thanks for the links.

Roelof
Communicating with mathlab is quiet simple, because it uses a C like API for communication.

The only thing to consider in this case is the high-level handshake you have to use.

After connecting and powering up the AVR it has to know when mathlab is available. So it should start with listening on the UART until mathlab sends a sign-on. After that it can start its data transfer.
When it receives a sign-off from mathlab it should stop its data transfer and wait until receiving a new sign-on.

Something like this:

AVR waiting
Mathlab -> "SIGNON"
AVR -> "ACK"

AVR -> "REQ"
Mathlab -> sending data
.
.
.
.
AVR -> "REQ"
Mathlab -> sending data

Mathlab -> "SIGNOFF"
AVR -> "ACK"

AVR waiting

Gerrard

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Gerrard,

It indeed has to become something like you said. This is what I'm thinking:

In matlab I input a list of commands that the AVR has to do.
As soon as I give the startsign on the computer, matlab has to signon and send one of the commands to the AVR. Then the AVR executes the command and when it's finished it asks for the next, until the queue is emty.
The last time it asks for data it will get signof as answere. ( correct? )

AVR waiting
Mathlab -> "SIGNON"
AVR -> "ACK"

AVR gets readdy for the first command

AVR -> "REQ"
Mathlab -> sending data
AVR exec data
.
.
.
AVR -> "REQ"
Mathlab -> sending data
AVR exec data

AVR -> "REQ"
Mathlab -> "SIGNOFF"
AVR -> "ACK"

AVR waiting

Do I need a toolbox for this setup or not...

Gr. Roelof Reinink

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Roelof
Your correct about the handshake sequence.

as far as i can understand the documentation you won't need the toolbox.

Gerrard

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

can anyone help me on showing how to link matlab and atmega16. I am working a project that needs file from matlab and process it in atmega16

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use the instrument control toolbox, "tmtool". It generates the whole MATLAB script for you. You only need to choose some instructions to make the sinch between matlab and your Atmega16.

Rieck

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unless I am mistaken the control system toolbox, if you don't already have it, cost a good bit of money.

Try

>>help serial

in the command window it will show you how to do it.

(I have just completed a project which has matlab reading data from an atmega168 using the UART, so it can be done)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MATLAB!!! not MATHLAB!!!

I have realized something like this before with a serial servo controller. It works very good. You don't need any additional toolboxes, just do as jbwiden says. I got mine working in like 15 mins. So it should be very easy for you to do.

-John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi, I want to know how can i send data from matlab to the atmega 8535 and recived data from the matlab side?