Page 8 of 17

Re: Hacking cartridge HP 84/85

Posted: Fri Nov 02, 2018 9:20 pm
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

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 03, 2018 9:54 am
by MAsic12345
Wonko Thank you, how's your HP Designjet 90?

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 03, 2018 11:43 am
by MAsic12345
again faileda

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 03, 2018 12:27 pm
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.

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 03, 2018 2:46 pm
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;
}

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 03, 2018 4:45 pm
by MAsic12345
1.8MHz what can be replaced on the spot (analogWrite)?

Re: Hacking cartridge HP 84/85

Posted: Sun Nov 04, 2018 9:34 pm
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)

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 10, 2018 9:57 am
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 12643 times
2233.png
2233.png (22.29 KiB) Viewed 12643 times
Please tell me how I will achieve 3 megahertz
code

Code: Select all

delay ()
too slow

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 10, 2018 10:35 am
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;
      }

Re: Hacking cartridge HP 84/85

Posted: Sat Nov 10, 2018 12:41 pm
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?