2020年5月25日月曜日

NTC thermistor Setting for Duet

I changed settings for HT-NTC100K thermistor.

I get thermistor from here.





I found this PDF Datasheet.

I set the value to configurator
and I get the result as above.

Settings for Duet firmware Ver3.0 is bellow.
M308 S1 P"e0_temp" Y"thermistor" T100000 B5007 C1.687660e-7 ; HT-NTC100K


2020年4月17日金曜日

Use XSL as Model of MVC

This is a sample of xslt which transform xml to sql.
I confirmed its result by using this link
https://www.freeformatter.com/xsl-transformer.html#ad-output

XSL having basic function and selection method of XPath.
It is possible to build Logic of Translation from GUI values to SQL.

Followings are the example.

XML
<Models>
  <model_1>
    <table>TBL_SAMPLE</table>
    <param_1>101</param_1>
    <param_2>102</param_2>
  </model_1>
</Models>

XSL
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="text" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
    <xsl:template match="//model_1">
        SELECT *
        FROM <xsl:value-of select="table" />
        WHERE p1 = <xsl:value-of select="param_1" />
        AND   p2 = '<xsl:value-of select="param_2" />'
    </xsl:template>
</xsl:transform>

Result
SELECT * FROM TBL_SAMPLE WHERE p1 = 101 AND p2 = '102'



2020年4月6日月曜日

Duet Maestro Firmware 2.0 to 3.0 settings changes and Precision Piezo Orion settings

;EndStops
2.0
M574 X2 Y2 Z2 S1                            ; set active high endstops
3.0
; Endstops
;M574 X2 Y2 Z2 S1                            ; set active high endstops
M574 X2 S1 P"xstop"   ; X min active high endstop switch
M574 Y2 S1 P"ystop"   ; Y min active high endstop switch
M574 Z2 S1 P"zstop"   ; Z min active high endstop switch

; Z-Probe
2.0
M558 P5 I1 H5 R0.4 F300 X0 Y0 Z0 T10000              ; set Z probe type to switch and the dive height + speeds

3.0
M558 P5 I1 H5 R0.4 F300 X0 Y0 Z0 T10000 C"^zprobe.in" ; Piezo connected to Z probe IN pin, free up MOD pin
G31 X0 Y0 Z-0.1 P100                                  ; set Z probe trigger value, offset and trigger height
M557 R140 S20                                         ; define mesh grid

; Heaters
2.0
; Heaters
M305 P0 T100000 B4138 R2200                 ; set thermistor + ADC parameters for heater 0
M143 H0 S120                                ; set temperature limit for heater 0 to 120C
M305 P1 T100000 B4138 R2200                 ; set thermistor + ADC parameters for heater 1
M143 H1 S280                                ; set temperature limit for heater 1 to 280C

3.0
M308 S0 P"bed_temp" Y"thermistor" T100000 B4607 ; define bed temperature sensor
M308 S1 P"e0_temp" Y"thermistor" T100000 B3950 C7.06e-8 ; define E0 temperature sensor
M950 H0 C"bed_heat" T0 ; heater 0 uses the bed_heat pin, sensor 0
M950 H1 C"e0_heat" T1 ; heater 1 uses the e0_heat pin and sensor 1






2020年2月3日月曜日

VirtualBox not launches VM

Open .vbox file and find following lines.

<Machine uuid="{xxxxxxxxxx-xxxx-xxxx-xxxxxxxx}" name="Windows7" OSType="Windows7_64" stateFile="{xxxxxxxxxx-xxxx-xxxx-xxxxxxxx}.sav" currentSnapshot="{xxxxxxxxxx-xxxx-xxxx-xxxxxxxx}" snapshotFolder="Snapshots" lastStateChange="2020-02-01T11:11:111">

and remove red part.


2019年9月25日水曜日

reinterprit_cast

I met strange situations.
There were reinterprit_cast in the code.
The code was working when it was developed by Visual Studio 2008.
But I changed to Visual Studio 2010, the code make access violations at delete the pointer and its memory.
The class was derived from 2 classes.
I am not sure if it were related on this issue.
I inspected the address of the pointer.
The pointer address was shift 2 byte from first pointed address at deletion.
I changed from reinterprit_cast to Simple Cast.
After that, access violations were blowed out.
Strange...

2019年3月12日火曜日

DPI change test (MFC dialog base applicatoin)

These codes are the result of try and error.
It means not so good codes.
SaveAppLayout and UpdateLayoutForDPI function should not be callback function.

Add to OnInitdialog
// save current size
 SaveAppLayout(this->m_hWnd,(LPARAM)this);
 // Resize child windows
// ::EnumChildWindows(this->m_hWnd, SaveAppLayout, (LPARAM)this); // Not necessary



Add to Header

afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
 afx_msg void OnPaint();

 DECLARE_MESSAGE_MAP()
 virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

Add to Dlg.cpp

BOOL CALLBACK SaveAppLayout(HWND hWnd,LPARAM lParam)
{
 CDPIChangeTestDlg* pParent = (CDPIChangeTestDlg*)lParam;
 int iDpi = GetDpiForWindow(hWnd);

 // Get current size(at 96 DPI base)
 CRect rect;
 ::GetWindowRect(hWnd, &rect);
 pParent->mResMap[hWnd] = rect;

 // recalc size
 double rate = iDpi / 96;
 rect.left *= rate;
 rect.top *= rate;
 rect.right  *= rate;
 rect.bottom *= rate;

 // resize
 SetWindowPos(hWnd, hWnd, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);

 return TRUE;
}

BOOL CALLBACK UpdateLayoutForDpi(HWND hWnd, LPARAM lParam)
{
 CDPIChangeTestDlg* pParent = (CDPIChangeTestDlg*)lParam;

 try {
  int iDpi = GetDpiForWindow(hWnd);
  // calc current DPI and rate from 96 DPI
  double rate = iDpi / 96;
  CRect rect = pParent->mResMap[hWnd];

  int dpiScaledX = rect.left / rate;
  int dpiScaledY = rect.top / rate;
  int dpiScaledWidth = rect.Width() / rate;
  int dpiScaledHeight = rect.Height() / rate;

  // resize
  SetWindowPos(hWnd, hWnd, dpiScaledX, dpiScaledY, dpiScaledWidth, dpiScaledHeight, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
 }
 catch (...) {
  return FALSE;
 }
 return TRUE;
}

void CDPIChangeTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
 if ((nID & 0xFFF0) == IDM_ABOUTBOX)
 {
  CAboutDlg dlgAbout;
  dlgAbout.DoModal();
 }
 else
 {
  CDialogEx::OnSysCommand(nID, lParam);
 }
}

LRESULT CDPIChangeTestDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
 
 switch (message) {
 case WM_DPICHANGED:
 {
  // Resize
  UpdateLayoutForDpi(this->m_hWnd, (LPARAM)this);
  // Resize Child Windows
//  ::EnumChildWindows(this->m_hWnd, UpdateLayoutForDpi, (LPARAM)this); // Not necessary
 }
 break;

 }
 return CDialogEx::WindowProc(message, wParam, lParam);
}


download all source here

2018年12月8日土曜日

filament case

I made filament case for 3D printer.
Parts bellow.
https://www.thingiverse.com/thing:569333
https://www.thingiverse.com/thing:1750875









2018年8月26日日曜日

C#+ NLua (Byte Array)

I wanted to use Byte Array between Lua Script and C#.
I read many site, but I couldn't get solution,
I visit NLua site today and it was description of using dotnet object from Lua Script.
So I finally get solution as following.

C# code.


_lua = new NLua.Lua();
_lua.LoadCLRPackage();
_lua.RegisterFunction("SendData", this, this.GetType().GetMethod("SendData"));


public void SendData(object dat)
{
    byte[] byteData = (byte[])data;
    // you can use ByteData from Lua Script
}
  

Lua Sctipt



import ('System')

    byteData = Byte[4]  -- create 4 length Byte Array
    byteData[0] = 0x00
    byteData[1] = 0x11
    byteData[2] = 0x22
    byteData[3] = 0x33
    SendData(byteData)  -- Call C# Function from Lua
  

2018年7月6日金曜日

VisualStudio2017

VisualStudio2017でMFCで組んでる人、
日本に居ないの?
ダイアログベースでプロジェクト作って、
ダイアログリソースをいじって、
普通にコンパイルするとLANGUAGE のとこにカンマが無いとエラーが出る。
見てみると、
LANGUAGE 17、1
のようになってる。
「、」のところを「,」に変えると普通にコンパイルできるのだが、
もう一度ダイアログのどこかのリソースをいじるとまた同じエラーが出る。
MSも把握していて治すと聞いていたのだが、
いつ治すの?

chinachu その後

RaspberryPiのCPU負荷はまだ余裕がある。
電波レベルも問題なし(フジテレビとかNHKとか)
しかし、録画すると録画済みリストに同じ名前が2つ並ぶ。
これ、フォーラムでも報告されていたのだけど、
問題が解決できていないらしい。
この状態になると、ファイルとしては一つなのだが、
ブロックノイズが混ざったファイルが出来ている。
今の所VLCで直してみたりしているけど、
修復しても結構長い時間ロスト状態で画面が固まるようなファイルが出来てしまう。
ブロックノイズの原因がチューナにある可能性も否定できない。
どのチューナで録画されたのかも分かるようにログを吐き出してもらえないもんだろうか