HP Forums

Full Version: Arduino IL Drive Sim read good write bad
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I have build the "IL Drive Simulator" from the thread "Arduino Board as HP-IL device?". It works fine with existings LIF-files. I can read them with my HP-41CX and HP-71B. That Beautiful and I was happy with it for weeks.

Then I try to write in an existing LIF-file with the "IL Drive Simulator" and it doesnt work. I can't see any error-message. But to store or purge a program never work.

I have made further attempts and found out the following:
• Attempting to save a program with the IL Drive Sim will not result in an error message.
• The stored program is not displayed with CAT or DIR.
• The saved program will be added to the end of the file. There is also a copy of the directory stored. The IL Drive Sim does not write into the file but makes an append.
• The HP-41CX behaves exactly the same as the HP-71B.

If you wish to make a closer look I have attacht LIF-files: before, good result (with Ilper on PC) and bad result(with IL Drive Sim).

What are your experiences? Can someone successfully save programs with the IL Drive Simulator? Does anyone have problems? Does anyone have advice for me?

- are there no errrors in the monitor, when then system writes?
- try an arduino SD write test programm (in examples)
- what happend when you INITIALIZE a LIF with the HP71?

Hello Tobie,
thank you for your fast reply. There are no errrors in serial monitor, when the system writes. I have tried the arduino SD test Programms CardInfo, Files and ReadWrite with success.

INITIALIZE a LIF append 256kByte to a file. I think the row
for (i = 0; i < 1024; ++i) // 640kb
in ildrive.cpp mean 256kb: 1024 times 256 byte

This page say, that open a file with the normal parameter FILE_WRITE mean that it is open for append, as for datalogging.

This page show a solution that work for me:
I change the both occurrence of FILE_WRITE in ildrive.cpp into O_RDWR and storing a program works!!!

Maybe the seek-command in ildrive.cpp can't go before the end of file anymore if the file is open for append. Maybe this was changed in the sd-library in the last years. Or the reason is my Arduino clone "ELEGOO Mega2560R3". I don't know...

Tobie, thank you very much for your work on the IL-Drive Simulator and your understandable and accessible program code. I am in the feeling of having understood this problem, at least a little …

Best Regards
there was indeed an important change to the SD card library. First, FILE_WRITE had the same meaning as O_RDWR. It was O_READ and O_WRITE (and O_CREAT, which does not matter because the IL-Drive simulator never want to create a file).

As mentioned in the second link above, O_APPEND means:
/ ** The file offset shall be the end of the file prior to each write. */

At the end of the year 2017, FILE_WRITE was redefined:
This means that the SD card library now jumps to the end of the file with every write command if the file was opened with the parameter FILE_WRITE. However, the IL-Drive simulator must be able to change the data within the existing file because the directory entries are stored at the beginning of the LIF file. If you want to program a Arduino Mega 2560 for the IL-Drive simulator with the current Arduino IDE, you have to replace FILE_WRITE in the file ildrive.cpp with O_RDWR at two places.

In this entry also someone describes his surprise about the changed behavior of the SD card library:

Best Regards
Hallo Klaus

Ich Danke Dir!

Thank you for this important find. I will change the code and i will make an entry
in the manual.

Best regards
Hello Tobi,

thank you very much for your kind words. I Like to share what I have done with the advice of your manual. The photos below show my version of the now perfectly working Arduino IL Drive simulator. I soldered the PIL-IO board component kit and the wiring myself. Thanks to the SORA Acrylic Box, however, it was not necessary to drill or saw.

I used a WINGONEER Prototype PCB and inserted and soldered the SD Card module directly underneath. As a result, there was no place for the regular 5V Pin Header Row. That's OK because 5V and GND are also at the two ends of the longest Pin Header Row. With two self adhesive elastic buffer at the outside of the longest Pin Header Row the Arduino board fits well in the Acrylic Box.4 elastic buffer a needed as feet under the box.

parts list:
  • ELEGOO Mega2560R3 Mikrocontroller Board
  • WINGONEER Prototype PCB for Arduino MEGA 2560 R3
  • kwmobile SD Card Modul
  • SORA Acryl Box for Arduino Mega
  • Elegoo Jumper Wire 40x 20cm Female-Female or Male-Female
  • a PIL-IO board component kit equipped with the PIL-Box firmware from jeffcalc
    (see http://www.jeffcalc.hp41.eu/hpil/index.html)
  • a HP-IL-Cabel (cut in two half)
  • 2 SD-Cards (one for HP-41C-LIF-files and one for HP-71B-LIF-files)
  • Arduino 9V adapter
  • 6 elastic buffer self adhesive hemisphere

In total, the parts cost about 170 € (about 190 $). 50 € less if you already have one HP-IL cable and two SD cards left.

Best Regards
(11-28-2019 04:48 PM)Klaus Overhage Wrote: [ -> ][*]2 SD-Cards (one for HP-41C-LIF-files and one for HP-71B-LIF-files)

Very cool, thanks for sharing this and the photos Klaus.

Why do you specify 2 different media, one each for 41C and 71B? They usually can share LIF media, although most files are not easily usable by the other platform. Is there some limitation of this system (somehow?) or are you just suggesting practical use?
Hello Bob,

both of them, some limitation of this system and practical use.

In the source-file ildrive.h there is this row:
#define sd_maxlif 17       // max number of lif files
Maybe sd_maxlif can be set higher. The Arduino IL Drive simulator load the name of all LIF-files at startup, so there will be a point when the SRAM is full.

But more important is the practical use. At startup only the both LIF-Files first copy on the SD-card are accessible under the Name HDRIVE1 and HDRIVE2. In short as ":1" and ":2" on the HP-71B. You can switch to another LIF-File, but: At startup only the both LIF-Files first copy...

Tobie writes about this in his manual: "It’s a good idea that you will have more then one sd card. For example one for the HP41 and one for the HP71, so you don’t have to change the current LIF file for each controler."

Best Regards
Nice system !
I'm happy that you solved your problem, and thanks for sharing it!

(11-28-2019 05:32 PM)rprosperi Wrote: [ -> ]Why do you specify 2 different media, one each for 41C and 71B? They usually can share LIF media, although most files are not easily usable by the other platform. Is there some limitation of this system (somehow?) or are you just suggesting practical use?

There is a potential problem when using the same disc for the HP41 and the HP71/75, in relation with the PACK command, see a description here: http://hhuc.us/2014/files/Speakers/08,09...ACKBUG.txt

It's ok to mix HP41 and HP71/75 files for archiving or sharing, but is not recommended for a working disc.

Thanks to both of you (Klaus and J-F). These comments are clear.

As a matter of use, I never mix machine type files on media, and never, ever use PACK. Even when using real diskette media, the issues and risks of data loss are not worth the risks.

As for this system, it appears the drive simulator reads all (up to 17 files) directory data into a cache-like buffer on startup, so while quite limited, at least a DIR or CAT ALL will be very quick!

Thanks again.
Reference URL's