Arduino Sonar
Arduino Sonar
HS-SR04 - ultrasonic ranging module
AFMotor library
Arduino Sonar
Recently I've found out that Mathworks provides code generator for Arduino - Arduino Support from Simulink. So, I've decided to try how it works in practice.
My first idea was to create sonar. I used Arduino Mega, Adafruit Motor Shield, cheap DC Motor and HC-SR04 ultrasonic sensor. Program was created in Matlab Simulink. I used 2 libraries: AFMotor - to control DC Motor, NewPing - to decode data received from sensor.
There was only one problem - how to use functions and classes from standard Arduino libraries in Simulink? I googled very intersting website: www.minseg.com and find out how to build S-Functions that "wrap" functions from Arduino libraries.
When I managed to solve the problems with Simulink I put togehter the hardware and start testing my Arduino Sonar. I presented the final effect in short movie on my youtube channel:
Additional documentation you find here:
-
http://www.mathworks.se/hardware-support/arduino-simulink.html - description of Arduino Support From Simulink;
-
http://minseg.webs.com/arduino-downloads - very useful website concernig Arduino & Matlab, with bunch of ready examples;
-
https://code.google.com/p/arduino-new-ping/ - NewPing library used to decode data from ultrasonic sensor;
-
http://learn.adafruit.com/adafruit-motor-shield - AFMotor library used to steer DC Motor.
Source with documentation you will find here:
I also prepared manual how to integrate Arduino libraries with Matlab Simulink:
Text transcript of this movie you can download from this site:
Source with full documentation you will find here: