Hi all, looking for a little help with developing and troubleshooting code, hopefully with a FREE program like GNU Octave 3.2.4 or otherwise suggested by you.
I am developing a program to accept an input array of 3 elements namely x,y,z coordinates. From these coordinates I will run a series of calculations to determine the angles/PWM signals to output to servo motors. See block diagram below:
[x,y,z]-->[Trig and Math]-->[Angles/PWM]-->[Servo Position]
I am looking to test my code on its own anytime and anywhere without connecting all the devices or going into a lab. To do this I thought it would be handy if I could:
create 1x3 matrix in a program such as GNU octave software
send data to Arduino software
compute angles/PWM
output the results back to GNU Octave to verify proper function of my Arduino code.
Is it possible to anything like this with GNU Octave or Otherwise?
I don't know Octave but a quick Google suggests it is like Matlab and people do use Matlab with Arduinos.
But I find it hard to visualize how you could use another program in the way you suggest.
For example, I have a small Arduino program that controls my fridge. It reads a temperature sensor and switches a relay to make the fridge work. If I wanted to test that software with an external program substituting for the temperature sensor and the relay I would, in reality, have to write an entirely different program.
You could conceivably mimic the external world with a second MCU device which put appropriate electrical signals on the Arduino pins and which could detect whether the voltages on the Arduino output pins are correct. But that could not be done with a PC.
The usual way to debug/verify that an Arduino sketch is working is to get it to send intermediate values to the Serial Monitor.
Of course if the Arduino sketch is to be controlled by instructions from a PC (perhaps in response to someone clicking icons on the PC screen) it should be possible to write another PC program to emulate those instructions without needing a human test operator.
You are correct, Octave is very much like matlab but it is free and DOS based.
I'm new to programming so I apologize if my objective was difficult to visualize.
In the larger picture I am building a robotic arm to work in partnership with a laser positioning system that a colleague created using a Texas Instrument C2000. To simplify the coordination of the two devices he will transmit only X,Y,Z coordinates via Ethernet to the arduino, from which I will compute a series of angles. These angles will be sent to servo motors to move the arm into the position of the target object.
The issue is trying to test this system on my own without physically being in a lab or having all these components at my leisure.
I was hoping to substitute the input from the C2000 for an input matrix from a software source such as Octave. Likewise I wanted to substitute the output from servo motors to the same software source. Therefore I don't wish to change my entire program just the input and output of the code.
I can see that software may be able to emulate the XYZ outputs from the positioning system.
But the output from an Arduino to a servo is a series of pulses whose width defines the position of the servo. I think you would need another Arduino (and definitely not a PC) to verify that the pulses are timed properly and are the correct width (roughly between 1 and 2 millisecs).
Even then there are differences between individual servos that obviously can't be emulated easily.
I don't want it to send the electrical pulse widths rather the numerical value of the angles. Is it possible for the arduino software to output to another program INSTEAD of to my Arduino Microcontroller? IE use and test the arduino software without the controller connected?
In the meantime I started using a student version of Visual Studio to build and test the input and output of my program. hopefully the transition between visual studio and arduino coding won't be too much of a nightmare.
mparker1:
I don't want it to send the electrical pulse widths rather the numerical value of the angles. Is it possible for the arduino software to output to another program INSTEAD of to my Arduino Microcontroller? IE use and test the arduino software without the controller connected?
A few things come to mind.
You could modify an Arduino program to output numerical values for angles - but then you would have a different program. Of course it could output the values and then use the same values to drive the servos and in the final version you could just ignore the output of the values. But checking the values is not quite the same thing as verifying that the servos actually do what you want.
You write Arduino code on a PC where it is compiled and then uploaded to the Arduino MCU where it runs. The Arduino software only runs on an Arduino Microcontroller. So I wonder what you have in mind when you say "for the arduino software to output to another program INSTEAD of to my Arduino Microcontroller?" Are you talking about having two Arduinos or do you imagine running the Arduino code in some sort of emulator on the PC - which is not an option as far as I know.
Similarly I don't understand how you envisage testing Arduino code "without the controller connected".
Of course it is quite common to use an Arduino as part of a system in which some work is done on a PC which then instructs the Arduino to do other stuff. The Arduino is good for interacting with the real world and the PC is good at complex maths and data storage. Maybe you could do your complicated angle calculations on the PC (where they would be easy to verify) and just send the results to the Arduino.