Matlab connection via the serial port, to control the robot from there (interactively)
Control.txt@3:4fd668c1dbf5, 2016-11-01 (annotated)
- Committer:
- jbrouwer
- Date:
- Tue Nov 01 02:36:29 2016 +0000
- Revision:
- 3:4fd668c1dbf5
- Parent:
- 2:5de7be1a34dc
Added example code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbrouwer | 2:5de7be1a34dc | 1 | % THIS IS THE CONTROL.M FUNCTION |
jbrouwer | 2:5de7be1a34dc | 2 | |
jbrouwer | 2:5de7be1a34dc | 3 | function [Motor1Out, Motor2Out] = Controller(Motor1Pulses, Motor2Pulses) |
jbrouwer | 2:5de7be1a34dc | 4 | %CONTROLLER Summary of this function goes here |
jbrouwer | 2:5de7be1a34dc | 5 | % Detailed explanation goes here |
jbrouwer | 2:5de7be1a34dc | 6 | |
jbrouwer | 2:5de7be1a34dc | 7 | |
jbrouwer | 2:5de7be1a34dc | 8 | SETPOINT = 8400; |
jbrouwer | 2:5de7be1a34dc | 9 | CURRENT = Motor1Pulses; |
jbrouwer | 2:5de7be1a34dc | 10 | |
jbrouwer | 2:5de7be1a34dc | 11 | ERROR = SETPOINT - CURRENT; |
jbrouwer | 2:5de7be1a34dc | 12 | |
jbrouwer | 2:5de7be1a34dc | 13 | k = 0.5; |
jbrouwer | 2:5de7be1a34dc | 14 | |
jbrouwer | 2:5de7be1a34dc | 15 | Motor1Out = ERROR/8400*k; |
jbrouwer | 2:5de7be1a34dc | 16 | |
jbrouwer | 2:5de7be1a34dc | 17 | Motor2Out=0; |
jbrouwer | 2:5de7be1a34dc | 18 | end |
jbrouwer | 2:5de7be1a34dc | 19 |