Commit 01e0e7b7b34e136045bd83af05f5eb28e9d4d146

Authored by pfrison
1 parent 3fcb1d7b

modification PercTeacher java et test moteurs sur le robot (pcb)

PercTeacher/Sources/ApplicationJava/SerialCommands.java
... ... @@ -2,9 +2,19 @@
2 2 public class SerialCommands {
3 3 public static void sendDeltas(SerialCom serialCom, int deltaLeft, int deltaRight) {
4 4 byte dataL1 = (byte) ((deltaLeft & 0xFF00) >> 8);
  5 + if(deltaLeft < 0)
  6 + dataL1 &= 0x7F;
  7 + else
  8 + dataL1 |= 0x80;
5 9 byte dataL2 = (byte) (deltaLeft & 0xFF);
  10 +
6 11 byte dataR1 = (byte) ((deltaRight & 0xFF00) >> 8);
  12 + if(deltaRight < 0)
  13 + dataR1 &= 0x7F;
  14 + else
  15 + dataR1 |= 0x80;
7 16 byte dataR2 = (byte) (deltaRight & 0xFF);
  17 +
8 18 byte[] data = new byte[] {dataL1, dataL2, dataR1, dataR2};
9 19 serialCom.send(data);
10 20  
... ...
tests/atmega2560/servoAndStepperControl/servoAndStepperControl.c
... ... @@ -3,26 +3,26 @@
3 3  
4 4 int main(void){
5 5 // pin 13
6   - DDRB = 0xC0;
  6 + DDRB = 0x60;
7 7  
8   - PORTB |= 0x40; // forward
  8 + PORTB |= 0x20; // forward
9 9 int i = 0;
10 10 int sens = 0;
11 11 while(1){
12 12 // step
13   - PORTB |= 0x80;
14   - _delay_ms(5);
15   - PORTB &= 0x7F;
16   - _delay_ms(5);
  13 + PORTB |= 0x40;
  14 + _delay_ms(2);
  15 + PORTB &= 0xBF;
  16 + _delay_ms(2);
17 17 // dir
18 18 i++;
19   - if(i > 200){
  19 + if(i > 1000){
20 20 i = 0;
21 21 sens = 1 - sens;
22 22 if(sens == 0)
23   - PORTB |= 0x40; // forward
  23 + PORTB |= 0x20; // forward
24 24 else
25   - PORTB &= 0xBF; // backward
  25 + PORTB &= 0xDF; // backward
26 26 }
27 27 }
28 28 return 0;
... ...