Hacking cartridge HP 84/85
Re: Hacking cartridge HP 84/85
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."
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."
-
- Posts: 116
- Joined: Sat Aug 25, 2018 5:26 pm
- Location: Poland
Re: Hacking cartridge HP 84/85
Wonko Thank you, how's your HP Designjet 90?
-
- Posts: 116
- Joined: Sat Aug 25, 2018 5:26 pm
- Location: Poland
- dragonator
- Site Admin
- Posts: 597
- Joined: Fri Aug 14, 2015 4:48 pm
- Location: The Nethelands
- Contact:
Re: Hacking cartridge HP 84/85
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.
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
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():
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;
}
-
- Posts: 116
- Joined: Sat Aug 25, 2018 5:26 pm
- Location: Poland
Re: Hacking cartridge HP 84/85
1.8MHz what can be replaced on the spot (analogWrite)?
- Attachments
-
- 56.png (29.4 KiB) Viewed 14784 times
- dragonator
- Site Admin
- Posts: 597
- Joined: Fri Aug 14, 2015 4:48 pm
- Location: The Nethelands
- Contact:
Re: Hacking cartridge HP 84/85
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)
-
- Posts: 116
- Joined: Sat Aug 25, 2018 5:26 pm
- Location: Poland
Re: Hacking cartridge HP 84/85
Here at last I achieved 12 megahertz
with code
Here is a diagram and oscillogram
Please tell me how I will achieve 3 megahertz
code
too slow
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;
}
}
code
Code: Select all
delay ()
- dragonator
- Site Admin
- Posts: 597
- Joined: Fri Aug 14, 2015 4:48 pm
- Location: The Nethelands
- Contact:
Re: Hacking cartridge HP 84/85
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
You can string them together like this.
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.
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");
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"
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;
}
-
- Posts: 116
- Joined: Sat Aug 25, 2018 5:26 pm
- Location: Poland
Re: Hacking cartridge HP 84/85
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?
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 (43.82 KiB) Viewed 14654 times