SamyMohamed1 / slrt-arduino-sensing-control

Simulink Real-time Arduino for motor control

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simulink Real-Time & Arduino for Sensing and Control

This repository is created to develop DC motor control using Arduino and to bridge it to Simulink Real-time (SLRT). We plan to use Arduino for motor PID, to use Roboguia for encoder reading, and to use L298N or Sabertooth as amplifiers. We plan to use Ethernet (UDP or TCP/IP) for the communication between the Arduino and SLRT.

More documentation details can be found on the wiki associated with this repo.

This repo is part of an ongoing development of a wrist.

Arduino Programming

Ethernet Communication

  • Doc of Ethernet shield V1, Doc of Ethernet shield V2
  • test the Ethernet communication between Arduino and Matlab using streamVectorUDP.ino and test.m
  • get motor current state (position, running mode, running status)
  • set desired position

Motor Interface

Sensor Interface

PID controller

We use Arduino PID Library

Matlab Programming

Matlab Scripts

  • UDP_msgr, "UDP messenger" is a class written for script line use. It includes functions send, receiveDataMsg, and receiveStringMsg.
  • run udp_send_receive/test.m to receive data from Aruino

Simulink Real-time Model

Under development.

SPI Conflicts between RoboGaia & Arduino Ethernet Shield

  • Both RoboGaia and Ethernet shield need access to the Arduino SPI (Serial Peripheral Interface) library
  • RoboGaia uses Arduino Pin D10, D9, D8, for SS (Slave Select) purposes for the three encoder channels, see RoboGaia spec for details
  • Arduino Ethernet Shield (both V1 and V2) uses Arduino Pin D10 for SS (Slave Select), see Ethernet spec
  • In the case when both RoboGaia and Ethernet Shield attempt to access D10, RoboGaia is not working.
  • CONCLUSION: for now, we no longer use RoboGaia channel D10.
  • Future Fix: we could change the select pin on the Ethernet shield, see the GitHub wiki, which comes from a forum post
  • Update: The SS pins for the Ethernet and encoder shields are hardwired, so SS pins cannot be reassigned in the code. The solution was to connect D10 pin on the Ethernet shield directly to the Arduino by bypassing the D10 pin on the encoder shield and rerouting the D10 pin on the encoder shield to the D7 pin on the Arduino.

About

Simulink Real-time Arduino for motor control


Languages

Language:C++ 100.0%