2025年12月18日 星期四

針對固定USB裝置上帶出的Com port位置下指令

使用了兩個同樣規格同類型之USB Serial Part裝置,在每次電腦重新啟動,可能因為啟動或讀取的順序關係,會造成與原先所使用的Com Port不同,有時電腦重新啟動即可復原,但如何使每次開機都可以固定在所設定的Com Port上呢?

可以利用

在裝置管理員上在COM Port的裝置上按滑鼠右鍵出現的內容上 位置的資料
利用這個資料只要不去換USB的PORT位置就可針對這個裝置下指令!

2025年12月17日 星期三

nRF52 PCA10040 DK 量產 nrf52840 產品

The nRF52 Development Kit (PCA10040) hardware provides support for the Nordic Semiconductor nRF52832 ARM Cortex-M4F CPU and the following devices:
ADC
CLOCK
FLASH
GPIO
I2C
MPU
NVIC
PWM
RADIO (Bluetooth Low Energy)
RTC
Segger RTT (RTT Console)
SPI
UART
WDT

利用 這個J-Link Prog Connector

PIN #
Signal Name
1    VDD
2    IMCU_TMSS
3    GND
4    IMCU_TCKS
5    V5V
6    IMCU_TDOS
7    Cut off
8    IMCU_TDIS
9    Cut off
10    IMCU_RESET

來做燒錄nrf52840 DUT的FW.
介面設計是同時燒錄四組DUT並且去偵測帶出的com port!
Demo Vedio:



2025年11月28日 星期五

Microchip PAC1934 - ADM00805 與 Arduino 通訊

ADM00805評估板
ADM00805具有USB連接器,用於連接到電腦進行裝置通訊。給PAC1934裝置供電有兩種方式:
一是透過USB連接器直接由VBUS供電,
二是透過VDD的外部連接供電。
利用板上MCP2221 USB轉I2C橋接器,可透過USB提供I2C通訊。
另外還有一個連接器,透過此連接器可以將VDD_IO、接地、SDA和SCL連接到PC主機板或Linux系統等外部源,可直接實現I2C通訊。有關使用直接I2C連接的重要詳細信息
Microchip_PAC193x Arduino_Library
The PAC1934 is a four channel power/energy monitor with current sensor amplifier and bus voltage monitors that feed high resolution ADCs.  Digital circuitry performs power calculations and energy accumulation.  The PAC1934 enables energy monitoring with integration periods from 1 ms to up to 36 hours.  Bus voltage, sense resistor voltage, and accumulated proportional power are stored in registers for retrieval by the system master or embedded controller. This library supports all the 4 channels on the PAC1934.  Source: http://ww1.microchip.com/downloads/en/DeviceDoc/PAC193x_Arduino_Library_v1_0_0.zip

透過Arduino的I2C與ADM00805連接去量測電壓與電流

將上述連結的Arduino Library 的Microchip_PAC193x sample upload 到Mega2560板子上就可以看到輸出了!!






2025年8月5日 星期二

PeakCAN 與 ECU Simulator 通訊利用OpenAI 來找尋DTC 的解釋

在這一篇文章中PeakCAN Bus 與 ECU Simulator 通訊 擷取 DTC Data
得到DTC錯誤代碼但是有太多的錯誤代碼, 本來想說在本機建立一個database來搜尋, 靈機一動想說現在萬物都OpenAI, 於是就在得到DTC時把OpenAI API的功能寫進去來尋找 DTC的意義!
錯誤碼=>所有常見的 OBD2 錯誤代碼:解讀 P、B、C、U 程式碼
在Microsoft Visual Studio中利用NuGet 安裝OpenAI

using OpenAI;
using OpenAI.Chat;

private async void button3_Click(object sender, EventArgs e)
{
    //string dtcCode = txtDTC.Text.Trim();
    string dtcCode = "P0218".Trim();

    if (string.IsNullOrEmpty(dtcCode))
    {
        MessageBox.Show("請輸入 DTC 代碼,例如 P0202");
        return;
    }

    button3.Enabled = false;
    //txtResult.Text = "查詢中,請稍候...";
    CommonData.WriteMessage("查詢中,請稍候...", "", Color.Blue, Color.Red);

    string myApiKey = "your key";

    ChatClient client = new(
        model: "gpt-4.1",  //gpt-4
        apiKey: myApiKey
    );

    try
    {
        var prompt = $"請解釋 OBD2 故障碼 {dtcCode} 的意思,用繁體中文回答";
        
        ChatCompletion completion = await client.CompleteChatAsync(prompt);   
        CommonData.WriteMessage("查詢結果...", completion.Content[0].Text.ToString(), Color.Blue, Color.Red);
    }
    catch (Exception ex)
    {
        //txtResult.Text = "錯誤:" + ex.Message;
    }
    finally
    {
        button3.Enabled = true;
    }
}


還真的可以用!真是方便!!