📜 ⬆️ ⬇️

Futaba M204SD02AJ indicator in sequential mode

image

In this article I want to share the experience of using the FUTABA MSD204AJ indicator in the serial interface mode. We will program on arduine.

To put the indicator into serial mode, jumpers must be set in accordance with the datasheet :

J3-on
J4-off
J5-on
J6-on
J7-off
')
image

In this mode, the pin assignment is as follows (in accordance with table 11):

1 - General
2 - 5V power supply
3 - I / O data
4 - Strobe pulse
6 - Clock pulses

A typical parcel to an indicator consists of a start byte and the byte of the information we need directly (be it a command or data).

The start byte consists of five logical units, the RW Read (1) / Write bit (0), the RS identifier bit. Commands (0) / Data (1), the logical zero - a total of eight bits. In this case, the recording of bits in the indicator occurs on the leading edge of the clock pulse. And reading the bits from the indicator is on the falling edge. Any read / write sending starts after the falling edge of the Strobe signal, and ends at the leading edge.

image

1 - at this moment the reception / transmission begins.
2 - reception / transmission ends at that moment
3 - at this moment the indicator is reading the bit
4 - bit Defines Write / Read

In general, our task:

1. set the strobe to zero.
2. set the clock output to zero.
3. issue an information bit.
3a a bit to wait.
4. Set the clock output to unity.
4a. a bit to wait.
5a points 2-4 do 8 times. - this will be the first byte.
5b points 2-4 do another 8 times. - it will be the second byte.
6. Install the gate into the unit.

So, we take the arduin mockup and development environment.

Let's declare defajny:

#define _STB 2 #define _SCK 3 #define _SISO 4 

Configure the Arduin ports:

  pinMode(_STB, OUTPUT); pinMode(_SCK, OUTPUT); pinMode(_SISO, OUTPUT); 

Install strob and clock in the log unit:

  digitalWrite(_STB,1); digitalWrite(_SCK,1); 

And start sending bits to the indicator. Since we need to send 2 bytes one after the other, then we will do it using a nested for loop in for.

Create a procedure, call it futab. It will use two incoming variables. x1 is the first start byte, x2 is the data byte.

 void futab(int x1, int x2){ digitalWrite(_STB,0); //.1 for (j=1; j<3; j++){ if (j==1) {cmd = x1;} else {cmd = x2;} //. 5, 5 for (i=7; i>-1; i--) { digitalWrite(_SCK,0); //.2 digitalWrite(_SISO,bitRead(cmd,i)); //.3    i-   delayMicroseconds(2); //.3   digitalWrite(_SCK,1); //.4 delayMicroseconds(2); //.4   } } digitalWrite(_STB,1); //.6 } 

Well and everything, it is possible to use this procedure. How? That's how:

 futab(0b11111000,0b00000001); //    4-4-1  . //   futab(0b11111000,0b10010101); //    4-4-8   DDRAM = 15h, ..    3-  2-  //    futab(0b11111010,0b010000010); //  41h ( ).  4-4-10. 

This is how it looks on the oscilloscope screen.

image

image

Well, then just throw the commands and data in the indicator and get on the scoreboard all sorts of inscriptions. The command system itself is very similar to the commands of the popular HD44780 controller, with the exception of a pair of control bits that can be used to control the brightness of the indicator.

Since I don’t see the use of this indicator, I’ll display a simple Hello, world. I will write what is called in the forehead, spell. No libraries, only character codes, only hardcore.

Here is the code
 /* FUTABA */ #define _STB 2 #define _SCK 3 #define _SISO 4 int i,j,n,m; int cmd; void futab(int x1, int x2){ digitalWrite(_STB,0); for (j=1; j<3; j++){ // delay(1500); if (j==1) {cmd = x1;} else {cmd = x2;} for (i=7; i>-1; i--) { digitalWrite(_SCK,0); digitalWrite(_SISO,bitRead(cmd,i)); delayMicroseconds(2); digitalWrite(_SCK,1); delayMicroseconds(2); } } digitalWrite(_STB,1); delay(50); } void setup() { // put your setup code here, to run once: Serial.begin(9600); // starts the serial monitor pinMode(_STB, OUTPUT); //  "  " pinMode(_SCK, OUTPUT); pinMode(_SISO, OUTPUT); digitalWrite(_STB,1); //      digitalWrite(_SCK,1); futab(248,1); //   4-4-1 delay(2000); //   futab(250,0x87); //  futab(250,0x50); //  futab(250,0x84); //  futab(250,0x42); //  futab(250,0x45); //  futab(250,0x54); //  futab(248,0b11000011); //  4-4-8   =43h    ,   futab(250,0x48); // H futab(250,0x61); // a futab(250,0x62); // b futab(250,0x72); // r futab(248,0b11011111); //  4-4-8   =5Fh  4- , 12  futab(250,0x35); // 5 futab(250,0x65); // e futab(250,0x72); // r futab(250,0x47); // G futab(250,0x30); // 0 futab(248,0b10011011); //  4-4-8   =5Dh  3- , 10  futab(250,0x30); // 0 futab(250,0x37); // 7 futab(250,0x2E); // . futab(250,0x30); // 0 futab(250,0x34); // 4 futab(250,0x2E); // . futab(250,0x32); // 2 futab(250,0x30); // 0 futab(250,0x31); // 1 futab(250,0x36); // 6 for (m=1; m<5; m++){ for (n=1; n<4; n++){ futab(248,0b00011100); // 4-4-5     delay(100); } for (n=1;n<4;n++){ futab(248,0b00011000); // 4-4-5     delay(100); } } delay(1500); for (n=1;n<5;n++){ futab(248,0b00001000); // 4-4-4   delay(100); futab(248,0b00001100); // 4-4-4   delay(100); } delay(1500); for (n=1;n<5;n++){ futab(248,0b00111101); // 4-4-6   75% delay(100); futab(248,0b00111110); // 4-4-6   50% delay(100); futab(248,0b00111111); // 4-4-6   25% delay(100); futab(248,0b00111110); // 4-4-6   50% delay(100); futab(248,0b00111101); // 4-4-6   75% delay(100); futab(248,0b00111100); // 4-4-6   100% delay(100); } delay(1000); //     futab(248,0b01001000); // 4-4-7   CGRAM=8 futab(250,0b00001110); futab(250,0b00010001); futab(250,0b00010001); futab(250,0b00010011); // futab(250,0b00010111); futab(250,0b00011111); futab(250,0b00011111); futab(250,0b00011111); futab(248,0b01010000); // 4-4-7   CGRAM=16 futab(250,0b00000000); futab(250,0b00000001); futab(250,0b00000110); futab(250,0b00001100); //-  futab(250,0b00010001); futab(250,0b00000110); futab(250,0b00001100); futab(250,0b00010000); //    futab(248,0b10010011); //    1*20 futab(250,0b00000001); //    CGRAM c  1 futab(248,0b11010011); //    2*20 futab(250,0b00000010); //    CGRAM c  2 } void loop() { } 


image

And in conclusion of the video work:

Source: https://habr.com/ru/post/392757/


All Articles