digitalWrite()???

Hello Arduino friends!

thanks for everyone who helped me with last posts. I am currently working on a cool project which is driving a thermal printer of a POS device. I have successfully drove the motor and now I am working on printing section. here is my code for printing section:

updateShiftRegister(data);
              
            digitalWrite(DST1, HIGH);
            delayMicroseconds(840);
            digitalWrite(DST1, LOW);

            digitalWrite(DST2, HIGH);
            delayMicroseconds(840);
            digitalWrite(DST2, LOW);

            digitalWrite(DST3, HIGH);
            delayMicroseconds(840);
            digitalWrite(DST3, LOW);

            digitalWrite(DST4, HIGH);
            delayMicroseconds(840);
            digitalWrite(DST4, LOW);

            digitalWrite(DST5, HIGH);
            delayMicroseconds(840);
            digitalWrite(DST5, LOW);

            digitalWrite(DST6, HIGH);
            delayMicroseconds(840);
            digitalWrite(DST6, LOW);

            
      
    }
    
 }
  
 }
}
 
 void updateShiftRegister(uint8_t *image){
      
      digitalWrite(LAT,HIGH);
      for(int row=0; row<384; row+=48){
         shiftOut(DI, CLK, LSBFIRST, image[row]);  
        }
      digitalWrite(LAT,LOW);
 }

where “data” is a bitmap image I’ve attached below.

now when I start the process and drive motor simultaneously, I get nothing on paper. what do you think is the problem people?

I can see some out going pulses on DST2-6 with 3v MAX but on DST1 I only see one pulse with 5v MAX!

thanks again everyone! I hope I’ll be able to SOLVE this problem with you and share the solution so we all can use it for our future projects.

bitmap.ino (4 KB)

void updateShiftRegister(uint8_t *image) {
  digitalWrite(LAT, HIGH);
  for (int row = 0; row < 384; row += 48) {
    shiftOut(DI, CLK, LSBFIRST, image[row]);
  }
  digitalWrite(LAT, LOW);
}

Why are you only sending out every 48th byte of the first 384 bytes of a 750 byte array? (750 bytes being the size of the data array)

I can see some out going pulses on DST2-6 with 3v MAX but on DST1 I only see one pulse with 5v MAX!

No idea, the problem is somewhere in the part of the code you did not post, or in how you have everything connected together.

Since you are storing the data array in PROGMEM, you cannot access it in the updateShiftRegister() function as image[row], you need to use pgm_read_byte(&image[row])

what do you mean by PROGMEM?

Look at how the data array is declared and initialised in bitmap.ino

static const uint8_t PROGMEM data[] = {
  0x00,0x00,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x01,0xf0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0xf0,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x03,0xf8,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x07,0xf8,0x00,0x00,0x00,0x00,
etc, etc

now I only want to print a single line so I just send 1 to DI pin which is data pin. but as I've said, still the same results

Sorry, but I cannot make much sense of that. Can you please explain it in more detail, perhaps with an example

My guess is that the output pins on which you see only 3V were either not set to pinMode(pin, OUTPUT) or they are driving too heavy a load. I can't tell which because you are not showing the relavent parts of your code and not showing the wiring at all.

now the problem is that with the last code is that when I turn DSTs on, I only get 5v on DST1, which the first DST to be turned, and on the rest I get 3v!!! even though I've wrote digitalWrite(DSTi,HIGH)

Sounds like your circuit is poorly designed or the power supply is not up to driving the current. Can you post a schematic.

Also read https://snippets-r-us.com to see advice on selecting the right snippet to post.

Thanks for that but I really meant a schematic of your circuit not a physical layout diagram.

What is that board in the middle of your bread board, what is its part number and can you post a link to its data sheet.

What voltage are you feeding in from that socket on the bread board and where is it coming from. What is the current capacity of this external power source. Have you got a data sheet for the printer which shows how much current each dot input requires?

yellow wires present DSTs

I can’t see any yellow wires in what you posted? As those are the ones you are having trouble with I would have expected to see them somewhere even in a physical layout diagram.

FWIW - here's the OP's 'wiring' diagram
wiring.jpg

wiring.jpg