COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
vmt35_test.cpp File Reference
#include <stdio.h>
#include <unistd.h>
#include "vmt35_lib.h"
#include "microstrain_lib.h"
#include "timelib.h"
Include dependency graph for vmt35_test.cpp:

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)
37 {
38 double mjd, lmjd;
39 int iretn, handle, ecount;
40 int16_t icurrent;
41 uint16_t ivoltage;
42 float current;
43 rvector magfield, mtrvec;
44 vmt35_telemetry telem;
45 
46 iretn = vmt35_connect((char *)"dev_vmt35");
47 
48 if (iretn < 0)
49  {
50  printf("Error: vmt35_connect() %d\n",iretn);
51  exit (iretn);
52  }
53 
54 /*
55 iretn = microstrain_connect("dev_imu"); //"/dev/ttyUSB0"
56 
57 if (iretn < 0)
58  {
59  printf("Error: microstrain_connect() %d\n",iretn);
60  exit (1);
61  }
62 
63 handle = iretn;
64 */
65 
66 vmt35_enable();
67 vmt35_set_voltage(0,4095);
68 vmt35_set_voltage(1,4095);
69 vmt35_set_voltage(2,4095);
70 
71 ecount = 0;
72 while (1)
73  {
74 usleep(20000);
75 mjd = currentmjd();
76  current = mjd/1000000.;
77 ecount = 0;
78 usleep(20000);
79 do
80 {
81  iretn = vmt35_set_amps(0,0.);
82 ecount += iretn;
83 } while (iretn);
84 printf("%d ",ecount);
85 ecount = 0;
86 usleep(20000);
87 do
88 {
89  iretn = vmt35_set_amps(1,0.);
90 ecount += iretn;
91 } while (iretn);
92 printf("%d ",ecount);
93 ecount = 0;
94 usleep(20000);
95 do
96 {
97  iretn = vmt35_set_amps(2,0.);
98 ecount += iretn;
99 } while (iretn);
100 printf("%d ",ecount);
101 // sleep(2);
102 // microstrain_magfield(handle,&magfield);
103 // magfield.col[1] = -magfield.col[1];
104 // normalize_rv(&magfield);
105 // mtrvec = rv_smult(1.,rv_cross(magfield,rv_unitz()));
106 // normalize_rv(&mtrvec);
107 // current = mtrvec.col[0]*.2;
108 ecount = 0;
109 usleep(20000);
110 do
111 {
112  iretn = vmt35_set_amps(0,current);
113 ecount += iretn;
114 } while (iretn);
115 printf("%d ",ecount);
116 // current = mtrvec.col[1]*.2;
117 ecount = 0;
118 usleep(20000);
119 do
120 {
121  iretn = vmt35_set_amps(1,current/2);
122 ecount += iretn;
123 } while (iretn);
124 printf("%d ",ecount);
125 ecount = 0;
126 usleep(20000);
127 do
128 {
129  iretn = vmt35_set_amps(2,current/3);
130 ecount += iretn;
131 } while (iretn);
132 printf("%d ",ecount);
133 ecount = 0;
134 usleep(20000);
135 do
136 {
137  iretn = vmt35_get_telemetry(&telem);
138 ecount += iretn;
139 } while (iretn);
140 printf("%d\n",ecount);
141  printf("%f %hu %hu %hu %d %d %d %hu %hu\n",(mjd-lmjd)*86400.,telem.status,telem.count,telem.invalidcount,telem.daca,telem.dacb,telem.dacc,telem.temp,telem.voltage);
142 // printf("[ %5.3f %5.3f %5.3f ] [ %5.3f %5.3f %5.3f ]\n",magfield.col[0],magfield.col[1],magfield.col[2],mtrvec.col[0]*.2,mtrvec.col[1]*.2,mtrvec.col[2]*.2);
143  fflush(stdout);
144 lmjd = mjd;
145  }
146 vmt35_disable();
147 exit(1);
148 vmt35_set_amps(0,0.);
149 vmt35_set_current(1,0.);
150 vmt35_set_current(2,0.);
151 
152 current = .1;
153 
154 vmt35_set_current(0,current);
155 vmt35_get_current(0,&icurrent);
156 printf("0: %u ",icurrent);
157 vmt35_get_current(1,&icurrent);
158 printf("1: %u ",icurrent);
159 vmt35_get_current(2,&icurrent);
160 printf("2: %u\n\n",icurrent);
161 sleep(34);
162 vmt35_set_current(0,0.);
163 vmt35_set_current(1,current);
164 vmt35_get_current(0,&icurrent);
165 printf("0: %u ",icurrent);
166 vmt35_get_current(1,&icurrent);
167 printf("1: %u ",icurrent);
168 vmt35_get_current(2,&icurrent);
169 printf("2: %u\n\n",icurrent);
170 sleep(4);
171 vmt35_set_current(1,0.);
172 vmt35_set_current(2,current);
173 vmt35_get_current(0,&icurrent);
174 printf("0: %u ",icurrent);
175 vmt35_get_current(1,&icurrent);
176 printf("1: %u ",icurrent);
177 vmt35_get_current(2,&icurrent);
178 printf("2: %u\n\n",icurrent);
179 
180 
181 
182 sleep(4);
183 
184 current = -.1;
185 
186 vmt35_set_current(2,0.);
187 vmt35_set_current(0,current);
188 vmt35_get_current(0,&icurrent);
189 printf("0: %u ",icurrent);
190 vmt35_get_current(1,&icurrent);
191 printf("1: %u ",icurrent);
192 vmt35_get_current(2,&icurrent);
193 printf("2: %u\n\n",icurrent);
194 sleep(4);
195 vmt35_set_current(0,0.);
196 vmt35_set_current(1,current);
197 vmt35_get_current(0,&icurrent);
198 printf("0: %u ",icurrent);
199 vmt35_get_current(1,&icurrent);
200 printf("1: %u ",icurrent);
201 vmt35_get_current(2,&icurrent);
202 printf("2: %u\n\n",icurrent);
203 sleep(4);
204 vmt35_set_amps(1,0.);
205 vmt35_set_amps(2,current);
206 vmt35_get_current(0,&icurrent);
207 printf("0: %u ",icurrent);
208 vmt35_get_current(1,&icurrent);
209 printf("1: %u ",icurrent);
210 vmt35_get_current(2,&icurrent);
211 printf("2: %u\n\n",icurrent);
212 sleep(4);
213 vmt35_set_amps(2,0.);
214 vmt35_get_current(0,&icurrent);
215 printf("0: %u ",icurrent);
216 vmt35_get_current(1,&icurrent);
217 printf("1: %u ",icurrent);
218 vmt35_get_current(2,&icurrent);
219 printf("2: %u\n\n",icurrent);
220 
221 vmt35_disable();
222 }
3 element generic row vector
Definition: vector.h:53
int iretn
Definition: rw_test.cpp:37
static antstruc current
Definition: agent_antenna.cpp:161
double mjd
Definition: udp_send.cpp:41
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65