Graynomad:
I can't see how the speed has any bearing on how many bytes are transmitted. It may have a bearing on how the printer handles them.
I can write 24 bytes but nothing gets transmitted after that.
How do you know this? Logic analyser trace?
If anyone wants ill attach the timing diagrams/datasheet.
That would be good.
Rob
I do agree it is quite odd, the transmission cut off. Whats even more odd is that the thermal printer print array consists of 6 heating blocks, each of 8 bytes. I can transmit perfectly to the first 3 but not the last three. Seldom i manage to address the last 3 but it is not consistent so im thinking its a speed issue.
No it i dont have a logic analyzer, its just a guess.
I have attached the datasheet.
68tjs:
You can write your own shiftout function and remove the for loop.
Have a look on wiring_shift.c file
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;
for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
}
change
uint8_t i;
for (i = 0; i < 8; i++)
by
uint16_t i; // with uint8_t imax= 255 too low for 384 bits
for (i = 0; i < 383; i++) // i<8 is for transmiting byte --> i<383 is for transmiting 384 bits
Other improvement: remove the arduino function digitalWrite and use direct register DDRx and PORTx manipulation. You will be 10 time faster.
Other solution use SPI : it can works with a 8MHz clock.
Would not using a for loop also speed it up? Im taking up your advise on using direct port addressing for sure!
LTPZ245-B_J.pdf (1.24 MB)