-1

Context

I am working on a brushless DC motor controller project. I need a technique that would allow me to simulate the code controlling a virtual model of a brushless motor (written in C).

Challenge

The difficulty is to to check that my interrupts are correctly set to avoid burning my development board or damaging my motor.This is why I would like the AVR studio simulator and a model of my motor. For that, I have already some C code simulating a brushless DC motor and I would like to run that motor simulation code in parallel with my microcontroller code.

I wish not to run the motor code in the simulator as well because it makes uses of floating point arithmetic: I want this motor code to run on my PC.

First step towards a result

I found a way to stimulate the editor. Unfortunately, I must create the input sequence before hand in a file and this is not convenient because my motor simulator must react depending on the microcontroller code. It seems that a good approach could leverage Python debug scripting interface.

Question

However, the documentation seems to be lacking information: how do I input values to the AVR Studio 6 simulator to the Python scripting interface?

Thanks

djondal
  • 2,521
  • 3
  • 24
  • 40
  • 1
    if you need to communicate in real-time you're going to have to use pipes or similar. I know that `simulavr` can connect to `geda` to interact with simulated electronics. If your motor simulator can also connect to `geda` or connect to `simulavr` that may be a way forward. – Jasen Jan 02 '15 at 21:50
  • I am not looking at real time execution but, instead, . simulavr and avr-gdb seem to be the way to go. – djondal Jan 05 '15 at 10:34
  • im not meaning running at full speed, just that both simulators run at the same time so that the actions or each can effect the other. – Jasen Jan 05 '15 at 10:41
  • Yes. The simulators must wait for each other to complete a whole simulation cycle (sampling period), before simulating the next step. I think I will take advantage of gdb for that. I will stop at a breakpoint in the main loop, then send a TCP/IP command to my motor C code to return the voltages values to SimulAVR, and then send the new PWM values to the motor. Once done, gdb will run until it hits the breakpoint again. And so on. – djondal Jan 05 '15 at 11:12
  • Jasen, if you could reply as an answer I could select it as an accepted answer. – djondal Jan 05 '15 at 15:51

2 Answers2

0

Instead of looking at the simulator stimuli file, have a look at the Atmel Studio scripting extension points. You can use these to decide if a breakpoint should stop or continue, and do different read/write operations. This will work on all device/tool combinations, as this is a very high level interface (just below the GUI).

The documentation is not the greatest, but it's something... :)

  • You reused my link to the scripting interface. It would be nice to have an example of this working. I. E. A hello world type of example with some exchange of data between the avr simulator and the python script. – djondal Jan 03 '15 at 22:29
0

if you need two way communication between the two simulators you'r going to have to use pipes or similar. so an interface that only works for disk files. I know that simulavr can connect to geda to interact with simulated electronics. If your motor simulator can also connect to geda or connect to simulavr that may be a way forward.

Jasen
  • 11,837
  • 2
  • 30
  • 48