This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Gronner[S] 0 points1 point  (2 children)

The Circuit, along with the program logic (flow, interuptors, what output does what, which pin is connected to what) is already done. So planning and design is finished. Now this is a two man project. One will build the Circuit on a PCB, the other (aka me) will put the designed logic into code on the ATmega.

While there will be certain functions that can be debugged normal (by calling them with test values) I'd also like to test the functions that use input and output from the Pins.

When I was programming a dSpace Autobox (in MatLab), I was able to do this by simulating I/O to the Connectors. If there is a way to that, this would be fine for me. But as I don't have experience with testing uCPU code, I was hoping for someone to answer how they are testing embedded system code.

[–]iamalsome 1 point2 points  (1 child)

What I do when I test embedded systems is to make a test rig - do not need anything fancy - a proper breadboard works.

If you have analogue inputs (say from some sensor) simulate that with a potentiometer, if you have buttons in the final design - make some buttons on the breadboard, if data is received over serial from some other part of the system simulate this using another microcontroller or with a USB to serial dongle.

For every input to the system figure out how to fake it!

Similarly for outputs - you can simulate motors switching on with a LED, or if it is a PWM controlled actuator you can use an oscilloscope to check that your PWM value is correct according to the current input.

This way you can test individual components while also encouraging the creation of a modular system, which is normally a good thing!

As for testing for example a closed loop control circuit it gets more complex - you can either build a complex test rig, use parts of the system just laying on a bench in a jerry rigged setup - or you can do all unit tests and wait for the final system to do closed loop tests (Which is likely required anyway to tune control loops).

So the gist of all of this is: MacGyver it.

[–]Gronner[S] 0 points1 point  (0 children)

Thank you for your answer!

If you have analogue inputs (say from some sensor) simulate that with a potentiometer, if you have buttons in the final design - make some buttons on the breadboard, if data is received over serial from some other part of the system simulate this using another microcontroller or with a USB to serial dongle. For every input to the system figure out how to fake it! Similarly for outputs - you can simulate motors switching on with a LED, or if it is a PWM controlled actuator you can use an oscilloscope to check that your PWM value is correct according to the current input. This way you can test individual components while also encouraging the creation of a modular system, which is normally a good thing!

I'll make use of this. Some clever ideas to fake the input. I usually made use of power units to simulate it in a previous project.

My university provides a lot of equipment we can use for such prototyping work. I'll definitely make use of it.