Hallo zusammen, ich habe nun schon das 3te Display bei folgendem Händler erworben: http://www.ebay.de/itm/CRIUS-CO-16-OLED-Display-Module-V1-0-for-MWC-MultiWii-Flight-Control-Board-/251195490020?ssPageName=ADME:X:DERP:DE:1123 ich verbinde das Display mit einem Atmega 328 und nutze Arduino mit einem i2C Scanner und auch der i2cOled ino-datei. Leider wird a das Display nicht als I2C erkannt und b die i2cOled läuft auch nicht. Das Display bleibt schwarz. Habe direkt 5V, GND und SDA,SCL angeschlossen. Was mache ich falsch? Gruß kami
Stefan S. schrieb: > Was mache ich falsch? So ziemlich alles? Mehr Details! Code, Schaltplan nach deinem aktuellen! Aufbau, usw.
Hi, also der Controller ist ein Jeenode SMD Kit: http://jeelabs.net/attachments/download/345/jlpcb-132.pdf Habe das Display direkt an 5V, GND, SDA, SCL geklemmt. für den I2C-Scanner nehme ich folgenden Code:
1 | #include <Wire.h> |
2 | |
3 | |
4 | void setup() |
5 | { |
6 | Wire.begin(); |
7 | |
8 | Serial.begin(9600); |
9 | Serial.println("\nI2C Scanner"); |
10 | } |
11 | |
12 | |
13 | void loop() |
14 | { |
15 | byte error, address; |
16 | int nDevices; |
17 | |
18 | Serial.println("Scanning..."); |
19 | |
20 | nDevices = 0; |
21 | for(address = 1; address < 127; address++ ) |
22 | { |
23 | // The i2c_scanner uses the return value of |
24 | // the Write.endTransmisstion to see if |
25 | // a device did acknowledge to the address. |
26 | Wire.beginTransmission(address); |
27 | error = Wire.endTransmission(); |
28 | |
29 | if (error == 0) |
30 | { |
31 | Serial.print("I2C device found at address 0x"); |
32 | if (address<16) |
33 | Serial.print("0"); |
34 | Serial.print(address,HEX); |
35 | Serial.println(" !"); |
36 | |
37 | nDevices++; |
38 | } |
39 | else if (error==4) |
40 | { |
41 | Serial.print("Unknow error at address 0x"); |
42 | if (address<16) |
43 | Serial.print("0"); |
44 | Serial.println(address,HEX); |
45 | } |
46 | } |
47 | if (nDevices == 0) |
48 | Serial.println("No I2C devices found\n"); |
49 | else |
50 | Serial.println("done\n"); |
51 | |
52 | delay(5000); // wait 5 seconds for next scan |
53 | } |
und für das Oled folgendes Paket:
1 | #include <avr/pgmspace.h> |
2 | #include <Wire.h> |
3 | //---------------FONT + GRAPHIC-----------------------------// |
4 | #include "C:\data.h" |
5 | //==========================================================// |
6 | |
7 | // OLED I2C bus address |
8 | #define OLED_address 0x3c |
9 | |
10 | |
11 | void setup() |
12 | { |
13 | // Initialize I2C and OLED Display |
14 | Wire.begin(); |
15 | init_OLED(); |
16 | reset_display(); // Clear logo and load saved mode |
17 | } |
18 | |
19 | |
20 | //==========================================================// |
21 | void loop() |
22 | { |
23 | |
24 | for(int i=0;i<128*8;i++) // show 128* 64 Logo |
25 | SendChar(pgm_read_byte(logo+i)); |
26 | delay(4000); |
27 | displayOn(); |
28 | |
29 | while(1) |
30 | { |
31 | clear_display(); |
32 | sendStrXY("Hardware Design by Mike Rankin",3,0); |
33 | delay(3000); |
34 | reset_display(); |
35 | } |
36 | //displayOff(); |
37 | //clear_display(); |
38 | //delay(4000); |
39 | |
40 | } |
41 | |
42 | //==========================================================// |
43 | // Resets display depending on the actual mode. |
44 | static void reset_display(void) |
45 | { |
46 | displayOff(); |
47 | clear_display(); |
48 | |
49 | |
50 | displayOn(); |
51 | } |
52 | |
53 | |
54 | |
55 | |
56 | //==========================================================// |
57 | // Turns display on. |
58 | void displayOn(void) |
59 | { |
60 | sendcommand(0xaf); //display on |
61 | } |
62 | |
63 | //==========================================================// |
64 | // Turns display off. |
65 | void displayOff(void) |
66 | { |
67 | sendcommand(0xae); //display off |
68 | } |
69 | |
70 | //==========================================================// |
71 | // Clears the display by sendind 0 to all the screen map. |
72 | static void clear_display(void) |
73 | { |
74 | unsigned char i,k; |
75 | for(k=0;k<8;k++) |
76 | { |
77 | setXY(k,0); |
78 | { |
79 | for(i=0;i<128;i++) //clear all COL |
80 | { |
81 | SendChar(0); //clear all COL |
82 | //delay(10); |
83 | } |
84 | } |
85 | } |
86 | } |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | |
93 | //==========================================================// |
94 | static void printBigTime(char *string) |
95 | { |
96 | |
97 | int Y; |
98 | int lon = strlen(string); |
99 | if(lon == 3) { |
100 | Y = 0; |
101 | } else if (lon == 2) { |
102 | Y = 3; |
103 | } else if (lon == 1) { |
104 | Y = 6; |
105 | } |
106 | |
107 | int X = 2; |
108 | while(*string) |
109 | { |
110 | printBigNumber(*string, X, Y); |
111 | |
112 | Y+=3; |
113 | X=2; |
114 | setXY(X,Y); |
115 | *string++; |
116 | } |
117 | } |
118 | |
119 | |
120 | //==========================================================// |
121 | // Prints a display big number (96 bytes) in coordinates X Y, |
122 | // being multiples of 8. This means we have 16 COLS (0-15) |
123 | // and 8 ROWS (0-7). |
124 | static void printBigNumber(char string, int X, int Y) |
125 | { |
126 | setXY(X,Y); |
127 | int salto=0; |
128 | for(int i=0;i<96;i++) |
129 | { |
130 | if(string == ' ') { |
131 | SendChar(0); |
132 | } else |
133 | SendChar(pgm_read_byte(bigNumbers[string-0x30]+i)); |
134 | |
135 | if(salto == 23) { |
136 | salto = 0; |
137 | X++; |
138 | setXY(X,Y); |
139 | } else { |
140 | salto++; |
141 | } |
142 | } |
143 | } |
144 | |
145 | //==========================================================// |
146 | // Actually this sends a byte, not a char to draw in the display. |
147 | // Display's chars uses 8 byte font the small ones and 96 bytes |
148 | // for the big number font. |
149 | static void SendChar(unsigned char data) |
150 | { |
151 | Wire.beginTransmission(OLED_address); // begin transmitting |
152 | Wire.write(0x40);//data mode |
153 | Wire.write(data); |
154 | Wire.endTransmission(); // stop transmitting |
155 | } |
156 | |
157 | //==========================================================// |
158 | // Prints a display char (not just a byte) in coordinates X Y, |
159 | // being multiples of 8. This means we have 16 COLS (0-15) |
160 | // and 8 ROWS (0-7). |
161 | static void sendCharXY(unsigned char data, int X, int Y) |
162 | { |
163 | setXY(X, Y); |
164 | Wire.beginTransmission(OLED_address); // begin transmitting |
165 | Wire.write(0x40);//data mode |
166 | |
167 | for(int i=0;i<8;i++) |
168 | Wire.write(pgm_read_byte(myFont[data-0x20]+i)); |
169 | |
170 | Wire.endTransmission(); // stop transmitting |
171 | } |
172 | |
173 | //==========================================================// |
174 | // Used to send commands to the display. |
175 | static void sendcommand(unsigned char com) |
176 | { |
177 | Wire.beginTransmission(OLED_address); //begin transmitting |
178 | Wire.write(0x80); //command mode |
179 | Wire.write(com); |
180 | Wire.endTransmission(); // stop transmitting |
181 | |
182 | } |
183 | |
184 | //==========================================================// |
185 | // Set the cursor position in a 16 COL * 8 ROW map. |
186 | static void setXY(unsigned char row,unsigned char col) |
187 | { |
188 | sendcommand(0xb0+row); //set page address |
189 | sendcommand(0x00+(8*col&0x0f)); //set low col address |
190 | sendcommand(0x10+((8*col>>4)&0x0f)); //set high col address |
191 | } |
192 | |
193 | |
194 | //==========================================================// |
195 | // Prints a string regardless the cursor position. |
196 | static void sendStr(unsigned char *string) |
197 | { |
198 | unsigned char i=0; |
199 | while(*string) |
200 | { |
201 | for(i=0;i<8;i++) |
202 | { |
203 | SendChar(pgm_read_byte(myFont[*string-0x20]+i)); |
204 | } |
205 | *string++; |
206 | } |
207 | } |
208 | |
209 | //==========================================================// |
210 | // Prints a string in coordinates X Y, being multiples of 8. |
211 | // This means we have 16 COLS (0-15) and 8 ROWS (0-7). |
212 | static void sendStrXY( char *string, int X, int Y) |
213 | { |
214 | setXY(X,Y); |
215 | unsigned char i=0; |
216 | while(*string) |
217 | { |
218 | for(i=0;i<8;i++) |
219 | { |
220 | SendChar(pgm_read_byte(myFont[*string-0x20]+i)); |
221 | } |
222 | *string++; |
223 | } |
224 | } |
225 | |
226 | |
227 | //==========================================================// |
228 | // Inits oled and draws logo at startup |
229 | static void init_OLED(void) |
230 | { |
231 | sendcommand(0xae); //display off |
232 | sendcommand(0xa6); //Set Normal Display (default) |
233 | // Adafruit Init sequence for 128x64 OLED module |
234 | sendcommand(0xAE); //DISPLAYOFF |
235 | sendcommand(0xD5); //SETDISPLAYCLOCKDIV |
236 | sendcommand(0x80); // the suggested ratio 0x80 |
237 | sendcommand(0xA8); //SSD1306_SETMULTIPLEX |
238 | sendcommand(0x3F); |
239 | sendcommand(0xD3); //SETDISPLAYOFFSET |
240 | sendcommand(0x0); //no offset |
241 | sendcommand(0x40 | 0x0); //SETSTARTLINE |
242 | sendcommand(0x8D); //CHARGEPUMP |
243 | sendcommand(0x14); |
244 | sendcommand(0x20); //MEMORYMODE |
245 | sendcommand(0x00); //0x0 act like ks0108 |
246 | |
247 | sendcommand(0xA0 | 0x1); //SEGREMAP //Rotate screen 180 deg |
248 | //sendcommand(0xA0); |
249 | |
250 | sendcommand(0xC8); //COMSCANDEC Rotate screen 180 Deg |
251 | //sendcommand(0xC0); |
252 | |
253 | sendcommand(0xDA); //0xDA |
254 | sendcommand(0x12); //COMSCANDEC |
255 | sendcommand(0x81); //SETCONTRAS |
256 | sendcommand(0xCF); // |
257 | sendcommand(0xd9); //SETPRECHARGE |
258 | sendcommand(0xF1); |
259 | sendcommand(0xDB); //SETVCOMDETECT |
260 | sendcommand(0x40); |
261 | sendcommand(0xA4); //DISPLAYALLON_RESUME |
262 | sendcommand(0xA6); //NORMALDISPLAY |
263 | |
264 | clear_display(); |
265 | sendcommand(0x2e); // stop scroll |
266 | //----------------------------REVERSE comments----------------------------// |
267 | // sendcommand(0xa0); //seg re-map 0->127(default) |
268 | // sendcommand(0xa1); //seg re-map 127->0 |
269 | // sendcommand(0xc8); |
270 | // delay(1000); |
271 | //----------------------------REVERSE comments----------------------------// |
272 | // sendcommand(0xa7); //Set Inverse Display |
273 | // sendcommand(0xae); //display off |
274 | sendcommand(0x20); //Set Memory Addressing Mode |
275 | sendcommand(0x00); //Set Memory Addressing Mode ab Horizontal addressing mode |
276 | // sendcommand(0x02); // Set Memory Addressing Mode ab Page addressing mode(RESET) |
277 | |
278 | setXY(0,0); |
279 | /* |
280 | for(int i=0;i<128*8;i++) // show 128* 64 Logo |
281 | { |
282 | SendChar(pgm_read_byte(logo+i)); |
283 | } |
284 | */ |
285 | sendcommand(0xaf); //display on |
286 | |
287 | |
288 | } |
Stefan S. schrieb: > Habe das Display direkt an 5V, GND, SDA, SCL geklemmt. Du brauchst auf jeden Fall noch Pullup Widerstände für SDA und SCL 1.5 KOhm passen immer ganz gut ,ohne die wird das mit der I2C kommunikation nichts.
Eine kurze Recherche zeigte ziemlich schnell: Dein OLED Module ist Mist! http://forum.arduino.cc/index.php?PHPSESSID=0p0n85bplhoiguaffotv7bojd7&topic=159851.60 Du kannst die Empfehlung von Eagle67 mal versuchen, aber wie er selbst schrieb, zuverlässig läuft es deswegen trotzdem nicht. Das heißt für dich: Wenn du ein zuverlässiges Display haben willst, wirst du es modifizieren müssen, da die Reset Funktion in dem eBay Modul nicht ordnungsgemäß verdrahtet ist und somit es sich nicht zuverlässig initialisiert, auch nicht mit oben genannten Code. http://forum.arduino.cc/index.php?PHPSESSID=pjgv84n1re6a0q06o8fprthcg7&topic=159851.msg1322649#msg1322649 http://rayvenn.alnet.com.ua/2013/08/crius-oled-display-fix/ Meine Empfehlung: Schmeiß es fort und kauf dir ein gescheites, bevor du, vor allem vermutlich als Anfänger, endlos kostbare Zeit damit verschwendest.
Hi, der Umbau mit dem Fix hat gut geklappt. Ich löte SMD schon etwas länger. Also die Erfahrung beim Umbau ist da. Aber irgendwie klappt das immer noch nicht? Noch jemand einen Tipp? Gruß kami
Hi, zusammen läuft jetzt alles super. Nachdem Umbau musste ich die CRIUSoled.ino aus dem ersten Forumpost nehmen. Die lief super. Vielen Dank Gruß kami
Könntest Du uns an Deinem Erfolg teilhaben lassen, indem Du die funktionierende Konfiguration oder Quellcode postest? Das wäre klasse. Ich habe selber ein CRIUS CO-16 v1.2, welches mir einige Fehler beschehrt.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.