Hallo an das Forum!
Ich habe folgendes Problem. Ich möchte einen 5pol Schrittmotor Schaltung
PCF8574/ULN2803 über den I2C Bus ansteuern.
Hier habe ich mal einen C Code als Ansatzpunkt geschrieben:
1 | #include "main.h"
|
2 |
|
3 | #include "i2c.h"
|
4 |
|
5 | #define STEPPER_DEV 0x42 //Adresse für PCF8574
|
6 |
|
7 | int motorStep[4]; // Array für Steppersequenz
|
8 |
|
9 | void stepper_left(void)
|
10 | {
|
11 | InitI2C();
|
12 | StartI2C(STEPPER_DEV);
|
13 |
|
14 | motorStep[0] = 0x0A; // Binär: 0000_1010;
|
15 | motorStep[1] = 0x06; // Binär: 0000_0110;
|
16 | motorStep[2] = 0x05; // Binär: 0000_0101;
|
17 | motorStep[3] = 0x09; // Binär: 0000_1001;
|
18 |
|
19 | for (int i=0;i < 4;i++)
|
20 | WriteI2C(motorStep[i]);
|
21 | StopI2C();
|
22 | }
|
23 |
|
24 | void stepper_right(void)
|
25 | {
|
26 |
|
27 | InitI2C();
|
28 | StartI2C(STEPPER_DEV);
|
29 |
|
30 | motorStep[0] = 0x09; // Binär: 0000_1001;
|
31 | motorStep[1] = 0x05; // Binär: 0000_0101;
|
32 | motorStep[2] = 0x06; // Binär: 0000_0110;
|
33 | motorStep[3] = 0x0A; // Binär: 0000_1010;
|
34 |
|
35 | for (int i=0;i < 4;i++)
|
36 | WriteI2C(motorStep[i]);
|
37 |
|
38 | StopI2C();
|
39 | }
|
Bin ich mit dieser Routine auf dem richtigen Weg. Bin noch unerfahren in
C Code. Hat jemand für mich einen Link indem soetwa in C Code realisiert
ist
Danke für eure Mühe von OLLI