Generic Step Motor WebInterface - control a step motor using a Pololu A4983 driver from a webinterface (EXPERIMENTAL PROTOTYPE - just to be used as a proof-of-concept for a IoT talk, will not be updating this code so often)

Dependencies:   EthernetNetIf RPCInterface mbed HTTPServer

Committer:
botdream
Date:
Mon Apr 16 09:41:53 2012 +0000
Revision:
0:8b3857d4ce02

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
botdream 0:8b3857d4ce02 1 /* //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 2 // disable/enable auto-run
botdream 0:8b3857d4ce02 3 http://192.168.1.100/rpc/enable/write%200
botdream 0:8b3857d4ce02 4 http://192.168.1.100/rpc/enable/write%201
botdream 0:8b3857d4ce02 5
botdream 0:8b3857d4ce02 6 // normal/inverse direction
botdream 0:8b3857d4ce02 7 http://192.168.1.100/rpc/direction/write%200
botdream 0:8b3857d4ce02 8
botdream 0:8b3857d4ce02 9 // timer delay - motor speed
botdream 0:8b3857d4ce02 10 http://192.168.1.100/rpc/delay/write%200.00001 (default)
botdream 0:8b3857d4ce02 11 http://192.168.1.100/rpc/delay/write%200.0000025 (max)
botdream 0:8b3857d4ce02 12
botdream 0:8b3857d4ce02 13 http://192.168.1.100/rpc/delay/write%200.00048 (super slow)
botdream 0:8b3857d4ce02 14
botdream 0:8b3857d4ce02 15 // RPC number of steps
botdream 0:8b3857d4ce02 16 http://192.168.1.100/rpc/nsteps/run%2016 (16 microsteps => 1 step)
botdream 0:8b3857d4ce02 17 http://192.168.1.100/rpc/nsteps/run%203200 (200 Steps -> 360�)
botdream 0:8b3857d4ce02 18
botdream 0:8b3857d4ce02 19 // RPC StepCmd
botdream 0:8b3857d4ce02 20 http://192.168.1.100/rpc/stepcmd/run%201000%20100%201
botdream 0:8b3857d4ce02 21
botdream 0:8b3857d4ce02 22 // RPC StepMode
botdream 0:8b3857d4ce02 23 http://192.168.1.100/rpc/stepmode/run%200
botdream 0:8b3857d4ce02 24 http://192.168.1.100/rpc/stepmode/run%201
botdream 0:8b3857d4ce02 25
botdream 0:8b3857d4ce02 26 //Sleep mode
botdream 0:8b3857d4ce02 27 http://192.168.1.100/rpc/sleepmode/run%200
botdream 0:8b3857d4ce02 28 http://192.168.1.100/rpc/sleepmode/run%201
botdream 0:8b3857d4ce02 29
botdream 0:8b3857d4ce02 30 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 31 // resources
botdream 0:8b3857d4ce02 32 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 33 http://mbed.org/handbook/C-Data-Types
botdream 0:8b3857d4ce02 34 http://mbed.org/cookbook/RPC-Interface-Library
botdream 0:8b3857d4ce02 35 http://mbed.org/cookbook/HTTP-Server
botdream 0:8b3857d4ce02 36 http://mbed.org/cookbook/Ethernet
botdream 0:8b3857d4ce02 37 http://mbed.org/handbook/Ticker
botdream 0:8b3857d4ce02 38 //--------------------------------------------------------------------------------------------- */
botdream 0:8b3857d4ce02 39 #include "mbed.h"
botdream 0:8b3857d4ce02 40 #include "EthernetNetIf.h"
botdream 0:8b3857d4ce02 41 #include "HTTPServer.h"
botdream 0:8b3857d4ce02 42 #include "RPCVariable.h"
botdream 0:8b3857d4ce02 43 #include "RPCFunction.h"
botdream 0:8b3857d4ce02 44 #include "A4983.h"
botdream 0:8b3857d4ce02 45 // TListObjects units
botdream 0:8b3857d4ce02 46 #include "TList.h"
botdream 0:8b3857d4ce02 47 #include "TObjects.h"
botdream 0:8b3857d4ce02 48
botdream 0:8b3857d4ce02 49 //#include <memory>
botdream 0:8b3857d4ce02 50 //#include <vector>
botdream 0:8b3857d4ce02 51 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 52 // Defines - remove comments to enable special mode
botdream 0:8b3857d4ce02 53 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 54 #define internaldebug // send debug messages to USB Serial port (9600,1,N)
botdream 0:8b3857d4ce02 55 //#define dhcpenable // auto-setup IP Address from DHCP router
botdream 0:8b3857d4ce02 56 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 57 // Ethernet Object Setup
botdream 0:8b3857d4ce02 58 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 59 #ifdef dhcpenable
botdream 0:8b3857d4ce02 60 EthernetNetIf eth;
botdream 0:8b3857d4ce02 61 #else
botdream 0:8b3857d4ce02 62 /*
botdream 0:8b3857d4ce02 63 EthernetNetIf eth(
botdream 0:8b3857d4ce02 64 IpAddr(192,168,0,100), //IP Address
botdream 0:8b3857d4ce02 65 IpAddr(255,255,255,0), //Network Mask
botdream 0:8b3857d4ce02 66 IpAddr(192,168,0,1), //Gateway - Laptop sharing Internet via 3G
botdream 0:8b3857d4ce02 67 IpAddr(208,67,220,220) //OpenDNS
botdream 0:8b3857d4ce02 68 );
botdream 0:8b3857d4ce02 69 */
botdream 0:8b3857d4ce02 70 EthernetNetIf eth(
botdream 0:8b3857d4ce02 71 IpAddr(192,168,1,100), //IP Address
botdream 0:8b3857d4ce02 72 IpAddr(255,255,255,0), //Network Mask
botdream 0:8b3857d4ce02 73 IpAddr(192,168,1,254), //Gateway
botdream 0:8b3857d4ce02 74 IpAddr(192,168,1,254) //DNS
botdream 0:8b3857d4ce02 75 );
botdream 0:8b3857d4ce02 76 #endif
botdream 0:8b3857d4ce02 77 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 78 // HTTP Server
botdream 0:8b3857d4ce02 79 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 80 HTTPServer svr;
botdream 0:8b3857d4ce02 81 LocalFileSystem fs("webfs");
botdream 0:8b3857d4ce02 82 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 83 // Misc
botdream 0:8b3857d4ce02 84 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 85
botdream 0:8b3857d4ce02 86 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 87 // Timer Interrupt - NetPool
botdream 0:8b3857d4ce02 88 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 89 Ticker netpool;
botdream 0:8b3857d4ce02 90 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 91 // auxiliar pointer - necessary for the rpc_nsteps(char *input, char *output) function
botdream 0:8b3857d4ce02 92 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 93 A4983 *p_stepmotor;
botdream 0:8b3857d4ce02 94 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 95 // temporary TList object
botdream 0:8b3857d4ce02 96 TList *pListPointer = NULL;
botdream 0:8b3857d4ce02 97 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 98
botdream 0:8b3857d4ce02 99 bool request_handle = false;
botdream 0:8b3857d4ce02 100
botdream 0:8b3857d4ce02 101 //#############################################################################################
botdream 0:8b3857d4ce02 102
botdream 0:8b3857d4ce02 103 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 104 // Pool Ethernet - will be triggered by netpool ticker
botdream 0:8b3857d4ce02 105 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 106 void netpoolupdate()
botdream 0:8b3857d4ce02 107 {
botdream 0:8b3857d4ce02 108 Net::poll();
botdream 0:8b3857d4ce02 109 }
botdream 0:8b3857d4ce02 110 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 111 // RPC function
botdream 0:8b3857d4ce02 112 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 113 void rpc_nsteps(char *input, char *output)
botdream 0:8b3857d4ce02 114 {
botdream 0:8b3857d4ce02 115 while(request_handle);
botdream 0:8b3857d4ce02 116
botdream 0:8b3857d4ce02 117 request_handle = true;
botdream 0:8b3857d4ce02 118
botdream 0:8b3857d4ce02 119 int arg1 = 0; // number of steps
botdream 0:8b3857d4ce02 120 sscanf(input, "%i", &arg1);
botdream 0:8b3857d4ce02 121
botdream 0:8b3857d4ce02 122 #ifdef internaldebug
botdream 0:8b3857d4ce02 123 printf("Calling RCP Function Step.\r\n");
botdream 0:8b3857d4ce02 124 printf("INPUT: %s.\r\n", input);
botdream 0:8b3857d4ce02 125 printf("OUTPUT: %s.\r\n", output);
botdream 0:8b3857d4ce02 126 printf("ARG1: %i.\r\n", arg1);
botdream 0:8b3857d4ce02 127 #endif
botdream 0:8b3857d4ce02 128
botdream 0:8b3857d4ce02 129 p_stepmotor->loopstop();
botdream 0:8b3857d4ce02 130 for(int i=0; i<arg1; i++)
botdream 0:8b3857d4ce02 131 {
botdream 0:8b3857d4ce02 132 wait(p_stepmotor->k_delay);
botdream 0:8b3857d4ce02 133 p_stepmotor->singlestep();
botdream 0:8b3857d4ce02 134 }
botdream 0:8b3857d4ce02 135
botdream 0:8b3857d4ce02 136 sprintf(output, "<html><body>RCP NSteps Completed!</body></html>");
botdream 0:8b3857d4ce02 137 request_handle = false;
botdream 0:8b3857d4ce02 138 }
botdream 0:8b3857d4ce02 139 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 140 void rpc_stepmode(char *input, char *output)
botdream 0:8b3857d4ce02 141 {
botdream 0:8b3857d4ce02 142 while(request_handle);
botdream 0:8b3857d4ce02 143
botdream 0:8b3857d4ce02 144 request_handle = true;
botdream 0:8b3857d4ce02 145
botdream 0:8b3857d4ce02 146 int arg1 = 0; // microstep=1; fullstep=0;
botdream 0:8b3857d4ce02 147 sscanf(input, "%i", &arg1);
botdream 0:8b3857d4ce02 148
botdream 0:8b3857d4ce02 149 #ifdef internaldebug
botdream 0:8b3857d4ce02 150 printf("Calling RCP Function Step Mode.\r\n");
botdream 0:8b3857d4ce02 151 printf("INPUT: %s.\r\n", input);
botdream 0:8b3857d4ce02 152 printf("OUTPUT: %s.\r\n", output);
botdream 0:8b3857d4ce02 153 printf("ARG1: %i.\r\n", arg1);
botdream 0:8b3857d4ce02 154 #endif
botdream 0:8b3857d4ce02 155
botdream 0:8b3857d4ce02 156 if(arg1 == 0)
botdream 0:8b3857d4ce02 157 {
botdream 0:8b3857d4ce02 158 p_stepmotor->adjust_microstepping_mode(1); // full step
botdream 0:8b3857d4ce02 159
botdream 0:8b3857d4ce02 160 #ifdef internaldebug
botdream 0:8b3857d4ce02 161 printf("--> FullStep\r\n");
botdream 0:8b3857d4ce02 162 #endif
botdream 0:8b3857d4ce02 163 }
botdream 0:8b3857d4ce02 164 else
botdream 0:8b3857d4ce02 165 {
botdream 0:8b3857d4ce02 166 p_stepmotor->adjust_microstepping_mode(16); // microstep 1/16
botdream 0:8b3857d4ce02 167
botdream 0:8b3857d4ce02 168 #ifdef internaldebug
botdream 0:8b3857d4ce02 169 printf("--> MicroStep 1/16\r\n");
botdream 0:8b3857d4ce02 170 #endif
botdream 0:8b3857d4ce02 171 }
botdream 0:8b3857d4ce02 172
botdream 0:8b3857d4ce02 173 sprintf(output, "<html><body>RCP Step Mode Completed!</body></html>");
botdream 0:8b3857d4ce02 174 request_handle = false;
botdream 0:8b3857d4ce02 175 }
botdream 0:8b3857d4ce02 176 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 177 void rpc_sleepmode(char *input, char *output)
botdream 0:8b3857d4ce02 178 {
botdream 0:8b3857d4ce02 179 while(request_handle);
botdream 0:8b3857d4ce02 180
botdream 0:8b3857d4ce02 181 request_handle = true;
botdream 0:8b3857d4ce02 182
botdream 0:8b3857d4ce02 183 int arg1 = 0; // microstep=1; fullstep=0;
botdream 0:8b3857d4ce02 184 sscanf(input, "%i", &arg1);
botdream 0:8b3857d4ce02 185
botdream 0:8b3857d4ce02 186 #ifdef internaldebug
botdream 0:8b3857d4ce02 187 printf("Calling RCP Function Sleep CMD.\r\n");
botdream 0:8b3857d4ce02 188 printf("INPUT: %s.\r\n", input);
botdream 0:8b3857d4ce02 189 printf("OUTPUT: %s.\r\n", output);
botdream 0:8b3857d4ce02 190 printf("ARG1: %i.\r\n", arg1);
botdream 0:8b3857d4ce02 191 #endif
botdream 0:8b3857d4ce02 192
botdream 0:8b3857d4ce02 193 if(arg1 == 1)
botdream 0:8b3857d4ce02 194 p_stepmotor->sleep(true);
botdream 0:8b3857d4ce02 195 else
botdream 0:8b3857d4ce02 196 p_stepmotor->sleep(false);
botdream 0:8b3857d4ce02 197
botdream 0:8b3857d4ce02 198 sprintf(output, "<html><body>RCP Sleep CMD Completed!</body></html>");
botdream 0:8b3857d4ce02 199 request_handle = false;
botdream 0:8b3857d4ce02 200 }
botdream 0:8b3857d4ce02 201 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 202 // RPC TList Commands (Task/Job List)
botdream 0:8b3857d4ce02 203 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 204 void rpc_stepcmd(char *input, char *output)
botdream 0:8b3857d4ce02 205 {
botdream 0:8b3857d4ce02 206 while(request_handle);
botdream 0:8b3857d4ce02 207
botdream 0:8b3857d4ce02 208 request_handle = true;
botdream 0:8b3857d4ce02 209
botdream 0:8b3857d4ce02 210 int insteps = 0; // number of steps
botdream 0:8b3857d4ce02 211 int ideltatime = 0; // time in ms between Step Motor SPI frames
botdream 0:8b3857d4ce02 212 int idirection = 0; // direction {0->CCW; 1->CW}
botdream 0:8b3857d4ce02 213
botdream 0:8b3857d4ce02 214 sscanf(input, "%i %i %i", &insteps, &ideltatime, &idirection);
botdream 0:8b3857d4ce02 215
botdream 0:8b3857d4ce02 216 #ifdef internaldebug
botdream 0:8b3857d4ce02 217 printf("Calling RCP Function StepCmd.\r\n");
botdream 0:8b3857d4ce02 218 printf("INPUT: %s.\r\n", input);
botdream 0:8b3857d4ce02 219 printf("OUTPUT: %s.\r\n", output);
botdream 0:8b3857d4ce02 220 printf("ARG1: %d\r\n", insteps);
botdream 0:8b3857d4ce02 221 printf("ARG2: %d\r\n", ideltatime);
botdream 0:8b3857d4ce02 222 printf("ARG3: %d\r\n", idirection);
botdream 0:8b3857d4ce02 223 #endif
botdream 0:8b3857d4ce02 224
botdream 0:8b3857d4ce02 225 // adding cmd (TObjectStep) to TList
botdream 0:8b3857d4ce02 226 pListPointer = SetListNextObject();
botdream 0:8b3857d4ce02 227 TObjectStep *pobjectstep = new TObjectStep(insteps, ideltatime, idirection);
botdream 0:8b3857d4ce02 228 pListPointer->cmdtype = 0x01;
botdream 0:8b3857d4ce02 229 pListPointer->cmdobject = (TObjectStep*)pobjectstep;
botdream 0:8b3857d4ce02 230
botdream 0:8b3857d4ce02 231 sprintf(output, "<html><body>RCP Step Cmd Completed!</body></html>");
botdream 0:8b3857d4ce02 232 request_handle = false;
botdream 0:8b3857d4ce02 233 }
botdream 0:8b3857d4ce02 234 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 235
botdream 0:8b3857d4ce02 236
botdream 0:8b3857d4ce02 237 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 238 // MAIN routine
botdream 0:8b3857d4ce02 239 //---------------------------------------------------------------------------------------------
botdream 0:8b3857d4ce02 240 int main()
botdream 0:8b3857d4ce02 241 {
botdream 0:8b3857d4ce02 242 //std::auto_ptr<int>abc;
botdream 0:8b3857d4ce02 243 //std::vector<int>def;
botdream 0:8b3857d4ce02 244 //--------------------------------------------------------
botdream 0:8b3857d4ce02 245 // Setting RPC
botdream 0:8b3857d4ce02 246 //--------------------------------------------------------
botdream 0:8b3857d4ce02 247 /*
botdream 0:8b3857d4ce02 248 Base::add_rpc_class<AnalogIn>();
botdream 0:8b3857d4ce02 249 Base::add_rpc_class<AnalogOut>();
botdream 0:8b3857d4ce02 250 Base::add_rpc_class<DigitalIn>();
botdream 0:8b3857d4ce02 251 Base::add_rpc_class<DigitalOut>();
botdream 0:8b3857d4ce02 252 Base::add_rpc_class<DigitalInOut>();
botdream 0:8b3857d4ce02 253 Base::add_rpc_class<PwmOut>();
botdream 0:8b3857d4ce02 254 Base::add_rpc_class<Timer>();
botdream 0:8b3857d4ce02 255 Base::add_rpc_class<BusOut>();
botdream 0:8b3857d4ce02 256 Base::add_rpc_class<BusIn>();
botdream 0:8b3857d4ce02 257 Base::add_rpc_class<BusInOut>();
botdream 0:8b3857d4ce02 258 Base::add_rpc_class<Serial>(); */
botdream 0:8b3857d4ce02 259
botdream 0:8b3857d4ce02 260 //--------------------------------------------------------
botdream 0:8b3857d4ce02 261 // Setting Ethernet
botdream 0:8b3857d4ce02 262 //--------------------------------------------------------
botdream 0:8b3857d4ce02 263 #ifdef internaldebug
botdream 0:8b3857d4ce02 264 printf("Setting up...\r\n");
botdream 0:8b3857d4ce02 265 #endif
botdream 0:8b3857d4ce02 266 EthernetErr ethErr = eth.setup();
botdream 0:8b3857d4ce02 267 if(ethErr)
botdream 0:8b3857d4ce02 268 {
botdream 0:8b3857d4ce02 269 #ifdef internaldebug
botdream 0:8b3857d4ce02 270 printf("Error %d in setup.\r\n", ethErr);
botdream 0:8b3857d4ce02 271 #endif
botdream 0:8b3857d4ce02 272 return -1;
botdream 0:8b3857d4ce02 273 }
botdream 0:8b3857d4ce02 274 #ifdef internaldebug
botdream 0:8b3857d4ce02 275 printf("Setup OK\r\n");
botdream 0:8b3857d4ce02 276 #endif
botdream 0:8b3857d4ce02 277
botdream 0:8b3857d4ce02 278 //--------------------------------------------------------
botdream 0:8b3857d4ce02 279 // instance of the Step Motor Driver interface
botdream 0:8b3857d4ce02 280 //--------------------------------------------------------
botdream 0:8b3857d4ce02 281 A4983 stepmotor;
botdream 0:8b3857d4ce02 282 p_stepmotor = &stepmotor; // auxiliar pointer for rpc_nsteps(char *input, char *output);
botdream 0:8b3857d4ce02 283
botdream 0:8b3857d4ce02 284 //--------------------------------------------------------
botdream 0:8b3857d4ce02 285 // adding RPC variables
botdream 0:8b3857d4ce02 286 //--------------------------------------------------------
botdream 0:8b3857d4ce02 287 RPCVariable<uint8_t> RPCenable(&stepmotor.f_motor_enable, "enable");
botdream 0:8b3857d4ce02 288 RPCVariable<uint8_t> RPCdir(&stepmotor.f_motor_direction, "direction");
botdream 0:8b3857d4ce02 289 RPCVariable<float> RPCdelay(&stepmotor.k_delay, "delay");
botdream 0:8b3857d4ce02 290
botdream 0:8b3857d4ce02 291 //--------------------------------------------------------
botdream 0:8b3857d4ce02 292 // adding RPC functions
botdream 0:8b3857d4ce02 293 //--------------------------------------------------------
botdream 0:8b3857d4ce02 294 RPCFunction RPCnsteps(&rpc_nsteps, "nsteps");
botdream 0:8b3857d4ce02 295 RPCFunction RPCsleepmode(&rpc_sleepmode, "sleepmode");
botdream 0:8b3857d4ce02 296 RPCFunction RPCstepmode(&rpc_stepmode, "stepmode");
botdream 0:8b3857d4ce02 297
botdream 0:8b3857d4ce02 298 RPCFunction RPCstepcmd(&rpc_stepcmd, "stepcmd");
botdream 0:8b3857d4ce02 299
botdream 0:8b3857d4ce02 300 //--------------------------------------------------------
botdream 0:8b3857d4ce02 301 // adding Handlers
botdream 0:8b3857d4ce02 302 //--------------------------------------------------------
botdream 0:8b3857d4ce02 303 FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path
botdream 0:8b3857d4ce02 304 FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path
botdream 0:8b3857d4ce02 305
botdream 0:8b3857d4ce02 306 //svr.addHandler<SimpleHandler>("/hello");
botdream 0:8b3857d4ce02 307 svr.addHandler<RPCHandler>("/rpc");
botdream 0:8b3857d4ce02 308 svr.addHandler<FSHandler>("/files");
botdream 0:8b3857d4ce02 309 svr.addHandler<FSHandler>("/"); //Default handler
botdream 0:8b3857d4ce02 310 //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm
botdream 0:8b3857d4ce02 311
botdream 0:8b3857d4ce02 312 //--------------------------------------------------------
botdream 0:8b3857d4ce02 313 // bind http server to port 80 (Listen)
botdream 0:8b3857d4ce02 314 //--------------------------------------------------------
botdream 0:8b3857d4ce02 315 svr.bind(80);
botdream 0:8b3857d4ce02 316 #ifdef internaldebug
botdream 0:8b3857d4ce02 317 printf("Listening on port 80 ...\r\n");
botdream 0:8b3857d4ce02 318 #endif
botdream 0:8b3857d4ce02 319
botdream 0:8b3857d4ce02 320 //--------------------------------------------------------
botdream 0:8b3857d4ce02 321 // attach timer interrupt to update Net::Pool();
botdream 0:8b3857d4ce02 322 //--------------------------------------------------------
botdream 0:8b3857d4ce02 323 netpool.attach(&netpoolupdate, 0.1);
botdream 0:8b3857d4ce02 324
botdream 0:8b3857d4ce02 325 //--------------------------------------------------------
botdream 0:8b3857d4ce02 326 // main loop
botdream 0:8b3857d4ce02 327 //--------------------------------------------------------
botdream 0:8b3857d4ce02 328 //stepmotor.f_motor_enable = 1; // used for debug, force motor to star when micro is reset
botdream 0:8b3857d4ce02 329 //stepmotor.k_delay = 0.01;
botdream 0:8b3857d4ce02 330 while(1)
botdream 0:8b3857d4ce02 331 {
botdream 0:8b3857d4ce02 332 stepmotor.looprun();
botdream 0:8b3857d4ce02 333 //stepmotor.singlestep();
botdream 0:8b3857d4ce02 334 }
botdream 0:8b3857d4ce02 335 }
botdream 0:8b3857d4ce02 336 //---------------------------------------------------------------------------------------------