Once again about arrow indicators (and absolutely without MK)

    Hello!
    I immediately really liked the article about the arrow indication of the processor and memory load. Sometimes you need to look at how much free memory is left, starting the third or fourth instance of a heavy program / game (I do not want to bring to a situation where the previous instances code swap). Or with processor loading - I used to think that modern Crysis, Call of Duty, Mass Effect, etc. load both the video card and percent. Now I know that even when the picture slows down, the percent is loaded no more than 30-40%. Well, or straight away to evaluate whether all the kernels use rendering. And what a pleasure the eye gives twitching arrows.
    The second implementation, although it is just as clear, is not sunk into the soul - there is no such entertainment.
    So I decided - someday I will certainly repeat with the arrows.
    The only problem that I didn’t do right away is laziness lack of indicators of course. And so, sorting out the old-old stuff in the old-old cupboard, I found THEM.



    Just two arrow indicators from the old bobbin tape recorder. Oh, how much he once rewound reels with Cinema and Modern Talking.

    So, for the idea to work, we needed:
    • beautiful indicators with a suitable scale;
    • hardware for connecting indicators to a computer;
    • program for outputting memory and processor load.

    When the tasks are clear, it’s easier to work.

    Beautiful indicators

    The head housings were flooded with glue from the heart, but he did not survive under the usual clerical knife. Divided in half, took out the old scale, drew and printed a new one in size. Assembled in reverse order.



    After writing the article, I looked at the photographs and took them apart again. He took red nail polish from his wife and painted arrows. It turned out more noticeable - this is visible on the video.

    Hardware

    Then I did not become wise with the controllers. There is LPT on my mom, it’s unlikely to be useful to me for some other purposes, so there’s nothing to stand idle.
    LPT is 8 bits, 4 bits per channel, 16 positions of the arrow - I was quite happy. The simplest DACs are resistors and diodes, we draw for two channels (aesthetes, sorry for ISIS): I



    neglected the accuracy of the resistors, filmed what happens in nature (10, 20, 39, 82 kOhm). As usual, solder the layout:



    and check in work. Calibration consists in setting the switches with the trimmers to the maximum division of the scale when transmitting the value 255 to the port. That's all with iron.

    Program

    The most difficult thing was to find a driver for working with LPT (Win 8 x64). After several hours of searching, I finally found DLPortIO (driver + library) 32 bits, but with instructions for installing on 64-bit systems. Unfortunately, I already lost the link, I just saved it on Yandex.Disk .
    Further it is easier. After half an hour, the program in Delphi (the only thing I somehow remember from the time of my studies) was written:
    Spoiler
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      MemStatus.dwLength := sizeof( TMemoryStatus );
      GlobalMemoryStatus( MemStatus );
      MemVal := round(15*MemStatus.dwMemoryLoad/100) shl 4; //верхние 4 бита - память, нижние - CPU
      CPUUsage3:= CPUUsage2;  //небольшое
      CPUUsage2:= CPUUsage1;  //сглаживание
      CPUUsage1:= CPUUsage;   //
      CPUUsage := 0;
      CollectCPUData;
      for i:= 0 to GetCPUCount - 1 do begin
        CPUUsage:= CPUUsage + GetCPUUsage(i);
      end;
      CPUUsage:= CPUUsage / GetCPUCount;
      CPUUsage:= (CPUUsage + CPUUsage1 + CPUUsage2 + CPUUsage3)/4; //небольшое сглаживание
      CPUVal := Round(15 * CPUUsage);
      CPUVal := CPUVal or MemVal;
      DlPortWritePortUchar (888, CPUVal);
    end;
    


    The RAM and CPU load values ​​are read twice per second and sent to the & H378 port. In the comments to the original article, there was a question about how many resources a program showing loading resources eats. I answer: according to the task manager, there was no more than 0% processor load, but 956k of memory (I would have to take my hands off: I went the simplest way, I have a form, and then it hides. Nothing, I’ll get to the optimization and fix it).
    Accuracy in the first half of the scale is lame, the closer to 100% - the more accurate.



    There is no corps and is not planned, let them lie on the monitor. There is no backlight, but it is planned. I think where to feed. The design is more aesthetic in nature, plus the pleasure of being made / assembled / soldered in person, but it is priceless.
    Finally, a short video:


    Thank you for your attention, I wish you to find a dial indicator in the cabinet.

    Also popular now: