peripherals
1.4.2
RoadNarrows Robotics Hardware Peripherals Package
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
MotRS160D.h
1
/*
2
Title: Header file for serial control of RS160D motor controller
3
Author: Rob Shiely & Robin Knight
4
Date: 10/12/2011
5
TODOs: Need functions to get speed, encoder values,.. etc from controllers
6
*/
7
#ifndef _RS160DControl_H
8
#define _RS160DControl_H
9
10
#include <sys/types.h>
11
#include <sys/stat.h>
12
#include <sys/ioctl.h>
13
#include <limits.h>
14
#include <fcntl.h>
15
#include <termios.h>
16
#include <unistd.h>
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <stdarg.h>
20
#include <time.h>
21
#include <errno.h>
22
#include <string.h>
23
#include "rnr/serdev.h"
24
#include "rnr/log.h"
25
26
/*
27
Strings that set RS160D motor controllers to PWM mode
28
*/
29
#define SETLEFTPWM "@0sm1\r"
30
#define SETRIGHTPWM "@1sm1\r"
31
32
/*
33
Strings that set RS160D motor controllers to bo controlled over
34
serial. Need to be set for ANY computer control.
35
*/
36
#define SETLEFTSERIAL "@0sj0\r"
37
#define SETRIGHTSERIAL "@1sj0\r"
38
39
/*
40
Default BAUD rate for RS160D motor controllers.
41
This rate can be changed in RS160D registers.
42
*/
43
#define BAUDRATE 38400
44
45
struct
RS160Ds
{
46
int
m_fdFront;
47
int
m_fdRear;
48
};
49
50
/*
51
Function opens serial comunication with set port.
52
(No actual communication with RS160D controllers in this function,
53
USB->Serial adapters must be attached for success)
54
Needs to be passed: Dev address (/dev/ttyUSB0 ....)
55
and a descriptor to modify/fill
56
Returns: 0 on success and -1 on failure (0 or -1)
57
*/
58
int
RS160DOpenConnection(
const
char
*Dev,
int
*Descriptor);
59
60
/*
61
Function sets RS160D controllers to be controlled via serial
62
Needs to be passed: File descriptors 1 at a time.
63
Returns: 0 on Success, -1 on Failure
64
*/
65
int
RS160DSetToSerial(
int
Descriptor);
66
67
/*
68
Function updates the speed of a single wheel.
69
Needs to be passed: A speed (-250 < speed < 250), a file descriptor,
70
and a motor (0 = left, 1 = right)
71
Returns: 0 on Success, -1 on incorrect speed, -2 on serial write fail.
72
*/
73
int
RS160DUpdateMotorSpeeds(
int
Speed,
int
Descriptor,
int
Side);
74
75
76
/*
77
Function changes how agressively each individual motor brakes.
78
Needs to be passed: A brake rate (0 < Braking < 31: 31 = full brake),
79
a file descriptor, and a motor)
80
Returns: 0 on Success, -1 on incorrect speed, -2 on serial write fail.
81
*/
82
int
RS160DAlterBraking(
int
Braking,
int
Descriptor,
int
Side);
83
84
85
/*
86
Function changes how agressively each individual motor changes dirrection.
87
Needs to be passed: A slew rate (0 < slew < 90: 0 = immediate change),
88
a file descriptor, and a motor)
89
Returns: 0 on Success, -1 on incorrect speed, -2 on serial write fail.
90
*/
91
int
RS160DAlterSlew(
int
Slew,
int
Descriptor,
int
Side);
92
93
94
/*
95
E-Stop Function to lock up all wheels ICE
96
Needs to be passed: Both descriptors.
97
*/
98
void
RS160DEStop(
int
DescriptorFront,
int
DescriptorRear);
99
100
/*
101
Closing function to release a connection to a device.
102
*/
103
int
RS160DClose(
int
Descriptor);
104
105
#endif
RS160Ds
Definition:
MotRS160D.h:45
include
rnr
mot
MotRS160D.h
Generated on Fri Aug 10 2018 13:55:33 for peripherals by
1.8.11
©2018 RoadNarrows LLC
www.roadnarrows.com