Post Reply 
HP41C with Rp Pico attached
05-31-2023, 06:27 AM (This post was last modified: 05-31-2023 08:54 AM by blackjetrock.)
Post: #1
HP41C with Rp Pico attached
This is a project that I have been working on. It is a RP Pico sitting on the bus of an HP41C. It can trace the bus traffic and dump to USB and can also drive the bus and hence emulate a module or modules. It can also enter programs by pressing keys on the keyboard. There's a small OLED display that mirrors the LCD. It is very much a work in progress, so for instance, the entered programs aren't quite right and I've only emulated the MATH module.

https://github.com/blackjetrock/pico41.git

Andrew
Find all posts by this user
Quote this message in a reply
05-31-2023, 08:01 AM
Post: #2
RE: HP41C with Rp Pico attached
Hi Andrew!

Very interesting project indeed!

I assume this is connected between the CPU-board and the main PCB/Keyboard.
Would it be possible to connect the "analyzer" between the PCB/Keyboard and the I/O-module?
I guess that the information from (and emulating) the keyboard will be lost, maybe also vital part of the display I/O?
The reason I'm asking is that it might be possible to use a flex-strip (see this link), without soldering something inside the HP41.
Or even using only an old module connector just to analyze the inter-module communication.

Emulating modules is one achievement, but with USB connection a lot of other interesting possibilities might also be possible ...
I.e. maybe emulating the card reader or Wand to insert/save programs into the 41 from a PC Wink

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
05-31-2023, 08:31 AM
Post: #3
RE: HP41C with Rp Pico attached
(05-31-2023 08:01 AM)ThomasF Wrote:  Hi Andrew!

Very interesting project indeed!

I assume this is connected between the CPU-board and the main PCB/Keyboard.
Would it be possible to connect the "analyzer" between the PCB/Keyboard and the I/O-module?

The connections are soldered on to the CPU IC. That allows connection to the key matrix and the ISA/DATA etc bus lines. As it's a bus then it could be attached wherever those signals exist. You could build this into a module, I'd have thought, the components are small enough, but then you'd not have access to the keyboard matrix signals.

Quote:I guess that the information from (and emulating) the keyboard will be lost, maybe also vital part of the display I/O?
The reason I'm asking is that it might be possible to use a flex-strip (see this link), without soldering something inside the HP41.
Yes, you could connect it with a flexi circuit.

Quote:Or even using only an old module connector just to analyze the inter-module communication.

I think if you did build it into a module then you'd get access to all module and processor traffic as it is one bus connecting the modules,ROM,RAM and processor.

Quote:Emulating modules is one achievement, but with USB connection a lot of other interesting possibilities might also be possible ...
I.e. maybe emulating the card reader or Wand to insert/save programs into the 41 from a PC Wink

Yes, I've had a quick think about that. As the hardware for the wand and card reader is in the module or reader then it's tricky to get data inserted into the machine as you'd have to write your own ROM.
I have loaded programs by pressing keys. You take the text of a program, run it through a tool, reprogram the Pico and then you can select a menu option on the Pico interface and it presses the appropriate keys to load the program.
I'm going to have a look at emulating RAM as well as ROM so it should be possible to save and load all of the RAM contents that is emulated over the USB.

But, yes, lots of options.

Quote:Cheers,
Thomas
Find all posts by this user
Quote this message in a reply
06-01-2023, 05:24 AM
Post: #4
RE: HP41C with Rp Pico attached
(05-31-2023 08:01 AM)ThomasF Wrote:  Emulating modules is one achievement, but with USB connection a lot of other interesting possibilities might also be possible ...
I.e. maybe emulating the card reader or Wand to insert/save programs into the 41 from a PC Wink

Thinking about it, as the hardware is in the module, and the module is being emulated then it might be possible to emulate hardware like the card reader as well. If the amount of processing isn't too much. This does all of its emulation and tracing in firmware.

Andrrew
Find all posts by this user
Quote this message in a reply
06-01-2023, 05:53 AM
Post: #5
RE: HP41C with Rp Pico attached
(06-01-2023 05:24 AM)blackjetrock Wrote:  
(05-31-2023 08:01 AM)ThomasF Wrote:  Emulating modules is one achievement, but with USB connection a lot of other interesting possibilities might also be possible ...
I.e. maybe emulating the card reader or Wand to insert/save programs into the 41 from a PC Wink

Thinking about it, as the hardware is in the module, and the module is being emulated then it might be possible to emulate hardware like the card reader as well. If the amount of processing isn't too much. This does all of its emulation and tracing in firmware.

Andrrew

Hi Andrew,

Yes, that was my thought too. I've done similar emulations on other mobile devices, so I think it should be possible.
I.e. the Wand is quite "simple", and emulating that up to 16 bytes are available to be sent shouldn't be that hard to implement, dividing a program into 16 bytes chunks and feed them to the emulation of the module.
But, I've not seen any commented listing of the Wand ROM, so it might take a while to decode the processing, emulating the hardware connected to the module ...
If successful we could then use a battery powered Pico or similar device with WiFi or Bluetooth, and it should be possible to wireless transfer programs to the 41 - a dream come through!

With the Card Reader it would also be possible to send program from the 41, but that's another story ...

Another possibility would be to emulate X-Memory, and enable the Pico to send or receive programs to be stored in the XM, ie use the XM as a dual port memory - allowing a PC to read and write to that memory in realtime. The layout of the XM filesystem is well known, so that might be an easier approach (but not as fun as emulating hardware IMHO).

For me it sound like a very interesting thing to dive into, and I have already ordered some Pico's to play with ... Wink
Just wishing that time was something you could order online as well ... Tongue

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
06-01-2023, 06:11 AM
Post: #6
RE: HP41C with Rp Pico attached
(06-01-2023 05:53 AM)ThomasF Wrote:  I.e. the Wand is quite "simple", and emulating that up to 16 bytes are available to be sent shouldn't be that hard to implement, dividing a program into 16 bytes chunks and feed them to the emulation of the module.
But, I've not seen any commented listing of the Wand ROM, so it might take a while to decode the processing, emulating the hardware connected to the module ...

Having a ROM image and information about the hardware will be almost essential. One thing that makes this project possible is that there is a lot of information about the 41C and it's peripherals.

Quote:If successful we could then use a battery powered Pico or similar device with WiFi or Bluetooth, and it should be possible to wireless transfer programs to the 41 - a dream come through!

unfortunately the RP2040 (Pico IC) isn't a very low power device. It is low-ish power consumption so battery power is definitely an option but it isn't anywhere as low power as the HP41C itself, for instance.

Quote:With the Card Reader it would also be possible to send program from the 41, but that's another story ...

Is the card reader well documented?

Quote:Another possibility would be to emulate X-Memory, and enable the Pico to send or receive programs to be stored in the XM, ie use the XM as a dual port memory - allowing a PC to read and write to that memory in realtime. The layout of the XM filesystem is well known, so that might be an easier approach (but not as fun as emulating hardware IMHO).
As the Pico has the ROM that is being emulated in it's flash memory then you can already send and receive programs in ROM format to and from a PC by re-programming the Pico. The Pico code is actually storing the data in RAM and so it can be changed on the fly with the code on Github now. You'd need to add USB CLI commands to read/write RAM, but that's easy. There's also a Pico W with wireless built in, and I have used an external module to do Bluetooth with the Pico as well.

i think the XM module would be a good one to look at. As you say it is well known and so the code emulation should be straightforward. I think the circuitry for the Pico can be shrunk to a module size using the RP2040 IC, so it might be possible to put this in a module housing. A USB module should be simple, from the hardware side, it's just a matter of deciding what to emulate. Although, it should be able to emulate anything I suppose...

Quote:For me it sound like a very interesting thing to dive into, and I have already ordered some Pico's to play with ... Wink
When I order the PCBs I get 5 minimum, so I could send you a PCB if you want? PM me.

Quote:Just wishing that time was something you could order online as well ... Tongue
Oh yes.


Cheers,
Thomas
[/quote]
Find all posts by this user
Quote this message in a reply
06-01-2023, 09:41 AM
Post: #7
RE: HP41C with Rp Pico attached
This is a really cool project, and thanks for sharing. I like how you implement the extra display and the HP41 bus tracer. I have implemented an HP41 bus tracer myself and did not expect that a microcontroller would be able to keep up with the HP41 bus speed while dumping the results over USB in real time. But with a 2 core controller things are now different.
The Pico looks like a good candidate for a new generation of HP41 peripherals, although I doubt that it will fit in a module housing with all the level shifters. Also powering the RP2040 from the HP41 battery will be a challenge. But then again I do not mind a box external to the calculator with its own power source.

Regards, Meindert
Find all posts by this user
Quote this message in a reply
06-01-2023, 10:30 AM
Post: #8
RE: HP41C with Rp Pico attached
(06-01-2023 09:41 AM)MeindertKuipers Wrote:  This is a really cool project, and thanks for sharing. I like how you implement the extra display and the HP41 bus tracer. I have implemented an HP41 bus tracer myself and did not expect that a microcontroller would be able to keep up with the HP41 bus speed while dumping the results over USB in real time. But with a 2 core controller things are now different.
The Pico looks like a good candidate for a new generation of HP41 peripherals, although I doubt that it will fit in a module housing with all the level shifters. Also powering the RP2040 from the HP41 battery will be a challenge. But then again I do not mind a box external to the calculator with its own power source.

Thank you.

The extra display was hopefully for a version of this that can run with an HP41C processor PCB and provide a display and keyboard via the Pico. You then have a sort of 'desktop' HP41C. I have a few PCBs with no case and this would allow me to use them. Some of the boards are faulty, as well, so the bus tracing was to help me debug them, maybe. If ICs are broken then I'm hoping to remove the broken IC and emulate that functionality.

If my calculations are correct then the HP41C runs at about 6000 instructions per second on the bus. The bit rate is 56 times that so about 300KHz. The Pico is overclocked to 270MHz so about 800 instructions per clock cycle. There is quite a bit of processing that can be done in 800 instructions. Handling bus traffic is not a problem, therefore, but the emulated data from RAM, ROM, etc has to be presented quickly on the bus so that's a bit more demanding. There are the PIOs available which could probably handle the bus bitstream and hand bus 'words' to the cores. At the moment I'm running one core on the bus decoding and one doing the UI and trace decoding. (And no PIOs).

Yes, I think the Pico or RP2040 could help create quite a few interesting peripherals. There's a Pico with wifi too, although it's not difficult to use a module to do wifi or bluetooth.

The RP2040 is definitely not low power so that will have to be handled with external power or a big battery. I don't think there's any way around that other than power switching circuits that power the RP2040 down completely when not in use.

The RP2040 is very small, but it does need an external flash chip, crystal and some passives, even so, that should fit in a module. Level shifters are needed as the RP2040 is only 5V tolerant. I think the circuit on the prototype PCB I have made could just be fitted in a module. Maybe.

Andrew
Find all posts by this user
Quote this message in a reply
06-01-2023, 12:14 PM
Post: #9
RE: HP41C with Rp Pico attached
(06-01-2023 10:30 AM)blackjetrock Wrote:  If my calculations are correct then the HP41C runs at about 6000 instructions per second on the bus. The bit rate is 56 times that so about 300KHz. The Pico is overclocked to 270MHz so about 800 instructions per clock cycle. There is quite a bit of processing that can be done in 800 instructions. Handling bus traffic is not a problem, therefore, but the emulated data from RAM, ROM, etc has to be presented quickly on the bus so that's a bit more demanding. There are the PIOs available which could probably handle the bus bitstream and hand bus 'words' to the cores. At the moment I'm running one core on the bus decoding and one doing the UI and trace decoding. (And no PIOs).

You speed observations are correct. Worst case a 2* speed-up HP41 has a clock frequency of about 525 kHz. For ROM emulation this can indeed be a challenge, but knowing what Diego has done with a much slower PIC processor for the Clonix and NoVRAM this should not be a big problem.
And the PIO seems to be the way to go for a more efficient implementation of the bus interface with more CPU cycles left for doing other useful things, or reduce the clock frequency for power management.

With the current implementation, how much ROM and FLASH do you have to spare for ROM images?

I am actually working on HP41 interfacing using an FPGA and STM32 CPU, but your work has now triggered me to reconsider this approach and go the Pico way.

Regards, Meindert
Find all posts by this user
Quote this message in a reply
06-01-2023, 02:22 PM
Post: #10
RE: HP41C with Rp Pico attached
(06-01-2023 06:11 AM)blackjetrock Wrote:  unfortunately the RP2040 (Pico IC) isn't a very low power device. It is low-ish power consumption so battery power is definitely an option but it isn't anywhere as low power as the HP41C itself, for instance.

Yes, that I have realized, but I was thinking of having a battery for the Pico.
Ie using something similar to this.

(06-01-2023 06:11 AM)blackjetrock Wrote:  Is the card reader well documented?

Not that I'm aware of, that's why I thought of looking at the Wand, I think it would be easier ... Wink

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
06-01-2023, 02:27 PM (This post was last modified: 06-02-2023 09:04 AM by blackjetrock.)
Post: #11
RE: HP41C with Rp Pico attached
(06-01-2023 12:14 PM)MeindertKuipers Wrote:  You speed observations are correct. Worst case a 2* speed-up HP41 has a clock frequency of about 525 kHz. For ROM emulation this can indeed be a challenge, but knowing what Diego has done with a much slower PIC processor for the Clonix and NoVRAM this should not be a big problem.
And the PIO seems to be the way to go for a more efficient implementation of the bus interface with more CPU cycles left for doing other useful things, or reduce the clock frequency for power management.

Yes, the PIO is fast and can handle things like the HP41 bus. The only issues are that it has a 32 bit word FIFO and so the 56 bit bus words would have to be split. Syncing to the SYNC bit would also have to be done but none of this is impossible.

Quote:With the current implementation, how much ROM and FLASH do you have to spare for ROM images?

I just checked and at the moment the code is about 132K, and it's a 2Mbyte flash on the Pico. You can fit up to a 16Mbyte flash chip on the RP2040, so plenty of room in the flash. Say 1Mb of code, you'd have room for 128 ROM images in flash with a 2Mbyte chip and using the 16Mbyte chip about 2000 images of 4K words (I'm storing each word in 2 bytes) . I'm using a lot of the RAM at the moment for trace buffers, I fill the RAM with it so it's large, so not sure on that. I haven't used too much for the program. the chip has 260K or so of RAM. There is a circular buffer for communication between the cores but that can be sized appropriately. All very much a work in progress.

Quote:I am actually working on HP41 interfacing using an FPGA and STM32 CPU, but your work has now triggered me to reconsider this approach and go the Pico way.

I used to use STM32 microcontrollers but they got hard and expensive to soure, so I moved to the RP2040. They are just over 1 euro or 89pence each. A pico is £4-ish and both are very available. Debug and programming I use a Picoprobe, whcih is made form a Pico...
There's some stuff that only an FPGA can do, but the fast processor makes a lot of things possible, the PIOs make even more things possible and dual core is very useful if you want to do something more than just emulate a RAM or ROM, you can dump the contents to USB for example.

Andrew
Find all posts by this user
Quote this message in a reply
06-01-2023, 02:37 PM
Post: #12
RE: HP41C with Rp Pico attached
(06-01-2023 02:22 PM)ThomasF Wrote:  
(06-01-2023 06:11 AM)blackjetrock Wrote:  unfortunately the RP2040 (Pico IC) isn't a very low power device. It is low-ish power consumption so battery power is definitely an option but it isn't anywhere as low power as the HP41C itself, for instance.

Yes, that I have realized, but I was thinking of having a battery for the Pico.
Ie using something similar to this.

(06-01-2023 06:11 AM)blackjetrock Wrote:  Is the card reader well documented?

Not that I'm aware of, that's why I thought of looking at the Wand, I think it would be easier ... Wink

Cheers,
Thomas

Last time I was designing a Liion battery charger I have severe problems getting the ICs. Hopefully that situation will ease eventually.

Andrew
Find all posts by this user
Quote this message in a reply
06-22-2023, 11:31 AM
Post: #13
RE: HP41C with Rp Pico attached
Hi,

Found some time and connected a Tiny2040 to the 41 with success.
The Tiny2040 is small enough to fit in a small box

I can analyze the bus, decode the display-instruction etc, all through an old module case and connector, so no need to open the 41 (so I'm missing the keyboard events).

I have yet to get the driving of the ISA-port to work, to be able to emulate modules, but so far all good!

(The yellow text is just a test of the 41 font, but the blue text just below is the copy of the actual 41 display,
rest is just debug-info)

Cheers,
Thomas


Attached File(s) Thumbnail(s)
   

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
06-22-2023, 12:32 PM
Post: #14
RE: HP41C with Rp Pico attached
(06-22-2023 11:31 AM)ThomasF Wrote:  Hi,

Found some time and connected a Tiny2040 to the 41 with success.
The Tiny2040 is small enough to fit in a small box

I can analyze the bus, decode the display-instruction etc, all through an old module case and connector, so no need to open the 41 (so I'm missing the keyboard events).

Good news. Did you write your own code or use mine?

Quote:I have yet to get the driving of the ISA-port to work, to be able to emulate modules, but so far all good!

(The yellow text is just a test of the 41 font, but the blue text just below is the copy of the actual 41 display,
rest is just debug-info)

Cheers,
Thomas

There's some module emulation in my code, I managed to emulate a couple of modules. Not bank switched ones yet, though.
I have some module case snow and am looking at a PCB that attaches as a module. Maybe with an SD card slot poking out?

Andrew
Find all posts by this user
Quote this message in a reply
06-22-2023, 01:10 PM
Post: #15
RE: HP41C with Rp Pico attached
Hi Andrew,

I used your code as a base, but added another OLED driver.
I also implemented my own font (14-segment lookalike with original charset).

I thought I could use a single bi-directional levelshifter for ISA, but maybe changing the direction of the gpio on the fly makes things hickup.
The Tiny2040 doesn't have that many gpios, but it is small and easy to use.

I use the SDK, compile, pressing boot+reset and copy the file from the PC to the RPI, so turnaround time is very short when developing (and I don't need a second Pico for flashing).

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
06-22-2023, 02:47 PM
Post: #16
RE: HP41C with Rp Pico attached
(06-22-2023 01:10 PM)ThomasF Wrote:  Hi Andrew,

I used your code as a base, but added another OLED driver.
I also implemented my own font (14-segment lookalike with original charset).
I'm interested in your 14 segment font. Is your code online somewhere?

Quote:I thought I could use a single bi-directional levelshifter for ISA, but maybe changing the direction of the gpio on the fly makes things hickup.
I used a level shifter like that and it seems fine. I used a 74LVC245.

Quote:The Tiny2040 doesn't have that many gpios, but it is small and easy to use.

I use the SDK, compile, pressing boot+reset and copy the file from the PC to the RPI, so turnaround time is very short when developing (and I don't need a second Pico for flashing).

Cheers,
Thomas

Yes, I recently used an RP2040 Zero which is very similar. There's an SDK call you can make that puts the RP2040 into mass storage mode. So you can use the USB CLI instead of pressing the buttons.

Andrew
Find all posts by this user
Quote this message in a reply
06-22-2023, 03:50 PM
Post: #17
RE: HP41C with Rp Pico attached
(06-22-2023 11:31 AM)ThomasF Wrote:  I have yet to get the driving of the ISA-port to work, to be able to emulate modules, but so far all good!

Really cool that it works. I am about to get my PICO up and running, but some other real-life stuff interfered. I did do some studying and I think I have figured out how to use the PIO for interfacing with the HP41 bus. This will free many resources in one of the M0 cores.

I seriously doubt if you can drive ISA with the levelshifters in your picture. In my experience a '245 like driver with seperate ISA and output enable is needed.

Regards, Meindert
Find all posts by this user
Quote this message in a reply
06-22-2023, 08:13 PM
Post: #18
RE: HP41C with Rp Pico attached
(06-22-2023 02:47 PM)blackjetrock Wrote:  I'm interested in your 14 segment font. Is your code online somewhere?
Sure! I wrote a small "parser" that generated the font. I'll clean it up and send it to you so you can use it if you want.
It requires some special handling of the punctuation ( . , : ), it works ok for me, but not the"flying goose" yet, need another flag for that ...

And as Meindert also mentioned, I probably also need to add a driver (like 245) to get ISA driver to work. But I still have some gpios free on the Tiny for that!

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
06-22-2023, 08:38 PM
Post: #19
RE: HP41C with Rp Pico attached
(06-22-2023 08:13 PM)ThomasF Wrote:  
(06-22-2023 02:47 PM)blackjetrock Wrote:  I'm interested in your 14 segment font. Is your code online somewhere?
Sure! I wrote a small "parser" that generated the font. I'll clean it up and send it to you so you can use it if you want.
It requires some special handling of the punctuation ( . , : ), it works ok for me, but not the"flying goose" yet, need another flag for that ...

And as Meindert also mentioned, I probably also need to add a driver (like 245) to get ISA driver to work. But I still have some gpios free on the Tiny for that!

Cheers,
Thomas

Thanks.

Feel free to use my code. That uses a 74LVC245 as a level shifter and also has the ISA drive to emulate a ROM. It's all pretty simple really.

Andrew
Find all posts by this user
Quote this message in a reply
07-06-2023, 05:00 PM
Post: #20
RE: HP41C with Rp Pico attached
(06-22-2023 08:38 PM)blackjetrock Wrote:  Feel free to use my code. That uses a 74LVC245 as a level shifter and also has the ISA drive to emulate a ROM.

Thanks, I will do!

I spent some more time on the character handling, and can emulate most of the display now - even the Goose flies around when it should ... Wink

   
   

Some thing are still missing, like the annunciators, and default alpha register. When [ALPHA] is pressed, the OLED is cleared and not updated with the actual content of the alpha reg, but when entering text into alphareg, the OLED is updated accordingly.

So, I'll continue to analyze the display-commands until I get a driver to drive the ISA-bus for more MLDL experiments ... Wink

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)