Hacking cartridge HP 84/85

Powder and inkjet printing
Wonko
Posts: 110
Joined: Sat Aug 15, 2015 8:13 pm

Re: Hacking cartridge HP 84/85

Post by Wonko »

Teensy uses an emulation program to allow for PORTB and PORTD commands, because Teensy has a different CPU.

Please check the link below to see how Teensy ports are named and assigned:

https://forum.pjrc.com/threads/17532-Tu ... PDIR-_PDOR

"One can use "GPIOD_PDIR" and "GPIOD_PDOR" as almost exact replacements for "PIND" and "PORTD", if you are willing to use a funny set of pins instead of a pins 0 through 7."

Image
MAsic12345
Posts: 116
Joined: Sat Aug 25, 2018 5:26 pm
Location: Poland

Re: Hacking cartridge HP 84/85

Post by MAsic12345 »

Wonko Thank you, how's your HP Designjet 90?
MAsic12345
Posts: 116
Joined: Sat Aug 25, 2018 5:26 pm
Location: Poland

Re: Hacking cartridge HP 84/85

Post by MAsic12345 »

again faileda
Attachments
787.png
787.png (66.98 KiB) Viewed 12721 times
User avatar
dragonator
Site Admin
Posts: 595
Joined: Fri Aug 14, 2015 4:48 pm
Location: The Nethelands
Contact:

Re: Hacking cartridge HP 84/85

Post by dragonator »

Your Serial.println(pinTable) will take time to process. It does this on every pin change. I doubt it will fix everything, but try commenting it for a test.

Another one that I think should save a little time is while(1==1). Make this while (1). It will do the same but requires no comparison.

You are only setting one pin at a time. Perhaps some of the signals allow you to set several pins at once. If you can do this, you can save a lot of time. The actual signals take 2us, even with the serial print command.

Next time I am at the Hackerspace I will take my Teensy 3.6 with me and attach it to the oscilloscope there.
Wonko
Posts: 110
Joined: Sat Aug 15, 2015 8:13 pm

Re: Hacking cartridge HP 84/85

Post by Wonko »

Serial.println(...); will take forever in the context. If you set 19200bps, sending a digit plus a newline character will take 8 bit per character plus start bit plus stop bit times two, or 19200/20bit = 960 calls per second maximum plus overhead. A microcontroller is different to a PC. The serial line buffer is exactly one byte in size, so sending a single byte over Serial is busy waiting for the byte to leave the buffer. In your code, you are sending two bytes between every state change, hence the long delay.

As for "while (1==1)" or "while (1)", the compiler will optimize that and generate the exact same machine code.

Try this in loop():

Code: Select all

for (;;) {
GPIOD_PDOR = 255;
GPIOD_PDOR = 0;
}
MAsic12345
Posts: 116
Joined: Sat Aug 25, 2018 5:26 pm
Location: Poland

Re: Hacking cartridge HP 84/85

Post by MAsic12345 »

1.8MHz what can be replaced on the spot (analogWrite)?
Attachments
56.png
56.png (29.4 KiB) Viewed 12714 times
User avatar
dragonator
Site Admin
Posts: 595
Joined: Fri Aug 14, 2015 4:48 pm
Location: The Nethelands
Contact:

Re: Hacking cartridge HP 84/85

Post by dragonator »

Analog write will give you high speeds, but is is not a signal, it is simply a square wave. Some of the signals could be made this way (like the clock), but the others need to be high or low, depending the data you need to send. I do not know of a way to synchronize this data with the clock while the clock signal is on the PWM hardware (though I suspect there should be a way)
MAsic12345
Posts: 116
Joined: Sat Aug 25, 2018 5:26 pm
Location: Poland

Re: Hacking cartridge HP 84/85

Post by MAsic12345 »

Here at last I achieved 12 megahertz
with code

Code: Select all

byte pinTable[] = {2,14,7,8,6,20,21,5};

void setup() 
    {
      for (int i=0; i<8; i++) 
      { 
        pinMode(pinTable[i],OUTPUT); 
      } 
    }

void loop() 
      {
      for (int i=0; i<=7; i++)
       {
         byte b = 1<<i;
         GPIOD_PDOR = b;
        
       }
      }
  
Here is a diagram and oscillogram
34623.png
34623.png (23.38 KiB) Viewed 12583 times
2233.png
2233.png (22.29 KiB) Viewed 12583 times
Please tell me how I will achieve 3 megahertz
code

Code: Select all

delay ()
too slow
User avatar
dragonator
Site Admin
Posts: 595
Joined: Fri Aug 14, 2015 4:48 pm
Location: The Nethelands
Contact:

Re: Hacking cartridge HP 84/85

Post by dragonator »

Now that you are running a Teensy, you can use the method I am using for the printhead driver right now.

The assembler no operation command instructs the microcontroller directly to not not do any operation this cycle.
1 no operation is around 10 nanoseconds and is written like this

Code: Select all

 __asm__("nop\n\t");
You can string them together like this.

Code: Select all

__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t"); //18 NOP's, ca. 200ns"
Use this code like it were a delay.

This value is for 96MHz on a Teensy 3.2. I will be different on a Teensy 3.6, but that you can tweak.

You also do not need the 8 pins and diodes to make it reach this speed on a single pin. The code below will do the same, only on just pin 1.

Code: Select all

byte pinTable[] = {2,14,7,8,6,20,21,5};

void setup() 
    {
      for (int i=0; i<8; i++) 
      { 
        pinMode(pinTable[i],OUTPUT); 
      } 
    }

void loop() 
      {
     	GPIOD_PDOR |= 1;
     	
     	GPIOD_PDOR &= !1;
      }
MAsic12345
Posts: 116
Joined: Sat Aug 25, 2018 5:26 pm
Location: Poland

Re: Hacking cartridge HP 84/85

Post by MAsic12345 »

dragonator
your code doesn't send a signal to the first output
I replaced it on the seventh
and failed to get 96 megahertz
What do you advise to do?
What place should I put the delay?
Attachments
35345.png
35345.png (43.82 KiB) Viewed 12584 times
Post Reply