No changes between revisions
/Modules/H_Bridge/HBSTEP01A/SW/Wiring/speed_control/build/speed_control.cpp
0,0 → 1,90
#include <SPI.h>
 
#include "WProgram.h"
void command(char* buffer, unsigned int len);
void goTo(unsigned int pos);
void setParam(unsigned int reg, unsigned int val, unsigned int len);
void setup();
int readInt();
void loop();
void command(char* buffer, unsigned int len)
{
for (int i = 0; i < len; i++) {
delay(10);
digitalWrite(SS, 0);
SPI.transfer(buffer[i]);
digitalWrite(SS, 1);
}
}
 
void goTo(unsigned int pos)
{
char buffer[4];
buffer[0] = 0x60;
buffer[1] = pos >> 16;
buffer[2] = (pos >> 8) & 0xff;
buffer[3] = pos & 0xff;
command(buffer, 4);
}
 
void setParam(unsigned int reg, unsigned int val, unsigned int len)
{
char buffer[4];
buffer[0] = reg;
/* BUG: reg? */
for (int i = 0; i < len; i++)
buffer[i + 1] = (reg >> (8 * ((len - 1) - i))) & 0xff;
command(buffer, 1 + len);
}
 
void setup()
{
Serial.begin(9600);
SPI.begin(SPI_MASTER, MSBFIRST, SPI_MODE3, SPI_CLOCK_DIV32);
setParam(5, 0xd0, 2); // ACC
setParam(6, 0xd0, 2); // DEC
setParam(7, 0, 2); // MAX_SPEED
Serial.println("Testovaci program pro HBSTEP01A");
}
 
int readInt()
{
char line[100];
int i = 0;
while (true) {
if (Serial.available()) {
byte c = Serial.read();
if (c == '\n' || c == '\r') {
Serial.println();
line[i] = '\0';
return atoi(line);
}
Serial.write(c);
line[i++] = c;
}
}
}
 
void loop()
{
int speed = readInt();
 
int dir = speed > 0;
if (!dir)
speed = -speed;
char buffer[4];
buffer[0] = 0x50 | dir;
buffer[1] = (speed >> 16) & 0xff;
buffer[2] = (speed >> 8) & 0xff;
buffer[3] = speed & 0xff;
command(buffer, 4);
}
 
/Modules/H_Bridge/HBSTEP01A/SW/Wiring/speed_control/build/speed_control.cpp.eep
0,0 → 1,0
:00000001FF
/Modules/H_Bridge/HBSTEP01A/SW/Wiring/speed_control/build/speed_control.cpp.elf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Modules/H_Bridge/HBSTEP01A/SW/Wiring/speed_control/build/speed_control.cpp.hex
0,0 → 1,270
:100000000C9436000C945E000C945E000C945E0020
:100010000C945E000C945E000C945E000C945705EA
:100020000C9480050C94A9050C944D060C94D205F3
:100030000C94FB050C9424060C94DC040C9405052C
:100040000C942E050C945E000C940D020C945E0230
:100050000C945E000C945E000C945E000C945E00A8
:100060000C945E000C945E004A04BF0711241FBE6E
:10007000CFEFD8E0DEBFCDBF11E0A0E0B1E0E4E714
:10008000F0E102C005900D92A634B107D9F712E055
:10009000A6E4B1E001C01D92A830B107E1F710E07D
:1000A000CCE6D0E004C02297FE010E940E08C836BC
:1000B000D107C9F70E9406020C9438080C9400007E
:1000C000CF92DF92FF920F931F93DF93CF93CDB721
:1000D000DEB7C456D0400FB6F894DEBF0FBECDBF1A
:1000E00000E010E06E010894C11CD11C80E591E095
:1000F0000E94AB03892BD1F380E591E00E94B0030D
:10010000F82E8AE0F81619F0EDE0FE16D9F480E535
:1001100091E00E948F04CE010196080F191FF8018B
:1001200010820E941208CC59DF4F0FB6F894DEBF40
:100130000FBECDBFCF91DF911F910F91FF90DF9048
:10014000CF90089580E591E06F2D0E94F303F601B2
:10015000E00FF11FF0820F5F1F4FC8CFEF92FF92A9
:100160000F931F93CF93DF937C018B01C0E0D0E00E
:1001700011C06AE070E080E090E00E94DC012A9803
:10018000F701EC0FFD1F86E491E060810E94A3015E
:100190002A9A2196C017D10760F3DF91CF911F9162
:1001A0000F91FF90EF900895DF93CF9300D000D090
:1001B000CDB7DEB70E9460009C0180E090E012168F
:1001C00013061CF481E090E003C0309521953F4F69
:1001D000806589831A823B832C83CE01019664E07B
:1001E00070E00E94AE000F900F900F900F90CF9193
:1001F000DF910895DF93CF9300D000D0CDB7DEB765
:10020000BC0189834150504E9A0183E0220F331F75
:100210008A95E1F74F5F5F41FE0132960AC0CB013C
:10022000022E02C0969587950A94E2F78193285092
:1002300030408FEF283F380791F74F5F5F4FCE0177
:100240000196BA010E94AE000F900F900F900F9090
:10025000CF91DF910895CF92DF92EF920F9390E5C7
:10026000C92E91E0D92EC60140E855E260E070E069
:1002700028E001E0EE240E94EB0286E491E061E0D8
:1002800041E02CE006E00E94670185E090E060ED2F
:1002900070E042E050E00E94FA0086E090E060EDFD
:1002A00070E042E050E00E94FA0087E090E060E0F9
:1002B00070E042E050E00E94FA00C60160E071E0A8
:1002C0000E94A6040F91EF90DF90CF9008950F93B6
:1002D000613021F5229A259A239A2498442319F40F
:1002E0008CB5806202C08CB58F7D8CBD8CB5837F50
:1002F000822B8CBD8CB5902F93708C7F982B9CBDDE
:100300002DB5802F90E0959587959595879581706F
:100310002E7F822B8DBD8CB580610FC022982598D1
:100320002398249A442319F48CB5806202C08CB5BA
:100330008F7D8CBD8CB5837F822B8CBD8CB580640A
:100340008CBD0F9108956EBD0DB407FEFDCF8EB527
:10035000089580914B0190914C01A0914D01B09175
:100360004E0130914F010196A11DB11D232F2D5F2C
:100370002D3720F02D570196A11DB11D20934F015F
:1003800080934B0190934C01A0934D01B0934E018B
:100390008091470190914801A0914901B0914A0193
:1003A0000196A11DB11D8093470190934801A09330
:1003B0004901B0934A010895EF92FF920F931F9362
:1003C0007B018C018FB7F89440914B0150914C0107
:1003D00060914D0170914E018FBF2FB7F8948091BD
:1003E0004B0190914C01A0914D01B0914E012FBF56
:1003F000841B950BA60BB70B8E159F05A007B107A5
:1004000060F31F910F91FF90EF9008950E94B10447
:100410000E942B010E94D400FDCF1F920F920FB6B5
:100420000F9211241F932F933F934F935F936F93DA
:100430007F938F939F93AF93BF93EF93FF93E0913D
:10044000A001F091A1011081E0915201F0915301BE
:100450000190F081E02D82E591E009958097E0F42C
:100460008091560190915701019690935701809386
:1004700056018091580190915901FC01E05BFE4FBB
:10048000148701969093590180935801809724F026
:100490001092590110925801FF91EF91BF91AF91C5
:1004A0009F918F917F916F915F914F913F912F918C
:1004B0001F910F900FBE0F901F9018951F920F92D3
:1004C0000FB60F9211242F938F939F93AF93BF93E7
:1004D000EF93FF938091800190918101892B09F125
:1004E000A091A001B091A101809180019091810122
:1004F0000197909381018093800180918401909174
:100500008501FC01E05BFE4F26A9019690938501D1
:1005100080938401409724F0109285011092840109
:100520002C938091800190918101892B31F4E0918D
:100530009C01F0919D0188E98083FF91EF91BF912B
:10054000AF919F918F912F910F900FBE0F901F90A1
:100550001895FC0184E291E09183808386E391E029
:100560009383828380E290E095838483178216824E
:1005700086819781938782879187808780E491E045
:1005800095A784A780E190E097A786A711AA10AA53
:1005900080A991A995AB84AB93AB82AB6623D1F4D0
:1005A000EA5BFF4F85EC90E08193919384EC90E0BF
:1005B0008193919380EC90E08193919381EC90E012
:1005C0008193919382EC90E08193919386EC90E0FB
:1005D0009183808308955F926F927F928F929F9212
:1005E000AF92BF92CF92DF92EF92FF920F931F9341
:1005F000CF93DF93EC015A016B01922E502E8E2C7B
:1006000060E072E18AE790E0A60195010E94CF07C1
:100610002C5F3F4F4F4F5F4F93E05695479537956F
:1006200027959A95D1F7390160E074E284EF90E064
:10063000A60195010E94CF072C5F3F4F4F4F5F4FA0
:1006400083E056954795379527958A95D1F7790197
:1006500040E050E060E874E88EE190E00E94F1072D
:1006600089010A191B0917FF03C0109501951F4F37
:10067000930140E050E060E472E48FE090E00E947B
:10068000F1072A193B0937FF03C0309521953F4FE9
:10069000FE01E65BFF4F021713073CF40190F08167
:1006A000E02D82E08083970105C00190F081E02D6C
:1006B000108293012150304086E0981669F0891528
:1006C00020F095E09916B9F409C087E0981641F03A
:1006D00099E0991681F406C082E00EC080E00CC05B
:1006E00084E00AC0C45BDF4FE881F981CC54D0407C
:1006F00080818460808386E092E0591609F48860E6
:1007000091E0891621F092E0891621F402C08063FD
:1007100001C08062C25BDF4FE881F9818083289746
:10072000E991F9913083E881F98120832496E88169
:10073000F98188E98083DF91CF911F910F91FF901C
:10074000EF90DF90CF90BF90AF909F908F907F9071
:100750006F905F900895FC0126813781C90108954B
:10076000DC01FC0186819781892B19F42FEF3FEF83
:1007700017C03FB7F894FD01868197810197978351
:10078000868382859385E80FF91F24850196FD01F4
:1007900093878287809714F0138612863FBF30E0DC
:1007A000C9010895CF93DF93DC01EC018E819F8115
:1007B000892B19F42FEF3FEF08C0ED01EA85FB8587
:1007C000EA0FFB1F8485282F30E0C901DF91CF910C
:1007D0000895FC011782168286819781938782870C
:1007E0009187808708950F931F93CF93DF93EC0138
:1007F000162F88A999A94097E0F70FB7F894ECA5B0
:10080000FDA50190F081E02DCE018C9609954097D1
:1008100090F488A999A9019699AB88AB8AA99BA95C
:10082000FE01E80FF91F16AB01969BAB8AAB409710
:1008300014F01BAA1AAAC45BDF4FE881F9818081FA
:10084000806280830FBFDF91CF911F910F91089538
:10085000FC0124813581C9010895FC012481358181
:10086000C9010895665F7F4F680F791FCB01089516
:10087000665F7F4F680F791FCB010895665F7F4FDA
:10088000680F791FCB010895665F7F4F680F791F4E
:10089000CB01089580E591E060E00E94A9020895EF
:1008A0000F931F93CF93DF938C01EB0109C0219627
:1008B000D801ED91FC910190F081E02DC8010995DE
:1008C00068816623A1F7DF91CF911F910F91089561
:1008D000EF92FF920F931F93CF93DF938C017B01D5
:1008E000EA010CC0D7016D917D01D801ED91FC9119
:1008F0000190F081E02DC80109952197209791F78B
:10090000DF91CF911F910F91FF90EF900895DC013F
:10091000ED91FC910280F381E02D099508950F93EC
:100920001F938C01DC01ED91FC910190F081E02D91
:100930006DE00995D801ED91FC910190F081E02DD9
:10094000C8016AE009951F910F9108950F931F93B5
:100950008C010E948704C8010E948F041F910F918F
:1009600008950F931F9302EA11E0C80163E00E940B
:10097000A607C80160E049EA51E021E00E947B0738
:10098000C80164E00E94760604EC11E0C80161E051
:100990000E94A607C80164E00E94760606EE11E0F8
:1009A000C80161E00E94A607C80164E00E947606C3
:1009B00078941F910F9108951F920F920FB60F9286
:1009C00011242F933F934F935F936F937F938F9354
:1009D0009F93AF93BF93EF93FF93E091BC01F0918E
:1009E000BD01309709F00995FF91EF91BF91AF914B
:1009F0009F918F917F916F915F914F913F912F9137
:100A00000F900FBE0F901F9018951F920F920FB668
:100A10000F9211242F933F934F935F936F937F9384
:100A20008F939F93AF93BF93EF93FF93E091BE019A
:100A3000F091BF01309709F00995FF91EF91BF91B7
:100A4000AF919F918F917F916F915F914F913F9166
:100A50002F910F900FBE0F901F9018951F920F921D
:100A60000FB60F9211242F933F934F935F936F9381
:100A70007F938F939F93AF93BF93EF93FF93E091F7
:100A8000BA01F091BB01309709F00995FF91EF9100
:100A9000BF91AF919F918F917F916F915F914F9196
:100AA0003F912F910F900FBE0F901F9018951F929E
:100AB0000F920FB60F9211242F933F934F935F9392
:100AC0006F937F938F939F93AF93BF93EF93FF9316
:100AD000E0910002F0910102309709F00995FF9131
:100AE000EF91BF91AF919F918F917F916F915F91A6
:100AF0004F913F912F910F900FBE0F901F9018951F
:100B00001F920F920FB60F9211242F933F934F9382
:100B10005F936F937F938F939F93AF93BF93EF9365
:100B2000FF93E0910202F0910302309709F00995DA
:100B3000FF91EF91BF91AF919F918F917F916F91B5
:100B40005F914F913F912F910F900FBE0F901F908B
:100B500018951F920F920FB60F9211242F933F9367
:100B60004F935F936F937F938F939F93AF93BF93B5
:100B7000EF93FF93E091FE01F091FF01309709F0B0
:100B80000995FF91EF91BF91AF919F918F917F91C7
:100B90006F915F914F913F912F910F900FBE0F90EA
:100BA0001F9018951F920F920FB60F9211242F933A
:100BB0003F934F935F936F937F938F939F93AF93E5
:100BC000BF93EF93FF93E091DE01F091DF01309747
:100BD00009F00995FF91EF91BF91AF919F918F918E
:100BE0007F916F915F914F913F912F910F900FBE29
:100BF0000F901F9018951F920F920FB60F9211240D
:100C00002F933F934F935F936F937F938F939F9314
:100C1000AF93BF93EF93FF93E091E001F091E10177
:100C2000309709F00995FF91EF91BF91AF919F9196
:100C30008F917F916F915F914F913F912F910F9085
:100C40000FBE0F901F9018951F920F920FB60F9224
:100C500011242F933F934F935F936F937F938F93C1
:100C60009F93AF93BF93EF93FF93E091DC01F091DB
:100C7000DD01309709F00995FF91EF91BF91AF9198
:100C80009F918F917F916F915F914F913F912F91A4
:100C90000F900FBE0F901F9018951F920F920FB6D6
:100CA0000F9211242F933F934F935F936F937F93F2
:100CB0008F939F93AF93BF93EF93FF93E091E401E2
:100CC000F091E501309709F00995FF91EF91BF91FF
:100CD000AF919F918F917F916F915F914F913F91D4
:100CE0002F910F900FBE0F901F901895FC018081DF
:100CF000823081F4643031F1653028F46230E1F003
:100D00006330F0F40FC0663009F16630E8F0673008
:100D100009F51EC06630B1F0673038F4623061F01A
:100D2000643071F06130B1F409C0683079F0683036
:100D300058F0693079F40CC092E00DC091E00BC01E
:100D400093E009C094E007C095E005C096E003C0B9
:100D500097E001C090E00284F385E02D8081887FD8
:100D6000982B90830895CF93DF93EC0168836130D3
:100D700019F1613020F0623009F06CC048C01B826C
:100D80001A8286E490E09D838C838EE690E09F83B8
:100D90008E8384E490E09987888785E490E09B8740
:100DA0008A871D861C8687E490E09F878E87198A34
:100DB000188A88E490E022C08FE690E09F838E83BB
:100DC00085E890E09B838A8384E890E09D838C8310
:100DD00080E890E09987888781E890E09B878A8700
:100DE00089E890E09D878C8788E890E09F878E87D0
:100DF0008BE890E0998B888B8AE890E09B8B8A8BBC
:100E00001D8A1C8A1F8A1E8A82E0898323C01B8256
:100E10001A8282EB90E09D838C8380E790E09F8331
:100E20008E8380EB90E09987888781EB90E09B87A9
:100E30008A871D861C8683EB90E09F878E87198AA0
:100E4000188A84EB90E09B8B8A8B1D8A1C8A1F8AF0
:100E50001E8A6983CE0160E00E947606EA81FB81EA
:100E6000309709F01082EC81FD811082198E188E66
:100E70001B8E1A8E1D8E1C8E1F8E1E8E19A218A2FE
:100E8000DF91CF910895FC01623071F0633028F456
:100E9000662381F0613071F505C0633039F064304C
:100EA00049F506C081E007C082E005C083E003C0C9
:100EB00085E001C080E00680F781E02D2081682F69
:100EC000772767FD709581E090E0062E02C0880FBD
:100ED000991F0A94E2F78095822320E030E04423B2
:100EE00011F021E030E002C0220F331F6A95E2F7D3
:100EF000822B80830895FC01623091F0633028F4E6
:100F0000662341F06130A1F408C0633061F06430C1
:100F100079F40CC0518F408F0BC0538F428F08C0A3
:100F2000558F448F05C0578F468F02C051A340A3F1
:100F3000452B29F4CF0140E00E9443070895222366
:100F400021F0CF0141E00E9443070895CF93DF9342
:100F5000EC01E885F9858081962F93708C7F982B22
:100F60009083EA85FB85808170E06C707070660FFD
:100F7000771F877E862B8083DF91CF91089582EA49
:100F800091E060E00E94B30684EC91E061E00E9491
:100F9000B30686EE91E062E00E94B3060895A1E2F6
:100FA0001A2EAA1BBB1BFD010DC0AA1FBB1FEE1FE3
:100FB000FF1FA217B307E407F50720F0A21BB30B2E
:100FC000E40BF50B661F771F881F991F1A9469F7AA
:100FD00060957095809590959B01AC01BD01CF0106
:100FE000089597FB092E05260ED057FD04D0D7DFB4
:100FF0000AD0001C38F450954095309521953F4F0C
:101000004F4F5F4F0895F6F79095809570956195D5
:101010007F4F8F4F9F4F0895EE0FFF1F0590F49164
:10102000E02D0994FC0188279927E894219120322A
:10103000E9F3293010F02E30C8F32B3241F02D3275
:1010400039F4689404C00E943008820F911D2191E8
:1010500020532A30C0F31EF4909581959F4F089538
:101060007AE0979F902D879F802D910D11240895F0
:04107000F894FFCF22
:10107400546573746F766163692070726F6772610F
:101084006D2070726F2048425354455030314100F6
:1010940000000000F30350046804AB03D203B00360
:1010A400E903000000002D043E0444040000000095
:0610B40028043204380498
:00000001FF
/Modules/H_Bridge/HBSTEP01A/SW/Wiring/speed_control/build/speed_control.pde
0,0 → 1,82
#include <SPI.h>
 
void command(char* buffer, unsigned int len)
{
for (int i = 0; i < len; i++) {
delay(10);
digitalWrite(SS, 0);
SPI.transfer(buffer[i]);
digitalWrite(SS, 1);
}
}
 
void goTo(unsigned int pos)
{
char buffer[4];
buffer[0] = 0x60;
buffer[1] = pos >> 16;
buffer[2] = (pos >> 8) & 0xff;
buffer[3] = pos & 0xff;
command(buffer, 4);
}
 
void setParam(unsigned int reg, unsigned int val, unsigned int len)
{
char buffer[4];
buffer[0] = reg;
/* BUG: reg? */
for (int i = 0; i < len; i++)
buffer[i + 1] = (reg >> (8 * ((len - 1) - i))) & 0xff;
command(buffer, 1 + len);
}
 
void setup()
{
Serial.begin(9600);
SPI.begin(SPI_MASTER, MSBFIRST, SPI_MODE3, SPI_CLOCK_DIV32);
setParam(5, 0xd0, 2); // ACC
setParam(6, 0xd0, 2); // DEC
setParam(7, 0, 2); // MAX_SPEED
Serial.println("Testovaci program pro HBSTEP01A");
}
 
int readInt()
{
char line[100];
int i = 0;
while (true) {
if (Serial.available()) {
byte c = Serial.read();
if (c == '\n' || c == '\r') {
Serial.println();
line[i] = '\0';
return atoi(line);
}
Serial.write(c);
line[i++] = c;
}
}
}
 
void loop()
{
int speed = readInt();
 
int dir = speed > 0;
if (!dir)
speed = -speed;
char buffer[4];
buffer[0] = 0x50 | dir;
buffer[1] = (speed >> 16) & 0xff;
buffer[2] = (speed >> 8) & 0xff;
buffer[3] = speed & 0xff;
command(buffer, 4);
}
/Modules/H_Bridge/HBSTEP01A/SW/Wiring/speed_control/speed_control.pde
0,0 → 1,82
#include <SPI.h>
 
void command(char* buffer, unsigned int len)
{
for (int i = 0; i < len; i++) {
delay(10);
digitalWrite(SS, 0);
SPI.transfer(buffer[i]);
digitalWrite(SS, 1);
}
}
 
void goTo(unsigned int pos)
{
char buffer[4];
buffer[0] = 0x60;
buffer[1] = pos >> 16;
buffer[2] = (pos >> 8) & 0xff;
buffer[3] = pos & 0xff;
command(buffer, 4);
}
 
void setParam(unsigned int reg, unsigned int val, unsigned int len)
{
char buffer[4];
buffer[0] = reg;
/* BUG: reg? */
for (int i = 0; i < len; i++)
buffer[i + 1] = (reg >> (8 * ((len - 1) - i))) & 0xff;
command(buffer, 1 + len);
}
 
void setup()
{
Serial.begin(9600);
SPI.begin(SPI_MASTER, MSBFIRST, SPI_MODE3, SPI_CLOCK_DIV32);
setParam(5, 0xd0, 2); // ACC
setParam(6, 0xd0, 2); // DEC
setParam(7, 0, 2); // MAX_SPEED
Serial.println("Testovaci program pro HBSTEP01A");
}
 
int readInt()
{
char line[100];
int i = 0;
while (true) {
if (Serial.available()) {
byte c = Serial.read();
if (c == '\n' || c == '\r') {
Serial.println();
line[i] = '\0';
return atoi(line);
}
Serial.write(c);
line[i++] = c;
}
}
}
 
void loop()
{
int speed = readInt();
 
int dir = speed > 0;
if (!dir)
speed = -speed;
char buffer[4];
buffer[0] = 0x50 | dir;
buffer[1] = (speed >> 16) & 0xff;
buffer[2] = (speed >> 8) & 0xff;
buffer[3] = speed & 0xff;
command(buffer, 4);
}