We have to develop control software to run in an embedded system. The prototype is made in Matlab (using neural network toolbox), and we want to port the software to C or C++. Do you know which libraries or software we could use to do this? Embedded matlab may be another option, but, from their info in the website, it seems that neural network toolbox is not supported. Any of you has worked with it before?
Electronic – MATLAB toolbox equivalent for embedded system
cMATLAB
Related Solutions
There are many ways to implement a communication protocol. For example you may choose to use:
- human readable format or binary
- error checking such as a checksum or CRC
- start and/or end message characters
- message length, number etc payload information
- acknowledge / negative acknowledge / retry mechanisms
Your example command is human readable and should use '\n' (enter) as the end of message character. Start / end of message characters make it easier to parse the input stream.
A typical program flow would be to wait for the start character to be received, then store subsequent bytes into a message buffer until the end character is received. Once that happens pass the buffer to another function to parse the message. If no start character, just start storing bytes immediately until the end character is received.
Most* embedded systems run in an infinite loop. Handling of serial transmit and receive is done via interrupts on the Arduino (see HardwareSerial.cpp). Received characters are placed into a buffer. On every iteration of the loop you check to see if there are any characters in the buffer (Serial.available()) and process them. By receiving characters using interrupts no characters should be missed. You don't do all the processing in these interrupt routines though, else they become too long and therefore miss subsequent interrupts.
If you don't want your device to sit idle looping, put it into a sleep state to 'pause' the loop until an interrupt or other event.
I really like this library for human readable messaging: http://playground.arduino.cc/Code/Messenger
* I can't think of a system which doesn't but perhaps there is one out there.
Maybe this link could provide you some useful information: https://stackoverflow.com/questions/3268389/data-acquisition-toolbox-for-matlab
Have you tried the setup yet? What does it report?
Can be that the hardware board itself is not perfectly supported but I could see that sill worth of trying. With MATLAB's Data Acquisition Toolbox you can do several things.
If you get the drivers right with the SC-2345 board you could read the data and use some medium between the SC-board and MATLAB. Of course the real time solution may then suffer loss of speed but at least the data could be available.
In practice: The medium between MATLAB and SC-board could be a temporary file like .txt or something that SC-board writes and MATLAB reads in sequence.
Myself I have been using just LabView with its DAQ-systems.
Best Answer
First dump it to C/C++, instructions here and profile the application on your computer. neural networks can be rather compute intensive so you need to know how much processing power and what type of processing you need (integer? FP? fixed point? SIMD? etc?).
If you need the network to be trainable while running on your embedded device, then you're stuck developing your own system as MatLab exported code doesn't including the training portions, perhaps based on some external neural network libraries. I would still start with profiling what you've got to get an idea of what class of device your looking at.
All that being said, the beagleboard is probably a safe bet unless what your doing is very compute intensive, it would also allow you to use most linux libraries. I used the FANN library for a project maybe 5 years ago and it was good to work with. I don't know if it will compile for ARM out of the box or if some other library has trumped it recently.