-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCANOpenShellStateMachine.c
More file actions
3119 lines (2789 loc) · 78.2 KB
/
Copy pathCANOpenShellStateMachine.c
File metadata and controls
3119 lines (2789 loc) · 78.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
#include <pthread.h>
#include <time.h>
#include <unistd.h>
#include "CANOpenShellStateMachine.h"
#include "CANOpenShellMasterError.h"
int motor_active[CANOPEN_NODE_NUMBER]; /**< indica se un motore si è dichiarato */
volatile int motor_started[CANOPEN_NODE_NUMBER];
int motor_active_number; /**< tiene conto di quanti motori sono presenti */
long motor_position[CANOPEN_NODE_NUMBER]; /**< ultima posizione del motore */
UNS32 motor_interp_status[CANOPEN_NODE_NUMBER]; /**< ultimo stato del registro di interpolazione del motore*/
volatile UNS16 motor_status[CANOPEN_NODE_NUMBER]; /**< ultimo stato del motore */
volatile UNS16 motor_statusword0[CANOPEN_NODE_NUMBER]; /**< ultimo valore della statusword0 del motore */
UNS8 motor_mode[CANOPEN_NODE_NUMBER]; /**< ultimo stato del motore */
int verbose_flag_state = 1;
long next_machine_size[CANOPEN_NODE_NUMBER];
struct state_machine_struct **next_machine[CANOPEN_NODE_NUMBER];
int next_var_count[CANOPEN_NODE_NUMBER];
int var_count_total[CANOPEN_NODE_NUMBER];
UNS32 *args_ptr[CANOPEN_NODE_NUMBER];
UNS32 *next_args[CANOPEN_NODE_NUMBER];
volatile int machine_state_index[CANOPEN_NODE_NUMBER];
int machine_state_param_index[CANOPEN_NODE_NUMBER];
MachineCallback_t callback_user[CANOPEN_NODE_NUMBER];
#ifndef SDO_SYNC
pthread_mutex_t machine_mux[CANOPEN_NODE_NUMBER];
volatile int machine_run[CANOPEN_NODE_NUMBER];
#else
pthread_mutex_t machine_mux;
volatile int machine_run = 0;
pthread_cond_t machine_run_cond = PTHREAD_COND_INITIALIZER;
#endif
char error_text[100];
void *smart_start[12] =
{
&masterSendNMTstateChange, // Start canopen node
&writeNetworkDictCallBack, // Change state: switched off
&writeNetworkDictCallBack, // Reset status word
&writeNetworkDictCallBack, // Change state: switched off
&writeNetworkDictCallBack, // Set mode velocity
&writeNetworkDictCallBack, // Set velocity in PV mode
&writeNetworkDictCallBack, // Set acceleration
&writeNetworkDictCallBack, // Set deceleration
&writeNetworkDictCallBack, // Set following error window
&writeNetworkDictCallBack, // Change state: ready to switch on
&writeNetworkDictCallBack, // Change state: switched on
&writeNetworkDictCallBack,
// Start command
};
UNS32 smart_start_param[56] =
{
NMT_Start_Node, // Start canopen node
0x6040,
0x0,
2,
0,
0x0, // Change state: switched off
0x6040,
0x0,
2,
0,
0x80, // Reset status word
0x6040,
0x0,
2,
0,
0x0, // Change state: switched off
0x6060,
0x0,
1,
0,
0x3, // Set mode velocity
0x60FF,
0x0,
4,
0,
0x0, // Set velocity in PV mode
0x6083,
0x0,
4,
0,
0x1000, // Set acceleration
0x6084,
0x0,
4,
0,
0xa, // Set deceleration
0x6065,
0x0,
4,
0,
2000, // Set following error window
0x6040,
0x0,
2,
0,
0x6, // Change state: ready to switch on
0x6040,
0x0,
2,
0,
0x7, // Change state: switched on
0x6040,
0x0,
2,
0,
0xF,
// Start command
};
char *smart_start_error[2] =
{
"smartmotor started", "Cannot start smartmotor"
};
struct state_machine_struct smart_start_machine =
{
smart_start, 12, smart_start_param, 56, smart_start_error
};
void *map1_pdo[7] =
{
&writeNetworkDictCallBack, // Set bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set the number of entry to 0
&writeNetworkDictCallBack, // Set the mapping object
&writeNetworkDictCallBack, // Set the number of entry
&writeNetworkDictCallBack, // Clear bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set transmission type on event timer
&writeNetworkDictCallBack
// Set transmission time
};
/**
* Optional parameter:
* 0x1800 | pdo_number
* 0xC0000000 | COB-ID
* 0x1A00 | pdo_number
* 0x1A00 | pdo_number
* MAPPING OBJECT 1
* 0x1A00 | pdo_number
* 0x1800 | pdo_number
* 0x40000000 | COB-ID
* 0x1800 | pdo_number
* transmission type
* 0x1800 | pdo_number
* transmission time
*/UNS32 map1_pdo_param[35] =
{
0xFFFFFFFF, 0x1, 4, 0, 0xFFFFFFFF, // Set bit 31 of the COB-ID
0xFFFFFFFF,
0x0,
1,
0,
0x00, // Set the number of entry to 0
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Set the mapping object: status word
0xFFFFFFFF,
0x0,
1,
0,
0x01, // Set the number of entry
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Clear bit 31 of the COB-ID
0xFFFFFFFF,
0x2,
1,
0,
0xFFFFFFFF, // Set transmission type on event timer
0xFFFFFFFF,
0x5,
2,
0,
0xFFFFFFFF
// Set transmission time on event timer
};
char *map1_pdo_error[2] =
{
"PDO mapped", "Cannot map PDO"
};
struct state_machine_struct map1_pdo_machine =
{
map1_pdo, 7, map1_pdo_param, 35, map1_pdo_error
};
void *map2_pdo[8] =
{
&writeNetworkDictCallBack, // Set bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set the number of entry to 0
&writeNetworkDictCallBack, // Set the mapping object
&writeNetworkDictCallBack, // Set the mapping object
&writeNetworkDictCallBack, // Set the number of entry
&writeNetworkDictCallBack, // Clear bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set transmission type on event timer
&writeNetworkDictCallBack
// Set transmission time
};
/**
* Optional parameter:
* 0x1800 | pdo_number
* 0xC0000000 | COB-ID
* 0x1A00 | pdo_number
* 0x1A00 | pdo_number
* MAPPING OBJECT 1
* 0x1A00 | pdo_number
* MAPPING OBJECT 2
* 0x1A00 | pdo_number
* 0x1800 | pdo_number
* 0x40000000 | COB-ID
* 0x1800 | pdo_number
* transmission type
* 0x1800 | pdo_number
* transmission time
*/UNS32 map2_pdo_param[40] =
{
0xFFFFFFFF, 0x1, 4, 0, 0xFFFFFFFF, // Set bit 31 of the COB-ID
0xFFFFFFFF,
0x0,
1,
0,
0x00, // Set the number of entry to 0
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Set the mapping object
0xFFFFFFFF,
0x2,
4,
0,
0xFFFFFFFF, // Set the mapping object
0xFFFFFFFF,
0x0,
1,
0,
0x02, // Set the number of entry
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Clear bit 31 of the COB-ID
0xFFFFFFFF,
0x2,
1,
0,
0xFFFFFFFF, // Set transmission type on event timer
0xFFFFFFFF,
0x5,
2,
0,
0xFFFFFFFF
// Set transmission time on event timer
};
char *map2_pdo_error[2] =
{
"PDO mapped", "Cannot map PDO"
};
struct state_machine_struct map2_pdo_machine =
{
map2_pdo, 8, map2_pdo_param, 40, map2_pdo_error
};
void *map3_pdo[9] =
{
&writeNetworkDictCallBack, // Set bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set the number of entry to 0
&writeNetworkDictCallBack, // Set the mapping object 1
&writeNetworkDictCallBack, // Set the mapping object 2
&writeNetworkDictCallBack, // Set the mapping object 3
&writeNetworkDictCallBack, // Set the number of entry
&writeNetworkDictCallBack, // Clear bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set transmission type on event timer
&writeNetworkDictCallBack
// Set transmission time
};
/**
* Optional parameter:
* 0x1800 | pdo_number
* 0xC0000000 | COB-ID
* 0x1A00 | pdo_number
* 0x1A00 | pdo_number
* MAPPING OBJECT 1
* 0x1A00 | pdo_number
* MAPPING OBJECT 2
* 0x1A00 | pdo_number
* MAPPING OBJECT 3
* 0x1A00 | pdo_number
* 0x1800 | pdo_number
* 0x40000000 | COB-ID
* 0x1800 | pdo_number
* transmission type
* 0x1800 | pdo_number
* transmission time
*/UNS32 map3_pdo_param[45] =
{
0xFFFFFFFF, 0x1, 4, 0, 0xFFFFFFFF, // Set bit 31 of the COB-ID
0xFFFFFFFF,
0x0,
1,
0,
0x00, // Set the number of entry to 0
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Set the mapping object 1
0xFFFFFFFF,
0x2,
4,
0,
0xFFFFFFFF, // Set the mapping object 2
0xFFFFFFFF,
0x3,
4,
0,
0xFFFFFFFF, // Set the mapping object 3
0xFFFFFFFF,
0x0,
1,
0,
0x03, // Set the number of entry
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Clear bit 31 of the COB-ID
0xFFFFFFFF,
0x2,
1,
0,
0xFFFFFFFF, // Set transmission type on event timer
0xFFFFFFFF,
0x5,
2,
0,
0xFFFFFFFF
// Set transmission time on event timer
};
char *map3_pdo_error[2] =
{
"PDO mapped", "Cannot map PDO"
};
struct state_machine_struct map3_pdo_machine =
{
map3_pdo, 9, map3_pdo_param, 45, map3_pdo_error
};
void *map4_pdo[10] =
{
&writeNetworkDictCallBack, // Set bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set the number of entry to 0
&writeNetworkDictCallBack, // Set the mapping object 1
&writeNetworkDictCallBack, // Set the mapping object 2
&writeNetworkDictCallBack, // Set the mapping object 3
&writeNetworkDictCallBack, // Set the mapping object 4
&writeNetworkDictCallBack, // Set the number of entry
&writeNetworkDictCallBack, // Clear bit 31 of the COB-ID
&writeNetworkDictCallBack, // Set transmission type on event timer
&writeNetworkDictCallBack
// Set transmission time
};
/**
* Optional parameter:
* 0x1800 | pdo_number
* 0xC0000000 | COB-ID
* 0x1A00 | pdo_number
* 0x1A00 | pdo_number
* MAPPING OBJECT 1
* 0x1A00 | pdo_number
* MAPPING OBJECT 2
* 0x1A00 | pdo_number
* MAPPING OBJECT 3
* 0x1A00 | pdo_number
* MAPPING OBJECT 4
* 0x1A00 | pdo_number
* 0x1800 | pdo_number
* 0x40000000 | COB-ID
* 0x1800 | pdo_number
* transmission type
* 0x1800 | pdo_number
* transmission time
*/UNS32 map4_pdo_param[50] =
{
0xFFFFFFFF, 0x1, 4, 0, 0xFFFFFFFF, // Set bit 31 of the COB-ID
0xFFFFFFFF,
0x0,
1,
0,
0x00, // Set the number of entry to 0
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Set the mapping object 1
0xFFFFFFFF,
0x2,
4,
0,
0xFFFFFFFF, // Set the mapping object 2
0xFFFFFFFF,
0x3,
4,
0,
0xFFFFFFFF, // Set the mapping object 3
0xFFFFFFFF,
0x4,
4,
0,
0xFFFFFFFF, // Set the mapping object 4
0xFFFFFFFF,
0x0,
1,
0,
0x04, // Set the number of entry
0xFFFFFFFF,
0x1,
4,
0,
0xFFFFFFFF, // Clear bit 31 of the COB-ID
0xFFFFFFFF,
0x2,
1,
0,
0xFFFFFFFF, // Set transmission type on event timer
0xFFFFFFFF,
0x5,
2,
0,
0xFFFFFFFF
// Set transmission time on event timer
};
char *map4_pdo_error[2] =
{
"PDO mapped", "Cannot map PDO"
};
struct state_machine_struct map4_pdo_machine =
{
map4_pdo, 10, map4_pdo_param, 50, map4_pdo_error
};
void *heart_start[1] =
{
&writeNetworkDictCallBack
};
UNS32 heart_start_param[5] =
{
0x1017, 0x0, 2, 0, 0xFFFFFFFF
};
char *heart_start_error[2] =
{
"Heartbeat configured", "Cannot configure heartbeat"
};
struct state_machine_struct heart_start_machine =
{
heart_start, 1, heart_start_param, 5, heart_start_error
};
void *smart_stop[10] =
{
&writeNetworkDictCallBack, // Change state: switched off
&writeNetworkDictCallBack, // Change state: switched off
&writeNetworkDictCallBack, // Change state: switched off
&writeNetworkDictCallBack, // Disable positive limit switch input
&writeNetworkDictCallBack, // Disable negative limit switch input
&writeNetworkDictCallBack, // Set mode velocity
&writeNetworkDictCallBack, // Set velocity in PV mode
&writeNetworkDictCallBack, // Change state: ready to switch on
&writeNetworkDictCallBack, // Change state: switched on
&writeNetworkDictCallBack,
// Start command
};
UNS32 smart_stop_param[50] =
{
0x6040, 0x0, 2, 0, 0x0, // Change state: switched off
0x6040,
0x0,
2,
0,
0x80, // Change state: switched off
0x6040,
0x0,
2,
0,
0x0, // Change state: switched off
0x2101,
0x3,
2,
0,
0x2, // Disable positive limit switch input
0x2101,
0x3,
2,
0,
0x3, // Disable negative limit switch input
0x6060,
0x0,
1,
0,
0x3, // Set mode velocity
0x60FF,
0x0,
4,
0,
0x0, // Set velocity in PV mode
0x6040,
0x0,
2,
0,
0x6, // Change state: ready to switch on
0x6040,
0x0,
2,
0,
0x7, // Change state: switched on
0x6040,
0x0,
2,
0,
0xF,
// Start command
};
char *smart_stop_error[2] =
{
"smart motor stopped", "cannost stop smartmotor"
};
struct state_machine_struct smart_stop_machine =
{
smart_stop, 10, smart_stop_param, 50, smart_stop_error
};
void *smart_position_set_function[9] =
{
&writeNetworkDictCallBack, // Reset the status word
&writeNetworkDictCallBack, // Set mode position
&writeNetworkDictCallBack, // Set profile speed
&writeNetworkDictCallBack, // Set target position to zero
&writeNetworkDictCallBack, // Set acceleration
&writeNetworkDictCallBack, // Set deceleration
&writeNetworkDictCallBack, // Change state: ready to switch on
&writeNetworkDictCallBack, // Change state: switched on
&writeNetworkDictCallBack,
// Enable command, single setpoint (motion not actually started yet)
};
/*
* param
* profile speed
* target point
* procile acceleration
*/UNS32 smart_position_set_param[45] =
{
0x6040, 0x0, 2, 0, 0x80, // Reset status word
0x6060,
0x0,
1,
0,
0x1, // Set mode position
0x6083,
0x0,
4,
0,
0xFFFFFFFF, // Set acceleration
0x6084,
0x0,
4,
0,
0xFFFFFFFF, // Set deceleration
0x6040,
0x0,
2,
0,
0x6, // Change state: ready to switch on
0x6040,
0x0,
2,
0,
0x7, // Change state: switched on
0x6040,
0x0,
2,
0,
0x2F, // Enable command, single setpoint (motion not actually started yet)
0x6081,
0x0,
4,
0,
0xFFFFFFFF, // Set profile speed
0x607A,
0x0,
4,
0,
0xFFFFFFFF, // Set target position to destination
};
char *smart_position_set_error[2] =
{
"set target point", "cannot set target point"
};
struct state_machine_struct smart_position_set_machine =
{
smart_position_set_function, 9, smart_position_set_param, 45, smart_position_set_error
};
void *smart_position_start_function[1] =
{
&writeNetworkDictCallBack
// Begin motion to target position
};
UNS32 smart_position_start_param[5] =
{
0x6040, 0x0, 2, 0, 0x3F
// Begin motion to target position
};
char *smart_position_start_error[2] =
{
"smart motor go to target point. . .", "cannot begin motion"
};
struct state_machine_struct smart_position_start_machine =
{
smart_position_start_function, 1, smart_position_start_param, 5, smart_position_start_error
};
void *smart_set_mode_function[4] =
{
&writeNetworkDictCallBack,
&writeNetworkDictCallBack,
&writeNetworkDictCallBack,
&writeNetworkDictCallBack
};
UNS32 smart_set_mode_param[25] =
{
0x6040, 0x0, 2, 0, 0x80, // Reset status word
0x6060,
0x0,
1,
0,
0x1, // Set mode position
0x6040,
0x0,
2,
0,
0x6, // Change state: ready to switch on
0x6040,
0x0,
2,
0,
0x7, // Change state: switched on
0x6040,
0x0,
2,
0,
0x2F
// Enable command, single setpoint (motion not actually started yet)
};
char *smart_set_mode_error[2] =
{
"smart motor go to target point. . .", "cannot set mode"
};
struct state_machine_struct smart_set_mode_machine =
{
smart_set_mode_function, 4, smart_set_mode_param, 25, smart_set_mode_error
};
void *smart_message_function[1] =
{
&writeNetworkDictCallBack
};
UNS32 smart_message_param[5] =
{
0x2500, 0x01, 0xFFFFFFFF, visible_string, 0xFFFFFFFF
};
char *smart_message_error[2] =
{
"smartmotor message sent. . .", "cannot sent smart message"
};
struct state_machine_struct smart_message_machine =
{
smart_message_function, 1, smart_message_param, 5, smart_message_error
};
void *smart_interpolation_test1[19] =
{
&writeNetworkDictCallBack, // Reset the status word
&writeNetworkDictCallBack, // Set interpolation mode
&writeNetworkDictCallBack, // Change state: ready to switch on
&writeNetworkDictCallBack, // Change state: switched on
&writeNetworkDictCallBack, // Clear buffer
&writeNetworkDictCallBack, // Enable buffer
&writeNetworkDictCallBack, // Set time period to 1 (second)
&writeNetworkDictCallBack, // Set time period to seconds
&writeNetworkDictCallBack, // Write data point 1
&writeNetworkDictCallBack, // Write data point 2
&writeNetworkDictCallBack, // Write data point 3
&writeNetworkDictCallBack, // Write data point 4
&writeNetworkDictCallBack, // Write data point 5
&writeNetworkDictCallBack, // Write data point 6
&writeNetworkDictCallBack, // Write zero-length segment
&writeNetworkDictCallBack, // Write data point
&writeNetworkDictCallBack, // This is required to satisfy CiA 402 drive state machine
&writeNetworkDictCallBack, // Enable command (motion not actually started yet
&writeNetworkDictCallBack
// Begin motion
};
UNS32 smart_interpolation_test1_param[95] =
{
0x6040, 0x0, 2, 0, 0x80, // Reset the status word
0x6060,
0x0,
1,
0,
0x7, // Set interpolation mode
0x6040,
0x0,
2,
0,
0x6, // Change state: ready to switch on
0x6040,
0x0,
2,
0,
0x7, // Change state: switched on
0x60C4,
0x6,
1,
0,
0x0, // Clear buffer
0x60C4,
0x6,
1,
0,
0x1, // Enable buffer
0x60C2,
0x1,
1,
0,
0x1, // Set time period to 1 (second)
0x60C2,
0x2,
1,
0,
0x0, // Set time period to seconds
0x60C1,
0x1,
4,
0,
0x0, // Write data point 1
0x60C1,
0x1,
4,
0,
0x3E8, // Write data point 2
0x60C1,
0x1,
4,
0,
0xBB8, // Write data point 3
0x60C1,
0x1,
4,
0,
0x7D0, // Write data point 4
0x60C1,
0x1,
4,
0,
0x3E8, // Write data point 5
0x60C1,
0x1,
4,
0,
0x0, // Write data point 6
0x60C2,
0x1,
1,
0,
0x0, // Write zero-length segment
0x60C1,
0x1,
4,
0,
0x0, // Write data point
0x6040,
0x0,
2,
0,
0x6, // This is required to satisfy CiA 402 drive state machine
0x6040,
0x0,
2,
0,
0xF, // Enable command (motion not actually started yet
0x6040,
0x0,
2,
0,
0x1F
// Begin motion
};
char *smart_interpolation_test1_error[2] =
{
"smartmotor interpolation mode started", "Cannot start smartmotor in interpolation mode"
};
struct state_machine_struct smart_interpolation_test1_machine =
{
smart_interpolation_test1, 19, smart_interpolation_test1_param, 95, smart_interpolation_test1_error
};
void *smart_interpolation_test2[19] =
{
&writeNetworkDictCallBack, // Reset the status word
&writeNetworkDictCallBack, // Change state: ready to switch on
&writeNetworkDictCallBack, // Change state: switched on
&writeNetworkDictCallBack, // Clear buffer
&writeNetworkDictCallBack, // Enable buffer
&writeNetworkDictCallBack, // Set time period to seconds
&writeNetworkDictCallBack, // Set time period to 1 (second)
&writeNetworkDictCallBack, // Set interpolation mode
&writeNetworkDictCallBack, // Write data point 1
&writeNetworkDictCallBack, // Write data point 2
&writeNetworkDictCallBack, // Write data point 3
&writeNetworkDictCallBack, // Write data point 4
&writeNetworkDictCallBack, // Write data point 5
&writeNetworkDictCallBack, // Write data point 6
&writeNetworkDictCallBack, // Write zero-length segment
&writeNetworkDictCallBack, // Write data point
&writeNetworkDictCallBack, // This is required to satisfy CiA 402 drive state machine
&writeNetworkDictCallBack, // Enable command (motion not actually started yet
&writeNetworkDictCallBack
// Begin motion
};
UNS32 smart_interpolation_test2_param[95] =
{
0x6040, 0x0, 2, 0, 0x80, // Reset the status word
0x6040,
0x0,
2,
0,
0x6, // Change state: ready to switch on
0x6040,
0x0,
2,
0,
0x7, // Change state: switched on
0x60C4,
0x6,
1,
0,
0x0, // Clear buffer
0x60C4,
0x6,
1,
0,
0x1, // Enable buffer
0x60C2,
0x2,
1,
0,
0xFD, // Set time period to seconds
0x60C2,
0x1,
1,
0,
0x14, // Set time period to 1 (second)
0x6060,
0x0,
1,
0,
0x7, // Set interpolation mode
0x60C1,
0x1,
4,
0,
0x0, // Write data point 1
0x60C1,
0x1,
4,
0,
0x3E8, // Write data point 2
0x60C1,
0x1,
4,
0,
0xBB8, // Write data point 3
0x60C1,
0x1,
4,
0,
0x7D0, // Write data point 4
0x60C1,
0x1,
4,
0,
0x3E8, // Write data point 5
0x60C1,
0x1,
4,
0,
0x0, // Write data point 6
0x60C2,
0x1,
1,
0,
0x0, // Write zero-length segment
0x60C1,
0x1,
4,
0,
0x0, // Write data point
0x6040,
0x0,
2,
0,
0x6, // This is required to satisfy CiA 402 drive state machine
0x6040,
0x0,
2,
0,
0xF, // Enable command (motion not actually started yet
0x6040,
0x0,
2,
0,
0x1F
// Begin motion
};
char *smart_interpolation_test2_error[2] =
{
"smartmotor interpolation mode started", "Cannot start smartmotor in interpolation mode"
};
struct state_machine_struct smart_interpolation_test2_machine =
{
smart_interpolation_test2, 19, smart_interpolation_test2_param, 95, smart_interpolation_test2_error
};
void *init_interpolation_function[10] =
{
&writeNetworkDictCallBack, // Change state: ready to switch on
&writeNetworkDictCallBack, // Change state: switched on
//&writeNetworkDictCallBack, // Enable positive limit switch
//&writeNetworkDictCallBack, // Enable negative limit switch
&writeNetworkDictCallBack, // Enable command (motion not actually started yet)
&writeNetworkDictCallBack, // Clear buffer
&writeNetworkDictCallBack, // Enable buffer
&writeNetworkDictCallBack, // Set time period to seconds
&writeNetworkDictCallBack, // Set time period to 1 (second)
&writeNetworkDictCallBack, // Set interpolation mode
&writeNetworkDictCallBack, // Set interpolation sub-mode (spline)
&writeNetworkDictCallBack
// Set first point to zero
};
/*
* Param
* current_position
*/UNS32 init_interpolation_param[50] =
{
0x6040, 0x0, 2, 0, 0x6, // Change state: ready to switch on
0x6040,